/// <summary> /// 判断技能升级是否有足够的钱 /// </summary> /// <returns></returns> public SkillLevelUpCode HaveEnoughMoney() { var iter = userSkilldic.GetEnumerator(); uint skillID = 0; uint minLevel = 1000; uint skillLv = 0; while (iter.MoveNext()) { SkillDatabase temp = GameTableManager.Instance.GetTableItem <SkillDatabase>(iter.Current.Value.skillID, (int)iter.Current.Value.level + 1); if (temp != null) { if (temp.IsBasic) { continue; } if (temp.dwNeedLevel <= minLevel) { minLevel = temp.dwNeedLevel; skillID = iter.Current.Value.skillID; skillLv = iter.Current.Value.level; } } } SkillDatabase sdb = GameTableManager.Instance.GetTableItem <SkillDatabase>(skillID, (int)skillLv); if (sdb == null) { return(SkillLevelUpCode.NoneData); } if (!UserSkilldic.ContainsKey(sdb.wdID)) { return(SkillLevelUpCode.NoSkill); } IPlayer player = Client.ClientGlobal.Instance().MainPlayer; if (player != null) { //需要等级 int playerLv = player.GetProp((int)CreatureProp.Level); uint nextLevel = sdb.wdLevel + 1; SkillDatabase nextDataBase = GameTableManager.Instance.GetTableItem <SkillDatabase>(sdb.wdID, (int)nextLevel); if (nextDataBase != null) { if (playerLv < nextDataBase.dwNeedLevel) { return(SkillLevelUpCode.LevelNotEnough); } //消耗金币 if (player.GetProp((int)Client.PlayerProp.Coupon) < nextDataBase.dwMoney) { return(SkillLevelUpCode.NoMoney); } } } return(SkillLevelUpCode.Ok); }
/// <summary> /// 是否可升级 /// </summary> /// <param name="sdb"></param> /// <returns></returns> public bool IsSkillEnableUpgrade(SkillDatabase sdb) { bool isEnableUpgrade = true; if (sdb == null) { isEnableUpgrade = false; return(isEnableUpgrade); } if (sdb.isnormal) { return(false); } if (!UserSkilldic.ContainsKey(sdb.wdID)) { return(false); } IPlayer player = Client.ClientGlobal.Instance().MainPlayer; if (player != null) { //需要等级 int playerLv = player.GetProp((int)CreatureProp.Level); uint nextLevel = sdb.wdLevel + 1; SkillDatabase nextDataBase = GameTableManager.Instance.GetTableItem <SkillDatabase>(sdb.wdID, (int)nextLevel); if (nextDataBase != null) { if (playerLv < nextDataBase.dwNeedLevel) { return(false); } // //消耗金币 // if (player.GetProp((int)Client.PlayerProp.Coupon) < nextDataBase.dwMoney) // { // return false; // } // // //消耗经验 // if (player.GetProp((int)PlayerProp.Exp) < nextDataBase.dwExp) // { // return false; // } } else { return(false); } } //前置技能 SkillDatabase preSkilldb = GameTableManager.Instance.GetTableItem <SkillDatabase>(sdb.dwNeedSkill1, (int)sdb.dwNeedSkill1Level); if (preSkilldb != null) { SkillInfo skill; if (userSkilldic.TryGetValue(preSkilldb.wdID, out skill)) { if (skill.level < sdb.dwNeedSkill1Level) { return(false); } } else { return(false); } } return(isEnableUpgrade); }