public MainMenuState() { const int buffer = 50; const int buttonWidth = 300; int leftx = (GameEnvironment.Screen.X - (buttonWidth * 2 + buffer)) / 2; int rightx = leftx + buttonWidth + buffer; SpriteFont defaultFont = GameEnvironment.AssetManager.GetFont("Arial12"); SpriteFont textfieldFont = GameEnvironment.AssetManager.GetFont("Arial26"); singlePlayerButton = new Button("button", "Singleplayer", textfieldFont, Color.Black); singlePlayerButton.Action = () => { GameSetupState gss = GameEnvironment.GameStateManager.GetGameState("gameSetupState") as GameSetupState; gss.InitializeGameMode(GameSetupState.GameMode.Singleplayer); GameEnvironment.GameStateManager.SwitchTo("gameSetupState"); }; singlePlayerButton.Position = new Vector2(leftx, 300); Add(singlePlayerButton); multiPlayerButton = new Button("button", "Multiplayer", textfieldFont, Color.Black); multiPlayerButton.Position = new Vector2(rightx, 300); multiPlayerButton.Action = () => { GameEnvironment.GameStateManager.SwitchTo("multiplayerMenu"); }; Add(multiPlayerButton); helpButton = new Button("button", "Help", textfieldFont, Color.Black); helpButton.Action = () => { GameEnvironment.GameStateManager.SwitchTo("helpMenu"); }; helpButton.Position = new Vector2(leftx, 375); Add(helpButton); optionsButton = new Button("button", "Options", textfieldFont, Color.Black); optionsButton.Action = () => { GameEnvironment.GameStateManager.SwitchTo("optionsMenu"); }; optionsButton.Position = new Vector2(rightx, 375); Add(optionsButton); creditsButton = new Button("button", "Credits", textfieldFont, Color.Black); creditsButton.Action = () => { GameEnvironment.GameStateManager.SwitchTo("creditsMenu"); }; creditsButton.Position = new Vector2(leftx, 450); Add(creditsButton); quitButton = new Button("button", "Quit", textfieldFont, Color.Black); quitButton.Action = () => { Treehugger.ExitGame(); }; quitButton.Position = new Vector2(rightx, 450); Add(quitButton); }
public GameOverState() { const int buffer = 50; const int buttonWidth = 300; int leftx = (GameEnvironment.Screen.X - (buttonWidth * 2 + buffer)) / 2; int rightx = leftx + buttonWidth + buffer; int centerx = (GameEnvironment.Screen.X - buttonWidth) / 2; int buttonOffSett = 75; SpriteFont defaultFont = GameEnvironment.AssetManager.GetFont("Arial12"); SpriteFont textfieldFont = GameEnvironment.AssetManager.GetFont("Arial26"); TextGameObject gameOverMessage = new TextGameObject("Arial26"); gameOverMessage.Text = "GameOver"; gameOverMessage.Color = Color.Red; gameOverMessage.Position = new Vector2(centerx, 200); Add(gameOverMessage); mainMenuButton = new Button("button", "MainMenu", textfieldFont, Color.Black); mainMenuButton.Action = () => { GameEnvironment.GameStateManager.SwitchTo("mainMenuState"); GameEnvironment.AssetManager.PlayMusic("Sounds/Welcome Screen"); }; mainMenuButton.Position = new Vector2(centerx, 300); Add(mainMenuButton); restartButton = new Button("button", "Restart", textfieldFont, Color.Black); restartButton.Action = () => { GameSetupState gss = GameEnvironment.GameStateManager.GetGameState("gameSetupState") as GameSetupState; gss.InitializeGameMode(gameMode); GameEnvironment.GameStateManager.SwitchTo("gameSetupState"); }; restartButton.Position = new Vector2(centerx, mainMenuButton.Position.Y + buttonOffSett); Add(restartButton); quitButton = new Button("button", "Quit", textfieldFont, Color.Black); quitButton.Action = () => { Treehugger.ExitGame(); }; quitButton.Position = new Vector2(centerx, restartButton.Position.Y + buttonOffSett); Add(quitButton); }
public PlayingMenu() : base(350, 500, true, false) { SpriteFont sf = GameEnvironment.AssetManager.GetFont("Arial26"); backButton = new Button("button", "Main Menu", sf, Color.Black); backButton.Position = new Vector2(25, 25); backButton.Action = () => { GameEnvironment.GameStateManager.SwitchTo("mainMenuState"); GameEnvironment.AssetManager.PlayMusic("Sounds/Welcome Screen"); }; Add(backButton); Vector2 buttonDistance = new Vector2(0, backButton.Sprite.Height + 15); restartButton = new Button("button", "Restart", sf, Color.Black); restartButton.Position = backButton.Position + buttonDistance; restartButton.Action = () => { GameSetupState gss = GameEnvironment.GameStateManager.GetGameState("gameSetupState") as GameSetupState; PlayingState ps = GameEnvironment.GameStateManager.GetGameState("playingState") as PlayingState; ps.Reset(); gss.InitializeGameMode(ps.CurrentGameMode); GameEnvironment.GameStateManager.SwitchTo("gameSetupState"); }; Add(restartButton); optionsButton = new Button("button", "Options", sf, Color.Black); optionsButton.Action = () => { }; optionsButton.Position = restartButton.Position + buttonDistance; Add(optionsButton); quitButton = new Button("button", "Quit", sf, Color.Black); quitButton.Position = optionsButton.Position + buttonDistance; quitButton.Action = () => { Treehugger.ExitGame(); }; Add(quitButton); }
public void execute() { Treehugger.WindowSize = new Point(width, height); Treehugger.ApplyResolutionSettings(); }
static void Main() { Treehugger.RunGame(); }