예제 #1
0
        public void Draw(GameTime time)
        {
            spriteBatch.Begin();

            spriteBatch.Draw(background, new Rectangle(0, 0, (int)GameConstants.WINDOWSIZE.X, (int)GameConstants.WINDOWSIZE.Y), Color.White);

            MainPanel.Draw(spriteBatch);

            switch (State)
            {
            case SettingState.Difficulty:
                DifficultyPanel.Draw(spriteBatch);
                break;

            case SettingState.Volume:
                VolumePanel.Draw(spriteBatch);
                break;

            case SettingState.Controls:
                ControlsPanel.Draw(spriteBatch);
                break;
            }

            spriteBatch.End();
        }
예제 #2
0
    // Start is called before the first frame update
    void Start()
    {
        // Determines which scene is open
        switch (SceneManager.GetActiveScene().name)
        {
        case "Main Menu":
            IsLoadingLevel = false;

            MainMenuPanel.SetActive(true);
            ControlsPanel.SetActive(false);
            CreditsPanel.SetActive(false);
            LoadingPanel.SetActive(false);

            MusicCreditsTitle.SetActive(false);
            MusicCredits.SetActive(false);
            ArtCreditsTitle.SetActive(false);
            ArtCredits.SetActive(false);
            ProgrammingCreditsTitle.SetActive(false);
            ProgrammingCredits.SetActive(false);
            GameDesignCreditsTitle.SetActive(false);
            GameDesignCredits.SetActive(false);

            TutorialIndex = 0;

            break;

        case "Gamefield":
            IsLoadingLevel = false;

            // Holds the amount of time which has elapsed
            Seconds        = 60.0f;
            WaveInProgress = true;
            // Holds the wave of enemies
            Wave = 1;
            // Determines whether the lose conditions of the game has been met
            PlayerHasLost = false;

            Direction = 0;

            InitiateCameras();

            SelectedBarracks = Barracks[0];

            UIBarracksBlocked.SetActive(false);
            UIPrompt.gameObject.SetActive(false);

            Currency   = 1000;
            SpawnGates = GameObject.FindGameObjectsWithTag("Spawn Gate");

            AutoAttack = true;
            break;
        }
    }
예제 #3
0
    // Return Buttons

    // Closes all panels other than the Main Menu
    void Return()
    {
        if (ControlsPanel.activeSelf)
        {
            ControlsPanel.SetActive(false);
        }
        if (CreditsPanel.activeSelf)
        {
            CreditsPanel.SetActive(false);
        }

        MainMenuPanel.SetActive(true);
    }
        private void MinimizePanel_Click(object sender, RoutedEventArgs e)
        {
            switch (FormattingPanel.Visibility)
            {
            case Visibility.Visible:
                double originalTop  = this.Top;
                double originalLeft = this.Left;
                panelLocation = ControlsPanel.TransformToVisual(this).Transform(new Point(0, 0));
                FormattingPanel.Visibility  = Visibility.Collapsed;
                MinimizePanelButton.Content = "+";
                this.Top  = originalTop + panelLocation.Y;
                this.Left = originalLeft + panelLocation.X;
                break;

            case Visibility.Hidden:
            case Visibility.Collapsed:
                FormattingPanel.Visibility  = Visibility.Visible;
                MinimizePanelButton.Content = "-";
                this.Top  -= panelLocation.Y;
                this.Left -= panelLocation.X;
                break;
            }
        }
예제 #5
0
 // Opens the Controls Panel
 void Controls()
 {
     MainMenuPanel.SetActive(false);
     ControlsPanel.SetActive(true);
 }
예제 #6
0
 public void ShowAllUserControls()
 {
     ControlsGroupbox.Show();
     ControlsPanel.Show();
 }
예제 #7
0
        private void LoadControls()
        {
            ControlsPanel.SuspendLayout();
            foreach (var control in customControls)
            {
                if (control is ComboBox)
                {
                    var combo = (ComboBox)control;
                    var panel = ControlPanel();
                    combo.Size    = combo.PreferredSize;
                    combo.Padding = new Padding(5, 5, 5, 10);
                    panel.Controls.Add(NewControlLabel(combo.Tag.ToString()));
                    panel.Controls.Add(combo);
                    ControlsPanel.Controls.Add(panel);
                }
                else if (control is TextBox)
                {
                    var textBox = (TextBox)control;
                    var panel   = ControlPanel();

                    if (textBox.Name.Contains("pass"))
                    {
                        textBox.UseSystemPasswordChar = true;
                    }

                    panel.Controls.Add(NewControlLabel(textBox.Tag.ToString()));
                    textBox.Width    = 150;
                    textBox.KeyDown += TextBox_KeyDown;
                    panel.Controls.Add(textBox);
                    ControlsPanel.Controls.Add(panel);
                }
                else if (control is CheckBox)
                {
                    var checkBox = (CheckBox)control;
                    checkBox.AutoSize = true;
                    checkBox.Text     = checkBox.Tag.ToString();
                    ControlsPanel.Controls.Add(checkBox);
                }
                else if (control is Label)
                {
                    var label = (Label)control;
                    label.AutoSize = true;
                    label.Padding  = new Padding(5, 5, 5, 10);
                    ControlsPanel.Controls.Add(label);
                }
                else if (control is RichTextBox)
                {
                    var rtb = (RichTextBox)control;

                    if (isMessageBox)
                    {
                        ControlsPanel.Visible = false;
                        rtb.ReadOnly          = true;
                        rtb.Margin            = new Padding(5, 10, 5, 0);
                        rtb.BackColor         = ControlsMainPanel.BackColor;
                        rtb.TabStop           = false;
                        rtb.LinkClicked      += ClickedLink;
                        ControlsMainPanel.Controls.Add(rtb);
                        // Set the local field for later loading/resizing changes.
                        messageBox = rtb;
                    }
                    else
                    {
                        var panel = ControlPanel();

                        rtb.Width  = 150;
                        rtb.Height = 80;
                        if (rtb.Tag != null)
                        {
                            panel.Controls.Add(NewControlLabel(rtb.Tag.ToString()));
                        }
                        panel.Controls.Add(rtb);
                        ControlsPanel.Controls.Add(panel);
                    }
                }
                else if (control is Button)
                {
                    var button = (Button)control;
                    button.AutoSize = true;
                    button.Click   += ButtonClick;
                    ControlsPanel.Controls.Add(button);
                }
                else
                {
                    var panel = ControlPanel();
                    panel.Controls.Add(NewControlLabel(control.Tag.ToString()));
                    panel.Controls.Add(control);
                    ControlsPanel.Controls.Add(panel);
                }
            }
            ControlsPanel.ResumeLayout();
            ControlsMainPanel.PerformLayout();
        }
예제 #8
0
 public void Controls()
 {
     ControlsPanel.SetActive(true);
 }
예제 #9
0
 public void Back()
 {
     CreditsPanel.SetActive(false);
     HelpPanel.SetActive(false);
     ControlsPanel.SetActive(false);
 }
예제 #10
0
        private void CreateUI()
        {
            mainMenu = new MainMenu(Content, StartNewGame, game.Exit);
            mainMenuCanvas.AddChild(mainMenu);
            mainMenuCanvas.Finish();

            Dictionary <string, SoundEffect> sounds = new Dictionary <string, SoundEffect>()
            {
                { "level0Intro", Content.Load <SoundEffect>("Sounds/level0Intro") },
                { "level1Intro", Content.Load <SoundEffect>("Sounds/level1Intro") },
                { "level2Intro", Content.Load <SoundEffect>("Sounds/level2Intro") },
                { "gameFinished", Content.Load <SoundEffect>("Sounds/gameFinished") },
                { "gameOver", Content.Load <SoundEffect>("Sounds/gameOver") },
            };

            transitionText = new MapTransitionText(TransitionContinueClicked, BackToMenu, game.Exit, sounds);
            transitionCanvas.AddChild(transitionText);
            transitionCanvas.Finish();


            mapCanvas.AddChild(new UnitPanel(() => { if (currentMap != null)
                                                     {
                                                         return(currentMap.GetSelectedUnit());
                                                     }
                                                     else
                                                     {
                                                         return(null);
                                                     } }, mapCanvas.sprites));
            mapCanvas.AddChild(new EnemyInfoPanel(() => { if (currentMap != null)
                                                          {
                                                              return(currentMap.GetMouseOverEnemy());
                                                          }
                                                          else
                                                          {
                                                              return(null);
                                                          } }));

            damagePopup     = new DamagePopup(camera);
            Map.damagePopup = damagePopup;
            mapCanvas.AddChild(damagePopup);


            HorizontalLayout mainButtons = new HorizontalLayout();

            mainButtons.SetMargin(6).Padding = new Point(6, 6);
            mainButtons.SetLayoutSize(LayoutSize.WrapContent, LayoutSize.FixedSize);
            mainButtons.SetFixedHeight(44);
            mainButtons.SetFixedWidth(270);
            mainButtons.sprite = mapCanvas.sprites["panel"];

            Button menuButton = new Button(mapCanvas.sprites["menu"]);

            menuButton.SetFixedSize(32, 32);

            Button musicButton = new Button(Config.musicPlaying ? mapCanvas.sprites["musicOn"] : mapCanvas.sprites["musicOff"]);

            musicButton.SetFixedSize(32, 32);
            musicButton.OnMouseClick = () => {
                Config.musicPlaying = !Config.musicPlaying;
                if (Config.musicPlaying)
                {
                    musicButton.sprite = mapCanvas.sprites["musicOn"];
                }
                else
                {
                    musicButton.sprite = mapCanvas.sprites["musicOff"];
                }
            };

            Button nextTurnButton = new Button(mapCanvas.sprites["nextTurn"]);

            nextTurnButton.SetFixedSize(32, 32);
            nextTurnButton.OnMouseClick = () => { if (currentMap != null)
                                                  {
                                                      currentMap.EndTurn();
                                                  }
            };

            KeyValueText turnText = new KeyValueText("turns", "12");

            turnText.SetLayoutSizeForBoth(LayoutSize.MatchParent);
            turnText.SetValueTextUpdate(() => { return(currentMap != null ? currentMap.turnCounter.ToString() : ""); });
            mainButtons.AddChild(menuButton, musicButton, nextTurnButton, turnText);

            mapCanvas.AddChild(mainButtons);


            EnemyTurnSign enemyTurnSign = new EnemyTurnSign(() => { return(currentMap); });

            mapCanvas.AddChild(enemyTurnSign);

            ControlsPanel controls = new ControlsPanel(mapCanvas.sprites);

            mapCanvas.AddChild(controls);

            mapCanvas.Finish();
        }