Beispiel #1
0
        public void PrepareAndPurchaseNewBuilding(BuildingTypeVO buildingType)
        {
            this.buildingMover.EnsureLoweredLiftedBuilding();
            this.EnsureDeselectSelectedBuilding();
            GameStateMachine gameStateMachine = Service.Get <GameStateMachine>();

            if (!(gameStateMachine.CurrentState is EditBaseState))
            {
                gameStateMachine.SetState(new EditBaseState(false));
            }
            int stampableQuantity = 0;

            if (buildingType.Type == BuildingType.Wall)
            {
                BuildingLookupController buildingLookupController = Service.Get <BuildingLookupController>();
                int buildingMaxPurchaseQuantity = buildingLookupController.GetBuildingMaxPurchaseQuantity(buildingType, 0);
                int buildingPurchasedQuantity   = buildingLookupController.GetBuildingPurchasedQuantity(buildingType);
                stampableQuantity = buildingMaxPurchaseQuantity - buildingPurchasedQuantity;
            }
            this.StartPurchaseBuilding(buildingType, stampableQuantity);
        }
        public void HandleUnableToCollect(CurrencyType currencyType)
        {
            BuildingLookupController buildingLookupController = Service.Get <BuildingLookupController>();
            IDataController          dataController           = Service.Get <IDataController>();
            CurrentPlayer            currentPlayer            = Service.Get <CurrentPlayer>();
            BuildingTypeVO           buildingTypeVO           = null;

            foreach (BuildingTypeVO current in dataController.GetAll <BuildingTypeVO>())
            {
                if (current.Faction == currentPlayer.Faction && current.Type == BuildingType.Storage && current.Currency == currencyType)
                {
                    buildingTypeVO = current;
                    break;
                }
            }
            int num = 0;

            if (buildingTypeVO != null)
            {
                num = buildingLookupController.GetBuildingMaxPurchaseQuantity(buildingTypeVO, 0);
            }
            int num2           = 0;
            int num3           = 0;
            int highestLevelHQ = buildingLookupController.GetHighestLevelHQ();

            for (StorageNode storageNode = buildingLookupController.StorageNodeList.Head; storageNode != null; storageNode = storageNode.Next)
            {
                if (storageNode.BuildingComp.BuildingType.Currency == currencyType)
                {
                    num2++;
                    if (storageNode.BuildingComp.BuildingType.Lvl == highestLevelHQ)
                    {
                        num3++;
                    }
                }
            }
            bool   flag         = num2 < num;
            string instructions = string.Empty;

            switch (currencyType)
            {
            case CurrencyType.Credits:
                if (flag)
                {
                    instructions = Service.Get <Lang>().Get("BUILD_MORE_CREDIT_STORAGE", new object[0]);
                }
                else if (num3 == num2)
                {
                    instructions = Service.Get <Lang>().Get("FULL_CREDIT_STORAGE", new object[0]);
                }
                else
                {
                    instructions = Service.Get <Lang>().Get("UPGRADE_CREDIT_STORAGE", new object[0]);
                }
                break;

            case CurrencyType.Materials:
                if (flag)
                {
                    instructions = Service.Get <Lang>().Get("BUILD_MORE_MATERIAL_STORAGE", new object[0]);
                }
                else if (num3 == num2)
                {
                    instructions = Service.Get <Lang>().Get("FULL_MATERIAL_STORAGE", new object[0]);
                }
                else
                {
                    instructions = Service.Get <Lang>().Get("UPGRADE_MATERIAL_STORAGE", new object[0]);
                }
                break;

            case CurrencyType.Contraband:
                if (flag)
                {
                    instructions = Service.Get <Lang>().Get("BUILD_MORE_CONTRABAND_STORAGE", new object[0]);
                }
                else if (num3 == num2)
                {
                    instructions = Service.Get <Lang>().Get("FULL_CONTRABAND_STORAGE", new object[0]);
                }
                else
                {
                    instructions = Service.Get <Lang>().Get("UPGRADE_CONTRABAND_STORAGE", new object[0]);
                }
                break;
            }
            Service.Get <UXController>().MiscElementsManager.ShowPlayerInstructions(instructions);
        }