//删除某个天赋天赋数据 private bool DeleteTalent(Talent _this, int nId) { var nLayer = GetTalent(_this, nId); if (nLayer < 1) { return(false); } _this.Talents.Remove(nId); ChangeDistributablePoint(_this, nId, nLayer); //TalentCount += nLayer; _this.mFlag = true; _this.MarkDirty(); var tbTalent = Table.GetTalent(nId); if (tbTalent == null) { Logger.Error("CleanTalent={0} is Success! but Talent Not Find!", nId); return(true); } if (tbTalent.ActiveSkillId != -1) { var nOldLevel = _this.mCharacter.mSkill.GetSkillLevel(tbTalent.ActiveSkillId); if (nOldLevel == 0) { Logger.Info("CleanTalent={0} is Success! ForgetSkill is Faild SkillId={1}", nId, tbTalent.ActiveSkillId); return(true); } _this.mCharacter.mSkill.ForgetSkill(tbTalent.ActiveSkillId); if (tbTalent.ForgetSkillId != -1) { _this.mCharacter.mSkill.LearnSkill(tbTalent.ForgetSkillId, nOldLevel); } } return(true); }
//增加某个天赋的投入点数(接口) public ErrorCodes AddTalent(Talent _this, CharacterController character, int talent) { //PlayerLog.WriteLog(_this.mCharacter.mGuid, "----------AddTalent----------TalentId={0}", talent); var tbTalent = Table.GetTalent(talent); if (tbTalent == null) { return(ErrorCodes.Error_InnateID); } //剩余点数判断 if (GetDistributablePoint(_this, talent) <= 0) { return(ErrorCodes.Error_InnateNoPoint); } //职业判断 //最大点数判断 var nLayer = GetTalent(_this, talent); if (nLayer >= tbTalent.MaxLayer) { return(ErrorCodes.Error_InnateMaxLayer); } //前置判断 if (tbTalent.BeforeId != -1 && GetTalent(_this, tbTalent.BeforeId) < tbTalent.BeforeLayer) { return(ErrorCodes.Error_InnateNoBefore); } //天赋需要消耗资源 if (tbTalent.ModifySkill == -1) { if (tbTalent.NeedLevel > _this.mCharacter.GetLevel()) { return(ErrorCodes.Error_LevelNoEnough); } var tbUpgrade = Table.GetSkillUpgrading(tbTalent.CastItemCount); var needValue = tbUpgrade.GetSkillUpgradingValue(nLayer); if (needValue > _this.mCharacter.mBag.GetItemCount(tbTalent.CastItemId)) { return(ErrorCodes.Error_ResNoEnough); } _this.mCharacter.mBag.DeleteItem(tbTalent.CastItemId, needValue, eDeleteItemType.UpgradeSkill); } //互斥判断 if (GetTalent(_this, tbTalent.HuchiId) != 0) { //如果互斥了,需要所有互斥的点数,然后增加这个 CleanTalent(_this, tbTalent.HuchiId); } //执行操作 nLayer = AddTalent(_this, talent); if (tbTalent.ActiveSkillId != -1 && nLayer == 1) { if (tbTalent.ForgetSkillId != -1) { var nOldLevel = character.mSkill.GetSkillLevel(tbTalent.ForgetSkillId); if (nOldLevel == 0) { Logger.Info("AddTalent={0} is Faild! SkillId={1}", talent, tbTalent.ForgetSkillId); } else { character.mSkill.ForgetSkill(tbTalent.ForgetSkillId); character.mSkill.LearnSkill(tbTalent.ActiveSkillId, nOldLevel); } } else { character.mSkill.LearnSkill(tbTalent.ActiveSkillId, 1); } } _this.mFlag = true; _this.MarkDirty(); ChangeDistributablePoint(_this, talent, -1); EventDispatcher.Instance.DispatchEvent(new AddTalentEvent(character, talent)); return(ErrorCodes.OK); }