Ejemplo n.º 1
0
 /// <summary>
 ///  更新价格
 /// </summary>
 private void UpdateCost()
 {
     MallDefine.MallLocalData current = CurrentMallData;
     if (null != m_trans_PurchaseCostGrid)
     {
         UICurrencyGrid currencyGrid = m_trans_PurchaseCostGrid.GetComponent <UICurrencyGrid>();
         if (null != currencyGrid)
         {
             GameCmd.MoneyType moneyType = GameCmd.MoneyType.MoneyType_Coin;
             uint totalCost = 0;
             if (null != current)
             {
                 moneyType = (GameCmd.MoneyType)current.LocalMall.moneyType;
                 totalCost = (uint)((current.IsInDiscount) ? current.LocalMall.offPrice * purchaseNum
                     : current.LocalMall.buyPrice * purchaseNum);
             }
             currencyGrid.SetGridData(new UICurrencyGrid.UICurrencyGridData(
                                          MallDefine.GetCurrencyIconNameByType((GameCmd.MoneyType)moneyType), totalCost));
         }
     }
 }
Ejemplo n.º 2
0
    public void Execute(stRefreshMoneyPropertyUserCmd_S cmd)
    {
        IPlayer player = ClientGlobal.Instance().MainPlayer;

        GameCmd.MoneyType e = (GameCmd.MoneyType)cmd.type;
        //为第一次加载 || InitType 服务器通知是否是游戏运行中刷新货币
        bool firstLoad = (null == player) || cmd.inittype == 1;

        ItemDefine.UpdateCurrecyPassData passData = null;
        int changeNum = 0;

        switch (e)
        {
        case GameCmd.MoneyType.MoneyType_MoneyTicket:     // (文钱)
        {
            if (player != null)
            {
                player.SetProp((int)PlayerProp.Money, (int)cmd.dwNum);
            }
            changeNum      = (int)cmd.dwNum - UserData.Money;
            UserData.Money = (int)cmd.dwNum;
            break;
        }

        case GameCmd.MoneyType.MoneyType_Gold:     // (金币)
        {
            if (player != null)
            {
                player.SetProp((int)PlayerProp.Coupon, (int)cmd.dwNum);
            }
            changeNum       = (int)cmd.dwNum - (int)UserData.Coupon;
            UserData.Coupon = (int)cmd.dwNum;

            break;
        }

        case GameCmd.MoneyType.MoneyType_Coin:     // (元宝)
        {
            if (player != null)
            {
                player.SetProp((int)PlayerProp.Cold, (int)cmd.dwNum);
            }
            changeNum     = (int)cmd.dwNum - (int)UserData.Cold;
            UserData.Cold = (int)cmd.dwNum;
            break;
        }

        case GameCmd.MoneyType.MoneyType_Score:     //积分
        {
            if (player != null)
            {
                player.SetProp((int)PlayerProp.Score, (int)cmd.dwNum);
            }
            changeNum      = (int)cmd.dwNum - (int)UserData.Score;
            UserData.Score = (int)cmd.dwNum;
            break;
        }

        case GameCmd.MoneyType.MoneyType_Reputation:     //声望
        {
            if (player != null)
            {
                player.SetProp((int)PlayerProp.Reputation, (int)cmd.dwNum);
            }
            changeNum           = (int)cmd.dwNum - (int)UserData.Reputation;
            UserData.Reputation = (int)cmd.dwNum;
            break;
        }

        case GameCmd.MoneyType.MoneyType_AchievePoint:     //声望
        {
            if (player != null)
            {
                player.SetProp((int)PlayerProp.AchievePoint, (int)cmd.dwNum);
            }
            changeNum             = (int)cmd.dwNum - (int)UserData.AchievePoint;
            UserData.AchievePoint = (int)cmd.dwNum;
            break;
        }

        case GameCmd.MoneyType.MoneyType_CampCoin:     //阵营积分
        {
            if (player != null)
            {
                player.SetProp((int)PlayerProp.CampCoin, (int)cmd.dwNum);
            }
            changeNum         = (int)cmd.dwNum - (int)UserData.CampCoin;
            UserData.CampCoin = (int)cmd.dwNum;
            break;
        }

        case GameCmd.MoneyType.MoneyType_HuntingCoin:     //狩猎积分
        {
            if (player != null)
            {
                player.SetProp((int)PlayerProp.ShouLieScore, (int)cmd.dwNum);
            }
            changeNum             = (int)cmd.dwNum - (int)UserData.ShouLieScore;
            UserData.ShouLieScore = (int)cmd.dwNum;
            break;
        }

        case GameCmd.MoneyType.MoneyType_FishingMoney:     //鱼币
        {
            if (player != null)
            {
                player.SetProp((int)PlayerProp.FishingMoney, (int)cmd.dwNum);
            }
            changeNum             = (int)cmd.dwNum - (int)UserData.FishingMoney;
            UserData.FishingMoney = (int)cmd.dwNum;
            break;
        }

        case GameCmd.MoneyType.MoneyType_TradeGold:     //银两
        {
            if (player != null)
            {
                player.SetProp((int)PlayerProp.YinLiang, (int)cmd.dwNum);
            }
            changeNum         = (int)cmd.dwNum - (int)UserData.YinLiang;
            UserData.YinLiang = (int)cmd.dwNum;
            break;
        }

        default:
        {
            break;
        }
        }

        if (!firstLoad)
        {
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.UIEVENT_REFRESHCURRENCYNUM, new ItemDefine.UpdateCurrecyPassData()
            {
                MoneyType = e,
                ChangeNum = changeNum,
            });
        }
    }