Ejemplo n.º 1
0
        public static void SetUnionPalaceCount(GameClient client, int count)
        {
            count = ((count < 0) ? 0 : count);
            UnionPalaceManager.ModifyUpCount(client, count);
            UnionPalaceData myUPData = client.ClientData.MyUnionPalaceData;

            myUPData.ZhanGongNeed = UnionPalaceManager.GetUnionPalaceZG(client, 0);
        }
Ejemplo n.º 2
0
 public static void initSetUnionPalaceProps(GameClient client, bool isUpdataProps = false)
 {
     lock (client.ClientData.LockUnionPalace)
     {
         client.ClientData.MyUnionPalaceData = null;
         UnionPalaceData UnionPalaceData = UnionPalaceManager.UnionPalaceGetData(client, isUpdataProps);
         GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
         GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
     }
 }
Ejemplo n.º 3
0
        public static void SetUnionPalaceLevelByID(GameClient client, int id)
        {
            List <int> dataList = new List <int>();
            List <int> list     = dataList;

            int[] array = new int[5];
            array[0] = id;
            list.AddRange(array);
            Global.SaveRoleParamsIntListToDB(client, dataList, "UnionPalace", true);
            client.ClientData.MyUnionPalaceData = null;
            UnionPalaceManager.initSetUnionPalaceProps(client, true);
        }
Ejemplo n.º 4
0
 public static int GetUnionPalaceZG(GameClient client, int upCount = 0)
 {
     if (upCount <= 0)
     {
         int today = Global.GetOffsetDayNow();
         upCount = UnionPalaceManager.GetUpCount(client, today);
     }
     int[] zhanGongList = GameManager.systemParamsList.GetParamValueIntArrayByName("ZhanMengShenDian", ',');
     if (upCount >= zhanGongList.Length)
     {
         upCount = zhanGongList.Length - 1;
     }
     return(zhanGongList[upCount]);
 }
Ejemplo n.º 5
0
 private bool ProcessCmdUnionPalaceData(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 1))
         {
             return(false);
         }
         UnionPalaceData data = UnionPalaceManager.UnionPalaceGetData(client, false);
         client.sendCmd <UnionPalaceData>(1035, data, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Ejemplo n.º 6
0
        public static int GetUpCount(GameClient client, int day)
        {
            int        count  = 0;
            int        dayOld = 0;
            List <int> data   = Global.GetRoleParamsIntListFromDB(client, "UnionPalaceUpCount");

            if (data != null && data.Count > 0)
            {
                dayOld = data[0];
            }
            if (dayOld == day)
            {
                count = data[1];
            }
            else
            {
                UnionPalaceManager.ModifyUpCount(client, count);
            }
            return(count);
        }
Ejemplo n.º 7
0
 public static void InitConfig()
 {
     UnionPalaceManager.LoadUnionPalaceBasicInfo();
     UnionPalaceManager.LoadUnionPalaceSpecialInfo();
     UnionPalaceManager.LoadUnionPalaceRateInfo();
 }
Ejemplo n.º 8
0
 public static void SetUnionPalaceProps(GameClient client, UnionPalaceData myData)
 {
     lock (client.ClientData.LockUnionPalace)
     {
         int life    = 0;
         int attack  = 0;
         int defense = 0;
         int injure  = 0;
         UnionPalaceBasicInfo basicInfo = UnionPalaceManager.GetUPBasicInfoByID(myData.StatueID);
         int bangHuiLevel = Global.GetBangHuiLevel(client);
         if (basicInfo != null && basicInfo.UnionLevel <= bangHuiLevel && myData.StatueLevel <= bangHuiLevel)
         {
             life    = myData.LifeAdd;
             attack  = myData.AttackAdd;
             defense = myData.DefenseAdd;
             injure  = myData.AttackInjureAdd;
         }
         foreach (UnionPalaceBasicInfo d in UnionPalaceManager._unionPalaceBasicList.Values)
         {
             if (d.StatueID < myData.StatueID && d.UnionLevel <= bangHuiLevel && d.StatueLevel <= bangHuiLevel)
             {
                 life    += d.LifeMax;
                 attack  += d.AttackMax;
                 defense += d.DefenseMax;
                 injure  += d.AttackInjureMax;
             }
         }
         double lifePercent = 0.0;
         int    step        = (myData.StatueID - 1) / 8;
         if (step > 0)
         {
             if (myData.ResultType == 4 || myData.ResultType == -7)
             {
                 int maxID = 0;
                 IOrderedEnumerable <UnionPalaceBasicInfo> temp = from info in UnionPalaceManager._unionPalaceBasicList.Values
                                                                  where info.StatueID <= myData.StatueID && info.StatueLevel <= myData.StatueLevel && info.UnionLevel <= myData.UnionLevel && info.UnionLevel > 0
                                                                  orderby info.StatueID descending
                                                                  select info;
                 if (temp.Any <UnionPalaceBasicInfo>())
                 {
                     maxID = temp.First <UnionPalaceBasicInfo>().StatueID;
                 }
                 step = maxID / 8;
             }
             UnionPalaceSpecialInfo s = UnionPalaceManager.GetUPSpecialInfoByID(step);
             if (s != null && s.UnionLevel <= bangHuiLevel)
             {
                 lifePercent = s.MaxLifePercent;
             }
         }
         EquipPropItem propItem = new EquipPropItem();
         propItem.ExtProps[13] = (double)life;
         propItem.ExtProps[45] = (double)attack;
         propItem.ExtProps[46] = (double)defense;
         propItem.ExtProps[27] = (double)injure;
         propItem.ExtProps[14] = lifePercent;
         client.ClientData.PropsCacheManager.SetExtProps(new object[]
         {
             19,
             propItem.ExtProps
         });
     }
 }
Ejemplo n.º 9
0
 public bool startup()
 {
     TCPCmdDispatcher.getInstance().registerProcessorEx(1035, 1, 1, UnionPalaceManager.getInstance(), TCPCmdFlags.IsStringArrayParams);
     TCPCmdDispatcher.getInstance().registerProcessorEx(1036, 1, 1, UnionPalaceManager.getInstance(), TCPCmdFlags.IsStringArrayParams);
     return(true);
 }
Ejemplo n.º 10
0
        public static UnionPalaceData UnionPalaceUp(GameClient client)
        {
            UnionPalaceData result;

            lock (client.ClientData.LockUnionPalace)
            {
                UnionPalaceData myUPData = UnionPalaceManager.UnionPalaceGetData(client, false);
                if (myUPData.ResultType < 0)
                {
                    result = myUPData;
                }
                else if (myUPData.ResultType == 3 || myUPData.ResultType == -4)
                {
                    myUPData.ResultType = -4;
                    result = myUPData;
                }
                else if (!UnionPalaceManager.IsGongNengOpened(client))
                {
                    myUPData.ResultType = -1;
                    result = myUPData;
                }
                else
                {
                    UnionPalaceBasicInfo basicInfo = UnionPalaceManager.GetUPBasicInfoByID(myUPData.StatueID);
                    if (basicInfo.UnionLevel < 0)
                    {
                        myUPData.ResultType = -4;
                        result = myUPData;
                    }
                    else
                    {
                        int bhLevel = Global.GetBangHuiLevel(client);
                        if (basicInfo.UnionLevel > bhLevel)
                        {
                            myUPData.ResultType = -8;
                            result = myUPData;
                        }
                        else if (bhLevel < myUPData.StatueLevel)
                        {
                            myUPData.ResultType = -7;
                            result = myUPData;
                        }
                        else
                        {
                            int zhanGongNeed = UnionPalaceManager.GetUnionPalaceZG(client, 0);
                            if (!GameManager.ClientMgr.SubUserBangGong(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, zhanGongNeed))
                            {
                                myUPData.ResultType = -3;
                                result = myUPData;
                            }
                            else
                            {
                                UnionPalaceRateInfo rateInfo = UnionPalaceManager.GetUPRateInfoByID(basicInfo.StatueLevel);
                                int[] addNums = null;
                                int   rate    = 0;
                                int   r       = Global.GetRandomNumber(0, 100);
                                for (int i = 0; i < rateInfo.RateList.Count; i++)
                                {
                                    rate += rateInfo.RateList[i];
                                    if (r <= rate)
                                    {
                                        addNums            = rateInfo.AddNumList[rateInfo.RateList[i]].ToArray();
                                        myUPData.BurstType = i;
                                        break;
                                    }
                                }
                                List <int> logList = new List <int>();
                                logList.Add(myUPData.StatueID);
                                logList.Add(myUPData.LifeAdd);
                                logList.Add(myUPData.AttackAdd);
                                logList.Add(myUPData.DefenseAdd);
                                logList.Add(myUPData.AttackInjureAdd);
                                myUPData.LifeAdd         += addNums[0] * UnionPalaceManager._gmRate;
                                myUPData.LifeAdd          = ((myUPData.LifeAdd > basicInfo.LifeMax) ? basicInfo.LifeMax : myUPData.LifeAdd);
                                myUPData.AttackAdd       += addNums[1] * UnionPalaceManager._gmRate;
                                myUPData.AttackAdd        = ((myUPData.AttackAdd > basicInfo.AttackMax) ? basicInfo.AttackMax : myUPData.AttackAdd);
                                myUPData.DefenseAdd      += addNums[2] * UnionPalaceManager._gmRate;
                                myUPData.DefenseAdd       = ((myUPData.DefenseAdd > basicInfo.DefenseMax) ? basicInfo.DefenseMax : myUPData.DefenseAdd);
                                myUPData.AttackInjureAdd += addNums[3] * UnionPalaceManager._gmRate;
                                myUPData.AttackInjureAdd  = ((myUPData.AttackInjureAdd > basicInfo.AttackInjureMax) ? basicInfo.AttackInjureMax : myUPData.AttackInjureAdd);
                                if (myUPData.LifeAdd < basicInfo.LifeMax || myUPData.DefenseAdd < basicInfo.DefenseMax || myUPData.AttackAdd < basicInfo.AttackMax || myUPData.AttackInjureAdd < basicInfo.AttackInjureMax)
                                {
                                    myUPData.ResultType = 1;
                                }
                                else
                                {
                                    myUPData.StatueID++;
                                    basicInfo                = UnionPalaceManager.GetUPBasicInfoByID(myUPData.StatueID);
                                    myUPData.StatueType      = basicInfo.StatueType;
                                    myUPData.StatueLevel     = basicInfo.StatueLevel;
                                    myUPData.LifeAdd         = 0;
                                    myUPData.AttackAdd       = 0;
                                    myUPData.DefenseAdd      = 0;
                                    myUPData.AttackInjureAdd = 0;
                                    myUPData.ResultType      = 2;
                                    if (myUPData.StatueID > UnionPalaceManager._unionPalaceBasicList.Count || basicInfo.UnionLevel < 0)
                                    {
                                        myUPData.ResultType = 3;
                                    }
                                    else if (bhLevel < basicInfo.UnionLevel)
                                    {
                                        myUPData.ResultType = 5;
                                    }
                                    else if (bhLevel < myUPData.StatueLevel)
                                    {
                                        myUPData.ResultType = 4;
                                    }
                                }
                                int today   = Global.GetOffsetDayNow();
                                int upCount = UnionPalaceManager.GetUpCount(client, today);
                                myUPData.ZhanGongNeed = UnionPalaceManager.GetUnionPalaceZG(client, upCount + 1);
                                UnionPalaceManager.ModifyUpCount(client, upCount + 1);
                                UnionPalaceManager.ModifyUnionPalaceData(client, myUPData);
                                client.ClientData.MyUnionPalaceData = myUPData;
                                UnionPalaceManager.SetUnionPalaceProps(client, myUPData);
                                GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                                GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                                myUPData.ZhanGongLeft = client.ClientData.BangGong;
                                logList.Add(myUPData.StatueID);
                                logList.Add(myUPData.LifeAdd);
                                logList.Add(myUPData.AttackAdd);
                                logList.Add(myUPData.DefenseAdd);
                                logList.Add(myUPData.AttackInjureAdd);
                                logList.Add(upCount);
                                EventLogManager.AddUnionPalaceEvent(client, LogRecordType.UnionPalace, new object[]
                                {
                                    logList.ToArray()
                                });
                                result = myUPData;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 11
0
 public bool initialize()
 {
     UnionPalaceManager.InitConfig();
     return(true);
 }
Ejemplo n.º 12
0
        public static UnionPalaceData UnionPalaceGetData(GameClient client, bool isUpdataProps = false)
        {
            UnionPalaceData myUPData2;

            lock (client.ClientData.LockUnionPalace)
            {
                UnionPalaceData      myUPData  = client.ClientData.MyUnionPalaceData;
                UnionPalaceBasicInfo basicInfo = null;
                if (!UnionPalaceManager.IsGongNengOpened(client))
                {
                    myUPData            = new UnionPalaceData();
                    myUPData.ResultType = -1;
                    myUPData2           = myUPData;
                }
                else if (Global.GetBangHuiLevel(client) <= 0)
                {
                    if (myUPData == null)
                    {
                        myUPData = new UnionPalaceData();
                    }
                    myUPData.ResultType = -2;
                    if (isUpdataProps)
                    {
                        UnionPalaceManager.SetUnionPalaceProps(client, myUPData);
                    }
                    myUPData2 = myUPData;
                }
                else
                {
                    if (myUPData == null)
                    {
                        myUPData = new UnionPalaceData();
                        List <int> data = Global.GetRoleParamsIntListFromDB(client, "UnionPalace");
                        if (data == null || data.Count <= 0)
                        {
                            myUPData.RoleID   = client.ClientData.RoleID;
                            myUPData.StatueID = 1;
                            UnionPalaceManager.ModifyUnionPalaceData(client, myUPData);
                        }
                        else
                        {
                            myUPData.RoleID          = client.ClientData.RoleID;
                            myUPData.StatueID        = data[0];
                            myUPData.LifeAdd         = data[1];
                            myUPData.AttackAdd       = data[2];
                            myUPData.DefenseAdd      = data[3];
                            myUPData.AttackInjureAdd = data[4];
                        }
                        basicInfo            = UnionPalaceManager.GetUPBasicInfoByID(myUPData.StatueID);
                        myUPData.StatueType  = basicInfo.StatueType;
                        myUPData.StatueLevel = basicInfo.StatueLevel;
                        client.ClientData.MyUnionPalaceData = myUPData;
                        UnionPalaceManager.SetUnionPalaceProps(client, myUPData);
                    }
                    myUPData.ZhanGongNeed = UnionPalaceManager.GetUnionPalaceZG(client, 0);
                    myUPData.UnionLevel   = Global.GetBangHuiLevel(client);
                    myUPData.BurstType    = 0;
                    if (basicInfo == null)
                    {
                        basicInfo = UnionPalaceManager.GetUPBasicInfoByID(myUPData.StatueID);
                    }
                    if (basicInfo.UnionLevel < 0)
                    {
                        myUPData.ResultType = 3;
                        if (myUPData.UnionLevel < 9)
                        {
                            myUPData.ResultType = 4;
                        }
                    }
                    else
                    {
                        myUPData.ResultType = 0;
                        if (myUPData.UnionLevel < basicInfo.UnionLevel)
                        {
                            myUPData.ResultType = 5;
                            if (myUPData.LifeAdd != 0 || myUPData.AttackInjureAdd != 0 || myUPData.DefenseAdd != 0 || myUPData.AttackAdd != 0 || myUPData.StatueType > 1)
                            {
                                myUPData.ResultType = 4;
                            }
                            else
                            {
                                int maxLevel = 0;
                                IOrderedEnumerable <UnionPalaceBasicInfo> temp = from info in UnionPalaceManager._unionPalaceBasicList.Values
                                                                                 where info.StatueID <= myUPData.StatueID && info.StatueLevel <= myUPData.StatueLevel && info.UnionLevel <= myUPData.UnionLevel && info.UnionLevel > 0
                                                                                 orderby info.StatueID descending
                                                                                 select info;
                                if (temp.Any <UnionPalaceBasicInfo>())
                                {
                                    maxLevel = temp.First <UnionPalaceBasicInfo>().StatueLevel;
                                }
                                if (basicInfo.StatueLevel > maxLevel + 1)
                                {
                                    myUPData.ResultType = 4;
                                }
                            }
                        }
                    }
                    if (isUpdataProps)
                    {
                        UnionPalaceManager.SetUnionPalaceProps(client, myUPData);
                    }
                    myUPData.ZhanGongLeft = client.ClientData.BangGong;
                    myUPData2             = myUPData;
                }
            }
            return(myUPData2);
        }