コード例 #1
0
        public static bool CostGoodsList(GameClient client, List <List <int> > needGoods, bool notBind, ref string strCostList, string logMsg)
        {
            bool result = true;
            bool bUsedBinding_just_placeholder     = false;
            bool bUsedTimeLimited_just_placeholder = false;

            for (int i = 0; i < needGoods.Count; i++)
            {
                if (needGoods[i].Count >= 2)
                {
                    int goodsId   = needGoods[i][0];
                    int costCount = needGoods[i][1];
                    if (notBind)
                    {
                        if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsId, costCount, false, out bUsedBinding_just_placeholder, out bUsedTimeLimited_just_placeholder, false))
                        {
                            LogManager.WriteLog(LogTypes.Error, string.Format("{0},消耗{1}个GoodsID={2}的非绑定物品失败", logMsg, costCount, goodsId), null, true);
                            result = false;
                            goto IL_15A;
                        }
                    }
                    else if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsId, costCount, false, out bUsedBinding_just_placeholder, out bUsedTimeLimited_just_placeholder, false))
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("{0},消耗{1}个GoodsID={2}的物品失败", logMsg, costCount, goodsId), null, true);
                        result = false;
                        goto IL_15A;
                    }
                    if (strCostList != null)
                    {
                        GoodsData goodsDataCost = new GoodsData
                        {
                            GoodsID = goodsId,
                            GCount  = costCount
                        };
                        strCostList += EventLogManager.NewGoodsDataPropString(goodsDataCost);
                    }
                }
                IL_15A :;
            }
            return(result);
        }
コード例 #2
0
        private bool ProcessHuiJiStarUpCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            int result = 0;
            HuiJiUpdateResultData resultData = new HuiJiUpdateResultData();
            RoleHuiJiData         huiJiData  = client.ClientData.HuiJiData;
            int exp = 0;
            HuiJiUpdateResultData requestData = DataHelper.BytesToObject <HuiJiUpdateResultData>(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 = -12;
            }
            else
            {
                lock (this.RuntimeData.Mutex)
                {
                    EmblemStarInfo starInfo;
                    EmblemStarInfo starInfo2;
                    if (huiJiData.huiji != requestData.HuiJi)
                    {
                        result = -3;
                    }
                    else if (!this.RuntimeData.EmblemStarDict.Value.TryGetValue(huiJiData.huiji, out starInfo))
                    {
                        result = -3;
                    }
                    else if (!this.RuntimeData.EmblemStarDict.Value.TryGetValue(huiJiData.huiji + 1, out starInfo2))
                    {
                        result = -4004;
                    }
                    else
                    {
                        bool   useBind      = false;
                        bool   useTimeLimit = false;
                        string strCostList;
                        if (type == 0)
                        {
                            if (starInfo.EmblemUpInfo.MaxStarLevel == starInfo.EmblemStar)
                            {
                                result = -4;
                                goto IL_646;
                            }
                            if (Global.UseGoodsBindOrNot(client, starInfo.NeedGoods[0], starInfo.NeedGoods[1], true, out useBind, out useTimeLimit) < 0)
                            {
                                if (zuanshi <= 0 || zuanshi != starInfo.NeedDiamond)
                                {
                                    result = -6;
                                    goto IL_646;
                                }
                                if (!GameManager.ClientMgr.SubUserMoney(client, zuanshi, "徽记升星", true, true, true, true, DaiBiSySType.HuiJiShengXing))
                                {
                                    result = -10;
                                    goto IL_646;
                                }
                                exp         = starInfo.ZuanShiExp;
                                strCostList = EventLogManager.NewResPropString(ResLogType.ZuanShi, new object[]
                                {
                                    -zuanshi,
                                    client.ClientData.UserMoney + zuanshi,
                                    client.ClientData.UserMoney
                                });
                                if (Global.GetRandom() < this.RuntimeData.EmblemShengXing[1])
                                {
                                    exp = (int)((double)exp * this.RuntimeData.EmblemShengXing[2]);
                                }
                            }
                            else
                            {
                                exp         = starInfo.GoodsExp;
                                strCostList = EventLogManager.NewGoodsDataPropString(new GoodsData
                                {
                                    GoodsID = starInfo.NeedGoods[0],
                                    GCount  = starInfo.NeedGoods[1]
                                });
                                if (Global.GetRandom() < this.RuntimeData.EmblemShengXing[0])
                                {
                                    exp = (int)((double)exp * this.RuntimeData.EmblemShengXing[2]);
                                }
                            }
                            huiJiData.Exp += exp;
                            if (huiJiData.Exp >= starInfo.StarExp)
                            {
                                huiJiData.huiji++;
                                if (starInfo.EmblemStar < starInfo.EmblemUpInfo.MaxStarLevel - 1)
                                {
                                    huiJiData.Exp -= starInfo.StarExp;
                                }
                                else
                                {
                                    huiJiData.Exp = 0;
                                }
                            }
                        }
                        else
                        {
                            if (starInfo.EmblemUpInfo.MaxStarLevel != starInfo.EmblemStar)
                            {
                                result = -4;
                                goto IL_646;
                            }
                            if (Global.UseGoodsBindOrNot(client, starInfo.EmblemUpInfo.NeedGoods[0], starInfo.EmblemUpInfo.NeedGoods[1], true, out useBind, out useTimeLimit) < 0)
                            {
                                if (zuanshi <= 0 || zuanshi != starInfo.EmblemUpInfo.NeedDiamond)
                                {
                                    result = -6;
                                    goto IL_646;
                                }
                                if (!GameManager.ClientMgr.SubUserMoney(client, zuanshi, "徽记升阶", true, true, true, true, DaiBiSySType.HuiJiShengJie))
                                {
                                    result = -10;
                                    goto IL_646;
                                }
                                strCostList = EventLogManager.NewResPropString(ResLogType.ZuanShi, new object[]
                                {
                                    -zuanshi,
                                    client.ClientData.UserMoney + zuanshi,
                                    client.ClientData.UserMoney
                                });
                            }
                            else
                            {
                                strCostList = EventLogManager.NewGoodsDataPropString(new GoodsData
                                {
                                    GoodsID = starInfo.EmblemUpInfo.NeedGoods[0],
                                    GCount  = starInfo.EmblemUpInfo.NeedGoods[1]
                                });
                                exp = starInfo.GoodsExp;
                            }
                            huiJiData.Exp++;
                            if (starInfo.EmblemUpInfo.LuckyOne + huiJiData.Exp >= 110000)
                            {
                                huiJiData.huiji++;
                                huiJiData.Exp = 0;
                            }
                            else if (starInfo.EmblemUpInfo.LuckyOne + huiJiData.Exp > starInfo.EmblemUpInfo.LuckyTwo)
                            {
                                if (Global.GetRandom() < starInfo.EmblemUpInfo.LuckyTwoRate)
                                {
                                    huiJiData.huiji++;
                                    huiJiData.Exp = 0;
                                }
                            }
                        }
                        Global.SendToDB <RoleDataCmdT <RoleHuiJiData> >(1446, new RoleDataCmdT <RoleHuiJiData>(client.ClientData.RoleID, huiJiData), client.ServerId);
                        if (huiJiData.huiji > requestData.HuiJi)
                        {
                            client.ClientData.PropsCacheManager.SetExtProps(new object[]
                            {
                                PropsSystemTypes.HuiJiHuTi,
                                starInfo2.ExtPropValues
                            });
                            client.delayExecModule.SetDelayExecProc(new DelayExecProcIds[]
                            {
                                DelayExecProcIds.RecalcProps,
                                DelayExecProcIds.NotifyRefreshProps
                            });
                            EventLogManager.AddHuiJiEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.EmblemLevel, starInfo.EmblemStar, starInfo2.EmblemLevel, starInfo2.EmblemStar, huiJiData.Exp, strCostList);
                        }
                        else
                        {
                            EventLogManager.AddHuiJiEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.EmblemLevel, starInfo.EmblemStar, starInfo.EmblemLevel, starInfo.EmblemStar, huiJiData.Exp, strCostList);
                        }
                    }
                }
            }
IL_646:
            if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieRiHuiJi))
            {
                client._IconStateMgr.SendIconStateToClient(client);
            }
            resultData.Result = result;
            resultData.HuiJi  = huiJiData.huiji;
            resultData.Exp    = huiJiData.Exp;
            resultData.Auto   = auto;
            resultData.Type   = type;
            client.sendCmd <HuiJiUpdateResultData>(nID, resultData, false);
            return(true);
        }
コード例 #3
0
        private bool ProcessArmorStarUpCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            int result = 0;
            ArmorUpdateResultData resultData = new ArmorUpdateResultData();
            RoleArmorData         ArmorData  = client.ClientData.ArmorData;
            int exp = 0;
            ArmorUpdateResultData requestData = DataHelper.BytesToObject <ArmorUpdateResultData>(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 = -12;
            }
            else
            {
                bool updateProps = false;
                lock (this.RuntimeData.Mutex)
                {
                    if (ArmorData.Armor != requestData.Armor)
                    {
                        result = -3;
                        goto IL_611;
                    }
                    ArmorStarInfo starInfo;
                    if (!this.RuntimeData.ArmorStarDict.Value.TryGetValue(ArmorData.Armor, out starInfo))
                    {
                        result = -3;
                        goto IL_611;
                    }
                    ArmorStarInfo starInfo2;
                    if (!this.RuntimeData.ArmorStarDict.Value.TryGetValue(ArmorData.Armor + 1, out starInfo2))
                    {
                        result = -4004;
                        goto IL_611;
                    }
                    bool   useBind      = false;
                    bool   useTimeLimit = false;
                    string strCostList;
                    if (type == 0)
                    {
                        if (starInfo.ArmorUpInfo.MaxStarLevel == starInfo.StarLevel)
                        {
                            result = -4;
                            goto IL_611;
                        }
                        if (Global.UseGoodsBindOrNot(client, starInfo.NeedGoods[0], starInfo.NeedGoods[1], true, out useBind, out useTimeLimit) < 0)
                        {
                            if (zuanshi <= 0 || zuanshi != starInfo.NeedDiamond)
                            {
                                result = -6;
                                goto IL_611;
                            }
                            if (!GameManager.ClientMgr.SubUserMoney(client, zuanshi, "神圣护盾升星", true, true, true, true, DaiBiSySType.None))
                            {
                                result = -10;
                                goto IL_611;
                            }
                            exp         = starInfo.ZuanShiExp;
                            strCostList = EventLogManager.NewResPropString(ResLogType.ZuanShi, new object[]
                            {
                                -zuanshi,
                                client.ClientData.UserMoney + zuanshi,
                                client.ClientData.UserMoney
                            });
                            if (Global.GetRandom() < this.RuntimeData.HudunBaoji[1])
                            {
                                exp = (int)((double)exp * this.RuntimeData.HudunBaoji[2]);
                            }
                        }
                        else
                        {
                            exp         = starInfo.GoodsExp;
                            strCostList = EventLogManager.NewGoodsDataPropString(new GoodsData
                            {
                                GoodsID = starInfo.NeedGoods[0],
                                GCount  = starInfo.NeedGoods[1]
                            });
                            if (Global.GetRandom() < this.RuntimeData.HudunBaoji[0])
                            {
                                exp = (int)((double)exp * this.RuntimeData.HudunBaoji[2]);
                            }
                        }
                        ArmorData.Exp += exp;
                        if (ArmorData.Exp >= starInfo.StarExp)
                        {
                            ArmorData.Armor++;
                            if (starInfo.StarLevel < starInfo.ArmorUpInfo.MaxStarLevel - 1)
                            {
                                ArmorData.Exp -= starInfo.StarExp;
                            }
                            else
                            {
                                ArmorData.Exp = 0;
                            }
                        }
                    }
                    else
                    {
                        if (starInfo.ArmorUpInfo.MaxStarLevel != starInfo.StarLevel)
                        {
                            result = -4;
                            goto IL_611;
                        }
                        if (Global.UseGoodsBindOrNot(client, starInfo.ArmorUpInfo.NeedGoods[0], starInfo.ArmorUpInfo.NeedGoods[1], true, out useBind, out useTimeLimit) < 0)
                        {
                            if (zuanshi <= 0 || zuanshi != starInfo.ArmorUpInfo.NeedDiamond)
                            {
                                result = -6;
                                goto IL_611;
                            }
                            if (!GameManager.ClientMgr.SubUserMoney(client, zuanshi, "神圣护盾升阶", true, true, true, true, DaiBiSySType.None))
                            {
                                result = -10;
                                goto IL_611;
                            }
                            strCostList = EventLogManager.NewResPropString(ResLogType.ZuanShi, new object[]
                            {
                                -zuanshi,
                                client.ClientData.UserMoney + zuanshi,
                                client.ClientData.UserMoney
                            });
                        }
                        else
                        {
                            strCostList = EventLogManager.NewGoodsDataPropString(new GoodsData
                            {
                                GoodsID = starInfo.ArmorUpInfo.NeedGoods[0],
                                GCount  = starInfo.ArmorUpInfo.NeedGoods[1]
                            });
                            exp = starInfo.GoodsExp;
                        }
                        ArmorData.Exp++;
                        if (starInfo.ArmorUpInfo.LuckyOne + ArmorData.Exp >= 110000)
                        {
                            ArmorData.Armor++;
                            ArmorData.Exp = 0;
                        }
                        else if (starInfo.ArmorUpInfo.LuckyOne + ArmorData.Exp > starInfo.ArmorUpInfo.LuckyTwo)
                        {
                            if (Global.GetRandom() < starInfo.ArmorUpInfo.LuckyTwoRate)
                            {
                                ArmorData.Armor++;
                                ArmorData.Exp = 0;
                            }
                        }
                    }
                    Global.SendToDB <RoleDataCmdT <RoleArmorData> >(1447, new RoleDataCmdT <RoleArmorData>(client.ClientData.RoleID, ArmorData), client.ServerId);
                    if (ArmorData.Armor > requestData.Armor)
                    {
                        updateProps = true;
                        EventLogManager.AddArmorEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.ArmorupStage, starInfo.StarLevel, starInfo2.ArmorupStage, starInfo2.StarLevel, ArmorData.Exp, strCostList);
                    }
                    else
                    {
                        EventLogManager.AddArmorEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.ArmorupStage, starInfo.StarLevel, starInfo.ArmorupStage, starInfo.StarLevel, ArmorData.Exp, strCostList);
                    }
                }
                if (updateProps)
                {
                    this.ResetArmor(client, true);
                }
            }
IL_611:
            resultData.Result = result;
            resultData.Armor  = ArmorData.Armor;
            resultData.Exp    = ArmorData.Exp;
            resultData.Auto   = auto;
            resultData.Type   = type;
            client.sendCmd <ArmorUpdateResultData>(nID, resultData, false);
            return(true);
        }