Пример #1
0
        private void AssignClickEventsAndStatusToButtons()
        {
            var nextLevel = PlayerDataManager.LastLevelNumberCompleted + 1;
            var results   = PlayerDataManager.LevelResults;

            foreach (var element in MapScreenGumInstance.ContainedElements)
            {
                if (element is LevelButtonRuntime levelButton)
                {
                    if (results.Any(lr => lr.LevelName + "Level" == levelButton.LevelName))
                    {
                        //TODO:  Show level as completed
                        levelButton.Visible = true;
                        levelButton.Disable();
                    }
                    else if (levelButton.LevelAsNumber == nextLevel)
                    {
                        levelButton.Click  += LoadLevel;
                        levelButton.Visible = true;
                    }
                    else
                    {
                        levelButton.Visible = false;
                        levelButton.Disable();
                    }
                }
                if (element is ButtonFrameRuntime optionsButton)
                {
                    optionsButton.Click += ShowMenu;
                }
                if (element is MenuWindowRuntime menuWindow)
                {
                    menuWindow.AssignEventToCloseButton(window => MapScreenGumInstance.HideMenuAnimation.Play(this));
                    menuWindow.AssignEventToButton1(window =>
                    {
                        ConfirmationWindowInstance.Confirm("Exit and return to desktop?", () =>
                        {
                            LocalLogManager.AddLine("Main Menu - Exiting game");
                            PlayerDataManager.SaveData();
                            FlatRedBallServices.Game.Exit();
                        });
                    });
                    //menuWindow.ButtonType3State = ButtonFrameRuntime.ButtonType.Disabled;
                    menuWindow.AssignEventToButton3(window =>
                    {
                        LocalLogManager.AddLine("Main Menu - Show chat history");
                        ChatHistoryInstance.PopulateWithAllChatHistory();
                        ChatHistoryInstance.Visible = true;
                    });
                    menuWindow.AssignEventToButton4(window => OkMessageInstance.ShowMessage(Messages["Intro"].MessageText));
                }
            }
            ChatHistoryInstance.CloseButtonClick += (sender, args) =>
            {
                ChatHistoryInstance.Children.Clear();
                ChatHistoryInstance.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;
        }