Ejemplo n.º 1
0
 internal void HandleArenaBuyFightCount(ulong guid, int handle)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "--handle arena buy fight count!");
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaBuyFightCountResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaBuyFightCountResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaBuyFightCountResult();
     ArenaInfo own_arena = m_ArenaSystem.GetArenaInfoById(guid);
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     DataProcessScheduler scheduler = LobbyServer.Instance.DataProcessScheduler;
     protoData.CurBuyTime = 0;
     protoData.CurFightCount = 0;
     protoData.Result = (int)GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
     if (own_arena != null && user != null && scheduler != null)
     {
         ArenaBuyFightCountConfig buy_config = ArenaConfigProvider.Instance.BuyFightCountConfig.GetDataById(own_arena.FightCountBuyTime + 1);
         if (user.Vip >= buy_config.RequireVipLevel && user.Gold >= buy_config.Cost)
         {
             if (own_arena.LeftFightCount < own_arena.MaxFightCount)
             {
                 own_arena.FightCountBuyTime += 1;
                 own_arena.LeftFightCount = own_arena.MaxFightCount;
                 protoData.Result = (int)GeneralOperationResult.LC_Succeed;
             }
             else
             {
                 protoData.Result = (int)GeneralOperationResult.LC_Failure_Full;
             }
             protoData.CurBuyTime = own_arena.FightCountBuyTime;
             protoData.CurFightCount = own_arena.LeftFightCount;
         }
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "--send arena buy fight count result!");
 }
Ejemplo n.º 2
0
    //设置可购买信息
    private void SetFightCountBuyTime()
    {
        RoleInfo role_info = LobbyClient.Instance.CurrentRole;

        if (role_info == null || role_info.ArenaStateInfo == null)
        {
            return;
        }
        int CurFightCountBuyTime = role_info.ArenaStateInfo.CurFightCountBuyTime;
        int playerVipLevel       = role_info.Vip;
        MyDictionary <int, object> countCfgDic = ArenaConfigProvider.Instance.BuyFightCountConfig.GetData();
        int maxCount = 0;

        foreach (int times in countCfgDic.Keys)
        {
            if (times > maxCount && countCfgDic[times] != null)
            {
                ArenaBuyFightCountConfig cfg = (ArenaBuyFightCountConfig)countCfgDic[times];
                if (cfg.RequireVipLevel <= playerVipLevel)
                {
                    maxCount = times;
                }
            }
        }
        int leftFightCountBuyTime = maxCount - CurFightCountBuyTime;

        leftFightCountBuyTime = leftFightCountBuyTime < 0 ? 0 : leftFightCountBuyTime;
        if (lblCanBuyCount != null)
        {
            lblCanBuyCount.text = leftFightCountBuyTime + "/" + maxCount;
        }
        ArenaBuyFightCountConfig countCfg = ArenaConfigProvider.Instance.BuyFightCountConfig.GetDataById(CurFightCountBuyTime + 1);

        if (countCfg != null)
        {
            if (lblDiamondOfBuyCount != null)
            {
                lblDiamondOfBuyCount.text = countCfg.Cost.ToString();
            }
            if (leftFightCountBuyTime > 0 && countCfg.Cost <= role_info.Gold)
            {
                CanBuyFightCount(true);
            }
            else
            {
                CanBuyFightCount(false);
            }
        }
        else
        {
            if (lblDiamondOfBuyCount != null)
            {
                lblDiamondOfBuyCount.text = "0";
            }
            CanBuyFightCount(false);
        }
    }