示例#1
0
    // 请求快速升级士兵
    public void RequestQuickTrainSoldier(int soldierCfgID, bool costRes)
    {
        PCMInt data = new PCMInt();

        data.arg = soldierCfgID;

        Net.Send(eCommand.TRAIN_SOLIDER_RIGHT_NOW, data, (buffer) => {
            PBuildInfo ret = Net.Deserialize <PBuildInfo>(buffer);

            if (!Net.CheckErrorCode(ret.errorCode, eCommand.TRAIN_SOLIDER_RIGHT_NOW))
            {
                return;
            }

            TrainBuildingInfo tbinfo = GetBuildingByType(CityBuildingType.TRAIN) as TrainBuildingInfo;
            if (tbinfo != null)
            {
                if (costRes)
                {
                    // 扣去相应资源(先减再升级)
                    UserManager.Instance.CostMoney(tbinfo.GetTrainCost(soldierCfgID), PriceType.MONEY);
                }

                // 无论哪种情况都要把黄金扣了
                UserManager.Instance.CostMoney(tbinfo.GetQuickTrainCost(), PriceType.GOLD);

                tbinfo.Deserialize(ret);
                RefreshUI(tbinfo.EntityID);

                UIManager.Instance.RefreshWindow <UICityTrainSelectView>();
            }
        });
    }
示例#2
0
    // 请求升级士兵
    public void RequestTrainSoldier(int soldierID, int cost)
    {
        PCMInt data = new PCMInt();

        data.arg = soldierID;

        Net.Send(eCommand.TRAIN_SOLIDERS, data, (buffer) => {
            PBuildInfo ret = Net.Deserialize <PBuildInfo>(buffer);
            if (!Net.CheckErrorCode(ret.errorCode, eCommand.TRAIN_SOLIDERS))
            {
                return;
            }

            TrainBuildingInfo info = GetBuilding(ret.buildId) as TrainBuildingInfo;
            if (info != null)
            {
                UserManager.Instance.CostMoney(cost, PriceType.MONEY);
                info.Deserialize(ret);
                RefreshUI(info.EntityID);
            }
        });
    }