Example #1
0
        private void CreateFirstPage(Manager manager, Player[] playerList, TabPage control)
        {
            var yPos = 16;
            var padding = 10;
            // Get the player that won
            var winningPlayer = playerList.MaxBy(i => i.TotalValue);

            var winningPlayerLabel = new Label(manager) {
                Text = "The current leader is " + winningPlayer.Name,
                Width = 400,
                Alignment = Alignment.MiddleCenter,
                Parent = control,
                Top = yPos,
                Name = IgnoreString
            };
            yPos += winningPlayerLabel.Height + 16;

            var playerAvatar = winningPlayer.Avatar;

            var imageIcon = new Button(manager) {
                Glyph = new Glyph(playerAvatar),
                Height = (int)(playerAvatar.Height / 1.5),
                Width = (int)(playerAvatar.Width / 1.5),
                Left = 16,
                Name = IgnoreString,
                Top = yPos,
                Parent = control,
                Color = winningPlayer.PlayerColor,
            };
            imageIcon.Init();
            imageIcon.FocusGained += (sender, args) => imageIcon.Enabled = false;

            var descriptionText = new Label(manager) {
                Left = imageIcon.Left + imageIcon.Width + 16, Width = 200,
                Height = imageIcon.Height,
                Top = yPos + 9,
                Text = String.Format(
                    "Player Name : {0}\n\n" +
                    "Player Cash : ${1:N0}\n\n" +
                    "Player Total Worth : ${2:N0}\n\n" +
                    "Player Position : {3:N0}\n\n",
                    winningPlayer.Name, winningPlayer.Cash, winningPlayer.TotalValue, 1),
                Alignment = Alignment.TopLeft,
                Parent = control,
                Name = IgnoreString,
            };
            descriptionText.Init();

            yPos = imageIcon.Top + imageIcon.Height + 16;

            int playerCount = 0;

            var leaderBoard = new ImageBox(manager) {
                Image = manager.Game.Content.Load<Texture2D>("images/leaderboard"),
                Top = yPos - padding,
                Left = 200 - 100, Parent = control, Width = 250,
                                Name = IgnoreString
            };
            leaderBoard.Init();
            yPos += leaderBoard.Height / 3;
            foreach (var player in playerList.OrderByDescending(i => i.TotalValue))
            {
                playerCount++;
                var label = new Label(manager)
                                {
                                    Text = String.Format("{0}. {1}\n\n          " +
                                                         "Total Value : ${3:N0}\n          " +
                                                         "Current Cash : ${2:N0}",
                                                         playerCount, player.Name, player.Cash, player.TotalValue),
                                    Height = 50,
                                    Width = 400,
                                    Parent = control,
                                    Left = 80,
                                    Top = yPos,
                                    Name = IgnoreString
                                };
                yPos += label.Height + 10;
            }

            createdPages[control] = yPos + 30;
        }
		////////////////////////////////////////////////////////////////////////////     

		////////////////////////////////////////////////////////////////////////////     
		public virtual void RemovePage(TabPage page, bool dispose)
		{
			tabPages.Remove(page);
			if (dispose)
			{
				page.Dispose();
				page = null;
			}
			SelectedIndex = 0;
		}
		////////////////////////////////////////////////////////////////////////////         

		////////////////////////////////////////////////////////////////////////////         
		public virtual void RemovePage(TabPage page)
		{
			RemovePage(page, true);
		}
Example #4
0
        private void InitializeControls()
        {
            _manager.Initialize();
            _manager.AutoCreateRenderTarget = true;

            _tabControl = new TabControl(_manager);
            _tabControl.Init();
            _tabControl.Left   = 600;
            _tabControl.Top    = 0;
            _tabControl.Width  = Width;
            _tabControl.Height = Height;
            _tabControl.Show();
            #region WavePage
            _wavePage      = _tabControl.AddPage();
            _wavePage.Text = "Waves";

            #region Constructors
            _health = new Label(_manager);
            _health.Init();
            _texture = new Label(_manager);
            _texture.Init();
            _speed = new Label(_manager);
            _speed.Init();
            _number = new Label(_manager);
            _number.Init();

            _waves = new ListBox(_manager);
            _waves.Init();
            _deleteWaveButton = new Button(_manager);
            _deleteWaveButton.Init();
            _addWaveButton = new Button(_manager);
            _addWaveButton.Init();
            _currentWave = new ListBox(_manager);
            _currentWave.Init();
            _addCreepsButton = new Button(_manager);
            _addCreepsButton.Init();
            _numberOfCreeps = new TextBox(_manager);
            _numberOfCreeps.Init();
            _speedOfCreeps = new TextBox(_manager);
            _speedOfCreeps.Init();
            _healthOfCreeps = new TextBox(_manager);
            _healthOfCreeps.Init();
            _creepTexture = new ComboBox(_manager);
            _creepTexture.Init();
            #endregion

            #region Properties
            _texture.Text   = "Textur";
            _texture.Top    = 2;
            _texture.Left   = 2;
            _texture.Parent = _wavePage;
            _wavePage.Add(_texture);

            _creepTexture.Items.AddRange(new[] { "Slyder", "Drone", "Ape", "Paw" });
            _creepTexture.Text      = "Slyder";
            _creepTexture.Width     = 80;
            _creepTexture.Left      = 2;
            _creepTexture.Top       = _texture.Top + _texture.Height + 2;
            _creepTexture.TextColor = Color.LightGray;
            _creepTexture.Parent    = _wavePage;

            _health.Text   = "Gesundheit";
            _health.Top    = 2;
            _health.Left   = _creepTexture.Left + _creepTexture.Width + 5;
            _health.Parent = _wavePage;

            _healthOfCreeps.Left      = _health.Left;
            _healthOfCreeps.Top       = _health.Top + _health.Height + 2;
            _healthOfCreeps.Width     = _health.Width;
            _healthOfCreeps.TextColor = Color.LightGray;
            _healthOfCreeps.Parent    = _wavePage;

            _speed.Text   = "Geschwindigkeit";
            _speed.Left   = _health.Left + _health.Width + 5;
            _speed.Top    = 2;
            _speed.Width  = 93;
            _speed.Parent = _wavePage;

            _speedOfCreeps.Left      = _speed.Left;
            _speedOfCreeps.Top       = _speed.Top + _speed.Height + 2;
            _speedOfCreeps.Width     = _speed.Width;
            _speedOfCreeps.TextColor = Color.LightGray;
            _speedOfCreeps.Parent    = _wavePage;

            _number.Text   = "Anzahl";
            _number.Top    = 2;
            _number.Left   = _speed.Left + _speed.Width + 5;
            _number.Width  = 40;
            _number.Parent = _wavePage;

            _numberOfCreeps.Left      = _number.Left;
            _numberOfCreeps.Top       = _number.Top + _number.Height + 2;
            _numberOfCreeps.Width     = _number.Width;
            _numberOfCreeps.TextColor = Color.LightGray;
            _numberOfCreeps.Parent    = _wavePage;

            _addCreepsButton.Text   = "Creeps hinzufügen";
            _addCreepsButton.Top    = _numberOfCreeps.Top + _numberOfCreeps.Height - _addCreepsButton.Height;
            _addCreepsButton.Left   = _numberOfCreeps.Left + _numberOfCreeps.Width + 5;
            _addCreepsButton.Width  = 120;
            _addCreepsButton.Parent = _wavePage;

            _currentWave.Left      = 2;
            _currentWave.Top       = _creepTexture.Top + _creepTexture.Height + 5;
            _currentWave.Width     = _addCreepsButton.Left + _addCreepsButton.Width;
            _currentWave.Height    = 150;
            _currentWave.TextColor = Color.LightGray;
            _currentWave.Parent    = _wavePage;

            _addWaveButton.Text   = "Wave hinzufügen";
            _addWaveButton.Left   = 2;
            _addWaveButton.Top    = _currentWave.Top + _currentWave.Height + 5;
            _addWaveButton.Width  = 150;
            _addWaveButton.Parent = _wavePage;

            _deleteWaveButton.Text   = "Wave löschen";
            _deleteWaveButton.Left   = _addWaveButton.Left + _addWaveButton.Width + 5;
            _deleteWaveButton.Top    = _currentWave.Top + _currentWave.Height + 5;
            _deleteWaveButton.Width  = _addWaveButton.Width;
            _deleteWaveButton.Parent = _wavePage;

            _waves.Left              = 2;
            _waves.Top               = _addWaveButton.Top + _addWaveButton.Height + 5;
            _waves.Width             = _currentWave.Width;
            _waves.Height            = 150;
            _waves.TextColor         = Color.LightGray;
            _waves.Parent            = _wavePage;
            _waves.ItemIndexChanged += _waves_ItemIndexChanged;
            #endregion

            #region Events
            _addCreepsButton.Click  += AddCreepsButton_Click;
            _addWaveButton.Click    += AddWaveButton_Click;
            _deleteWaveButton.Click += DeleteWaveButton_Click;
            #endregion
            #endregion

            #region SavePage
            _savePage      = _tabControl.AddPage();
            _savePage.Text = "Speichern & Laden";
            _path          = new TextBox(_manager);
            _path.Init();
            _path.Top      = 2;
            _path.Left     = 2;
            _path.Width    = 200;
            _path.Parent   = _savePage;
            _path.ReadOnly = true;

            _fileNameButton = new Button(_manager);
            _fileNameButton.Init();
            _fileNameButton.Text   = "...";
            _fileNameButton.Width  = 17;
            _fileNameButton.Height = _fileNameButton.Width;
            _fileNameButton.Top    = _path.Top + _path.Height / 2 - _fileNameButton.Height / 2;
            _fileNameButton.Left   = _path.Left + _path.Width + 2;
            _fileNameButton.Parent = _savePage;
            _fileNameButton.Click += delegate {
                var dlg = new SaveFileDialog {
                    Filter           = "Level-Dateien|*.xml",
                    InitialDirectory =
                        Path.GetFullPath(
                            Path.GetDirectoryName(
                                Assembly.GetExecutingAssembly().Location) +
                            @"\..\Content\Map")
                };
                dlg.ShowDialog();
                _path.Text = dlg.FileName;
            };

            _saveButton = new Button(_manager);
            _saveButton.Init();
            _saveButton.Top    = _path.Top + _path.Height + 2;
            _saveButton.Left   = 2;
            _saveButton.Text   = "Speichern";
            _saveButton.Width  = 120;
            _saveButton.Parent = _savePage;
            _saveButton.Click += delegate {
                if (_path.Text.Length > 0)
                {
                    string fileName = _path.Text;
                    Save(fileName);
                }
            };

            LoadButton = new Button(_manager);
            LoadButton.Init();
            LoadButton.Left   = 2;
            LoadButton.Top    = 50;
            LoadButton.Text   = "Laden";
            LoadButton.Width  = 120;
            LoadButton.Parent = _savePage;
            LoadButton.Click += LoadButton_Click;
            #endregion
            _manager.Add(_tabControl);
        }
		////////////////////////////////////////////////////////////////////////////     

		////////////////////////////////////////////////////////////////////////////     
		public virtual TabPage AddPage()
		{
			TabPage page = new TabPage(Manager);
			page.Init();
			page.Left = 0;
			page.Top = 0;
			page.Width = ClientWidth;
			page.Height = ClientHeight;
			page.Anchor = Anchors.All;
			page.Text = "Tab " + (tabPages.Count + 1).ToString();
			page.Visible = false;
			Add(page, true);
			tabPages.Add(page);
			tabPages[0].Visible = true;

			return page;
		}
Example #6
0
        private void CreateContentArea(String[] worldNames)
        {
            CreateTabs();
            _playerCount = 0;
            _gameInfoTab = _tabs.AddPage();
            CreateGameRules(_gameInfoTab, worldNames);
            CreatePlayers();

            SwitchToTab(0);
        }
Example #7
0
        private void PopulatePlayerPage(TabPage tabPage, int playerPosition)
        {
            var playerInfo = _defaultPlayerInfo[playerPosition];
            tabPage.Name = playerPosition.ToString(CultureInfo.InvariantCulture);
            var playerName = playerInfo.Item1;
            var playerColor = playerInfo.Item2;

            var objectEditor = new ObjectEditor<Player>(ControlManager.Manager, tabPage, spacing: Margin);
            objectEditor.Add(typeof(Color), new ColorEditSystem());
            objectEditor.Add(typeof(Texture2D), new ImageSelectorEditSystem(Constants.DefaultPlayerInfo.AvatarImages, playerPosition));
            objectEditor.CreateInterface();

            var nameControl = objectEditor.GetControl("Name");
            nameControl.TextChanged += (sender, args) => tabPage.Text = (((TextBox)sender).Text);
            nameControl.Text = playerName;

            var colorControl = objectEditor.GetControl("PlayerColor");
            colorControl.Color = playerColor;

            var endLocation = objectEditor.SizeY;
            tabPage.MinimumHeight = endLocation;

            _playerObjectEditors.Add(tabPage, objectEditor);
        }
Example #8
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        public virtual void RemovePage(TabPage page)
        {
            RemovePage(page, true);
        }
Example #9
0
        public void CreateGameRules(TabPage tabPage, String[] worldNames)
        {
            tabPage.Text = "Game rules";
            _gameLoaderEditor = new ObjectEditor<GameInfoLoader>(ControlManager.Manager, tabPage, spacing: Margin);
            _gameLoaderEditor.Add(typeof(WorldLoaderDropDown), new WorldLoaderDropDowner(worldNames));
            _gameLoaderEditor.CreateInterface();

            var gameRuleType = (ComboBox)_gameLoaderEditor.GetControl("GameRuleType");
            gameRuleType.ItemIndexChanged += (sender, args) => {
                var visible = gameRuleType.GetValue() == GameRuleType.Retirement.ToString();
                _gameLoaderEditor.GetControl("AgeCounterTarget").Visible = visible;
                _gameLoaderEditor.GetControl("AgeCounterTargetLabel").Visible = visible;
            };
            _gameLoaderEditor.GetControl("AgeCounterTarget").Text = "100";
        }
Example #10
0
		private void InitializeControls() {
			_manager.Initialize();
			_manager.AutoCreateRenderTarget = true;

			_tabControl = new TabControl(_manager);
			_tabControl.Init();
			_tabControl.Left = 600;
			_tabControl.Top = 0;
			_tabControl.Width = Width;
			_tabControl.Height = Height;
			_tabControl.Show();
			#region WavePage
			_wavePage = _tabControl.AddPage();
			_wavePage.Text = "Waves";

			#region Constructors
			_health = new Label(_manager);
			_health.Init();
			_texture = new Label(_manager);
			_texture.Init();
			_speed = new Label(_manager);
			_speed.Init();
			_number = new Label(_manager);
			_number.Init();

			_waves = new ListBox(_manager);
			_waves.Init();
			_deleteWaveButton = new Button(_manager);
			_deleteWaveButton.Init();
			_addWaveButton = new Button(_manager);
			_addWaveButton.Init();
			_currentWave = new ListBox(_manager);
			_currentWave.Init();
			_addCreepsButton = new Button(_manager);
			_addCreepsButton.Init();
			_numberOfCreeps = new TextBox(_manager);
			_numberOfCreeps.Init();
			_speedOfCreeps = new TextBox(_manager);
			_speedOfCreeps.Init();
			_healthOfCreeps = new TextBox(_manager);
			_healthOfCreeps.Init();
			_creepTexture = new ComboBox(_manager);
			_creepTexture.Init();
			#endregion

			#region Properties
			_texture.Text = "Textur";
			_texture.Top = 2;
			_texture.Left = 2;
			_texture.Parent = _wavePage;
			_wavePage.Add(_texture);

			_creepTexture.Items.AddRange(new[] { "Slyder", "Drone", "Ape", "Paw" });
			_creepTexture.Text = "Slyder";
			_creepTexture.Width = 80;
			_creepTexture.Left = 2;
			_creepTexture.Top = _texture.Top + _texture.Height + 2;
			_creepTexture.TextColor = Color.LightGray;
			_creepTexture.Parent = _wavePage;

			_health.Text = "Gesundheit";
			_health.Top = 2;
			_health.Left = _creepTexture.Left + _creepTexture.Width + 5;
			_health.Parent = _wavePage;

			_healthOfCreeps.Left = _health.Left;
			_healthOfCreeps.Top = _health.Top + _health.Height + 2;
			_healthOfCreeps.Width = _health.Width;
			_healthOfCreeps.TextColor = Color.LightGray;
			_healthOfCreeps.Parent = _wavePage;

			_speed.Text = "Geschwindigkeit";
			_speed.Left = _health.Left + _health.Width + 5;
			_speed.Top = 2;
			_speed.Width = 93;
			_speed.Parent = _wavePage;

			_speedOfCreeps.Left = _speed.Left;
			_speedOfCreeps.Top = _speed.Top + _speed.Height + 2;
			_speedOfCreeps.Width = _speed.Width;
			_speedOfCreeps.TextColor = Color.LightGray;
			_speedOfCreeps.Parent = _wavePage;

			_number.Text = "Anzahl";
			_number.Top = 2;
			_number.Left = _speed.Left + _speed.Width + 5;
			_number.Width = 40;
			_number.Parent = _wavePage;

			_numberOfCreeps.Left = _number.Left;
			_numberOfCreeps.Top = _number.Top + _number.Height + 2;
			_numberOfCreeps.Width = _number.Width;
			_numberOfCreeps.TextColor = Color.LightGray;
			_numberOfCreeps.Parent = _wavePage;

			_addCreepsButton.Text = "Creeps hinzufügen";
			_addCreepsButton.Top = _numberOfCreeps.Top + _numberOfCreeps.Height - _addCreepsButton.Height;
			_addCreepsButton.Left = _numberOfCreeps.Left + _numberOfCreeps.Width + 5;
			_addCreepsButton.Width = 120;
			_addCreepsButton.Parent = _wavePage;

			_currentWave.Left = 2;
			_currentWave.Top = _creepTexture.Top + _creepTexture.Height + 5;
			_currentWave.Width = _addCreepsButton.Left + _addCreepsButton.Width;
			_currentWave.Height = 150;
			_currentWave.TextColor = Color.LightGray;
			_currentWave.Parent = _wavePage;

			_addWaveButton.Text = "Wave hinzufügen";
			_addWaveButton.Left = 2;
			_addWaveButton.Top = _currentWave.Top + _currentWave.Height + 5;
			_addWaveButton.Width = 150;
			_addWaveButton.Parent = _wavePage;

			_deleteWaveButton.Text = "Wave löschen";
			_deleteWaveButton.Left = _addWaveButton.Left + _addWaveButton.Width + 5;
			_deleteWaveButton.Top = _currentWave.Top + _currentWave.Height + 5;
			_deleteWaveButton.Width = _addWaveButton.Width;
			_deleteWaveButton.Parent = _wavePage;

			_waves.Left = 2;
			_waves.Top = _addWaveButton.Top + _addWaveButton.Height + 5;
			_waves.Width = _currentWave.Width;
			_waves.Height = 150;
			_waves.TextColor = Color.LightGray;
			_waves.Parent = _wavePage;
			_waves.ItemIndexChanged += _waves_ItemIndexChanged;
			#endregion

			#region Events
			_addCreepsButton.Click += AddCreepsButton_Click;
			_addWaveButton.Click += AddWaveButton_Click;
			_deleteWaveButton.Click += DeleteWaveButton_Click;
			#endregion
			#endregion

			#region SavePage
			_savePage = _tabControl.AddPage();
			_savePage.Text = "Speichern & Laden";
			_path = new TextBox(_manager);
			_path.Init();
			_path.Top = 2;
			_path.Left = 2;
			_path.Width = 200;
			_path.Parent = _savePage;
			_path.ReadOnly = true;

			_fileNameButton = new Button(_manager);
			_fileNameButton.Init();
			_fileNameButton.Text = "...";
			_fileNameButton.Width = 17;
			_fileNameButton.Height = _fileNameButton.Width;
			_fileNameButton.Top = _path.Top + _path.Height / 2 - _fileNameButton.Height / 2;
			_fileNameButton.Left = _path.Left + _path.Width + 2;
			_fileNameButton.Parent = _savePage;
			_fileNameButton.Click += delegate {
											var dlg = new SaveFileDialog {
												Filter = "Level-Dateien|*.xml",
												InitialDirectory =
													Path.GetFullPath(
													Path.GetDirectoryName(
														Assembly.GetExecutingAssembly().Location) +
													@"\..\Content\Map")
											};
											dlg.ShowDialog();
											_path.Text = dlg.FileName;
										};

			_saveButton = new Button(_manager);
			_saveButton.Init();
			_saveButton.Top = _path.Top + _path.Height + 2;
			_saveButton.Left = 2;
			_saveButton.Text = "Speichern";
			_saveButton.Width = 120;
			_saveButton.Parent = _savePage;
			_saveButton.Click += delegate {
										if (_path.Text.Length > 0) {
											string fileName = _path.Text;
											Save(fileName);
										}
									};

			LoadButton = new Button(_manager);
			LoadButton.Init();
			LoadButton.Left = 2;
			LoadButton.Top = 50;
			LoadButton.Text = "Laden";
			LoadButton.Width = 120;
			LoadButton.Parent = _savePage;
			LoadButton.Click += LoadButton_Click;
			#endregion
			_manager.Add(_tabControl);
		}
Example #11
0
        public override void Initialize()
        {
            base.Initialize();

            int top = padding;
            const int buttonWidth = 200;
            const int buttonHeight = 50;

            playerObjectEditors = new ObjectEditor<Player>[maxPlayers];

            tabs = new TabControl(ControlManager.Manager);
            tabs.Init();

            tabs.SetPosition(300, 50);

            int width = (int)(ScreenWidth * 0.75f);
            int height = (int)(ScreenHeight * 0.75f);

            tabs.MinimumHeight = height;
            tabs.MinimumWidth = width;

            var playGame = new Button(ControlManager.Manager) { Text = "Play Game", Left = padding, Top = padding, Width = buttonWidth, Height = buttonHeight};
            playGame.Init();
            playGame.Click += (sender, args) => StartGame();

            top += playGame.Height + padding;

            var addPlayer = new Button(ControlManager.Manager) { Text = "Add Player", Left = padding, Top = top, Width = buttonWidth, Height = buttonHeight };
            addPlayer.Init();
            addPlayer.Click += (sender, args) => AddPlayer();

            top += addPlayer.Height+padding;

            var removePlayer = new Button(ControlManager.Manager) { Text = "Remove Player", Left = padding, Top = top, Width = buttonWidth, Height = buttonHeight };
            removePlayer.Init();
            removePlayer.Click += (sender, args) => RemovePlayer();

            top += addPlayer.Height + padding;

            var backButton = new Button(ControlManager.Manager) { Text = "Main Menu", Left = padding, Top = top, Width = buttonWidth, Height = buttonHeight };
            backButton.Init();
            backButton.Click += (sender, args) => ScreenManager.SwapScreens(this, Constants.ScreenNames.MainMenu);

            ControlManager.Add(tabs);
            ControlManager.Add(addPlayer);
            ControlManager.Add(removePlayer);
            ControlManager.Add(playGame);
            ControlManager.Add(backButton);

            gameInfoTab = tabs.AddPage();
            PopulateGameInfo(gameInfoTab);

            for (var i = 0; i < minPlayers; i++) {
                AddPlayer();
            }
            SwitchToTab(0);
        }
Example #12
0
        private void PopulatePlayerPage(TabPage tabPage)
        {
            const string playerName = "Unknown Player";
            tabPage.Text = playerName;
            var objectEditor = playerObjectEditors[playerCount - 1] = new ObjectEditor<Player>(ControlManager.Manager, tabPage, saveButton: false, spacing: Margin);
            objectEditor.CreateInterface(typeof(Player));

            var nameControl = objectEditor.GetControl("Name");
            nameControl.TextChanged += (sender, args) => tabPage.Text = (((TextBox)sender).Text);
            nameControl.Text = playerName;

            var cashControl = objectEditor.GetControl("Cash");
            cashControl.Enabled = false;
            cashControl.Text = Constants.GameRules.StartingCash.ToString(CultureInfo.InvariantCulture);

            // Add any additional controls!
            var endLocation = objectEditor.SizeY;
            var buttonTest = new Button(ControlManager.Manager) { Text = "Moar controls!", Top = endLocation, Left = Margin, Width = 200 };
            buttonTest.Init();
            tabPage.Add(buttonTest);
            endLocation += buttonTest.Height + Margin;

            tabPage.MinimumHeight = endLocation;
        }
Example #13
0
        public void PopulateGameInfo(TabPage tabPage)
        {
            /*tabPage.Text = "Game Info";

            var gameType = GuiHelpers.AddComboBox(ControlManager.Manager, tabPage, "Select Game Type", "gameType", new string[] { "Passport Stamps", "Age Counter" }, 50, 200, 30, 130);

            var ageTextBox = GuiHelpers.AddInputRow(ControlManager.Manager, tabPage, "Age Limit", "AgeLimit", 100, 200, 30, -1);

            gameType.ItemIndexChanged += (sender, args) => ChangeGameType(ageTextBox, gameType.ItemIndex);

            string[] temp = { "Default", "Custom" };
            var worldSelection = GuiHelpers.AddComboBox(ControlManager.Manager, tabPage, "Select World", "SelectWorld", temp, 150, 200, 30, 130);*/
            var Padding = 20;
            var imageSelector = new ImageSelector(ControlManager.Manager, "1", "2", "3", "4", "5", "6", "7", "8", "9", "10") { Width = Convert.ToInt16(tabPage.Width / 1.5f),
                                                                                Height = tabPage.Height / 2 - Padding, Parent = tabPage, Left = 200, Top = 200, AutoScroll = true };
             imageSelector.Initialise();
        }
Example #14
0
        private void InitializeControls()
        {
            manager = new Manager(CurrGame, CurrGame.Graphics, "Green") { SkinDirectory = CurrGame.ApplicationDirectory + @"\Content\GUI\Skin\" };
            try
            {
                manager.Initialize();
            }
            catch (Exception)
            {
                throw;
            }

            manager.AutoCreateRenderTarget = true;

            Console = new Console(manager);
            Console.Init();
            LoadConsoleCommands();
            manager.Add(Console);
            Console.ChannelsVisible = false;
            Console.MessageSent += Console_MessageSent;
            Console.MessageFormat = ConsoleMessageFormats.None;
            Console.Width = manager.ScreenWidth;
            Console.Channels.Add(new ConsoleChannel(0, "[System]", Color.Orange));
            Console.Channels.Add(new ConsoleChannel(1, "[User]", Color.White));
            Console.Channels.Add(new ConsoleChannel(2, "[Error]", Color.DarkRed));
            Console.SelectedChannel = 1;
            Console.Hide();

            tabControl = new TabControl(manager);
            tabControl.Init();
            tabControl.Left = CurrGame.CreepFieldWidth;
            tabControl.Top = 0;
            tabControl.Width = CurrGame.Width - CurrGame.CreepFieldWidth;
            tabControl.Height = CurrGame.Height;

            #region Gameplaypage

            GameplayPage = tabControl.AddPage();
            GameplayPage.Init();
            GameplayPage.Text = "Spiel";

            #region Turmauswahl

            var thumbnailBox = new GroupBox(manager);
            thumbnailBox.Init();
            thumbnailBox.Parent = GameplayPage;
            thumbnailBox.Left = 2;
            thumbnailBox.Top = 2;
            thumbnailBox.Width = thumbnailBox.Parent.Width - 4;
            thumbnailBox.Height = 100;

            int counter = 0;
            foreach (TowerClass towerClass in GamePlayScreen.TowerManager.TowerClassList)
            {
                var towerButton = new ImageButton(manager)
                                      {
                                          Image = GamePlayScreen.TowerManager.GetThumbnail(towerClass.TowerKey),
                                          SizeMode = SizeMode.Stretched,
                                          Top = 14,
                                          Tag = towerClass
                                      };
                towerButton.Width = towerButton.Height = 60;
                towerButton.Left = 6 + counter * (towerButton.Width + 5);
                towerButton.Click += towerButton_Click;
                towerButton.MouseOver += towerButton_MouseOver;
                towerButton.MouseOut += towerButton_MouseOut;
                towerButton.Init();
                thumbnailBox.Add(towerButton);
                BuyTowerButtons.Add(towerButton);
                counter++;
            }

            thumbnailBox.AutoScroll = true;

            var scrollBar = new ScrollBar(manager, Orientation.Horizontal);
            scrollBar.Init();
            thumbnailBox.Add(scrollBar);
            scrollBar.Visible = false;

            #endregion

            #region Informationen

            var infoBox = new GroupBox(manager);
            infoBox.Init();
            infoBox.Parent = GameplayPage;
            infoBox.Text = "Informationen";
            infoBox.Width = infoBox.Parent.Width - 4;
            infoBox.Height = 110;
            infoBox.Left = 2;
            infoBox.Top = thumbnailBox.Top + thumbnailBox.Height + 2;

            CreepNumber = new Label(manager);
            CreepNumber.Init();
            CreepNumber.Parent = infoBox;
            CreepNumber.Top = 14;
            CreepNumber.Left = 4;
            CreepNumber.Width = CreepNumber.Parent.Width - 4;
            CreepNumber.ToolTip = new ToolTip(manager) { Text = "So viele Creeps sind momentan\nauf dem Spielfeld" };
            CreepNumber.Passive = false;

            CreepHealth = new Label(manager);
            CreepHealth.Init();
            CreepHealth.Parent = infoBox;
            CreepHealth.Top = CreepNumber.Top + CreepNumber.Height + 2;
            CreepHealth.Left = CreepNumber.Left;
            CreepHealth.Width = CreepHealth.Parent.Width - 4;
            CreepHealth.ToolTip = new ToolTip(manager) { Text = "Die Gesamtenergie aller auf dem\nSpielfeld befindlicher Creeps" };
            CreepHealth.Passive = false;

            Money = new Label(manager);
            Money.Init();
            Money.Parent = infoBox;
            Money.Top = CreepHealth.Top + CreepHealth.Height + 2;
            Money.Left = CreepNumber.Left;
            Money.Width = Money.Parent.Width - 4;
            Money.ToolTip = new ToolTip(manager) { Text = "So viel Geld besitzt der Spieler" };
            Money.Passive = false;

            OwnHealth = new Label(manager);
            OwnHealth.Init();
            OwnHealth.Parent = infoBox;
            OwnHealth.Top = Money.Top + Money.Height + 2;
            OwnHealth.Left = CreepNumber.Left;
            OwnHealth.Width = OwnHealth.Parent.Width - 4;
            OwnHealth.ToolTip = new ToolTip(manager) { Text = "So viel Energie hat der Spieler noch" };
            OwnHealth.Passive = false;

            Points = new Label(manager);
            Points.Init();
            Points.Parent = infoBox;
            Points.Top = OwnHealth.Top + OwnHealth.Height + 2;
            Points.Left = CreepNumber.Left;
            Points.Width = Points.Parent.Width - 4;
            Points.ToolTip = new ToolTip(manager) { Text = "So viele Punkte hat der Spieler schon.\nDie Punkte setzen sich aus Energie\nund Geschwindigkeit der Creeps zusammen.\nJe näher ein Gegner am Ziel ist, desto mehr\nPunkte gibt er." };
            Points.Passive = false;

            #endregion

            #region Waves

            var waveBox = new GroupBox(manager);
            waveBox.Init();
            waveBox.Parent = GameplayPage;
            waveBox.Text = "Waves";
            waveBox.Left = 2;
            waveBox.Top = infoBox.Top + infoBox.Height + 2;
            waveBox.Width = waveBox.Parent.Width - 4;
            waveBox.Height = 137;

            WaveNumber = new Label(manager);
            WaveNumber.Init();
            WaveNumber.Parent = waveBox;
            WaveNumber.Top = 14;
            WaveNumber.Left = 4;
            WaveNumber.Width = WaveNumber.Parent.Width - 4;

            RealWaveNumber = new Label(manager);
            RealWaveNumber.Init();
            RealWaveNumber.Parent = waveBox;
            RealWaveNumber.Top = WaveNumber.Top + WaveNumber.Height + 2;
            RealWaveNumber.Left = WaveNumber.Left;
            RealWaveNumber.Width = RealWaveNumber.Parent.Width - 4;

            CreepsLeft = new Label(manager);
            CreepsLeft.Init();
            CreepsLeft.Parent = waveBox;
            CreepsLeft.Top = RealWaveNumber.Top + RealWaveNumber.Height + 2;
            CreepsLeft.Left = WaveNumber.Left;
            CreepsLeft.Width = CreepsLeft.Parent.Width - 4;
            CreepsLeft.Passive = false;
            CreepsLeft.ToolTip = new ToolTip(manager) { Text = "So viele Creeps werden noch im Level erscheinen,\nbevor die Aktuelle Welle vorbei ist." };

            CreepHealthLevel = new Label(manager);
            CreepHealthLevel.Init();
            CreepHealthLevel.Parent = waveBox;
            CreepHealthLevel.Top = CreepsLeft.Top + CreepsLeft.Height + 2;
            CreepHealthLevel.Left = WaveNumber.Left;
            CreepHealthLevel.Width = CreepHealthLevel.Parent.Width - 4;
            CreepHealthLevel.Passive = false;
            CreepHealthLevel.ToolTip = new ToolTip(manager) { Text = "Wenn alle Waves eines Levels fertig sind, werden die Waves von Anfang anwiederholt.\nAllerdings steigt die Energie der Creeps dabei.\nDas Gesundheitsniveau liegt dieser Energie zugrunde." };

            TimeLeftNextWave = new Label(manager);
            TimeLeftNextWave.Init();
            TimeLeftNextWave.Parent = waveBox;
            TimeLeftNextWave.Top = CreepHealthLevel.Top + CreepHealthLevel.Height + 2;
            TimeLeftNextWave.Left = WaveNumber.Left;
            TimeLeftNextWave.Width = TimeLeftNextWave.Parent.Width - 4;

            var nextWaveButton = new Button(manager);
            nextWaveButton.Init();
            nextWaveButton.Parent = waveBox;
            nextWaveButton.Text = "Nächste Welle";
            nextWaveButton.Left = 2;
            nextWaveButton.Top = TimeLeftNextWave.Top + TimeLeftNextWave.Height + 2;
            nextWaveButton.Width = nextWaveButton.Parent.Width - 4;
            nextWaveButton.Click += delegate { GamePlayScreen.StartNextWave(); };

            #endregion

            #region Spielsteuerung

            var gameBox = new GroupBox(manager);
            gameBox.Init();
            gameBox.Text = "Spielsteuerung";
            gameBox.Parent = GameplayPage;
            gameBox.Width = gameBox.Parent.Width - 4;
            gameBox.Height = 200;
            gameBox.Left = 2;
            gameBox.Top = waveBox.Top + waveBox.Height + 2;

            var playButton = new ImageButton(manager)
                                 {
                                     Image =
                                         CurrGame.Content.Load<Texture2D>(CurrGame.ApplicationDirectory + "\\Content\\GUI\\play"),
                                     SizeMode = SizeMode.Stretched,
                                     Top = 14,
                                     Left = 2,
                                     Width = 50
                                 };
            playButton.Height = playButton.Width;
            playButton.Click += ((sender, e) => GamePlayScreen.StartGame());
            playButton.Init();

            var pauseButton = new ImageButton(manager)
                                  {
                                      Image =
                                          CurrGame.Content.Load<Texture2D>(CurrGame.ApplicationDirectory +
                                                                           "\\Content\\GUI\\pause"),
                                      SizeMode = SizeMode.Stretched,
                                      Top = 14,
                                      Left = playButton.Left + playButton.Width + 4
                                  };
            pauseButton.Width = pauseButton.Height = playButton.Width;
            pauseButton.Click += ((sender, e) => GamePlayScreen.StopGame());
            pauseButton.Init();

            gameBox.Add(playButton);
            gameBox.Add(pauseButton);

            #endregion

            RefreshGameInformation();

            #endregion

            #region Optionspage

            OptionsPage = tabControl.AddPage();
            OptionsPage.Text = "Optionen";

            #endregion

            #region SaveLoadPage

            #endregion

            manager.Add(tabControl);
        }