public static void ModifyEffect(GameClient client, int effectID, int talentType, int newLevel) { try { TalentData talentData = client.ClientData.MyTalentData; TalentInfo talentInfo = TalentManager.GetTalentInfoByID(client.ClientData.Occupation, effectID); if (talentInfo != null) { List <TalentEffectInfo> newItemEffectList = talentInfo.EffectList[newLevel]; bool result = TalentManager.DBTalentEffectModify(client.ClientData.RoleID, talentType, effectID, newLevel, client.ClientData.ZoneID, client.ServerId); Dictionary <int, int> countList; (countList = talentData.CountList)[talentType] = countList[talentType] + newLevel; TalentEffectItem effectItemOld = TalentManager.GetOpenEffectItem(talentData, effectID); if (effectItemOld == null) { effectItemOld = new TalentEffectItem(); effectItemOld.ID = effectID; effectItemOld.TalentType = talentType; talentData.EffectList.Add(effectItemOld); } effectItemOld.Level = newLevel; effectItemOld.ItemEffectList = newItemEffectList; } } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } }
/// <summary> /// 效果是否开启 /// </summary> private static bool IsEffectOpen(TalentData talentData, int effectID, int level) { if (effectID <= 0) { return(true); } TalentEffectItem item = GetOpenEffectItem(talentData, effectID); if (item != null) { if (item.Level >= level) { return(true); } } return(false); }
private static void DbUpdateTalentEffect(DBManager dbMgr, int roleID, int talentType, int effectID, int effectLevel) { DBRoleInfo dbRoleInfo = dbMgr.DBRoleMgr.FindDBRoleInfo(ref roleID); if (null != dbRoleInfo) { lock (dbRoleInfo) { TalentEffectItem item = null; foreach (TalentEffectItem i in dbRoleInfo.MyTalentData.EffectList) { if (i.ID == effectID) { item = i; break; } } int add; if (item == null) { add = effectLevel; item = new TalentEffectItem { ID = effectID, Level = effectLevel, TalentType = talentType }; dbRoleInfo.MyTalentData.EffectList.Add(item); } else { add = effectLevel - item.Level; item.Level = effectLevel; } Dictionary <int, int> countList; (countList = dbRoleInfo.MyTalentData.CountList)[talentType] = countList[talentType] + add; } } }
private static bool IsEffectOpen(TalentData talentData, int effectID, int level) { bool result; if (effectID <= 0) { result = true; } else { TalentEffectItem item = TalentManager.GetOpenEffectItem(talentData, effectID); if (item != null) { if (item.Level >= level) { return(true); } } result = false; } return(result); }
private void SaveRoleCustomData(GameClient client, RoleCustomData customData) { int oldIndex = -1; RoleCustomDataItem roleCustomDataOld = null; RoleCustomDataItem roleCustomData = null; if (customData != null && customData.customDataList != null && customData.customDataList.Count > 0) { oldIndex = customData.customDataList.FindIndex((RoleCustomDataItem x) => x.Occupation == client.ClientData.Occupation); if (oldIndex >= 0) { roleCustomDataOld = customData.customDataList[oldIndex]; } } roleCustomData = new RoleCustomDataItem { Occupation = client.ClientData.Occupation }; roleCustomData.Main_quick_keys = client.ClientData.MainQuickBarKeys; roleCustomData.RolePointList.Add(client.ClientData.PropStrength - Global.GetRoleParamsInt32FromDB(client, "PropStrengthChangeless")); roleCustomData.RolePointList.Add(client.ClientData.PropIntelligence - Global.GetRoleParamsInt32FromDB(client, "PropIntelligenceChangeless")); roleCustomData.RolePointList.Add(client.ClientData.PropDexterity - Global.GetRoleParamsInt32FromDB(client, "PropDexterityChangeless")); roleCustomData.RolePointList.Add(client.ClientData.PropConstitution - Global.GetRoleParamsInt32FromDB(client, "PropConstitutionChangeless")); for (int i = 0; i < roleCustomData.RolePointList.Count; i++) { if (roleCustomData.RolePointList[i] < 0) { roleCustomData.RolePointList[i] = 0; } } int sum = roleCustomData.RolePointList.Sum(); while (sum > client.ClientData.TotalPropPoint) { for (int i = 0; i < roleCustomData.RolePointList.Count; i++) { if (roleCustomData.RolePointList[i] > 0) { List <int> rolePointList; int index; (rolePointList = roleCustomData.RolePointList)[index = i] = rolePointList[index] - 1; sum--; } } } TalentData talentData = client.ClientData.MyTalentData; if (talentData != null && null != talentData.EffectList) { foreach (TalentEffectItem item in talentData.EffectList) { roleCustomData.EffectList.Add(new TalentEffectItem { ID = item.ID, Level = item.Level, TalentType = item.TalentType }); } } roleCustomData.EffectList.Sort((TalentEffectItem x, TalentEffectItem y) => x.ID - y.ID); roleCustomData.DefaultSkillLev = client.ClientData.DefaultSkillLev; roleCustomData.DefaultSkillUseNum = client.ClientData.DefaultSkillUseNum; if (client.ClientData.FuWenTabList != null && client.ClientData.FuWenTabList.Count > 0) { List <SkillEquipData> skillList = new List <SkillEquipData>(); foreach (FuWenTabData item2 in client.ClientData.FuWenTabList) { skillList.Add(new SkillEquipData { SkillEquip = item2.SkillEquip, ShenShiActiveList = item2.ShenShiActiveList }); } roleCustomData.ShenShiEuipSkill = skillList; } bool changed = false; if (null == roleCustomDataOld) { customData.customDataList.Add(roleCustomData); } else { if (null == roleCustomDataOld.RolePointList) { changed = true; } else if (roleCustomDataOld.RolePointList.Count != roleCustomData.RolePointList.Count) { changed = true; } else { int i = 0; while (i < roleCustomDataOld.RolePointList.Count && i < roleCustomData.RolePointList.Count) { if (roleCustomDataOld.RolePointList[i] != roleCustomData.RolePointList[i]) { changed = true; break; } i++; } } if (null == roleCustomDataOld.EffectList) { changed = true; } else if (roleCustomDataOld.EffectList.Count != roleCustomData.EffectList.Count) { changed = true; } else { roleCustomDataOld.EffectList.Sort((TalentEffectItem x, TalentEffectItem y) => x.ID - y.ID); for (int i = 0; i < roleCustomDataOld.EffectList.Count; i++) { TalentEffectItem x2 = roleCustomDataOld.EffectList[i]; TalentEffectItem y2 = roleCustomData.EffectList[i]; if (x2.ID != y2.ID || x2.Level != y2.Level) { changed = true; break; } } } if (roleCustomDataOld.Main_quick_keys != roleCustomData.Main_quick_keys) { changed = true; } if (roleCustomData.DefaultSkillLev != roleCustomDataOld.DefaultSkillLev || roleCustomData.DefaultSkillUseNum != roleCustomDataOld.DefaultSkillUseNum) { changed = true; } if (null != roleCustomData.ShenShiEuipSkill) { changed = true; } if (changed) { customData.customDataList[oldIndex] = roleCustomData; } } if (client.ClientData.IsMainOccupation) { customData.roleData4Selector = Global.RoleDataEx2RoleData4Selector(client.ClientData.GetRoleData()); } Global.sendToDB <int, RoleCustomData>(10233, customData, client.ServerId); }
/// <summary> /// 效果升级 /// </summary> /// <param name="client"></param> /// <param name="effectID">效果id</param> /// <returns></returns> private static int TalentAddEffect(GameClient client, int effectID, int addCount) { //开放 if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.Talent)) { return(TalentResultType.EnoOpen); } // 如果1.6的功能没开放 if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot6)) { return(TalentResultType.EnoOpen); } //配置信息 TalentInfo talentInfo = GetTalentInfoByID(client.ClientData.Occupation, effectID); if (talentInfo == null) { return(TalentResultType.EnoEffect); } TalentData talentData = client.ClientData.MyTalentData; //天赋点数不足 int talentCountLeft = talentData.TotalCount - GetTalentUseCount(talentData); if (talentCountLeft < addCount) { return(TalentResultType.EnoTalentCount); } //前置效果开启 if (!IsEffectOpen(talentData, talentInfo.NeedTalentID, talentInfo.NeedTalentLevel)) { return(TalentResultType.EnoOpenPreEffect); } //前置开启点数 if (talentInfo.NeedTalentCount > 0 && talentInfo.NeedTalentCount > talentData.CountList[talentInfo.Type]) { return(TalentResultType.EnoOpenPreCount); } int newLevel = 0; List <TalentEffectInfo> newItemEffectList = null; //当前等级 TalentEffectItem effectItemOld = GetOpenEffectItem(talentData, effectID); if (effectItemOld != null) { //最高等级 if (effectItemOld.Level >= talentInfo.LevelMax) { return(TalentResultType.EisMaxLevel); } newLevel = effectItemOld.Level; } newLevel += addCount; newItemEffectList = talentInfo.EffectList[newLevel]; //是否溢出 if (newLevel > talentInfo.LevelMax) { return(TalentResultType.EisMaxLevel); } //更新数据库 bool result = DBTalentEffectModify(client.ClientData.RoleID, talentInfo.Type, effectID, newLevel, client.ClientData.ZoneID, client.ServerId); if (!result) { return(TalentResultType.EFail); } //更新内存 talentData.CountList[talentInfo.Type] += addCount; if (effectItemOld == null) { effectItemOld = new TalentEffectItem(); effectItemOld.ID = effectID; effectItemOld.TalentType = talentInfo.Type; talentData.EffectList.Add(effectItemOld); } effectItemOld.Level = newLevel; effectItemOld.ItemEffectList = newItemEffectList; //属性加成 initTalentEffectProp(client); //属性刷新 RefreshProp(client); return(TalentResultType.Success); }
private static int TalentAddEffect(GameClient client, int effectID, int addCount) { int result; if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.Talent, false)) { result = TalentResultType.EnoOpen; } else if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot6)) { result = TalentResultType.EnoOpen; } else { TalentInfo talentInfo = TalentManager.GetTalentInfoByID(client.ClientData.Occupation, effectID); if (talentInfo == null) { result = TalentResultType.EnoEffect; } else { TalentData talentData = client.ClientData.MyTalentData; int talentCountLeft = talentData.TotalCount - TalentManager.GetTalentUseCount(talentData); if (talentCountLeft < addCount) { result = TalentResultType.EnoTalentCount; } else if (!TalentManager.IsEffectOpen(talentData, talentInfo.NeedTalentID, talentInfo.NeedTalentLevel)) { result = TalentResultType.EnoOpenPreEffect; } else if (talentInfo.NeedTalentCount > 0 && talentInfo.NeedTalentCount > talentData.CountList[talentInfo.Type]) { result = TalentResultType.EnoOpenPreCount; } else { int newLevel = 0; TalentEffectItem effectItemOld = TalentManager.GetOpenEffectItem(talentData, effectID); if (effectItemOld != null) { if (effectItemOld.Level >= talentInfo.LevelMax) { return(TalentResultType.EisMaxLevel); } newLevel = effectItemOld.Level; } newLevel += addCount; List <TalentEffectInfo> newItemEffectList = talentInfo.EffectList[newLevel]; if (newLevel > talentInfo.LevelMax) { result = TalentResultType.EisMaxLevel; } else if (!TalentManager.DBTalentEffectModify(client.ClientData.RoleID, talentInfo.Type, effectID, newLevel, client.ClientData.ZoneID, client.ServerId)) { result = TalentResultType.EFail; } else { Dictionary <int, int> countList; int type; (countList = talentData.CountList)[type = talentInfo.Type] = countList[type] + addCount; if (effectItemOld == null) { effectItemOld = new TalentEffectItem(); effectItemOld.ID = effectID; effectItemOld.TalentType = talentInfo.Type; talentData.EffectList.Add(effectItemOld); } effectItemOld.Level = newLevel; effectItemOld.ItemEffectList = newItemEffectList; TalentManager.initTalentEffectProp(client); TalentManager.RefreshProp(client); result = TalentResultType.Success; } } } } return(result); }