/// <summary>
        /// Show player's selected units stat and activate command for the units
        /// </summary>
        /// <param name="holder"></param>
        /// <param name="e"></param>
        private void showUnitStatAndCommand(SameSizeChildrenFlowLayout holder, SelectionStateChangedArgs e, BuildLargePreviewPictureBoxVisitor visitor)
        {
            int count = e.SelectedEntities.Count;

            // Only non-zombie stat being displayed
            if (!((UnitComponent)e.SelectedEntities[0]).IsZombie)
            {
                // Individual unit
                if (count == 1 && holder != null)
                {
                    // Use the holder to show unit stats.
                    DisplaySelectedEntityStatsVisitor visitor2 = new DisplaySelectedEntityStatsVisitor();
                    visitor2.Game   = (XnaUITestGame)Game;
                    visitor2.Layout = holder;
                    e.SelectedEntities[0].Accept(visitor2);
                }

                e.SelectedEntities[0].Accept(visitor);
                PictureBox bigImage = visitor.PictureBox;

                bigImage.DrawBox = new Rectangle(25, 25, 150, 150);
                AddChild(bigImage);

                bool containsNonBuilders = true;
                for (int i = 0; i < e.SelectedEntities.Count; i++)
                {
                    if (!((UnitComponent)e.SelectedEntities[0]).CanBuild)
                    {
                        containsNonBuilders = false;
                        break;
                    }
                }
                commandBar.activateButtons(containsNonBuilders);  // show commandView if selected
            } // only non zombie
        }
        /// <summary>
        /// Update and refresh holder every time multiple new units are selected
        /// </summary>
        /// <param name="holder"></param>
        /// <param name="e"></param>
        private void updateHolder(SameSizeChildrenFlowLayout holder, SelectionStateChangedArgs e)
        {
            int count = e.SelectedEntities.Count;

            if (holder != null)
            {
                holder.Clear();
                if (count > 1)
                {
                    holder.Visible = true;
                    foreach (ModelComponent component in e.SelectedEntities)
                    {
                        BuildSelectedEntityUIVisitor visitor = new BuildSelectedEntityUIVisitor();
                        if (component is UnitComponent)
                        {
                            UnitComponent temp = (UnitComponent)component;

                            component.Accept(visitor);
                            if (visitor.UI != null)
                            {
                                holder.AddChild(visitor.UI);
                            }
                        }
                    } //for
                }     //if
            }         //if
        }
예제 #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="game">game object</param>
 /// <param name="sourceRect">Location on the user interface menu</param>
 /// <param name="text">String/text</param>
 public ProduceUnitButton(Game game, Rectangle sourceRect, string text) : base(game, sourceRect)
 {
     layout                  = new SameSizeChildrenFlowLayout(game);
     unitTypeTextBox         = new TextBox(game, text, "left", Color.Red);
     unitTypeTextBox.DrawBox = new Rectangle(0, 0, 76, 20);
     AddChild(unitTypeTextBox);
     this.OnClick += new ClickEventHandler(handleClick);
 }
        /// <summary>
        /// Event handler when selection of units has changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void onSelectionChanged(Object sender, SelectionStateChangedArgs e)
        {
            int count = e.SelectedEntities.Count;
            SameSizeChildrenFlowLayout holder = getSelectedEntityUIHolder();

            updateHolder(holder, e);               // Update the holder
            flushStatPanel();                      // Clear all stat panels
            updateStatAndCommandPanels(holder, e); // Update panel and activate new command menu
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="game">game object</param>
 /// <param name="sourceRect">Location on the user interface menu</param>
 /// <param name="text">String/text</param>
 public ProduceUnitButton(Game game, Rectangle sourceRect, string text)
     : base(game, sourceRect)
 {
     layout = new SameSizeChildrenFlowLayout(game);
     unitTypeTextBox = new TextBox(game, text, "left", Color.Red);
     unitTypeTextBox.DrawBox = new Rectangle(0, 0, 76, 20);
     AddChild(unitTypeTextBox);
     this.OnClick += new ClickEventHandler(handleClick);
 }
        private SameSizeChildrenFlowLayout getSelectedEntityUIHolder()
        {
            SameSizeChildrenFlowLayout holder = null;

            foreach (XnaUIComponent component in GetChildren())
            {
                if (component is SameSizeChildrenFlowLayout)
                {
                    holder = (SameSizeChildrenFlowLayout)component;
                    break;
                }
            }
            return(holder);
        }
예제 #7
0
        /// <summary>
        /// Update Stat panel and activate command panel for selected units
        /// </summary>
        /// <param name="holder"></param>
        /// <param name="e"></param>
        private void updateStatAndCommandPanels(SameSizeChildrenFlowLayout holder, SelectionStateChangedArgs e)
        {
            int count = e.SelectedEntities.Count;

            if (count > 0)
            {
                BuildLargePreviewPictureBoxVisitor visitor = new BuildLargePreviewPictureBoxVisitor();

                if (e.SelectedEntities[0] is UnitComponent)
                {
                    showUnitStatAndCommand(holder, e, visitor);
                } // unit
                else if (e.SelectedEntities[0] is Building)
                {
                    Building y = (Building)e.SelectedEntities[0];
                    commandBar.activateProduceUnitButtons(y.Type);
                }
            }
            else
            {
                commandBar.disableButtons();
            }
        }
        /// <summary>
        /// Setup View for the gameplay
        /// </summary>
        private void SetupView()
        {
            view = new XnaUIFrame(this);
            view.DrawBox = new Rectangle(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
            MapView mainView = new MapView(this);
            mainView.DrawBox = new Rectangle(0, 0, 1280, 720);

            SelectionState selectionState = model.GetSelectionState();
            SelectionView selectionView = new SelectionView(this, selectionState);
            selectionView.DrawBox = new Rectangle(275, 520, 730, 200);
            SameSizeChildrenFlowLayout selectedEntityUIHolder = new SameSizeChildrenFlowLayout(this);
            selectedEntityUIHolder.DrawBox = new Rectangle(215, 25, 450, 150);
            selectionView.AddChild(selectedEntityUIHolder);

            CommandView commandView = new CommandView(this);
            commandView.DrawBox = new Rectangle(1005, 445, 275, 275);
            SameSizeChildrenFlowLayout commandViewButtonBox = new SameSizeChildrenFlowLayout(this);
            selectionView.commandBar = commandView; // Register commandView to selection View

            view.AddChild(mainView);
            view.AddChild(selectionView);
            view.AddChild(commandView);
        }
예제 #9
0
        public CommandView(Game game)
            : base(game)
        {
            this.DrawBox = new Rectangle(0, 0, 275, 275);


            // Background Panel
            backgroundPanel         = new PictureBox(game, new Rectangle(GameConfig.BUILDPANEL_START_X, GameConfig.BUILDING_START_Y, 275, 275));
            backgroundPanel.DrawBox = new Rectangle(0, 0, 275, 275);
            AddChild(backgroundPanel);

            // buildPanel
            buildPanel                = new SameSizeChildrenFlowLayout(game);
            buildPanel.Visible        = false;
            buildPanel.DrawBox        = new Rectangle(10, 10, 255, 255);
            buildPanel.SpacingBetween = 7;
            AddChild(buildPanel);

            // mainPanel
            mainPanel                = new SameSizeChildrenFlowLayout(game);
            mainPanel.DrawBox        = new Rectangle(10, 10, 255, 255);
            mainPanel.SpacingBetween = 7;
            AddChild(mainPanel);

            // WorkerPanel
            workerPanel                = new SameSizeChildrenFlowLayout(game);
            workerPanel.DrawBox        = new Rectangle(10, 10, 255, 255);
            workerPanel.SpacingBetween = 7;
            AddChild(workerPanel);


            // Barrack building commandPanel
            barracksPanel                = new SameSizeChildrenFlowLayout(game);
            barracksPanel.DrawBox        = new Rectangle(10, 10, 255, 255);
            barracksPanel.Visible        = false;
            barracksPanel.SpacingBetween = 7;
            AddChild(barracksPanel);

            // HouseBuilding commandPanel
            housePanel                = new SameSizeChildrenFlowLayout(game);
            housePanel.DrawBox        = new Rectangle(10, 10, 255, 255);
            housePanel.SpacingBetween = 7;
            housePanel.Visible        = false;
            AddChild(housePanel);



            ZRTSCompositeViewUIFactory factory = ZRTSCompositeViewUIFactory.Instance;

            moveButton               = factory.BuildPictureBox("button", "move");
            moveButton.DrawBox       = new Rectangle(0, 0, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            moveButton.OnClick      += handleMoveButtonClick;
            moveButton.OnMouseEnter += handleMoveButtonOver;
            moveButton.OnMouseLeave += handleMoveButtonAway;
            moveButton.OnMouseDown  += handleMoveButtonDown;
            moveButton.OnMouseUp    += handleMoveButtonUp;
            workerPanel.AddChild(moveButton);

            mainMoveButton               = factory.BuildPictureBox("button", "move");
            mainMoveButton.DrawBox       = new Rectangle(0, 0, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            mainMoveButton.OnClick      += handleMoveButtonClick;
            mainMoveButton.OnMouseEnter += handleMoveButtonOver;
            mainMoveButton.OnMouseLeave += handleMoveButtonAway;
            mainMoveButton.OnMouseDown  += handleMoveButtonDown;
            mainMoveButton.OnMouseUp    += handleMoveButtonUp;
            mainPanel.AddChild(mainMoveButton);

            stopButton               = factory.BuildPictureBox("button", "stop");
            stopButton.DrawBox       = new Rectangle(0, 0, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            stopButton.OnClick      += handleStopButtonClick;
            stopButton.OnMouseEnter += handleStopButtonOver;
            stopButton.OnMouseLeave += handleStopButtonAway;
            stopButton.OnMouseDown  += handleStopButtonDown;
            stopButton.OnMouseUp    += handleStopButtonUp;
            workerPanel.AddChild(stopButton);

            mainStopButton               = factory.BuildPictureBox("button", "stop");
            mainStopButton.DrawBox       = new Rectangle(0, 0, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            mainStopButton.OnClick      += handleStopButtonClick;
            mainStopButton.OnMouseEnter += handleStopButtonOver;
            mainStopButton.OnMouseLeave += handleStopButtonAway;
            mainStopButton.OnMouseDown  += handleStopButtonDown;
            mainStopButton.OnMouseUp    += handleStopButtonUp;
            mainPanel.AddChild(mainStopButton);

            buildButton               = factory.BuildPictureBox("button", "build");
            buildButton.DrawBox       = new Rectangle(GameConfig.BUTTON_BUILD * GameConfig.BUTTON_DIM, GameConfig.BUTTON_START_Y_SECOND, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            buildButton.OnClick      += handleBuildButtonClick;
            buildButton.OnMouseEnter += handleBuildButtonOver;
            buildButton.OnMouseLeave += handleBuildButtonAway;
            buildButton.OnMouseDown  += handleBuildButtonDown;
            buildButton.OnMouseUp    += handleBuildButtonUp;
            workerPanel.AddChild(buildButton);

            attackButton               = factory.BuildPictureBox("button", "attack");
            attackButton.DrawBox       = new Rectangle(GameConfig.BUTTON_ATTACK * GameConfig.BUTTON_DIM, GameConfig.BUTTON_START_Y, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            attackButton.OnClick      += handleAttackButtonClick;
            attackButton.OnMouseEnter += handleAttackButtonOver;
            attackButton.OnMouseLeave += handleAttackButtonAway;
            attackButton.OnMouseDown  += handleAttackButtonDown;
            attackButton.OnMouseUp    += handleAttackButtonUp;
            workerPanel.AddChild(attackButton);

            harvestButton               = factory.BuildPictureBox("button", "harvest");
            harvestButton.DrawBox       = new Rectangle(GameConfig.BUTTON_ATTACK * GameConfig.BUTTON_DIM, GameConfig.BUTTON_START_Y, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            harvestButton.OnClick      += handleHarvestButtonClick;
            harvestButton.OnMouseEnter += handleharvestButtonOver;
            harvestButton.OnMouseLeave += handleharvestButtonAway;
            harvestButton.OnMouseDown  += handleharvestButtonDown;
            harvestButton.OnMouseUp    += handleharvestButtonUp;
            workerPanel.AddChild(harvestButton);

            mainAttackButton               = factory.BuildPictureBox("button", "attack");
            mainAttackButton.DrawBox       = new Rectangle(GameConfig.BUTTON_ATTACK * GameConfig.BUTTON_DIM, GameConfig.BUTTON_START_Y, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            mainAttackButton.OnClick      += handleAttackButtonClick;
            mainAttackButton.OnMouseEnter += handleAttackButtonOver;
            mainAttackButton.OnMouseLeave += handleAttackButtonAway;
            mainAttackButton.OnMouseDown  += handleAttackButtonDown;
            mainAttackButton.OnMouseUp    += handleAttackButtonUp;
            mainPanel.AddChild(mainAttackButton);

            mainPanel.Visible   = false;
            workerPanel.Visible = false;

            // Individual building buttons in the build panel

            List <String> buildingKeys = BuildingFactory.Instance.getBuildingTypes();

            foreach (String key in buildingKeys)
            {
                PictureBox buildingButton = factory.BuildPictureBox("building", key);
                buildingButton.OnClick += handleBuildingButtonClick;
                buildingButton.DrawBox  = new Rectangle(0, 0, 85, 85);
                buildPanel.AddChild(buildingButton);
                uiToBuildingType.Add(buildingButton, key);
            }

            // Get unit's information
            List <String> unitKeys = UnitFactory.Instance.getPrefixes();

            foreach (String key in buildingKeys)
            {
                PictureBox unitButton = null;
                if (key.Equals("barracks"))
                {
                    unitButton          = factory.BuildPictureBox("unitBuild", "soldier");
                    unitButton.OnClick += handleUnitProduceButtonClick;
                    unitButton.DrawBox  = new Rectangle(0, 0, 85, 85);
                    barracksPanel.AddChild(unitButton);
                }
                else if (key.Equals("house"))
                {
                    unitButton          = factory.BuildPictureBox("unitBuild", "worker");
                    unitButton.OnClick += handleUnitProduceButtonClick;
                    unitButton.DrawBox  = new Rectangle(0, 0, 85, 85);
                    housePanel.AddChild(unitButton);
                }

                uiToBuildingType.Add(unitButton, key);
            }


            pixel = new Texture2D(game.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            pixel.SetData(new[] { Color.White });
            color = new Color(100, 60, 88);
        }
        /// <summary>
        /// Update Stat panel and activate command panel for selected units
        /// </summary>
        /// <param name="holder"></param>
        /// <param name="e"></param>
        private void updateStatAndCommandPanels(SameSizeChildrenFlowLayout holder, SelectionStateChangedArgs e)
        {
            int count = e.SelectedEntities.Count;
            if (count > 0)
            {
                BuildLargePreviewPictureBoxVisitor visitor = new BuildLargePreviewPictureBoxVisitor();

                if (e.SelectedEntities[0] is UnitComponent)
                {
                    showUnitStatAndCommand(holder, e, visitor);
                } // unit
                else if (e.SelectedEntities[0] is Building)
                {
                    Building y = (Building)e.SelectedEntities[0];
                    commandBar.activateProduceUnitButtons(y.Type);
                }
            }
            else
            {
                commandBar.disableButtons();

            }
        }
        /// <summary>
        /// Update and refresh holder every time multiple new units are selected
        /// </summary>
        /// <param name="holder"></param>
        /// <param name="e"></param>
        private void updateHolder(SameSizeChildrenFlowLayout holder, SelectionStateChangedArgs e)
        {
            int count = e.SelectedEntities.Count;
            if (holder != null)
            {
                holder.Clear();
                if (count > 1)
                {
                    holder.Visible = true;
                    foreach (ModelComponent component in e.SelectedEntities)
                    {
                        BuildSelectedEntityUIVisitor visitor = new BuildSelectedEntityUIVisitor();
                        if (component is UnitComponent)
                        {
                            UnitComponent temp = (UnitComponent)component;

                            component.Accept(visitor);
                            if (visitor.UI != null)
                            {
                                holder.AddChild(visitor.UI);
                            }

                        }
                    }//for
                }//if
            }//if
        }
        /// <summary>
        /// Show player's selected units stat and activate command for the units
        /// </summary>
        /// <param name="holder"></param>
        /// <param name="e"></param>
        private void showUnitStatAndCommand(SameSizeChildrenFlowLayout holder, SelectionStateChangedArgs e, BuildLargePreviewPictureBoxVisitor visitor)
        {
            int count = e.SelectedEntities.Count;
            // Only non-zombie stat being displayed
            if (!((UnitComponent)e.SelectedEntities[0]).IsZombie)
            {
                // Individual unit
                if (count == 1 && holder != null)
                {
                    // Use the holder to show unit stats.
                    DisplaySelectedEntityStatsVisitor visitor2 = new DisplaySelectedEntityStatsVisitor();
                    visitor2.Game = (XnaUITestGame)Game;
                    visitor2.Layout = holder;
                    e.SelectedEntities[0].Accept(visitor2);
                }

                e.SelectedEntities[0].Accept(visitor);
                PictureBox bigImage = visitor.PictureBox;

                bigImage.DrawBox = new Rectangle(25, 25, 150, 150);
                AddChild(bigImage);

                bool containsNonBuilders = true;
                for (int i = 0; i < e.SelectedEntities.Count; i++)
                {
                    if (!((UnitComponent)e.SelectedEntities[0]).CanBuild)
                    {
                        containsNonBuilders = false;
                        break;
                    }
                }
                commandBar.activateButtons(containsNonBuilders);  // show commandView if selected

            } // only non zombie
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="game">game object</param>
        public CommandView(Game game)
            : base(game)
        {
            this.DrawBox = new Rectangle(0, 0, 275, 275);

            // Background Panel
            backgroundPanel = new PictureBox(game, new Rectangle(GameConfig.BUILDPANEL_START_X, GameConfig.BUILDING_START_Y, 275, 275));
            backgroundPanel.DrawBox = new Rectangle(0, 0, 275, 275);
            AddChild(backgroundPanel);

            // buildPanel
            buildPanel = new SameSizeChildrenFlowLayout(game);
            buildPanel.Visible = false;
            buildPanel.DrawBox = new Rectangle(10, 10, 255, 255);
            buildPanel.SpacingBetween = 7;
            AddChild(buildPanel);

            // mainPanel
            mainPanel = new SameSizeChildrenFlowLayout(game);
            mainPanel.DrawBox = new Rectangle(10, 10, 255, 255);
            mainPanel.SpacingBetween = 7;
            AddChild(mainPanel);

            // WorkerPanel
            workerPanel = new SameSizeChildrenFlowLayout(game);
            workerPanel.DrawBox = new Rectangle(10, 10, 255, 255);
            workerPanel.SpacingBetween = 7;
            AddChild(workerPanel);

            // Barrack building commandPanel
            barracksPanel = new SameSizeChildrenFlowLayout(game);
            barracksPanel.DrawBox = new Rectangle(10, 10, 255, 255);
            barracksPanel.Visible = false;
            barracksPanel.SpacingBetween = 7;
            AddChild(barracksPanel);

            // HouseBuilding commandPanel
            housePanel = new SameSizeChildrenFlowLayout(game);
            housePanel.DrawBox = new Rectangle(10, 10, 255, 255);
            housePanel.SpacingBetween = 7;
            housePanel.Visible = false;
            AddChild(housePanel);

            ZRTSCompositeViewUIFactory factory = ZRTSCompositeViewUIFactory.Instance;
            moveButton = factory.BuildPictureBox("button", "move");
            moveButton.DrawBox = new Rectangle(0, 0, GameConfig.BUTTON_DIM , GameConfig.BUTTON_DIM );
            moveButton.OnClick += handleMoveButtonClick;
            moveButton.OnMouseEnter += handleMoveButtonOver;
            moveButton.OnMouseLeave += handleMoveButtonAway;
            moveButton.OnMouseDown += handleMoveButtonDown;
            moveButton.OnMouseUp += handleMoveButtonUp;
            workerPanel.AddChild(moveButton);

            mainMoveButton = factory.BuildPictureBox("button", "move");
            mainMoveButton.DrawBox = new Rectangle(0, 0, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            mainMoveButton.OnClick += handleMoveButtonClick;
            mainMoveButton.OnMouseEnter += handleMoveButtonOver;
            mainMoveButton.OnMouseLeave += handleMoveButtonAway;
            mainMoveButton.OnMouseDown += handleMoveButtonDown;
            mainMoveButton.OnMouseUp += handleMoveButtonUp;
            mainPanel.AddChild(mainMoveButton);

            stopButton = factory.BuildPictureBox("button", "stop");
            stopButton.DrawBox = new Rectangle(0, 0, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            stopButton.OnClick += handleStopButtonClick;
            stopButton.OnMouseEnter += handleStopButtonOver;
            stopButton.OnMouseLeave += handleStopButtonAway;
            stopButton.OnMouseDown += handleStopButtonDown;
            stopButton.OnMouseUp += handleStopButtonUp;
            workerPanel.AddChild(stopButton);

            mainStopButton = factory.BuildPictureBox("button", "stop");
            mainStopButton.DrawBox = new Rectangle(0, 0, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            mainStopButton.OnClick += handleStopButtonClick;
            mainStopButton.OnMouseEnter += handleStopButtonOver;
            mainStopButton.OnMouseLeave += handleStopButtonAway;
            mainStopButton.OnMouseDown += handleStopButtonDown;
            mainStopButton.OnMouseUp += handleStopButtonUp;
            mainPanel.AddChild(mainStopButton);

            buildButton = factory.BuildPictureBox("button", "build");
            buildButton.DrawBox = new Rectangle(GameConfig.BUTTON_BUILD * GameConfig.BUTTON_DIM, GameConfig.BUTTON_START_Y_SECOND, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            buildButton.OnClick += handleBuildButtonClick;
            buildButton.OnMouseEnter += handleBuildButtonOver;
            buildButton.OnMouseLeave += handleBuildButtonAway;
            buildButton.OnMouseDown += handleBuildButtonDown;
            buildButton.OnMouseUp += handleBuildButtonUp;
            workerPanel.AddChild(buildButton);

            attackButton = factory.BuildPictureBox("button", "attack");
            attackButton.DrawBox = new Rectangle(GameConfig.BUTTON_ATTACK * GameConfig.BUTTON_DIM, GameConfig.BUTTON_START_Y, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            attackButton.OnClick += handleAttackButtonClick;
            attackButton.OnMouseEnter += handleAttackButtonOver;
            attackButton.OnMouseLeave += handleAttackButtonAway;
            attackButton.OnMouseDown += handleAttackButtonDown;
            attackButton.OnMouseUp += handleAttackButtonUp;
            workerPanel.AddChild(attackButton);

            harvestButton = factory.BuildPictureBox("button", "harvest");
            harvestButton.DrawBox = new Rectangle(GameConfig.BUTTON_ATTACK * GameConfig.BUTTON_DIM, GameConfig.BUTTON_START_Y, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            harvestButton.OnMouseEnter += handleharvestButtonOver;
            harvestButton.OnMouseLeave += handleharvestButtonAway;
            harvestButton.OnMouseDown += handleharvestButtonDown;
            harvestButton.OnMouseUp += handleharvestButtonUp;
            workerPanel.AddChild(harvestButton);

            mainAttackButton = factory.BuildPictureBox("button", "attack");
            mainAttackButton.DrawBox = new Rectangle(GameConfig.BUTTON_ATTACK * GameConfig.BUTTON_DIM, GameConfig.BUTTON_START_Y, GameConfig.BUTTON_DIM, GameConfig.BUTTON_DIM);
            mainAttackButton.OnClick += handleAttackButtonClick;
            mainAttackButton.OnMouseEnter += handleAttackButtonOver;
            mainAttackButton.OnMouseLeave += handleAttackButtonAway;
            mainAttackButton.OnMouseDown += handleAttackButtonDown;
            mainAttackButton.OnMouseUp += handleAttackButtonUp;
            mainPanel.AddChild(mainAttackButton);

            mainPanel.Visible = false;
            workerPanel.Visible = false;

            // Individual building buttons in the build panel

            List<String> buildingKeys = BuildingFactory.Instance.getBuildingTypes();
            foreach (String key in buildingKeys)
            {
                PictureBox buildingButton = factory.BuildPictureBox("building", key);
                buildingButton.OnClick += handleBuildingButtonClick;
                buildingButton.DrawBox = new Rectangle(0, 0, 85, 85);
                buildPanel.AddChild(buildingButton);
                uiToBuildingType.Add(buildingButton, key);
            }

            // Get unit's information
            List<String> unitKeys = UnitFactory.Instance.getPrefixes();

            foreach (String key in buildingKeys)
            {
                PictureBox unitButton = null;
                if (key.Equals("barracks"))
                {
                    unitButton = factory.BuildPictureBox("unitBuild", "soldier");
                    unitButton.OnClick += handleUnitProduceButtonClick;
                    unitButton.DrawBox = new Rectangle(0, 0, 85, 85);
                    barracksPanel.AddChild(unitButton);
                }
                else if (key.Equals("house"))
                {
                    unitButton = factory.BuildPictureBox("unitBuild", "worker");
                    unitButton.OnClick += handleUnitProduceButtonClick;
                    unitButton.DrawBox = new Rectangle(0, 0, 85, 85);
                    housePanel.AddChild(unitButton);
                }

                uiToBuildingType.Add(unitButton, key);
            }

            pixel = new Texture2D(game.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            pixel.SetData(new[] { Color.White });
            color = new Color(100, 60, 88);
        }