Пример #1
0
        public static PrestigeMedalData UpPrestigeMedal(GameClient client, int MedalID)
        {
            PrestigeMedalData prestigeMedalData = client.ClientData.prestigeMedalData;
            PrestigeMedalData result;

            if (prestigeMedalData != null && prestigeMedalData.UpResultType == 3)
            {
                prestigeMedalData.UpResultType = -4;
                result = prestigeMedalData;
            }
            else if (prestigeMedalData == null || prestigeMedalData.MedalID != MedalID)
            {
                prestigeMedalData.UpResultType = 0;
                result = prestigeMedalData;
            }
            else if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.PrestigeMedal, false))
            {
                prestigeMedalData.UpResultType = -1;
                result = prestigeMedalData;
            }
            else
            {
                PrestigeMedalBasicData basicMedal = PrestigeMedalManager.GetPrestigeMedalBasicDataByID(MedalID);
                int prestigeNow = GameManager.ClientMgr.GetShengWangValue(client);
                if (basicMedal.PrestigeCost > prestigeNow)
                {
                    prestigeMedalData.UpResultType = -2;
                    result = prestigeMedalData;
                }
                else
                {
                    int upCount     = PrestigeMedalManager.GetPrestigeMedalUpCount(client);
                    int diamondNeed = PrestigeMedalManager.GetPrestigeMedalDiamond(client, upCount);
                    if (diamondNeed > 0 && !GameManager.ClientMgr.SubUserMoney(client, diamondNeed, "声望勋章提升", true, true, true, true, DaiBiSySType.ShengWangYinJi))
                    {
                        prestigeMedalData.UpResultType = -3;
                        result = prestigeMedalData;
                    }
                    else
                    {
                        try
                        {
                            GameManager.ClientMgr.ModifyShengWangValue(client, -basicMedal.PrestigeCost, "声望勋章提升", false, true);
                        }
                        catch (Exception)
                        {
                            prestigeMedalData.UpResultType = -2;
                            return(prestigeMedalData);
                        }
                        int[] addNums = null;
                        int   rate    = 0;
                        int   r       = Global.GetRandomNumber(0, 100);
                        for (int i = 0; i < basicMedal.RateList.Count; i++)
                        {
                            rate += basicMedal.RateList[i];
                            if (r <= rate)
                            {
                                addNums = basicMedal.AddNumList[i];
                                prestigeMedalData.BurstType = i;
                                break;
                            }
                        }
                        prestigeMedalData.LifeAdd    += addNums[0] * PrestigeMedalManager._medalRate;
                        prestigeMedalData.LifeAdd     = ((prestigeMedalData.LifeAdd > basicMedal.LifeMax) ? basicMedal.LifeMax : prestigeMedalData.LifeAdd);
                        prestigeMedalData.AttackAdd  += addNums[1] * PrestigeMedalManager._medalRate;
                        prestigeMedalData.AttackAdd   = ((prestigeMedalData.AttackAdd > basicMedal.AttackMax) ? basicMedal.AttackMax : prestigeMedalData.AttackAdd);
                        prestigeMedalData.DefenseAdd += addNums[2] * PrestigeMedalManager._medalRate;
                        prestigeMedalData.DefenseAdd  = ((prestigeMedalData.DefenseAdd > basicMedal.DefenseMax) ? basicMedal.DefenseMax : prestigeMedalData.DefenseAdd);
                        prestigeMedalData.HitAdd     += addNums[3] * PrestigeMedalManager._medalRate;
                        prestigeMedalData.HitAdd      = ((prestigeMedalData.HitAdd > basicMedal.HitMax) ? basicMedal.HitMax : prestigeMedalData.HitAdd);
                        if (prestigeMedalData.LifeAdd < basicMedal.LifeMax || prestigeMedalData.DefenseAdd < basicMedal.DefenseMax || prestigeMedalData.AttackAdd < basicMedal.AttackMax || prestigeMedalData.HitAdd < basicMedal.HitMax)
                        {
                            prestigeMedalData.UpResultType = 1;
                            prestigeMedalData.Prestige     = basicMedal.PrestigeCost;
                            prestigeMedalData.Diamond      = PrestigeMedalManager.GetPrestigeMedalDiamond(client, upCount + 1);
                        }
                        else
                        {
                            prestigeMedalData.MedalID++;
                            prestigeMedalData.LifeAdd      = 0;
                            prestigeMedalData.AttackAdd    = 0;
                            prestigeMedalData.DefenseAdd   = 0;
                            prestigeMedalData.HitAdd       = 0;
                            prestigeMedalData.UpResultType = 2;
                            if (prestigeMedalData.MedalID > PrestigeMedalManager._prestigeMedalBasicList.Count)
                            {
                                prestigeMedalData.UpResultType = 3;
                                prestigeMedalData.Prestige     = 0;
                                prestigeMedalData.Diamond      = 0;
                            }
                            else
                            {
                                basicMedal = PrestigeMedalManager.GetPrestigeMedalBasicDataByID(prestigeMedalData.MedalID);
                                prestigeMedalData.Prestige = basicMedal.PrestigeCost;
                                prestigeMedalData.Diamond  = PrestigeMedalManager.GetPrestigeMedalDiamond(client, upCount + 1);
                            }
                        }
                        PrestigeMedalManager.ModifyPrestigeMedalUpCount(client, upCount + 1, true);
                        PrestigeMedalManager.ModifyPrestigeMedalData(client, prestigeMedalData, true);
                        client.ClientData.prestigeMedalData = prestigeMedalData;
                        PrestigeMedalManager.SetPrestigeMedalProps(client, prestigeMedalData);
                        GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                        GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                        prestigeMedalData.PrestigeLeft = GameManager.ClientMgr.GetShengWangValue(client);
                        result = prestigeMedalData;
                    }
                }
            }
            return(result);
        }
Пример #2
0
        public static void SetPrestigeMedalCount(GameClient client, int count)
        {
            count = ((count < 0) ? 0 : count);
            PrestigeMedalManager.ModifyPrestigeMedalUpCount(client, count, true);
            PrestigeMedalData prestigeMedalData = client.ClientData.prestigeMedalData;

            prestigeMedalData.Diamond           = PrestigeMedalManager.GetPrestigeMedalDiamond(client, PrestigeMedalManager.GetPrestigeMedalUpCount(client));
            client.ClientData.prestigeMedalData = prestigeMedalData;
        }
Пример #3
0
        public static PrestigeMedalData GetPrestigeMedalData(GameClient client)
        {
            PrestigeMedalData result;

            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot4Dot1))
            {
                result = null;
            }
            else if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.PrestigeMedal, false))
            {
                result = null;
            }
            else
            {
                PrestigeMedalData prestigeMedalData = client.ClientData.prestigeMedalData;
                if (prestigeMedalData == null)
                {
                    prestigeMedalData = new PrestigeMedalData();
                    List <int>             data = Global.GetRoleParamsIntListFromDB(client, "PrestigeMedal");
                    PrestigeMedalBasicData basic;
                    if (data == null || data.Count <= 0)
                    {
                        basic = PrestigeMedalManager.GetPrestigeMedalBasicDataByID(PrestigeMedalManager._defaultMedalID);
                        prestigeMedalData.RoleID  = client.ClientData.RoleID;
                        prestigeMedalData.MedalID = basic.MedalID;
                        PrestigeMedalManager.ModifyPrestigeMedalData(client, prestigeMedalData, true);
                    }
                    else
                    {
                        prestigeMedalData.RoleID     = client.ClientData.RoleID;
                        prestigeMedalData.MedalID    = data[0];
                        prestigeMedalData.LifeAdd    = data[1];
                        prestigeMedalData.AttackAdd  = data[2];
                        prestigeMedalData.DefenseAdd = data[3];
                        prestigeMedalData.HitAdd     = data[4];
                        if (prestigeMedalData.MedalID > PrestigeMedalManager._prestigeMedalBasicList.Count)
                        {
                            prestigeMedalData.UpResultType = 3;
                            basic = PrestigeMedalManager.GetPrestigeMedalBasicDataByID(PrestigeMedalManager._prestigeMedalBasicList.Count);
                        }
                        else
                        {
                            basic = PrestigeMedalManager.GetPrestigeMedalBasicDataByID(prestigeMedalData.MedalID);
                        }
                    }
                    prestigeMedalData.Diamond           = PrestigeMedalManager.GetPrestigeMedalDiamond(client, PrestigeMedalManager.GetPrestigeMedalUpCount(client));
                    prestigeMedalData.Prestige          = basic.PrestigeCost;
                    client.ClientData.prestigeMedalData = prestigeMedalData;
                }
                prestigeMedalData.PrestigeLeft = GameManager.ClientMgr.GetShengWangValue(client);
                result = prestigeMedalData;
            }
            return(result);
        }