public void LoadNextMap(ContentManager Content) { levelIndex++; if (levelIndex == 1) { Debug.WriteToFile("Trying to load Level " + levelIndex, true, false); map = Content.Load <TiledMap>("Level1"); playerSpawningPosition = new Vector2(96, 96); map = Content.Load <TiledMap>("Level1"); Debug.WriteToFile("Level " + levelIndex + " has been loaded", true, false); } else if (levelIndex == 2) { Game1.theGame.gameStates.InitGame(); Game1.theGame.player.isVisible = true; Game1.theGame.gameStates.isVisible = true; Debug.WriteToFile("Trying to load Level " + levelIndex, true, false); Game1.theGame.gameStates.isVisible = true; playerSpawningPosition = new Vector2(576, 512); map = Content.Load <TiledMap>("Level2"); Debug.WriteToFile("Level " + levelIndex + " has been loaded", true, false); Game1.theGame.gameStates.isVisible = true; } Game1.theGame.player.sPosition = playerSpawningPosition; foreach (TiledTileLayer layer in map.TileLayers) { if (layer.Name == "Collisions") { collisionLayer = layer; } } }
public void MousedClicked(int x, int y) { Rectangle mouseClickedRect = new Rectangle(x, y, 10, 10); if (gameState == GameState.MainMenu) { Rectangle startButtonRect = new Rectangle((int)startButtonPosition.X, (int)startButtonPosition.Y, 100, 20); Rectangle exitButtonRect = new Rectangle((int)exitButtonPosition.X, (int)exitButtonPosition.Y, 100, 20); if (mouseClickedRect.Intersects(startButtonRect)) { Game1.theGame.RestartGame(); healthBar.currentHealth = healthBar.maxHealth; gameState = GameState.Game; } else if (mouseClickedRect.Intersects(exitButtonRect)) { Environment.Exit(0); } } if (gameState == GameState.Game) { Rectangle pausebuttonRect = new Rectangle(1210, 0, 70, 70); if (mouseClickedRect.Intersects(pausebuttonRect)) { gameState = GameState.PauseMenu; Debug.WriteToFile("Pause Menu has been loaded and game has been paused", false, false); } } if (gameState == GameState.PauseMenu) { Rectangle resumeButtonRect = new Rectangle((int)resumeButtonPosition.X, (int)resumeButtonPosition.Y, 100, 20); if (mouseClickedRect.Intersects(resumeButtonRect)) { gameState = GameState.Game; Debug.WriteToFile("Pause Menu has been unloaded and game has been resumed", false, false); } } if (gameState == GameState.Options) { } if (gameState == GameState.EndGame) { } }
public Game1() { Debug = new DevLogging(); File.Delete(Debug.GetCurrentDirectory()); Debug.WriteToFile("This game proudly uses the TrebleSketch Utilities Debugger v6.2", true, false); GameVersionBuild = "v0.3.6.126 "; DateTime thisDay = DateTime.Now; Debug.WriteToFile("Starting Apocalyptic Sunrise " + GameVersionBuild + thisDay.ToString("dd-MM-yyyy HH:mm:ss zzz"), true, false); graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferHeight = 720; graphics.PreferredBackBufferWidth = 1280; graphics.ApplyChanges(); Content.RootDirectory = "Content"; theGame = this; IsMouseVisible = true; }
protected override void Initialize() { Debug.WriteToFile("Started Initializing Game", true, false); gameStates = new GameStates(); gameStates.Debug = Debug; level = new Level(); level.Debug = Debug; level.gameState = gameStates; player = new Player(level.playerSpawningPosition); // level.LoadNextMap(Content); camera = new Camera(); healthBar = new HealthBar(Content); gameStates.InitGame(); VideoPlayer vidPlayer = new VideoPlayer(); //map = new TiledMap(GraphicsDevice, 110, 110, 32, 32, TiledMapOrientation.Orthogonal); base.Initialize(); Debug.WriteToFile("Finished Initializing Game", true, false); }