//学习技能 public void LearnSkill(SkillData _this, int nId, int nLevel) { if (nId < 0) { return; } //PlayerLog.WriteLog(_this.mCharacter.mGuid, "----------LearnSkill----------skillId={0}:Lv{1}", nId, nLevel); int nOldLevel; if (_this.mDbData.Skills.TryGetValue(nId, out nOldLevel)) { Logger.Warn("LearnSkill={0} is haved! OldLevel={1},NewLevel={2}", nId, nOldLevel, nLevel); } _this.mDbData.Skills[nId] = nLevel; _this.mFlag = true; _this.MarkDirty(); Logger.Info("LearnSkill={0} is Success! Level={1}", nId, nLevel); _this.mCharacter.SkillChange(1, nId, nLevel); _this.mCharacter.AddExData((int)eExdataDefine.e332, 1); var e = new UpgradeSkillEvent(_this.mCharacter, nId); EventDispatcher.Instance.DispatchEvent(e); var tbSkill = Table.GetSkill(nId); if (tbSkill == null || tbSkill.Type == 2) /* ||tbSkill.Type == 2*/ { return; } var HaveFree = false; var list = new List <int>(); foreach (var i in _this.mDbData.EquipSkills) { if (i == -1 && !HaveFree) { list.Add(nId); HaveFree = true; } else { list.Add(i); } } if (HaveFree) { if (nId == 30 || nId == 231 || nId == 133) { if (list.Contains(nId)) { list.Remove(nId); list.Add(nId); } } EquipSkills(_this, list); } }
public ErrorCodes UpgradeSkill(SkillData _this, int nId, ref int result) { int nOldLevel; if (!_this.mDbData.Skills.TryGetValue(nId, out nOldLevel)) { Logger.Warn("UpgradeSkill={0} not find !", nId); return(ErrorCodes.Error_NotHaveSkill); } if (nOldLevel * 5 > _this.mCharacter.GetLevel()) { return(ErrorCodes.Error_SkillLevelMax); } //int maxLevel = mCharacter.GetLevel()/5 + 10; //todo //if (nOldLevel >= maxLevel) //{ // return ErrorCodes.Error_SkillLevelMax; //} var tbSkill = Table.GetSkill(nId); if (tbSkill == null) { return(ErrorCodes.Error_SkillID); } if (tbSkill.NeedMoney == -1)//表中需要改此数值 { return(ErrorCodes.Error_SkillNoTUpgrade); } var tbUpgrade = Table.GetSkillUpgrading(tbSkill.NeedMoney); var needValue = tbUpgrade.GetSkillUpgradingValue(nOldLevel - 1); var tbUpgradeTyp = Table.GetSkillUpgrading(999); var needValueType = tbUpgradeTyp.GetSkillUpgradingValue(nOldLevel - 1); if (needValue < 1) { return(ErrorCodes.Error_SkillNoTUpgrade); } if (_this.mCharacter.mBag.GetItemCount(needValueType) < needValue) { return(ErrorCodes.Error_ResNoEnough); } _this.mCharacter.mBag.DeleteItem(needValueType, needValue, eDeleteItemType.UpgradeSkill); LevelUpSkill(_this, nId, nOldLevel + 1); var e = new UpgradeSkillEvent(_this.mCharacter, nId); EventDispatcher.Instance.DispatchEvent(e); _this.mCharacter.AddExData((int)eExdataDefine.e89, 1); try { var klog = string.Format("upgradeskill#{0}|{1}|{2}|{3}|{4}|{5}", _this.mCharacter.mGuid, _this.mCharacter.GetLevel(), _this.mCharacter.serverId, nId, nOldLevel, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); PlayerLog.Kafka(klog, 2); } catch (Exception exception) { Logger.Error(exception.Message); } return(ErrorCodes.OK); }