Ejemplo n.º 1
0
        private void OfferStructureChoiceIfAvailable()
        {
            LocalLogManager.AddLine("Main Menu - Offer structure choice");
            var potentialTowers = PlayerDataManager.GetPossibleNewTowers();
            var numberOfChoices = potentialTowers.Count;

            if (numberOfChoices > 0)
            {
                var structure1 = StructureFactories.GetFactory(potentialTowers[0].Name).CreateNew(StructureLayer) as BaseStructure;
                structure1.LightSpriteInstance.Visible    = false;
                structure1.LightAimSpriteInstance.Visible = false;

                if (numberOfChoices == 1)
                {
                    TowerSelectionBoxInstance.SetOnlyChoice(structure1);
                }
                else
                {
                    var structure2 = StructureFactories.GetFactory(potentialTowers[1].Name).CreateNew(StructureLayer) as BaseStructure;
                    structure2.LightSpriteInstance.Visible    = false;
                    structure2.LightAimSpriteInstance.Visible = false;

                    TowerSelectionBoxInstance.SetChoices(structure1, structure2);
                }

                TowerSelectionBoxInstance.Visible = true;

                TowerSelectionBoxInstance.ConfirmTowerSelection += ConfirmTowerSelection;
            }
            else
            {
                TowerSelectionBoxInstance.Visible = false;
            }
        }
        private void AssignGumButtonEvents()
        {
            SetInfoBarControls();

            //Assign buildings to build buttons
            var listOfAllTowerTypes       = GameStateManager.GetAllTowers();
            var listOfAvailableTowerTypes = PlayerDataManager.GetAvailableTowers();

            var listOfAllInstantiatedTowers = new List <BaseStructure>();

            var listOfAvailableTowers         = new List <BaseStructure>();
            var listOfAvailableTowerFactories = new List <IEntityFactory>();

            foreach (var towerType in listOfAllTowerTypes)
            {
                var towerInstantiation = StructureFactories.GetNewObject(towerType) as BaseStructure;
                MachineLearningManager.LearnMaxTowerValues(towerInstantiation);
                _CheapestTowerCost = towerInstantiation.SatoshiCost < _CheapestTowerCost
                    ? towerInstantiation.SatoshiCost
                    : _CheapestTowerCost;
                listOfAllInstantiatedTowers.Add(towerInstantiation);

                if (listOfAvailableTowerTypes.Contains(towerType))
                {
                    listOfAvailableTowers.Add(towerInstantiation);
                    listOfAvailableTowerFactories.Add(StructureFactories.GetFactory(towerType.Name));
                }
            }

            BuildMenuInstance.AssociateTowers(listOfAvailableTowers, listOfAvailableTowerFactories, StructureInfoInstance, CurrentSatoshis);

            for (var i = listOfAllInstantiatedTowers.Count - 1; i >= 0; i--)
            {
                listOfAllInstantiatedTowers[i].Destroy();
            }

            ChatBoxInstance.ChatHistoryButtonClick += delegate(object sender, EventArgs args)
            {
                ChatHistoryInstance.PopulateWithRecentChatHistory();
                GameScreenGumInstance.ShowChatHistoryAnimation.Play();
            };

            ChatHistoryInstance.CloseButtonClick += delegate(object sender, EventArgs args)
            {
                if (GameScreenGumInstance.CurrentChatHistoryShowingState == GameScreenGumRuntime.ChatHistoryShowing.ChatHistoryShown)
                {
                    GameScreenGumInstance.HideChatHistoryAnimation.Play();
                }
            };
            GameScreenGumInstance.HideChatHistoryAnimation.AddAction("SetupResponseAvailability", ChatBoxInstance.SetupResponseAvailability);

            StructureInfoInstance.OnUpgradeAction = HandleUpgradeTower;

            ReadyButtonInstance.Click += OnStartButtonInstanceClick;
        }