public static void RefreshCast(this SkillItemDataModel dataModel)
    {
        if (dataModel.SkillId == -1 || dataModel.SkillId == 0)
        {
            dataModel.SkillCost = -1;
            return;
        }
        if (dataModel.SkillLv == 0)
        {
            return;
        }
        RefreshLevelCast(dataModel);
        var type = StringConvert.Level_Value_Ref(10000000 + 999, dataModel.SkillLv - 1);
        var upgradeTableIndex = Table.GetSkill(dataModel.SkillId).NeedMoney;
        var cost = StringConvert.Level_Value_Ref(10000000 + upgradeTableIndex, dataModel.SkillLv - 1);

        dataModel.SkillCost     = 0;
        dataModel.SkillSparCost = 0;

        if (type == 5)
        {
            dataModel.SkillSparCost = cost;
        }
        if (type == 2)
        {
            dataModel.SkillCost = cost;
        }
    }
Example #2
0
    public static void RefreshLevelCast(this SkillItemDataModel dataModel)
    {
        if (dataModel.SkillLv == 0)
        {
            return;
        }

        var level = PlayerDataManager.Instance.GetLevel();

        dataModel.SkillUpGradeLv = dataModel.SkillLv * 5;
        dataModel.ShowUpGradeBtn = dataModel.SkillUpGradeLv <= level;

        var type = StringConvert.Level_Value_Ref(10000000 + 999, dataModel.SkillLv - 1);

        if (type == 5)
        {
            dataModel.ShowGoldCost = false;
            dataModel.ShowSparCost = true;
        }
        else if (type == 2)
        {
            dataModel.ShowGoldCost = true;
            dataModel.ShowSparCost = false;
        }
    }
Example #3
0
    private void OnLevelUp(IEvent ievent)
    {
        var level = PlayerDataManager.Instance.GetLevel();

        var count2 = SkillDataModel.Talents.Count;

        for (var i = 0; i < count2; i++)
        {
            var talents = SkillDataModel.Talents[i];
            if (talents.NeedLevel <= level)
            {
                talents.LevelLock = false;
            }
        }


        if (level % 5 != 0)
        {
            return;
        }

        var count = SkillDataModel.OtherSkills.Count;

        for (var i = 0; i < count; i++)
        {
            var skill = SkillDataModel.OtherSkills[i];
            skill.RefreshCast();
            if (!skill.ShowUpGradeBtn)
            {
                continue;
            }
            var type = StringConvert.Level_Value_Ref(10000000 + 999, skill.SkillLv - 1);
            if (type == 5)
            {
                var spar = PlayerDataManager.Instance.GetRes((int)eResourcesType.Spar);
                if (spar < skill.SkillSparCost)
                {
                    continue;
                }
                PlayerDataManager.Instance.WeakNoticeData.SkillCanUpgrade = true;
                PlayerDataManager.Instance.WeakNoticeData.SkillTotal      = true;
                return;
            }
            var gold = PlayerDataManager.Instance.GetRes((int)eResourcesType.GoldRes);
            if (gold < skill.SkillCost)
            {
                continue;
            }
            PlayerDataManager.Instance.WeakNoticeData.SkillCanUpgrade = true;
            PlayerDataManager.Instance.WeakNoticeData.SkillTotal      = true;
            return;
        }
    }
Example #4
0
    public void RefreshSelected(SkillItemDataModel dataModel)
    {
        SkillDataModel.SelectSkill = dataModel;
        var skilldata = SkillDataModel;
        var selected  = skilldata.SelectedSkillList[0];

        selected.SkillId = dataModel.SkillId;
        selected.SkillLv = dataModel.SkillLv;
        var skillTable = Table.GetSkill(dataModel.SkillId);

        selected.ManaCast  = StringConvert.Level_Value_Ref(skillTable.NeedMp, dataModel.SkillLv - 1);
        selected.SkillType = getSkillTypeString(skillTable.ControlType);
        selected.SkillItem = dataModel;

        var current = 0;
//         var skillTalent = PlayerDataManager.Instance.mSkillTalent;
//         if (skillTalent.ContainsKey(dataModel.SkillId))
//         {
//             current = skillTalent[dataModel.SkillId];
//         }

        var skillboxs         = PlayerDataManager.Instance.PlayerDataModel.SkillData.SkillBoxes;
        SkillBoxDataModel box = null;

        for (var i = 0; i < skillboxs.Count; i++)
        {
            if (skillboxs[i].SkillId == dataModel.SkillId)
            {
                box = skillboxs[i];
                break;
            }
        }

        if (null != box)
        {
            current = box.LastCount + box.CurrentCount;
        }

        selected.TalentCount = string.Format("{0}/{1}", current, skillTable.TalentMax);

        var selected2 = skilldata.SelectedSkillList[1];

        selected2.SkillId   = selected.SkillId;
        selected2.SkillLv   = selected.SkillLv == 0 ? 2 : selected.SkillLv + 1;
        selected2.ManaCast  = selected.ManaCast;
        selected2.SkillType = selected.SkillType;
    }
    public static void RefreshLevelCast(this SkillItemDataModel dataModel)
    {
        if (dataModel.SkillLv == 0)
        {
            return;
        }
        var tb = Table.GetSkill(dataModel.SkillId);

        if (tb == null)
        {
            return;
        }

        var level = PlayerDataManager.Instance.GetLevel();

        dataModel.SkillUpGradeLv = dataModel.SkillLv * 5;
        dataModel.ShowUpGradeBtn = dataModel.SkillUpGradeLv <= level && tb.Type == 1;

        if (dataModel.IsXpSkill)
        {
            dataModel.ShowUpGradeBtn = false;
        }

        if (dataModel.SkillLv >= 80)
        {
            dataModel.ShowUpAbuotBtn = false;
            dataModel.ShowUpMaxLabel = true;
        }
        else
        {
            dataModel.ShowUpAbuotBtn = true;
            dataModel.ShowUpMaxLabel = false;
        }

        var type = StringConvert.Level_Value_Ref(10000000 + 999, dataModel.SkillLv - 1);

        if (type == 5)
        {
            dataModel.ShowGoldCost = false;
            dataModel.ShowSparCost = true;
        }
        else if (type == 2)
        {
            dataModel.ShowGoldCost = true;
            dataModel.ShowSparCost = false;
        }
    }
    public static void AddTalentAttrToPanel(ObservableCollection <TalentAttr> attrPanel, TalentCellDataModel talent)
    {
        if (talent.Count <= 0)
        {
            return;
        }

        var TalentTable = Table.GetTalent(talent.TalentId);

        if (TalentTable.AttrId != -1)
        {
            var talentAttr = new TalentAttr();
            talentAttr.AttrId    = TalentTable.AttrId;
            talentAttr.AttrName  = ExpressionHelper.AttrName[TalentTable.AttrId];
            talentAttr.AttrValue = StringConvert.Level_Value_Ref(10000000 + TalentTable.SkillupgradingId, talent.Count);
            var bExist = false;
            {
                // foreach(var attr in attrPanel)
                var __enumerator3 = (attrPanel).GetEnumerator();
                while (__enumerator3.MoveNext())
                {
                    var attr = __enumerator3.Current;
                    {
                        if (attr.AttrName == talentAttr.AttrName)
                        {
                            attr.AttrValue       = attr.AttrValue + talentAttr.AttrValue;
                            attr.AttrStringValue = GameUtils.AttributeValue(TalentTable.AttrId, attr.AttrValue);
                            bExist = true;
                        }
                    }
                }
            }
            if (!bExist)
            {
                talentAttr.AttrStringValue = GameUtils.AttributeValue(TalentTable.AttrId, talentAttr.AttrValue);
                attrPanel.Add(talentAttr);
            }
            PlayerDataManager.Instance.PlayerDataModel.SkillData.ShowAttrPanelButton = true;
        }
    }
Example #7
0
    public ErrorCodes CheckSkill(int skillId, bool isAuto = false)
    {
        var player = ObjManager.Instance.MyPlayer;

        if (null == player)
        {
            Logger.Error("CheckSkill ObjManager.Instance.MyPlayer is null");
            return(ErrorCodes.Unknow);
        }


        if (player.IsInSafeArea())
        {
            return(ErrorCodes.Error_SafeArea);
        }

        if (player.Dead)
        {
            return(ErrorCodes.Error_CharacterDie);
        }

//      if (player.GetCurrentStateName() == OBJ.CHARACTER_STATE.DIZZY)
//      {
//          return ErrorCodes.Error_Dizzy;
//      }

        if (isAuto)
        {
            var buffId = -1;
            if (AutoSkillBuff.TryGetValue(skillId, out buffId))
            {
                var buffManager = ObjManager.Instance.MyPlayer.GetBuffManager();
                if (buffManager != null && buffManager.HasBuff(buffId))
                {
                    return(ErrorCodes.Unknow);
                }
            }
        }

        var PlayerDataModel = PlayerDataManager.Instance.PlayerDataModel;
        //CD
        var skillStates = PlayerDataManager.Instance.PlayerDataModel.SkillData.SkillStates;

        if (skillStates == null)
        {
            Logger.Error("CheckSkill SkillStates is null");
            return(ErrorCodes.Unknow);
        }
        SkillStateData skillState = null;
        var            tbSkill    = Table.GetSkill(skillId);

        if (null == tbSkill)
        {
            return(ErrorCodes.Unknow);
        }

        if (PlayerDataManager.Instance.PlayerDataModel.SkillData.EquipSkills == null)
        {
            Logger.Error("CheckSkill EquipSkills is null");
            return(ErrorCodes.Unknow);
        }

        var isSkipCd = false;
        SkillItemDataModel skillItem = null;
        var skillLevel = 0;

        if (!PlayerDataManager.Instance.mAllSkills.TryGetValue(skillId, out skillItem))
        {
            return(ErrorCodes.Unknow);
        }

        //MP
        var needMp = StringConvert.Level_Value_Ref(tbSkill.NeedMp, skillLevel);

        if (needMp != -1 && PlayerDataModel.Attributes.MpNow < needMp)
        {
            return(ErrorCodes.Error_MpNoEnough);
        }
        //HP
        var needHP = StringConvert.Level_Value_Ref(tbSkill.NeedHp, skillLevel);

        if (needHP != -1 && PlayerDataModel.Attributes.HpNow < needHP)
        {
            return(ErrorCodes.Error_HpNoEnough);
        }

        if (skillStates.TryGetValue(skillId, out skillState))
        {
            if (skillState.State == SkillState.Send)
            {
                return(ErrorCodes.Error_SkillNoCD);
            }
        }
        if (PlayerDataManager.Instance.PlayerDataModel.SkillData.CommonCoolDown > 0 && tbSkill.Type != 3) //xp技能忽视cd
        {
            return(ErrorCodes.Error_SkillNoCD);
        }

        if ((skillItem.CoolDownTime > 0 && skillItem.ChargeLayerTotal <= 1) || skillItem.ChargeLayer == 0)
        {
            return(ErrorCodes.Error_SkillNoCD);
        }

        if (0 != tbSkill.IsEquipCanUse)
        {
            var euipList = PlayerDataManager.Instance.PlayerDataModel.EquipList;
            if (null == euipList)
            {
                return(ErrorCodes.Error_SkillNeedWeapon);
            }
            if (euipList.Count <= (int)eEquipType.WeaponMain)
            {
                return(ErrorCodes.Error_SkillNeedWeapon);
            }
            var item = euipList[(int)eEquipType.WeaponMain];
            if (null == item)
            {
                return(ErrorCodes.Error_SkillNeedWeapon);
            }
            if (-1 == item.ItemId)
            {
                return(ErrorCodes.Error_SkillNeedWeapon);
            }
        }

        //anger
        var needAnger = StringConvert.Level_Value_Ref(tbSkill.NeedAnger, skillLevel);


        //妫€鏌uff闄愬埗鏁堟灉
        if (CheckControlType(skillItem, player.GetBuffManager()))
        {
            return(ErrorCodes.Error_SkillNotUse);
        }
        return(ErrorCodes.OK);
    }
Example #8
0
    public void RefreshTalentBoardDesc(int talentId)
    {
        if (talentId < 0)
        {
            return;
        }
        var skillData = SkillDataModel;
        var descIndex = 0;
        TalentCellDataModel talentCellData = null;
        {
            // foreach(var talent in skillData.Talents)
            var __enumerator4 = (skillData.Talents).GetEnumerator();
            while (__enumerator4.MoveNext())
            {
                var talent = __enumerator4.Current;
                {
                    if (talent.TalentId == talentId)
                    {
                        descIndex      = talent.Count;
                        talentCellData = talent;
                    }
                }
            }
        }

        var talentTable = Table.GetTalent(talentId);

        if (talentTable.ModifySkill == -1 && talentTable.BeforeId != -1)
        {
            if (null == talentCellData || talentCellData.ShowLock)
            {
                skillData.TalentIdSelected = -1;
                return;
            }
        }

        skillData.SelectedTalentLevel   = string.Format("{0}/{1}", descIndex, talentTable.MaxLayer);
        skillData.ShowDesBoardAddButton = 1;
        //         if (talentTable.AttrId >= ExpressionHelper.AttrName.Count || talentTable.AttrId < 0)
        //         {
        //             return;
        //         }
        if (!ExpressionHelper.AttrName.ContainsKey(talentTable.AttrId))
        {
            if (descIndex == 0)
            {
                skillData.SelectedTalentDesc     = talentTable.BuffDesc[0];
                skillData.ShowDesBoardNext       = 0;
                skillData.SelectedTalentDescNext = string.Empty;
            }
            else if (descIndex == talentTable.MaxLayer)
            {
                skillData.SelectedTalentDesc     = talentTable.BuffDesc[talentTable.MaxLayer - 1];
                skillData.SelectedTalentDescNext = string.Empty;
                skillData.ShowDesBoardNext       = 0;
                skillData.ShowDesBoardAddButton  = 0;
            }
            else
            {
                skillData.SelectedTalentDesc     = talentTable.BuffDesc[descIndex - 1];
                skillData.SelectedTalentDescNext = talentTable.BuffDesc[descIndex];
                skillData.ShowDesBoardNext       = 1;
            }
        }
        else
        {
            var attrName = ExpressionHelper.AttrName[talentTable.AttrId];
            if (descIndex == 0)
            {
                var AttrValue = StringConvert.Level_Value_Ref(10000000 + talentTable.SkillupgradingId,
                                                              talentCellData.Count + 1);
                skillData.SelectedTalentDesc = string.Format("{0}+{1}", attrName,
                                                             GameUtils.AttributeValue(talentTable.AttrId, AttrValue));
                skillData.SelectedTalentDescNext = string.Empty;
                skillData.ShowDesBoardNext       = 0;
            }
            else if (descIndex == talentTable.MaxLayer)
            {
                var AttrValue = StringConvert.Level_Value_Ref(10000000 + talentTable.SkillupgradingId,
                                                              talentCellData.Count);
                skillData.SelectedTalentDesc = string.Format("{0}+{1}", attrName,
                                                             GameUtils.AttributeValue(talentTable.AttrId, AttrValue));
                skillData.SelectedTalentDescNext = string.Empty;
                skillData.ShowDesBoardNext       = 0;
                skillData.ShowDesBoardAddButton  = 0;
            }
            else
            {
                var AttrValue = StringConvert.Level_Value_Ref(10000000 + talentTable.SkillupgradingId,
                                                              talentCellData.Count);
                var nextAttrValue = StringConvert.Level_Value_Ref(10000000 + talentTable.SkillupgradingId,
                                                                  talentCellData.Count + 1);
                skillData.SelectedTalentDesc = string.Format("{0}+{1}", attrName,
                                                             GameUtils.AttributeValue(talentTable.AttrId, AttrValue));
                skillData.SelectedTalentDescNext = string.Format("{0}+{1}", attrName,
                                                                 GameUtils.AttributeValue(talentTable.AttrId, nextAttrValue));
                skillData.ShowDesBoardNext = 1;
            }
        }


        //天赋消耗刷新
        if (talentTable.ModifySkill == -1)
        {
            var tbUpgrade = Table.GetSkillUpgrading(talentTable.CastItemCount);
            skillData.TalentPanelUpgradeCast = tbUpgrade.GetSkillUpgradingValue(talentCellData.Count);
        }
    }