public void OnInitGame(GameClient client) { RoleBianShenData BianShenData = client.ClientData.BianShenData; if (BianShenData == null) { BianShenData = (client.ClientData.BianShenData = new RoleBianShenData()); } bool resetCD = false; int[] array = this.RuntimeData.BianShenFull; if (array != null && array[0] > 0) { for (int i = 1; i < array.Length; i++) { if (array[i] == client.ClientData.MapCode) { resetCD = true; break; } } } ExtData extData = ExtDataManager.GetClientExtData(client); this.InitDataByTask(client); if (BianShenData.BianShen > 0) { extData.BianShenToTicks = 0L; extData.skillIDList = null; lock (this.RuntimeData.Mutex) { List <BianShenStarInfo> list; if (this.RuntimeData.BianShenUpDict.TryGetValue(client.ClientData.Occupation, out list) && BianShenData.BianShen < list.Count) { BianShenStarInfo starInfo = list[BianShenData.BianShen]; if (null != starInfo) { client.ClientData.PropsCacheManager.SetExtProps(new object[] { PropsSystemTypes.BianShen, starInfo.ExtPropValues }); if (resetCD) { extData.BianShenCDTicks = 0L; } else { long nowTicks = TimeUtil.NOW(); long maxCdTicks = nowTicks + extData.BianShenCdTime; if (maxCdTicks < extData.BianShenCDTicks) { extData.BianShenCDTicks = maxCdTicks; } if (nowTicks < extData.BianShenCDTicks) { GameManager.ClientMgr.NotifySkillCDTime(client, -1, extData.BianShenCDTicks, true); } } } } } } }
private bool ProcessBianShenStarUpCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams) { int result = 0; BianShenUpdateResultData resultData = new BianShenUpdateResultData(); RoleBianShenData BianShenData = client.ClientData.BianShenData; BianShenUpdateResultData requestData = DataHelper.BytesToObject <BianShenUpdateResultData>(bytes, 0, bytes.Length); int type = requestData.Type; int zuanshi = requestData.ZuanShi; int auto = requestData.Auto; long nowTicks = TimeUtil.NOW(); if (!this.IsGongNengOpened(client)) { result = -400; } else { string strCostList = ""; lock (this.RuntimeData.Mutex) { List <BianShenStarInfo> list; if (BianShenData.BianShen != requestData.BianShen) { result = -18; } else if (!this.RuntimeData.BianShenUpDict.TryGetValue(client.ClientData.Occupation, out list)) { result = -400; } else if (BianShenData.BianShen >= list.Count - 1) { result = -23; } else { BianShenStarInfo starInfo = list[BianShenData.BianShen]; BianShenStarInfo starInfo2 = list[BianShenData.BianShen + 1]; if (starInfo == null || starInfo2 == null) { result = -3; } else if (!GoodsUtil.CostGoodsList(client, starInfo.NeedGoods, false, ref strCostList, "变身升级")) { result = -6; } else { int exp = starInfo.GoodsExp; if (Global.GetRandom() < starInfo.ExpCritRate) { exp = (int)((double)exp * starInfo.ExpCritTimes); } BianShenData.Exp += exp; if (BianShenData.Exp >= starInfo.UpExp) { BianShenData.BianShen++; BianShenData.Exp -= starInfo.UpExp; } Global.SendToDB <RoleDataCmdT <RoleBianShenData> >(1449, new RoleDataCmdT <RoleBianShenData>(client.ClientData.RoleID, BianShenData), client.ServerId); if (BianShenData.BianShen > requestData.BianShen) { client.ClientData.PropsCacheManager.SetExtProps(new object[] { PropsSystemTypes.BianShen, starInfo2.ExtPropValues }); client.delayExecModule.SetDelayExecProc(new DelayExecProcIds[] { DelayExecProcIds.RecalcProps, DelayExecProcIds.NotifyRefreshProps }); EventLogManager.AddBianShenEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.Level, starInfo2.Level, BianShenData.Exp, strCostList); } else { EventLogManager.AddBianShenEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.Level, starInfo.Level, BianShenData.Exp, strCostList); } } } } } resultData.Result = result; resultData.BianShen = BianShenData.BianShen; resultData.Exp = BianShenData.Exp; resultData.Auto = auto; resultData.Type = type; client.sendCmd <BianShenUpdateResultData>(nID, resultData, false); return(true); }