public void AddSkillPoint(Talent _this, int nSkillId, int nAdd) { if (nAdd <= 0) { Logger.Warn("AddSkillPoint error! Value < 0"); return; } _this.mFlag = true; _this.MarkDirty(); int count; if (_this.Skills.TryGetValue(nSkillId, out count)) { count += nAdd; _this.Skills[nSkillId] = count; var eAdd = new SkillPointChangeEvent(_this.mCharacter, nSkillId, count); EventDispatcher.Instance.DispatchEvent(eAdd); } else { _this.Skills[nSkillId] = nAdd; var eAdd = new SkillPointChangeEvent(_this.mCharacter, nSkillId, nAdd); EventDispatcher.Instance.DispatchEvent(eAdd); } }
//洗天赋 public void RefreshTalent(Talent _this, CharacterController character) { var templist = new List <int>(); foreach (var i in _this.Talents) { if (Table.GetTalent(i.Key).ModifySkill == -1) { templist.Add(i.Key); } } foreach (var id in templist) { DeleteTalent(_this, id); } //foreach (var i in Talents) //{ // ChangeDistributablePoint(i.Key, i.Value); // //TalentCount += i.Value; //} //Talents.Clear(); _this.mFlag = true; _this.MarkDirty(); PlayerLog.WriteLog(_this.mCharacter.mGuid, "----------RefreshTalent----------TalentCount={0}", _this.TalentCount); //Logger.Info("RefreshTalent is Success! TalentCount={0}", TalentCount); _this.mCharacter.TalentChange(3, -1, -1); }
//增加天赋的可分配点数 public void AddTalentPoint(Talent _this, int nAdd) { if (nAdd <= 0) { Logger.Warn("AddTalentPoint error! Value < 0"); return; } _this.mFlag = true; _this.MarkDirty(); _this.TalentCount += nAdd; if (_this.TalentCount < 0) { _this.TalentCount = 0; } PlayerLog.WriteLog(_this.mCharacter.mGuid, "----------AddTalentPoint----------TalentCount={0}", _this.TalentCount); //Logger.Info("AddTalentPoint is Success! TalentCount=={0}", TalentCount); }
//删除某个天赋天赋数据 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); }