//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public GameControl(GameManager gameManager) { this.gameManager = gameManager; this.roomStateStack = null; this.roomControl = null; this.world = null; this.player = null; this.hud = null; this.inventory = null; this.rewardManager = null; this.dropManager = null; this.isAdvancedGame = false; this.updateRoom = true; this.animateRoom = true; this.menuWeapons = null; this.menuSecondaryItems = null; this.menuEssences = null; this.scriptRunner = null; }
// Start a new game. public void StartGame() { roomTicks = 0; // Setup the player beforehand so certain classes such as the HUD can reference it player = new Player(); inventory = new Inventory(this); menuWeapons = new MenuWeapons(gameManager); menuSecondaryItems = new MenuSecondaryItems(gameManager); menuEssences = new MenuEssences(gameManager); menuWeapons.PreviousMenu = menuEssences; menuWeapons.NextMenu = menuSecondaryItems; menuSecondaryItems.PreviousMenu = menuWeapons; menuSecondaryItems.NextMenu = menuEssences; menuEssences.PreviousMenu = menuSecondaryItems; menuEssences.NextMenu = menuWeapons; mapDungeon = new ScreenDungeonMap(gameManager); GameData.LoadInventory(inventory, true); inventory.ObtainAmmo("ammo_ember_seeds"); inventory.ObtainAmmo("ammo_scent_seeds"); inventory.ObtainAmmo("ammo_pegasus_seeds"); inventory.ObtainAmmo("ammo_gale_seeds"); inventory.ObtainAmmo("ammo_mystery_seeds"); hud = new HUD(this); hud.DynamicHealth = player.Health; rewardManager = new RewardManager(this); GameData.LoadRewards(rewardManager); dropManager = new DropManager(this); GameData.LoadDrops(dropManager, rewardManager); // Create the script runner. scriptRunner = new ScriptRunner(this); // Create the room control. roomControl = new RoomControl(); gameManager.PushGameState(roomControl); // Load the world. //WorldFile worldFile = new WorldFile(); //world = worldFile.Load("Content/Worlds/temp_world.zwd"); // Begin the room state. if (gameManager.LaunchParameters.Length > 0) { LoadWorld(gameManager.LaunchParameters[0]); if (gameManager.LaunchParameters.Length > 1 && gameManager.LaunchParameters[1] == "-test") { // Launch parameters can define player's start position. int startLevel = Int32.Parse(gameManager.LaunchParameters[2]); int startRoomX = Int32.Parse(gameManager.LaunchParameters[3]); int startRoomY = Int32.Parse(gameManager.LaunchParameters[4]); int startPlayerX = Int32.Parse(gameManager.LaunchParameters[5]); int startPlayerY = Int32.Parse(gameManager.LaunchParameters[6]); player.SetPositionByCenter(new Point2I(startPlayerX, startPlayerY) * GameSettings.TILE_SIZE + new Point2I(8, 8)); player.MarkRespawn(); roomControl.BeginRoom(world.Levels[startLevel].Rooms[startRoomX, startRoomY]); } else { player.SetPositionByCenter(world.StartTileLocation * GameSettings.TILE_SIZE + new Point2I(8, 8)); player.MarkRespawn(); roomControl.BeginRoom(world.StartRoom); } } else { //WorldFile worldFile = new WorldFile(); //world = worldFile.Load("temp_world.zwd"); LoadWorld(GameDebug.CreateTestWorld()); player.SetPositionByCenter(world.StartTileLocation * GameSettings.TILE_SIZE + new Point2I(8, 8)); player.MarkRespawn(); roomControl.BeginRoom(world.StartRoom); } roomStateStack = new RoomStateStack(new RoomStateNormal()); roomStateStack.Begin(this); if (!roomControl.Room.IsHiddenFromMap) { lastRoomOnMap = roomControl.Room; } AudioSystem.MasterVolume = 0.04f; // The way David likes it. }