コード例 #1
0
        private void ConfirmUpgradeAllWalls(object result, object cookie)
        {
            string context = "UI_money_flow";
            string action  = (result == null) ? "close" : "buy";
            string message = "upgrade_all_walls";

            Service.Get <BILoggingController>().TrackGameAction(context, action, message, null);
            if (result == null)
            {
                return;
            }
            EventManager eventManager = Service.Get <EventManager>();

            eventManager.SendEvent(EventId.MuteEvent, EventId.InventoryResourceUpdated);
            eventManager.SendEvent(EventId.MuteEvent, EventId.ContractAdded);
            int num = GameUtils.CrystalCostToUpgradeAllWalls(this.nextBuildingInfo.UpgradeMaterials, this.allWallSameLevelCount);

            if (!GameUtils.SpendCrystals(num))
            {
                eventManager.SendEvent(EventId.UnmuteEvent, EventId.InventoryResourceUpdated);
                eventManager.SendEvent(EventId.UnmuteEvent, EventId.ContractAdded);
                return;
            }
            int    currencyAmount = -num;
            string itemType       = "soft_currency_flow";
            string itemId         = "materials";
            int    itemCount      = 1;
            string type           = "currency_purchase";
            string subType        = "durable";

            Service.Get <DMOAnalyticsController>().LogInAppCurrencyAction(currencyAmount, itemType, itemId, itemCount, type, subType);
            string             uid = this.buildingInfo.Uid;
            ISupportController supportController = Service.Get <ISupportController>();

            supportController.StartAllWallPartBuildingUpgrade(this.nextBuildingInfo, this.selectedBuilding, false, false);
            int count = this.wallsOfSameLevel.Count;

            for (int i = 0; i < count; i++)
            {
                supportController.StartAllWallPartBuildingUpgrade(this.nextBuildingInfo, this.wallsOfSameLevel[i], false, false);
            }
            BuildingUpgradeAllWallsCommand command = new BuildingUpgradeAllWallsCommand(new BuildingUpgradeAllWallsRequest
            {
                BuildingUid = uid,
                PlayerId    = Service.Get <CurrentPlayer>().PlayerId
            });

            Service.Get <ServerAPI>().Enqueue(command);
            for (int j = 0; j < count; j++)
            {
                supportController.FinishCurrentContract(this.wallsOfSameLevel[j], j != 0, false);
            }
            supportController.FinishCurrentContract(this.selectedBuilding, true, false);
            eventManager.SendEvent(EventId.UnmuteEvent, EventId.InventoryResourceUpdated);
            eventManager.SendEvent(EventId.UnmuteEvent, EventId.ContractAdded);
            eventManager.SendEvent(EventId.SimulateAudioEvent, new AudioEventData(EventId.InventoryResourceUpdated, "crystals"));
        }
コード例 #2
0
 public static void GrantInstantBuildingUpgrade(RewardVO reward, CurrentPlayer cp)
 {
     for (int i = 0; i < reward.BuildingInstantUpgrades.Length; i++)
     {
         string[] array = reward.BuildingInstantUpgrades[i].Split(new char[]
         {
             ':'
         });
         int            num            = Convert.ToInt32(array[1], CultureInfo.InvariantCulture);
         string         text           = array[0];
         BuildingTypeVO buildingTypeVO = Service.Get <IDataController>().Get <BuildingTypeVO>(text);
         if (buildingTypeVO == null)
         {
             Service.Get <StaRTSLogger>().WarnFormat("buildingUiD {0} does not exist", new object[]
             {
                 text
             });
         }
         else
         {
             BuildingUpgradeCatalog  buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
             ISupportController      supportController      = Service.Get <ISupportController>();
             NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();
             for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
             {
                 BuildingTypeVO buildingType = buildingNode.BuildingComp.BuildingType;
                 if (buildingType.Lvl < num && buildingType.Type == buildingTypeVO.Type && buildingType.Type != BuildingType.Clearable)
                 {
                     BuildingTypeVO byLevel = buildingUpgradeCatalog.GetByLevel(buildingType.UpgradeGroup, num);
                     if (byLevel != null && byLevel.PlayerFacing)
                     {
                         if (!string.IsNullOrEmpty(buildingTypeVO.LinkedUnit))
                         {
                             if (ContractUtils.IsChampionRepairing(buildingNode.Entity))
                             {
                                 supportController.FinishCurrentContract(buildingNode.Entity, true);
                             }
                             if (cp.Inventory.Champion.GetItemAmount(buildingTypeVO.LinkedUnit) == 0)
                             {
                                 cp.OnChampionRepaired(buildingTypeVO.LinkedUnit);
                             }
                         }
                         supportController.StartBuildingUpgrade(byLevel, buildingNode.Entity, true);
                         int   boardX = buildingNode.Entity.Get <BoardItemComponent>().BoardItem.BoardX;
                         int   boardZ = buildingNode.Entity.Get <BoardItemComponent>().BoardItem.BoardZ;
                         float x;
                         float z;
                         EditBaseController.BuildingBoardToWorld(buildingNode.Entity, boardX, boardZ, out x, out z);
                         Vector3 worldLocation = new Vector3(x, 0f, z);
                         worldLocation.x = Units.BoardToWorldX(boardX);
                         worldLocation.z = Units.BoardToWorldX(boardZ);
                         Service.Get <WorldInitializer>().View.PanToLocation(worldLocation);
                     }
                 }
             }
         }
     }
 }