示例#1
0
        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);
        }
示例#2
0
        private bool ProcessExecuteBianShenCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            int  result   = 0;
            long nowTicks = TimeUtil.NOW();

            if (!this.CanBianShenByMap(client))
            {
                result = -21;
            }
            else if (client.ClientData.IsDongJie())
            {
                result = -500;
            }
            else
            {
                ExtData extData = ExtDataManager.GetClientExtData(client);
                if (nowTicks < extData.BianShenCDTicks)
                {
                    result = -2007;
                }
                else if (!this.IsGongNengOpened(client) || client.ClientData.HideGM > 0)
                {
                    result = -12;
                }
                else
                {
                    ZuoQiManager.getInstance().RoleDisMount(client, true);
                    long             cdTime       = (long)(this.RuntimeData.BianShenCDSecs * 1000);
                    int              durationTime = 0;
                    int              skillLevel   = 1;
                    double[]         props        = null;
                    List <int>       skillIDList  = null;
                    BianShenStarInfo starInfo;
                    lock (this.RuntimeData.Mutex)
                    {
                        if (!this.RuntimeData.BianShenStarDict.Value.TryGetValue(client.ClientData.BianShenData.BianShen, out starInfo))
                        {
                            result = -20;
                            goto IL_4E7;
                        }
                        skillLevel = starInfo.Level;
                    }
                    string strCostList = "";
                    long   dayAndCount = client.ClientData.MoneyData[147];
                    int    dayid       = (int)(dayAndCount / 10000L);
                    int    dayCount    = (int)(dayAndCount % 10000L);
                    if (dayid != TimeUtil.GetOffsetDayNow())
                    {
                        dayCount = 0;
                        dayid    = TimeUtil.GetOffsetDayNow();
                    }
                    if (dayCount < this.RuntimeData.FreeNum)
                    {
                        dayCount++;
                        dayAndCount = (long)(dayid * 10000 + dayCount);
                        client.ClientData.MoneyData[147] = dayAndCount;
                        Global.SaveRoleParamsInt64ValueToDB(client, "10216", dayAndCount, true);
                        GameManager.ClientMgr.NotifySelfPropertyValue(client, 147, dayAndCount);
                    }
                    else if (!GoodsUtil.CostGoodsList(client, this.RuntimeData.NeedGoods, false, ref strCostList, "变身"))
                    {
                        result = -6;
                        goto IL_4E7;
                    }
                    int       damageType = OccupationUtil.GetOccuDamageType(client.ClientData.OccupationIndex);
                    GoodsData goodsData  = client.UsingEquipMgr.GetGoodsDataByCategoriy(client, 28);
                    if (null != goodsData)
                    {
                        FashionBagData fashionBagData = FashionManager.getInstance().GetFashionBagData(client, goodsData);
                        if (fashionBagData != null && fashionBagData.FasionTab == 7)
                        {
                            if (damageType == 1)
                            {
                                skillIDList = fashionBagData.MagicSkill;
                            }
                            else
                            {
                                skillIDList = fashionBagData.AttackSkill;
                            }
                            durationTime = fashionBagData.BianShenDuration;
                            if (fashionBagData.BianShenEffect > 0)
                            {
                                lock (this.RuntimeData.Mutex)
                                {
                                    FashionEffectInfo info;
                                    if (this.RuntimeData.FashionEffectInfoDict.Value.TryGetValue(fashionBagData.BianShenEffect, out info))
                                    {
                                        props = info.ExtPropValues;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        durationTime = starInfo.Duration;
                        if (damageType == 1)
                        {
                            skillIDList = starInfo.MagicSkill;
                        }
                        else
                        {
                            skillIDList = starInfo.AttackSkill;
                        }
                    }
                    if (null != skillIDList)
                    {
                        lock (client.ClientData.SkillDataList)
                        {
                            using (List <int> .Enumerator enumerator = skillIDList.GetEnumerator())
                            {
                                while (enumerator.MoveNext())
                                {
                                    int       skillID     = enumerator.Current;
                                    SkillData mySkillData = client.ClientData.SkillDataList.Find((SkillData x) => x.SkillID == skillID);
                                    if (null == mySkillData)
                                    {
                                        SkillData skillData = new SkillData();
                                        skillData.SkillID    = skillID;
                                        skillData.SkillLevel = skillLevel;
                                        client.ClientData.SkillDataList.Add(skillData);
                                    }
                                    else if (mySkillData.SkillLevel != skillLevel)
                                    {
                                        mySkillData.SkillLevel = skillLevel;
                                    }
                                }
                            }
                        }
                    }
                    extData.skillIDList     = skillIDList;
                    extData.BianShenCDTicks = nowTicks + cdTime + (long)(durationTime * 1000);
                    extData.BianShenCdTime  = cdTime;
                    extData.BianShenToTicks = nowTicks + (long)(durationTime * 1000);
                    client.buffManager.SetStatusBuff(121, nowTicks, (long)(durationTime * 1000), 0L);
                    this.OnBianShenStateChange(client, true, client.ClientData.BianShenData.BianShen, durationTime, props);
                    GameManager.ClientMgr.NotifySkillCDTime(client, -1, extData.BianShenCDTicks, false);
                }
            }
IL_4E7:
            client.sendCmd <int>(nID, result, false);
            return(true);
        }
        public bool ProcessJingLingYuanSuJueXingUpgradeCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 4))
                {
                    return(false);
                }
                int result      = 0;
                int yuanSuType  = Convert.ToInt32(cmdParams[1]);
                int shuXingType = Convert.ToInt32(cmdParams[2]);
                int useShenYou  = Convert.ToInt32(cmdParams[3]);
                int newID       = 0;
                JingLingYuanSuJueXingData jueXingData = client.ClientData.JingLingYuanSuJueXingData;
                if (jueXingData == null || jueXingData.ActiveIDs == null)
                {
                    jueXingData           = new JingLingYuanSuJueXingData();
                    jueXingData.ActiveIDs = new int[6];
                }
                int idx = (yuanSuType - 1) * 2 + shuXingType - 1;
                if (idx < 0 || idx >= jueXingData.ActiveIDs.Length)
                {
                    result = -18;
                }
                else
                {
                    int currentLevel = 0;
                    int currentID    = jueXingData.ActiveIDs[idx];
                    JingLingYuanSuInfo currentLevelInfo = null;
                    JingLingYuanSuInfo nextLevelInfo    = null;
                    JingLingYuanSuInfo preLevelInfo     = null;
                    lock (this.RuntimeData.Mutex)
                    {
                        if (currentID > 0)
                        {
                            if (this.RuntimeData.YuanSuInfoDict.Value.TryGetValue(currentID, out currentLevelInfo))
                            {
                                if (currentLevelInfo.YuanSuType != yuanSuType || currentLevelInfo.ShuXingType != shuXingType)
                                {
                                    result = -3;
                                    goto IL_4AB;
                                }
                                currentLevel = currentLevelInfo.QiangHuaLevel;
                            }
                        }
                        int nextLevel = currentLevel + 1;
                        int preLevel  = currentLevel - 1;
                        foreach (JingLingYuanSuInfo info in this.RuntimeData.YuanSuInfoDict.Value.Values)
                        {
                            if (info.YuanSuType == yuanSuType && info.ShuXingType == shuXingType)
                            {
                                if (info.QiangHuaLevel == currentLevel)
                                {
                                    currentLevelInfo = info;
                                }
                                else if (info.QiangHuaLevel == nextLevel)
                                {
                                    nextLevelInfo = info;
                                }
                                else if (info.QiangHuaLevel == preLevel)
                                {
                                    preLevelInfo = info;
                                }
                            }
                        }
                    }
                    if (currentLevelInfo == null)
                    {
                        result = -3;
                    }
                    else
                    {
                        newID = currentLevelInfo.ID;
                        if (nextLevelInfo == null)
                        {
                            result = -23;
                        }
                        else if (client.ClientData.MoneyData[144] < (long)currentLevelInfo.JieXingCurrency)
                        {
                            result = -47;
                        }
                        else if (!GoodsUtil.CheckHasGoodsList(client, currentLevelInfo.NeedGoods, false))
                        {
                            result = -6;
                        }
                        else
                        {
                            if (useShenYou > 0)
                            {
                                if (!GoodsUtil.CheckHasGoodsList(client, currentLevelInfo.Failtofail, false))
                                {
                                    result = -6;
                                    goto IL_4AB;
                                }
                            }
                            if (!GameManager.ClientMgr.ModifyYuanSuJueXingShiValue(client, -currentLevelInfo.JieXingCurrency, "精灵元素觉醒", true, true, false))
                            {
                                result = -47;
                            }
                            else
                            {
                                string strCostList = "";
                                if (!GoodsUtil.CostGoodsList(client, currentLevelInfo.NeedGoods, false, ref strCostList, "精灵元素觉醒"))
                                {
                                }
                                if (useShenYou > 0)
                                {
                                    if (!GoodsUtil.CostGoodsList(client, currentLevelInfo.Failtofail, false, ref strCostList, "精灵元素觉醒"))
                                    {
                                    }
                                }
                                bool   upLevel = false;
                                double rnd     = Global.GetRandom();
                                if (rnd <= currentLevelInfo.Success)
                                {
                                    upLevel = true;
                                }
                                int newLevel;
                                if (upLevel)
                                {
                                    newID    = nextLevelInfo.ID;
                                    newLevel = nextLevelInfo.QiangHuaLevel;
                                    jueXingData.ActiveIDs[idx] = newID;
                                }
                                else
                                {
                                    if (useShenYou > 0 || null == preLevelInfo)
                                    {
                                        result = 6;
                                        goto IL_4AB;
                                    }
                                    newID    = preLevelInfo.ID;
                                    newLevel = preLevelInfo.QiangHuaLevel;
                                    jueXingData.ActiveIDs[idx] = newID;
                                }
                                if (jueXingData.ActiveType == yuanSuType)
                                {
                                    JingLingYuanSuJueXingManager.getInstance().RefreshProps(client, false);
                                    client.delayExecModule.SetDelayExecProc(new DelayExecProcIds[]
                                    {
                                        DelayExecProcIds.NotifyRefreshProps
                                    });
                                }
                                EventLogManager.AddRoleEvent(client, OpTypes.Upgrade, OpTags.Trace, LogRecordType.JingLingYuanSuJueXing, new object[]
                                {
                                    currentID,
                                    currentLevel,
                                    newID,
                                    newLevel,
                                    currentLevelInfo.JieXingCurrency,
                                    useShenYou,
                                    strCostList
                                });
                                result = Global.sendToDB <int, RoleDataCmdT <JingLingYuanSuJueXingData> >(1452, new RoleDataCmdT <JingLingYuanSuJueXingData>(client.ClientData.RoleID, jueXingData), client.ServerId);
                            }
                        }
                    }
                }
IL_4AB:
                client.sendCmd(nID, string.Format("{0}:{1}:{2}", result, newID, useShenYou), false);
                return(true);
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("JingLingYuanSuJueXing :: 激活觉醒石错误。rid:{0}, ex:{1}", client.ClientData.RoleID, ex.Message), null, true);
            }
            return(false);
        }