示例#1
0
        public static void updateButtons()
        {
            if (GUIButtons[0].triggered)
            {
                //Buildings Menu Button
                //Resets button
                GUIButtons[0].triggered = false;
                //Makes button invisible
                GUIButtons[0].visible = false;
                //Build menu open bool updated
                buildMenuOpen = true;
                //Makes exit button visible
                GUIButtons[1].visible = true;
                //Makes pause button invisible
                GUIButtons[3].visible = false;
                //Makes repair button invisible
                GUIButtons[8].visible = false;
                //Makes all building buttons visible
                foreach (BuildingButton b in buildingButtons)
                {
                    b.visible = true;
                }
            }

            if (GUIButtons[1].triggered)
            {
                //Buildings Menu EXIT Button
                //Resets button
                GUIButtons[1].triggered = false;
                //Makes button invisible
                GUIButtons[1].visible = false;
                //Build menu open bool updated
                buildMenuOpen = false;
                //Makes menu button visible
                GUIButtons[0].visible = true;
                //Makes pause button visible
                GUIButtons[3].visible = true;
                //Makes repair button visible
                GUIButtons[8].visible = true;
                //Makes all building buttons invisible
                foreach (BuildingButton b in buildingButtons)
                {
                    b.visible = false;
                }
            }

            if (GUIButtons[2].triggered)
            {
                //Next turn button
                Game1.nextTurn();
                GUIButtons[2].triggered = false;
            }

            if (GUIButtons[3].triggered)
            {
                //Makes paused
                paused = true;

                //Makes all menu buttons visible and makes all other buttons invisible
                GUIButtons[0].visible = false;
                GUIButtons[2].visible = false;
                GUIButtons[3].visible = false;
                GUIButtons[4].visible = true;
                GUIButtons[5].visible = true;
                GUIButtons[6].visible = true;
                GUIButtons[7].visible = true;

                GUIButtons[3].triggered = false;
            }

            if (GUIButtons[5].triggered)
            {
                //Plays load function
                SavegameManager.loadGame(0);

                GUIButtons[4].triggered = true;
                GUIButtons[5].triggered = false;
            }

            if (GUIButtons[6].triggered)
            {
                //Plays load function
                SavegameManager.saveGame(0);

                GUIButtons[4].triggered = true;
                GUIButtons[6].triggered = false;
            }

            if (GUIButtons[4].triggered)
            {
                //Unpauses
                paused = false;

                //Makes all menu buttons invisible and makes all other buttons visible
                GUIButtons[0].visible = true;
                GUIButtons[3].visible = true;
                GUIButtons[4].visible = false;
                GUIButtons[5].visible = false;
                GUIButtons[6].visible = false;
                GUIButtons[7].visible = false;
                foreach (Tile b in Tile.tiles)
                {
                    if (b.built)
                    {
                        GUIButtons[2].visible = true;
                    }
                }

                GUIButtons[4].triggered = false;
            }

            if (GUIButtons[8].triggered)
            {
                //Presses or unpresses
                GUIButtons[8].toggled = !GUIButtons[8].toggled;

                repairMode = GUIButtons[8].toggled;

                GUIButtons[8].triggered = false;
            }
        }
示例#2
0
        public static void selectGrid(MouseState state)
        {
            if (state.LeftButton == ButtonState.Pressed)
            {
                if (GUI.buildMenuOpen)
                {
                    if (GUI.buildingButtonSelected != null)
                    {
                        //Building tile
                        foreach (Tile b in Tile.tiles)
                        {
                            if (b.tileRectangle.Contains(state.X, state.Y))
                            {
                                if (!b.built)
                                {
                                    if (Player.gold >= GUI.buildingButtonSelected.building.goldCost - (GUI.buildingButtonSelected.building.goldCost * Buffs.buffs[2]))
                                    {
                                        Player.gold        -= GUI.buildingButtonSelected.building.goldCost - (GUI.buildingButtonSelected.building.goldCost * Buffs.buffs[2]);
                                        Player.goldPerTurn += GUI.buildingButtonSelected.building.goldPerTurn;
                                        b.built             = true;
                                        //Temp Test
                                        b.building = GUI.buildingButtonSelected.building;
                                        b.health   = GUI.buildingButtonSelected.building.health;
                                        GUI.GUIButtons[2].visible = true;

                                        //Checks if black hole
                                        if (GUI.buildingButtonSelected.building.name == "Black Hole")
                                        {
                                            SavegameManager.saveGame(0);
                                            Environment.Exit(0);
                                        }

                                        if (GUI.buildingButtonSelected.building.buff)
                                        {
                                            for (int i = 0; i < GUI.buildingButtonSelected.building.modifier.Count(); i++)
                                            {
                                                if (GUI.buildingButtonSelected.building.modifier[i])
                                                {
                                                    Buffs.buffs[i] += GUI.buildingButtonSelected.building.percentIncrease[i];
                                                }

                                                //Clamps GoldCost
                                                if (i == 2)
                                                {
                                                    Buffs.buffs[i] = Operation.clamp(Buffs.buffs[i], 0F, .9F);
                                                }
                                            }
                                        }

                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    //Check if repair
                    if (GUI.repairMode)
                    {
                        foreach (Tile b in tiles)
                        {
                            if (b.tileRectangle.Contains(state.X, state.Y))
                            {
                                if (b.built)
                                {
                                    int goldCostAmount = (b.building.health - b.health) * Game1.repairCostMultiplier;
                                    if (Player.gold >= goldCostAmount)
                                    {
                                        //Repair
                                        Player.gold -= goldCostAmount;
                                        b.health     = b.building.health;
                                    }

                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }