| | |
| | |
|
| | | public Int2 jumpEquipPosition { get; set; }
|
| | |
|
| | | public bool isServerPrepare { get; private set; }
|
| | |
|
| | | public readonly Redpoint redpoint = new Redpoint(106, 10601);
|
| | | public static int REDPOINTBASE = 106010000;
|
| | |
|
| | | Dictionary<int, Redpoint> m_EquipSetRedpoints = new Dictionary<int, Redpoint>();
|
| | | Dictionary<int, EquipStrengthRedpoint> m_EquipStrengthRedpoints = new Dictionary<int, EquipStrengthRedpoint>();
|
| | |
|
| | |
|
| | | Dictionary<Int2, Redpoint> equipPositionRed = new Dictionary<Int2, Redpoint>();
|
| | |
|
| | | PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
| | | EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
| | | EquipStarModel equipStarModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
|
| | |
| | | {
|
| | | equipPlaces.Add(i);
|
| | | }
|
| | |
|
| | | 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(redpoint.id, equipSetRedpointBase);
|
| | | foreach (var place in equipPlaces)
|
| | | {
|
| | | var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
|
| | | if (!m_EquipStrengthRedpoints.ContainsKey(packIndex))
|
| | | {
|
| | | EquipStrengthRedpoint _redpoint = new EquipStrengthRedpoint(equipSetRedpointBase);
|
| | | m_EquipStrengthRedpoints.Add(packIndex, _redpoint);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | packModel.refreshItemCountEvent += RefreshItemCountEvent;
|
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
|
| | | }
|
| | |
|
| | | public void OnBeforePlayerDataInitialize()
|
| | | {
|
| | |
|
| | | isServerPrepare = false;
|
| | | }
|
| | |
|
| | | public void OnPlayerLoginOk()
|
| | | {
|
| | |
|
| | | UpdateRedpoint();
|
| | | isServerPrepare = true;
|
| | | }
|
| | |
|
| | | public override void UnInit()
|
| | | {
|
| | | packModel.refreshItemCountEvent -= RefreshItemCountEvent;
|
| | | FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
|
| | | }
|
| | |
|
| | | private void PlayerDataRefreshEvent(PlayerDataType dataType)
|
| | | {
|
| | | if (dataType == PlayerDataType.Silver)
|
| | | {
|
| | | if (isServerPrepare)
|
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnFuncStateChangeEvent(int id)
|
| | | {
|
| | | if (id == (int)FuncOpenEnum.Strength)
|
| | | {
|
| | | if (isServerPrepare)
|
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void RefreshItemCountEvent(PackType packType, int arg2, int itemId)
|
| | | {
|
| | | if (packType == PackType.Item)
|
| | | {
|
| | | if (isServerPrepare)
|
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void UpdateEuipPartPlusInfo(HA3B3_tagMCEquipPartPlusInfo info)
|
| | |
| | | if (EquipStrengthUpdate != null)
|
| | | {
|
| | | EquipStrengthUpdate();
|
| | | }
|
| | |
|
| | | if (isServerPrepare)
|
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | return 0;
|
| | | } |
| | | |
| | | public bool SatisfyEquipAdvance(Int2 position)
|
| | | {
|
| | | int equipLv = 0;
|
| | | int advancedLv = 0;
|
| | | int itemCount = 0;
|
| | | int equipIndex = EquipPlaceMapConfig.GetServerPlace(position.x, position.y);
|
| | | if (EquipStrengthDic.ContainsKey(equipIndex))//获取当前强化等级
|
| | | {
|
| | | equipLv = EquipStrengthDic[equipIndex].StrengthLevel;
|
| | | advancedLv = EquipStrengthDic[equipIndex].EvolveLV;
|
| | | }
|
| | | var equipPlusEvolve = GetEquipPlusEvolve(position.y, advancedLv + 1);
|
| | | if (equipPlusEvolve == null)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | if (equipPlusEvolve.NeedPlusLV > equipLv)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | itemCount = packModel.GetItemCountByID(PackType.Item, equipPlusEvolve.CostItemID);
|
| | | if (equipPlusEvolve.CostItemCount > itemCount)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | } |
| | | |
| | | public bool HasEnoughMoney(Int2 position)
|
| | | {
|
| | | var config = GetEquipConfig(position.x, position.y);
|
| | | if (config == null)
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | ulong money = UIHelper.GetMoneyCnt(3);
|
| | | ulong requireMoney = (ulong)config.costCount;
|
| | |
|
| | | return requireMoney < money;
|
| | | } |
| | | |
| | | public bool TryGetRedpoint(int level, out Redpoint _redpoint)
|
| | | {
|
| | | return m_EquipSetRedpoints.TryGetValue(level, out _redpoint);
|
| | | } |
| | | |
| | | public bool TryGetRedpoint(int level, int place, out EquipStrengthRedpoint _redpoint)
|
| | | {
|
| | | var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
|
| | | return m_EquipStrengthRedpoints.TryGetValue(packIndex, out _redpoint);
|
| | | } |
| | | |
| | | void UpdateRedpoint()
|
| | | {
|
| | | if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Strength))
|
| | | {
|
| | | RefreshRedpoint(Int2.zero, 0);
|
| | | return;
|
| | | }
|
| | |
|
| | | var equipSets = equipModel.GetAllEquipSets();
|
| | | foreach (var level in equipSets)
|
| | | {
|
| | | foreach (var place in equipPlaces)
|
| | | {
|
| | | var position = new Int2(level, place);
|
| | | var equipGuid = equipModel.GetEquip(position);
|
| | | if (string.IsNullOrEmpty(equipGuid))
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if (SatisfyEquipAdvance(position))
|
| | | {
|
| | | RefreshRedpoint(position, 2);
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | var satisfyPosition = Int2.zero;
|
| | | var minStage = int.MaxValue;
|
| | | foreach (var level in equipSets)
|
| | | {
|
| | | foreach (var place in equipPlaces)
|
| | | {
|
| | | var position = new Int2(level, place);
|
| | | var equipGuid = equipModel.GetEquip(position);
|
| | | if (string.IsNullOrEmpty(equipGuid))
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | var state = GetEquipStrengthState(position);
|
| | | if (state != 0)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (!HasEnoughMoney(position))
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | var serverPlace = EquipPlaceMapConfig.GetServerPlace(position.x, position.y);
|
| | | var strengthLevel = EquipStrengthDic[serverPlace].StrengthLevel;
|
| | | var stage = strengthLevel / 20;
|
| | |
|
| | | if (minStage > stage)
|
| | | {
|
| | | minStage = stage;
|
| | | satisfyPosition = position;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | RefreshRedpoint(satisfyPosition, 1);
|
| | | } |
| | | |
| | | void RefreshRedpoint(Int2 position, int type)
|
| | | {
|
| | | var equipSets = equipModel.GetAllEquipSets();
|
| | | foreach (var level in equipSets)
|
| | | {
|
| | | foreach (var place in equipPlaces)
|
| | | {
|
| | | var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
|
| | | EquipStrengthRedpoint redpoint;
|
| | | TryGetRedpoint(level, place, out redpoint);
|
| | |
|
| | | redpoint.strengthRedpoint.state =
|
| | | position.x == level && position.y == place && type == 1 ? RedPointState.Simple : RedPointState.None;
|
| | | redpoint.advanceRedpoint.state =
|
| | | position.x == level && position.y == place && type == 2 ? RedPointState.Simple : RedPointState.None;
|
| | | }
|
| | | }
|
| | | } |
| | | |
| | | public class EquipStrengthRedpoint
|
| | | {
|
| | | public readonly Redpoint redpoint;
|
| | | public readonly Redpoint strengthRedpoint;
|
| | | public readonly Redpoint advanceRedpoint;
|
| | |
|
| | | public EquipStrengthRedpoint(int baseId)
|
| | | {
|
| | | redpoint = new Redpoint(baseId, EquipStrengthModel.REDPOINTBASE++);
|
| | | strengthRedpoint = new Redpoint(redpoint.id, EquipStrengthModel.REDPOINTBASE++);
|
| | | advanceRedpoint = new Redpoint(redpoint.id, EquipStrengthModel.REDPOINTBASE++);
|
| | | }
|
| | | } |
| | | } |
| | | |
| | | |