コード例 #1
0
 public void UpdateMazingerStoreInfo(GameServerClient client, int nID, byte[] cmdParams, int count)
 {
     try
     {
         MazingerStoreData data = DataHelper.BytesToObject <MazingerStoreData>(cmdParams, 0, count);
         if (data != null)
         {
             if (!DBWriter.UpdateMazingerStoreInfo(data.RoleID, data.Type, data.Stage, data.StarLevel, data.Exp))
             {
                 LogManager.WriteLog(LogTypes.Error, string.Format("更新魔神秘宝信息失败,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, data.RoleID), null, true);
                 client.sendCmd <int>(nID, -1);
             }
         }
     }
     catch (Exception ex)
     {
         client.sendCmd <int>(nID, -1);
         LogManager.WriteException(ex.ToString());
     }
     client.sendCmd <int>(nID, 1);
 }
コード例 #2
0
        public MazingerStore ProcessMazingerStoreUpGrade(GameClient client, int ClientType, int ClientOpt)
        {
            MazingerStore res = new MazingerStore();

            res.IsBoom = 0;
            bool          up = false;
            MazingerStore result;

            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.MazingerStore, false))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("玩家魔神秘宝功能未开启, 玩家id RoleID={0}", client.ClientData.RoleID), null, true);
                res.result = 12;
                result     = res;
            }
            else
            {
                if (ClientOpt < 0 || ClientOpt > 1)
                {
                    res.result = 2;
                }
                else if (ClientOpt == 0)
                {
                    if (this.MazingerStar == null || this.MazingerStarLevelMax == null || !this.MazingerStar.ContainsKey(ClientType) || !this.MazingerStarLevelMax.ContainsKey(ClientType))
                    {
                        res.result = 3;
                    }
                    else
                    {
                        if (client.ClientData.MazingerStoreDataInfo == null)
                        {
                            client.ClientData.MazingerStoreDataInfo = new Dictionary <int, MazingerStoreData>();
                        }
                        MazingerStoreData newData = null;
                        bool flag         = false;
                        int  StarLevelMax = 0;
                        if (client.ClientData.MazingerStoreDataInfo.ContainsKey(ClientType))
                        {
                            StarLevelMax = this.MazingerStarLevelMax[ClientType][client.ClientData.MazingerStoreDataInfo[ClientType].Stage];
                            if (client.ClientData.MazingerStoreDataInfo[ClientType].StarLevel >= StarLevelMax)
                            {
                                res.result = 5;
                                goto IL_B64;
                            }
                            newData = this.CopyMazingerStoreMemData(client, ClientType);
                            flag    = true;
                        }
                        else
                        {
                            newData           = new MazingerStoreData();
                            newData.RoleID    = client.ClientData.RoleID;
                            newData.Type      = ClientType;
                            newData.Exp       = 0;
                            newData.Stage     = 1;
                            newData.StarLevel = 0;
                            StarLevelMax      = this.MazingerStarLevelMax[ClientType][newData.Stage];
                        }
                        if (newData == null || !this.MazingerStar.ContainsKey(newData.Type) || !this.MazingerStar[newData.Type].ContainsKey(newData.Stage) || !this.MazingerStar[newData.Type][newData.Stage].ContainsKey(newData.StarLevel) || this.MazingerStar[newData.Type][newData.Stage][newData.StarLevel].UseGoods == null || this.MazingerStar[newData.Type][newData.Stage][newData.StarLevel].UseGoods.Count == 0)
                        {
                            res.result = 6;
                        }
                        else
                        {
                            List <double> rate = this.GetSystemParamMibao();
                            if (rate == null || rate.Count != 2)
                            {
                                res.result = 4;
                            }
                            else
                            {
                                int    AddExp = this.MazingerStar[newData.Type][newData.Stage][newData.StarLevel].Exp;
                                double rand   = Global.GetRandom();
                                if (rand <= rate[0])
                                {
                                    AddExp     = Convert.ToInt32((double)AddExp * rate[1]);
                                    res.IsBoom = 1;
                                }
                                foreach (KeyValuePair <int, int> iter in this.MazingerStar[newData.Type][newData.Stage][newData.StarLevel].UseGoods)
                                {
                                    bool EquipBindUse;
                                    if (!RebornStone.RebornUseGoodHasBinding(client, iter.Key, iter.Value, 1, out EquipBindUse))
                                    {
                                        res.result = 7;
                                        break;
                                    }
                                }
                                if (res.result != 7)
                                {
                                    int totleExp  = newData.Exp + AddExp;
                                    int currLevel = newData.StarLevel;
                                    int oldUpExp  = this.MazingerStar[newData.Type][newData.Stage][newData.StarLevel].UpExp;
                                    while (currLevel < StarLevelMax)
                                    {
                                        if (totleExp < oldUpExp)
                                        {
                                            break;
                                        }
                                        currLevel++;
                                        totleExp -= oldUpExp;
                                        if (totleExp < 0)
                                        {
                                            totleExp = 0;
                                            break;
                                        }
                                        if (this.MazingerStar[newData.Type][newData.Stage].ContainsKey(currLevel))
                                        {
                                            oldUpExp = this.MazingerStar[newData.Type][newData.Stage][currLevel].UpExp;
                                        }
                                        if (!up)
                                        {
                                            up = true;
                                        }
                                    }
                                    newData.StarLevel = currLevel;
                                    if (currLevel >= StarLevelMax)
                                    {
                                        newData.Exp = 0;
                                    }
                                    else
                                    {
                                        newData.Exp = totleExp;
                                    }
                                    if (flag)
                                    {
                                        int ret = Global.sendToDB <int, MazingerStoreData>(14126, newData, client.ServerId);
                                        if (ret < 0)
                                        {
                                            LogManager.WriteLog(LogTypes.Error, string.Format("魔神秘宝修改数据出错, 玩家id RoleID={0}", client.ClientData.RoleID), null, true);
                                            res.result = 10;
                                            goto IL_B64;
                                        }
                                        GameManager.logDBCmdMgr.AddDBLogInfo(-1, "魔神秘宝升星", DateTime.Now.ToString(), newData.Type.ToString(), client.ClientData.RoleName, "系统", ClientType, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null);
                                        EventLogManager.AddMazingerStoreEvent(client, client.ClientData.MazingerStoreDataInfo[newData.Type].StarLevel, newData.StarLevel, client.ClientData.MazingerStoreDataInfo[newData.Type].Exp, newData.Exp, "魔神秘宝升星");
                                        client.ClientData.MazingerStoreDataInfo[newData.Type] = newData;
                                    }
                                    else
                                    {
                                        int ret = Global.sendToDB <int, MazingerStoreData>(14125, newData, client.ServerId);
                                        if (ret < 0)
                                        {
                                            LogManager.WriteLog(LogTypes.Error, string.Format("魔神秘宝插入数据出错, 玩家id RoleID={0}", client.ClientData.RoleID), null, true);
                                            res.result = 10;
                                            goto IL_B64;
                                        }
                                        GameManager.logDBCmdMgr.AddDBLogInfo(-1, "魔神秘宝升星", DateTime.Now.ToString(), newData.Type.ToString(), client.ClientData.RoleName, "系统", ClientType, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null);
                                        EventLogManager.AddMazingerStoreEvent(client, 0, newData.StarLevel, 0, newData.Exp, "魔神秘宝升星");
                                        client.ClientData.MazingerStoreDataInfo.Add(newData.Type, newData);
                                    }
                                    res.result = 1;
                                    res.data   = client.ClientData.MazingerStoreDataInfo[newData.Type];
                                }
                            }
                        }
                    }
                }
                else if (this.MazingerGrade == null || this.MazingerGradeLevelMax == null || !this.MazingerGrade.ContainsKey(ClientType) || !this.MazingerGradeLevelMax.ContainsKey(ClientType))
                {
                    res.result = 3;
                }
                else if (client.ClientData.MazingerStoreDataInfo == null || !client.ClientData.MazingerStoreDataInfo.ContainsKey(ClientType))
                {
                    res.result = 11;
                }
                else if (client.ClientData.MazingerStoreDataInfo[ClientType].Stage >= this.MazingerGradeLevelMax[ClientType])
                {
                    res.result = 5;
                }
                else
                {
                    MazingerStoreData newData = this.CopyMazingerStoreMemData(client, ClientType);
                    if (newData == null || !this.MazingerGrade.ContainsKey(newData.Type) || !this.MazingerGrade[newData.Type].ContainsKey(newData.Stage) || this.MazingerGrade[newData.Type][newData.Stage].UseGoods == null || this.MazingerGrade[newData.Type][newData.Stage].UseGoods.Count == 0)
                    {
                        res.result = 6;
                    }
                    else
                    {
                        foreach (KeyValuePair <int, int> iter in this.MazingerGrade[newData.Type][newData.Stage].UseGoods)
                        {
                            bool EquipBindUse;
                            if (!RebornStone.RebornUseGoodHasBinding(client, iter.Key, iter.Value, 1, out EquipBindUse))
                            {
                                res.result = 7;
                                break;
                            }
                        }
                        if (res.result != 7)
                        {
                            newData.Exp++;
                            if (this.MazingerGrade[newData.Type][newData.Stage].LuckyOne + newData.Exp >= 110000)
                            {
                                newData.Stage++;
                                newData.StarLevel = 0;
                                newData.Exp       = 0;
                                up = true;
                            }
                            else if (this.MazingerGrade[newData.Type][newData.Stage].LuckyOne + newData.Exp > this.MazingerGrade[newData.Type][newData.Stage].LuckyTwo)
                            {
                                if (Global.GetRandom() < this.MazingerGrade[newData.Type][newData.Stage].Rate)
                                {
                                    newData.Stage++;
                                    newData.StarLevel = 0;
                                    newData.Exp       = 0;
                                    up         = true;
                                    res.IsBoom = 1;
                                }
                            }
                            int ret = Global.sendToDB <int, MazingerStoreData>(14126, newData, client.ServerId);
                            if (ret < 0)
                            {
                                LogManager.WriteLog(LogTypes.Error, string.Format("魔神秘宝修改数据出错, 玩家id RoleID={0}", client.ClientData.RoleID), null, true);
                                res.result = 10;
                            }
                            else
                            {
                                GameManager.logDBCmdMgr.AddDBLogInfo(-1, "魔神秘宝升阶", DateTime.Now.ToString(), newData.Type.ToString(), client.ClientData.RoleName, "系统", ClientType, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null);
                                EventLogManager.AddMazingerStoreEvent(client, client.ClientData.MazingerStoreDataInfo[newData.Type].Stage, newData.Stage, client.ClientData.MazingerStoreDataInfo[newData.Type].Exp, newData.Exp, "魔神秘宝升阶");
                                client.ClientData.MazingerStoreDataInfo[newData.Type] = newData;
                                res.result = 1;
                                res.data   = client.ClientData.MazingerStoreDataInfo[newData.Type];
                            }
                        }
                    }
                }
IL_B64:
                if (up && res.result == 1)
                {
                    Global.RefreshEquipPropAndNotify(client);
                }
                result = res;
            }
            return(result);
        }