using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
namespace Snxxz.UI
|
{
|
[XLua.LuaCallCSharp]
|
[XLua.Hotfix]
|
public class EquipGemModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
Dictionary<int, int[]> m_EquipGems = new Dictionary<int, int[]>();
|
Dictionary<int, List<int>> m_EquipGemTypes = new Dictionary<int, List<int>>();
|
Dictionary<int, GemHoleCondition> m_GemHoleConditions = new Dictionary<int, GemHoleCondition>();
|
Dictionary<int, GemType> m_GemTypes = new Dictionary<int, GemType>();
|
Dictionary<int, EquipGemRedpoint> m_EquipGemRedpoints = new Dictionary<int, EquipGemRedpoint>();
|
Dictionary<int, Redpoint> m_EquipSetRedpoints = new Dictionary<int, Redpoint>();
|
|
List<int> m_EquipPlaces = new List<int>();
|
|
readonly List<int> m_GemHoleItemIds = new List<int> { 0, 0, 0, 0 };
|
|
public readonly Redpoint redpoint = new Redpoint(106, 10609);
|
|
public const int EQUIPGEM_HOLE_COUNT = 4;
|
public static int REDPOINTBASE = 106090000;
|
|
int m_SelectLevel = 0;
|
public int selectLevel
|
{
|
get { return m_SelectLevel; }
|
set
|
{
|
if (m_SelectLevel != value)
|
{
|
m_SelectLevel = value;
|
if (selectLevelRefresh != null)
|
{
|
selectLevelRefresh();
|
}
|
}
|
}
|
}
|
|
int m_SelectEquipPlace = 0;
|
public int selectEquipPlace
|
{
|
get { return m_SelectEquipPlace; }
|
set
|
{
|
if (m_SelectEquipPlace != value)
|
{
|
m_SelectEquipPlace = value;
|
if (selectEquipRefresh != null)
|
{
|
selectEquipRefresh();
|
}
|
}
|
}
|
}
|
|
public Int2 jumpEquipPosition { get; set; }
|
|
public event Action selectLevelRefresh;
|
public event Action selectEquipRefresh;
|
public event Action<int, int> equipGemRefresh;
|
public event Action<int, int, int> equipGemLevelUp;
|
|
EquipModel equipModel
|
{
|
get { return ModelCenter.Instance.GetModel<EquipModel>(); }
|
}
|
|
EquipStarModel equipStarModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
public bool serverInited { get; private set; }
|
|
public override void Init()
|
{
|
FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
packModel.refreshItemCountEvent += RefreshItemCountEvent;
|
PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshInfoEvent;
|
ParseConfig();
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
serverInited = false;
|
m_EquipGems.Clear();
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
serverInited = true;
|
}
|
|
public override void UnInit()
|
{
|
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
packModel.refreshItemCountEvent -= RefreshItemCountEvent;
|
PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshInfoEvent;
|
}
|
|
void ParseConfig()
|
{
|
var gemTypeConfig = FuncConfigConfig.Get("GemTypeCount");
|
var gemTypeCount = int.Parse(gemTypeConfig.Numerical1);
|
|
var gemCostConfig = FuncConfigConfig.Get("GemUpCostFormula");
|
var shopDict = ConfigParse.GetDic<int, int>(gemCostConfig.Numerical1);
|
var composeCount = int.Parse(gemCostConfig.Numerical2);
|
|
for (int i = 1; i <= gemTypeCount; i++)
|
{
|
int[] getWays = null;
|
string description = string.Empty;
|
var gemConfig = FuncConfigConfig.Get("GemType" + i);
|
if (gemConfig != null)
|
{
|
var equips = ConfigParse.GetMultipleStr<int>(gemConfig.Numerical1);
|
for (int k = 0; k < equips.Length; k++)
|
{
|
List<int> gemTypes = null;
|
if (!m_EquipGemTypes.TryGetValue(equips[k], out gemTypes))
|
{
|
gemTypes = new List<int>();
|
m_EquipGemTypes.Add(equips[k], gemTypes);
|
}
|
gemTypes.Add(i);
|
}
|
|
if (!string.IsNullOrEmpty(gemConfig.Numerical3))
|
{
|
getWays = ConfigParse.GetMultipleStr<int>(gemConfig.Numerical3);
|
}
|
|
description = gemConfig.Numerical2;
|
}
|
|
var level = 1;
|
var maxLevel = level;
|
var itemType = 0;
|
var itemConfig = ItemConfig.GetGemDataByLevelAndType(level, i);
|
if (itemConfig != null)
|
{
|
itemType = itemConfig.Type;
|
}
|
while (itemConfig != null && itemConfig.EffectValueA1 == i)
|
{
|
maxLevel = level;
|
level++;
|
itemConfig = ItemConfig.Get(itemConfig.EffectValueC1);
|
}
|
|
m_GemTypes.Add(i, new GemType()
|
{
|
maxLevel = maxLevel,
|
getWays = getWays,
|
description = description,
|
itemType = itemType,
|
shopId = shopDict.ContainsKey(i) ? shopDict[i] : 0,
|
composeCount = composeCount,
|
filterParams = new SinglePack.FilterParams()
|
{
|
itemTypes = new List<int>() { itemType },
|
}
|
});
|
}
|
|
m_EquipPlaces.AddRange(m_EquipGemTypes.Keys);
|
m_EquipPlaces.Sort();
|
|
var commonHoleConfig = FuncConfigConfig.Get("GemOpen");
|
var vipHoleConfig = FuncConfigConfig.Get("GemOpenVip");
|
var commonOpens = ConfigParse.GetMultipleStr<int>(commonHoleConfig.Numerical1);
|
for (int i = 0; i < commonOpens.Length; i++)
|
{
|
m_GemHoleConditions.Add(i, new GemHoleCondition()
|
{
|
equipStar = commonOpens[i],
|
vipLevel = 0,
|
});
|
}
|
m_GemHoleConditions.Add(3, new GemHoleCondition()
|
{
|
equipStar = commonOpens[0],
|
vipLevel = int.Parse(vipHoleConfig.Numerical1),
|
});
|
|
var configs = EquipControlConfig.GetValues();
|
var totalEquipLevels = new List<int>();
|
foreach (var item in configs)
|
{
|
var level = item.level;
|
if (!totalEquipLevels.Contains(level))
|
{
|
totalEquipLevels.Add(level);
|
}
|
}
|
|
foreach (var level in totalEquipLevels)
|
{
|
var equipSetRedpointBase = REDPOINTBASE++;
|
m_EquipSetRedpoints[level] = new Redpoint(10609, equipSetRedpointBase);
|
foreach (var place in m_EquipPlaces)
|
{
|
var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
|
if (!m_EquipGemRedpoints.ContainsKey(packIndex))
|
{
|
EquipGemRedpoint redpoint = new EquipGemRedpoint(equipSetRedpointBase);
|
m_EquipGemRedpoints.Add(packIndex, redpoint);
|
}
|
}
|
}
|
}
|
|
public bool TryGetGemHoleCondition(int hole, out GemHoleCondition condition)
|
{
|
return m_GemHoleConditions.TryGetValue(hole, out condition);
|
}
|
|
public bool TryGetEquipGems(int packIndex, out int[] gems)
|
{
|
return m_EquipGems.TryGetValue(packIndex, out gems);
|
}
|
|
public bool TryGetEquipGems(int level, int place, out int[] gems)
|
{
|
var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
|
return TryGetEquipGems(packIndex, out gems);
|
}
|
|
public bool TryGetEquipGem(int level, int place, int hole, out int equipGem)
|
{
|
equipGem = 0;
|
int[] equipGems;
|
if (TryGetEquipGems(level, place, out equipGems))
|
{
|
if (hole < equipGems.Length)
|
{
|
equipGem = equipGems[hole];
|
return equipGem != 0;
|
}
|
}
|
return false;
|
}
|
|
public bool TryGetGemTypes(int place, out List<int> types)
|
{
|
return m_EquipGemTypes.TryGetValue(place, out types);
|
}
|
|
public bool TryGetGemType(int type, out GemType gemType)
|
{
|
return m_GemTypes.TryGetValue(type, out gemType);
|
}
|
|
public bool TryGetRedpoint(int level, int place, out EquipGemRedpoint redpoint)
|
{
|
var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
|
return m_EquipGemRedpoints.TryGetValue(packIndex, out redpoint);
|
}
|
|
public bool TryGetRedpoint(int level, out Redpoint redpoint)
|
{
|
return m_EquipSetRedpoints.TryGetValue(level, out redpoint);
|
}
|
|
public Int2 TryGotoUseGem(int itemId)
|
{
|
var config = ItemConfig.Get(itemId);
|
if (config == null)
|
{
|
return Int2.zero;
|
}
|
GemType gemType;
|
if (!TryGetGemType(config.EffectValueA1, out gemType))
|
{
|
return Int2.zero;
|
}
|
Int2 equipPosition = Int2.zero;
|
foreach (var level in cacheEquipSets)
|
{
|
foreach (var place in m_EquipPlaces)
|
{
|
var gemTypes = m_EquipGemTypes[place];
|
if (!gemTypes.Contains(config.EffectValueA1))
|
{
|
continue;
|
}
|
for (int i = 0; i < EQUIPGEM_HOLE_COUNT; i++)
|
{
|
if (!IsEquipGemHoleOpen(level, place, i))
|
{
|
continue;
|
}
|
if (equipPosition.Equals(Int2.zero))
|
{
|
equipPosition.x = level;
|
equipPosition.y = place;
|
}
|
var equipGem = 0;
|
if (TryGetEquipGem(level, place, i, out equipGem))
|
{
|
var compareConfig = ItemConfig.Get(equipGem);
|
if(config.EffectValueB1 > compareConfig.EffectValueB1)
|
{
|
return new Int2(level, place);
|
}
|
}
|
else
|
{
|
return new Int2(level, place);
|
}
|
}
|
}
|
}
|
return equipPosition;
|
}
|
|
public bool IsEquipGemHoleOpen(int level, int place, int hole)
|
{
|
var equipPosition = new Int2(level, place);
|
var equipGuid = equipModel.GetEquip(equipPosition);
|
if (string.IsNullOrEmpty(equipGuid))
|
{
|
return false;
|
}
|
var equip = packModel.GetItemByGuid(equipGuid);
|
GemHoleCondition condition;
|
if (TryGetGemHoleCondition(hole, out condition))
|
{
|
var starLimit = 0;
|
if (GeneralDefine.equipStarLimit.ContainsKey(equip.config.ItemColor))
|
{
|
var itemLevelStars = GeneralDefine.equipStarLimit[equip.config.ItemColor];
|
if (itemLevelStars.ContainsKey(equip.config.LV))
|
{
|
starLimit = itemLevelStars[equip.config.LV];
|
}
|
}
|
var star = Mathf.Min(starLimit, equipStarModel.GetStarLevel(equipPosition));
|
if (star < condition.equipStar)
|
{
|
return false;
|
}
|
var vipLevel = PlayerDatas.Instance.baseData.VIPLv;
|
if (vipLevel < condition.vipLevel)
|
{
|
return false;
|
}
|
}
|
return true;
|
}
|
|
public bool IsEquipGemHoleOpen(int packIndex, int hole)
|
{
|
var config = EquipPlaceMapConfig.Get(packIndex);
|
if (config != null)
|
{
|
return IsEquipGemHoleOpen(config.LV, config.EquipPlace, hole);
|
}
|
return false;
|
}
|
|
public bool IsEquipGemMaxLevel(int id)
|
{
|
var itemConfig = ItemConfig.Get(id);
|
if (itemConfig == null)
|
{
|
return true;
|
}
|
var gemType = itemConfig.EffectValueA1;
|
if (m_GemTypes.ContainsKey(gemType))
|
{
|
return itemConfig.EffectValueB1 >= m_GemTypes[gemType].maxLevel;
|
}
|
return true;
|
}
|
|
public bool IsBetterGem(int itemId)
|
{
|
var config = ItemConfig.Get(itemId);
|
if (config == null)
|
{
|
return false;
|
}
|
foreach (var level in cacheEquipSets)
|
{
|
foreach (var place in m_EquipPlaces)
|
{
|
var gemTypes = m_EquipGemTypes[place];
|
if (!gemTypes.Contains(config.EffectValueA1))
|
{
|
continue;
|
}
|
for (int i = 0; i < EQUIPGEM_HOLE_COUNT; i++)
|
{
|
if (!IsEquipGemHoleOpen(level, place, i))
|
{
|
continue;
|
}
|
var equipGem = 0;
|
if (TryGetEquipGem(level, place, i, out equipGem))
|
{
|
var compareConfig = ItemConfig.Get(equipGem);
|
return config.EffectValueB1 > compareConfig.EffectValueB1;
|
}
|
else
|
{
|
return true;
|
}
|
}
|
}
|
}
|
return false;
|
}
|
|
public ICollection<int> GetMosaicEquipPlaces()
|
{
|
return m_EquipPlaces;
|
}
|
|
public int GetUnlockEquipSlotCount(int level)
|
{
|
var equipSet = equipModel.GetEquipSet(level);
|
if (equipSet == null || !equipSet.unLocked)
|
{
|
return 0;
|
}
|
var count = 0;
|
var places = GetMosaicEquipPlaces();
|
foreach (var place in places)
|
{
|
if (equipSet.IsSlotUnLocked(place))
|
{
|
count++;
|
}
|
}
|
return count;
|
}
|
|
public List<string> GetSatisfyEquipGemGuids(int place)
|
{
|
if (!m_EquipGemTypes.ContainsKey(place))
|
{
|
return null;
|
}
|
List<string> items = new List<string>();
|
var types = m_EquipGemTypes[place];
|
foreach (var type in types)
|
{
|
var gemType = m_GemTypes[type];
|
var itemModels = packModel.GetItems(PackType.Item, gemType.filterParams);
|
if (itemModels != null)
|
{
|
foreach (var itemModel in itemModels)
|
{
|
if (itemModel.config.EffectValueA1 == type)
|
{
|
items.Add(itemModel.guid);
|
}
|
}
|
}
|
}
|
return items;
|
}
|
|
public ItemConfig GetNextLevelConfig(int id)
|
{
|
if (IsEquipGemMaxLevel(id))
|
{
|
return null;
|
}
|
var config = ItemConfig.Get(id);
|
if (config == null)
|
{
|
return null;
|
}
|
return ItemConfig.GetGemDataByLevelAndType(config.EffectValueB1 + 1, config.EffectValueA1);
|
}
|
|
public int GetGemLevelUpCost(int type, int level)
|
{
|
GemType gemType;
|
if (TryGetGemType(type, out gemType))
|
{
|
var price = 0;
|
if (gemType.shopId != 0)
|
{
|
var shopConfig = StoreConfig.GetStoreCfg(gemType.shopId, 1);
|
if (shopConfig != null)
|
{
|
price = shopConfig.MoneyNumber;
|
}
|
}
|
return (int)Mathf.Pow(gemType.composeCount, level) * price * (gemType.composeCount - 1) / gemType.composeCount;
|
}
|
return 0;
|
}
|
|
public int GetGemCount(int type, int level)
|
{
|
GemType gemType;
|
TryGetGemType(type, out gemType);
|
var count = 0;
|
var items = packModel.GetItems(PackType.Item, gemType.filterParams);
|
if (items == null)
|
{
|
return 0;
|
}
|
for (int i = 0; i < items.Count; i++)
|
{
|
var item = items[i];
|
var config = ItemConfig.Get(item.itemId);
|
if (config.EffectValueA1 == type && config.EffectValueB1 == level)
|
{
|
count += item.count;
|
}
|
}
|
return count;
|
}
|
|
public int GetBetterGemCount(int type, int level)
|
{
|
GemType gemType;
|
TryGetGemType(type, out gemType);
|
var count = 0;
|
var items = packModel.GetItems(PackType.Item, gemType.filterParams);
|
if (items == null)
|
{
|
return 0;
|
}
|
for (int i = 0; i < items.Count; i++)
|
{
|
var item = items[i];
|
var config = ItemConfig.Get(item.itemId);
|
if (config.EffectValueA1 == type && config.EffectValueB1 > level)
|
{
|
count += item.count;
|
}
|
}
|
return count;
|
}
|
|
public int GetSameLevelGemCount(int type, int level)
|
{
|
GemType gemType;
|
TryGetGemType(type, out gemType);
|
var count = 0;
|
var items = packModel.GetItems(PackType.Item, gemType.filterParams);
|
if (items == null)
|
{
|
return 0;
|
}
|
for (int i = 0; i < items.Count; i++)
|
{
|
var item = items[i];
|
var config = ItemConfig.Get(item.itemId);
|
if (config.EffectValueA1 == type && config.EffectValueB1 == level)
|
{
|
count += item.count;
|
}
|
}
|
return count;
|
}
|
|
public int GetSameTypeEmptyUnlockHole(List<int> equipSets, int type)
|
{
|
var count = 0;
|
foreach (var level in equipSets)
|
{
|
foreach (var place in m_EquipPlaces)
|
{
|
if (!m_EquipGemTypes[place].Contains(type))
|
{
|
continue;
|
}
|
for (int i = 0; i < EQUIPGEM_HOLE_COUNT; i++)
|
{
|
if (!IsEquipGemHoleOpen(level, place, i))
|
{
|
continue;
|
}
|
int equipGem;
|
if (!TryGetEquipGem(level, place, i, out equipGem))
|
{
|
count++;
|
}
|
}
|
}
|
}
|
return count;
|
}
|
|
public int GetAllGemsLevel()
|
{
|
var level = 0;
|
foreach (var key in m_EquipGems.Keys)
|
{
|
var equipGems = m_EquipGems[key];
|
foreach (var equipGem in equipGems)
|
{
|
if (equipGem == 0)
|
{
|
continue;
|
}
|
var config = ItemConfig.Get(equipGem);
|
level += config != null ? config.EffectValueB1 : 0;
|
}
|
}
|
return level;
|
}
|
|
public int Compare(string lhs, string rhs)
|
{
|
var lhsItem = packModel.GetItemByGuid(lhs);
|
var rhsItem = packModel.GetItemByGuid(rhs);
|
if (lhsItem == null || rhsItem == null)
|
{
|
return 0;
|
}
|
var lhsConfig = ItemConfig.Get(lhsItem.itemId);
|
var rhsConfig = ItemConfig.Get(rhsItem.itemId);
|
if (lhsConfig.EffectValueB1 != rhsConfig.EffectValueB1)
|
{
|
return -lhsConfig.EffectValueB1.CompareTo(rhsConfig.EffectValueB1);
|
}
|
return lhsItem.itemId.CompareTo(rhsItem.itemId);
|
}
|
|
public void ReceivePackage(HA3BC_tagMCStoneInfo package)
|
{
|
for (int i = 0; i < package.EquipCount; i++)
|
{
|
var data = package.InfoList[i];
|
var config = EquipPlaceMapConfig.Get(data.EquipPlace);
|
if (config == null)
|
{
|
continue;
|
}
|
|
for (int k = 0; k < m_GemHoleItemIds.Count; k++)
|
{
|
int equipGem;
|
TryGetEquipGem(config.LV, config.EquipPlace, k, out equipGem);
|
m_GemHoleItemIds[k] = equipGem;
|
}
|
|
int[] gems = null;
|
if (!m_EquipGems.TryGetValue(data.EquipPlace, out gems))
|
{
|
gems = new int[EQUIPGEM_HOLE_COUNT];
|
m_EquipGems.Add(data.EquipPlace, gems);
|
}
|
for (int k = 0; k < data.MaxStoneCount; k++)
|
{
|
gems[k] = (int)data.StoneInfo[k];
|
if (data.StoneInfo[k] > m_GemHoleItemIds[k])
|
{
|
if (serverInited && equipGemLevelUp != null)
|
{
|
equipGemLevelUp(config.LV, config.EquipPlace, k);
|
}
|
}
|
}
|
if (equipGemRefresh != null)
|
{
|
equipGemRefresh(config.LV, config.EquipPlace);
|
}
|
}
|
RefreshRedpoint();
|
}
|
|
public void SendGemLevelUp(int level, int place, int hole, int levelUpType)
|
{
|
CA306_tagCMEquipStoneUpgrade levelUp = new CA306_tagCMEquipStoneUpgrade();
|
levelUp.EquipIndex = (byte)EquipPlaceMapConfig.GetServerPlace(level, place);
|
if (hole == 3)
|
{
|
levelUp.HoleIndex = 10;
|
}
|
else
|
{
|
levelUp.HoleIndex = (byte)hole;
|
}
|
levelUp.UpWay = (byte)levelUpType;
|
GameNetSystem.Instance.SendInfo(levelUp);
|
}
|
|
List<int> m_CacheEquipSets;
|
List<int> cacheEquipSets
|
{
|
get
|
{
|
if (m_CacheEquipSets == null)
|
{
|
m_CacheEquipSets = equipModel.GetAllEquipSets();
|
}
|
return m_CacheEquipSets;
|
}
|
}
|
List<int> cacheInlayGemTypes = new List<int>();
|
List<int> cacheComposeGemTypes = new List<int>();
|
Dictionary<int, List<bool>> inlayAbles = new Dictionary<int, List<bool>>();
|
Dictionary<int, List<bool>> composeAbles = new Dictionary<int, List<bool>>();
|
void RefreshRedpoint()
|
{
|
cacheInlayGemTypes.Clear();
|
|
foreach (var level in cacheEquipSets)
|
{
|
foreach (var place in m_EquipPlaces)
|
{
|
var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
|
if (!inlayAbles.ContainsKey(packIndex))
|
{
|
inlayAbles[packIndex] = new List<bool>(EQUIPGEM_HOLE_COUNT) { false, false, false, false };
|
}
|
if (!composeAbles.ContainsKey(packIndex))
|
{
|
composeAbles[packIndex] = new List<bool>(EQUIPGEM_HOLE_COUNT) { false, false, false, false };
|
}
|
for (int i = 0; i < EQUIPGEM_HOLE_COUNT; i++)
|
{
|
inlayAbles[packIndex][i] = false;
|
composeAbles[packIndex][i] = false;
|
}
|
}
|
}
|
|
#region 检查空的孔位
|
foreach (var level in cacheEquipSets)
|
{
|
foreach (var place in m_EquipPlaces)
|
{
|
EquipGemRedpoint equipGemRedpoint;
|
TryGetRedpoint(level, place, out equipGemRedpoint);
|
for (int i = 0; i < EQUIPGEM_HOLE_COUNT; i++)
|
{
|
int equipGem;
|
if (!TryGetEquipGem(level, place, i, out equipGem))
|
{
|
if (SatisfyInlayBetterGem(level, place, i))
|
{
|
var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
|
inlayAbles[packIndex][i] = true;
|
cacheInlayGemTypes.AddRange(m_EquipGemTypes[place]);
|
break;
|
}
|
}
|
}
|
}
|
}
|
#endregion
|
|
#region 检查所有孔位
|
foreach (var level in cacheEquipSets)
|
{
|
foreach (var place in m_EquipPlaces)
|
{
|
EquipGemRedpoint equipGemRedpoint;
|
TryGetRedpoint(level, place, out equipGemRedpoint);
|
for (int i = 0; i < EQUIPGEM_HOLE_COUNT; i++)
|
{
|
if (SatisfyInlayBetterGem(level, place, i))
|
{
|
var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
|
inlayAbles[packIndex][i] = true;
|
cacheInlayGemTypes.AddRange(m_EquipGemTypes[place]);
|
break;
|
}
|
}
|
}
|
}
|
#endregion
|
|
cacheComposeGemTypes.Clear();
|
#region 检查非空孔位
|
foreach (var level in cacheEquipSets)
|
{
|
foreach (var place in m_EquipPlaces)
|
{
|
EquipGemRedpoint equipGemRedpoint;
|
TryGetRedpoint(level, place, out equipGemRedpoint);
|
for (int i = 0; i < EQUIPGEM_HOLE_COUNT; i++)
|
{
|
int equipGem;
|
if (TryGetEquipGem(level, place, i, out equipGem))
|
{
|
if (SatisfyComposeGem(level, place, i))
|
{
|
var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
|
composeAbles[packIndex][i] = true;
|
var config = ItemConfig.Get(equipGem);
|
var type = config.EffectValueA1;
|
cacheComposeGemTypes.Add(type);
|
}
|
}
|
}
|
}
|
}
|
#endregion
|
|
foreach (var level in cacheEquipSets)
|
{
|
foreach (var place in m_EquipPlaces)
|
{
|
var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
|
EquipGemRedpoint equipGemRedpoint;
|
TryGetRedpoint(level, place, out equipGemRedpoint);
|
for (int i = 0; i < EQUIPGEM_HOLE_COUNT; i++)
|
{
|
equipGemRedpoint.SetInlayRedpoint(i, inlayAbles[packIndex][i]);
|
equipGemRedpoint.SetComposeRedpoint(i, composeAbles[packIndex][i]);
|
}
|
}
|
}
|
}
|
|
public bool SatisfyInlayBetterGem(int level, int place, int hole)
|
{
|
if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Gem))
|
{
|
return false;
|
}
|
if (!IsEquipGemHoleOpen(level, place, hole))
|
{
|
return false;
|
}
|
int equipGem;
|
TryGetEquipGem(level, place, hole, out equipGem);
|
var equipGemLevel = 0;
|
if (equipGem != 0)
|
{
|
var config = ItemConfig.Get(equipGem);
|
equipGemLevel = config.EffectValueB1;
|
}
|
List<int> gemTypes = m_EquipGemTypes[place];
|
foreach (var type in gemTypes)
|
{
|
if (cacheInlayGemTypes.Contains(type))
|
{
|
continue;
|
}
|
var count = GetBetterGemCount(type, equipGemLevel);
|
if (count > 0)
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public bool SatisfyComposeGem(int level, int place, int hole)
|
{
|
if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Gem))
|
{
|
return false;
|
}
|
if (!IsEquipGemHoleOpen(level, place, hole))
|
{
|
return false;
|
}
|
int equipGem;
|
TryGetEquipGem(level, place, hole, out equipGem);
|
if (equipGem == 0)
|
{
|
return false;
|
}
|
var config = ItemConfig.Get(equipGem);
|
var type = config.EffectValueA1;
|
if (cacheComposeGemTypes.Contains(type))
|
{
|
return false;
|
}
|
var emptyHoleCount = GetSameTypeEmptyUnlockHole(cacheEquipSets, type);
|
var sameLevelCount = GetSameLevelGemCount(type, config.EffectValueB1);
|
sameLevelCount -= emptyHoleCount;
|
GemType gemType;
|
TryGetGemType(type, out gemType);
|
return sameLevelCount >= gemType.composeCount;
|
}
|
|
private void OnFuncStateChangeEvent(int id)
|
{
|
if ((int)FuncOpenEnum.Gem == id)
|
{
|
RefreshRedpoint();
|
}
|
}
|
|
private void RefreshItemCountEvent(PackType packType, int arg2, int itemId)
|
{
|
if (packType == PackType.Equip)
|
{
|
RefreshRedpoint();
|
}
|
if (packType == PackType.Item)
|
{
|
var config = ItemConfig.Get(itemId);
|
if (m_GemTypes.ContainsKey(config.EffectValueA1)
|
&& m_GemTypes[config.EffectValueA1].itemType == config.Type)
|
{
|
RefreshRedpoint();
|
}
|
}
|
}
|
|
private void PlayerDataRefreshInfoEvent(PlayerDataType refreshType)
|
{
|
if (refreshType == PlayerDataType.VIPLv)
|
{
|
RefreshRedpoint();
|
}
|
}
|
}
|
|
public struct GemHoleCondition
|
{
|
public int equipStar;
|
public int vipLevel;
|
}
|
|
public struct GemType
|
{
|
public int maxLevel;
|
public int[] getWays;
|
public string description;
|
public int itemType;
|
public int shopId;
|
public int composeCount;
|
public SinglePack.FilterParams filterParams;
|
}
|
|
public class EquipGemRedpoint
|
{
|
public readonly Redpoint repoint;
|
readonly List<Redpoint> holeRedpooints;
|
readonly List<Redpoint> holeInlayRedpoints;
|
readonly List<Redpoint> holeComposeRedpoints;
|
|
public EquipGemRedpoint(int baseId)
|
{
|
repoint = new Redpoint(baseId, EquipGemModel.REDPOINTBASE++);
|
holeRedpooints = new List<Redpoint>(EquipGemModel.EQUIPGEM_HOLE_COUNT);
|
holeInlayRedpoints = new List<Redpoint>(EquipGemModel.EQUIPGEM_HOLE_COUNT);
|
holeComposeRedpoints = new List<Redpoint>(EquipGemModel.EQUIPGEM_HOLE_COUNT);
|
for (int i = 0; i < EquipGemModel.EQUIPGEM_HOLE_COUNT; i++)
|
{
|
holeRedpooints.Add(new Redpoint(repoint.id, EquipGemModel.REDPOINTBASE++));
|
holeInlayRedpoints.Add(new Redpoint(holeRedpooints[i].id, EquipGemModel.REDPOINTBASE++));
|
holeComposeRedpoints.Add(new Redpoint(holeRedpooints[i].id, EquipGemModel.REDPOINTBASE++));
|
}
|
}
|
|
public void SetInlayRedpoint(int hole, bool inlayable)
|
{
|
if (hole < holeInlayRedpoints.Count)
|
{
|
holeInlayRedpoints[hole].state = inlayable ? RedPointState.Simple : RedPointState.None;
|
}
|
}
|
|
public void SetComposeRedpoint(int hole, bool composeAble)
|
{
|
if (hole < holeComposeRedpoints.Count)
|
{
|
holeComposeRedpoints[hole].state = composeAble ? RedPointState.Simple : RedPointState.None;
|
}
|
}
|
|
public Redpoint GetInlayRedpoint(int hole)
|
{
|
if (hole < holeInlayRedpoints.Count)
|
{
|
return holeInlayRedpoints[hole];
|
}
|
return null;
|
}
|
|
public Redpoint GetComposeRedpoint(int hole)
|
{
|
if (hole < holeComposeRedpoints.Count)
|
{
|
return holeComposeRedpoints[hole];
|
}
|
return null;
|
}
|
|
public Redpoint GetHoleRedpoint(int hole)
|
{
|
if (hole < holeRedpooints.Count)
|
{
|
return holeRedpooints[hole];
|
}
|
return null;
|
}
|
}
|
|
public enum GemEquipType
|
{
|
MultiEquip,
|
}
|
}
|