public void SetGameState(StateOfGame state) { stateOfGame = state; switch (stateOfGame) { case StateOfGame.ending: // set camera to move to ending position Camera.main.GetComponent <CameraMovement> ().SetTarget(GameObject.Find("EndingCamera").transform); // stop the music GetComponent <CarSpawn> ().StopMusic(); // hide the old ui GetComponent <Score>().hideScore(); // start the ending canvas endingCanvas.SetActive(true); break; } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (Keyboard.GetState().IsKeyDown(Keys.Escape)) this.Exit(); switch (GameState) { case StateOfGame.MainMenu: if (Mouse.GetState().LeftButton == ButtonState.Pressed) { MediaPlayer.Play(RainSound); MediaPlayer.Volume = .25f; MediaPlayer.IsRepeating = true; GameState = StateOfGame.Play; } break; case StateOfGame.Play: #region Game Play Update // TODO: Add your update logic here frontRain.Update(gameTime, graphics.GraphicsDevice); backRain.Update(gameTime, graphics.GraphicsDevice); Bounds(); FireMechanism(gameTime); ScrollA.update(); ScrollB.update(); Character.Update(gameTime); if (Health.HP == 0) { GameState = StateOfGame.End; } Turret.CharDetails(Character.Position, Character.Velocity); Turret.Update(); Turret.UpdateBullets(); GotShot(); #endregion break; case StateOfGame.End: if (Mouse.GetState().LeftButton == ButtonState.Pressed) { MediaPlayer.Stop(); GameState = StateOfGame.MainMenu; } break; } base.Update(gameTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // När spelet är inaktivt eller pausat går det inte att göra saker (duh) if (this.IsActive && !Registry.pause) { wait = false; Mousecontrol.update(); } else { wait = true; } if (stateOfGame == StateOfGame.game) { player.Update(this, gameTime, Window.ClientBounds); Registry.changingRoom = false; Registry.currentRoom.Update(gameTime, Window.ClientBounds); //Muskontroll if (!player.InventoryInUse && Registry.currentRoom.isItemClickedInRoom()) { Sprite item = Registry.currentRoom.getClickedItem().getSprite(); if (Mousecontrol.inProximityToItem(item.Position, item.FrameSize)) { player.addItem(Registry.currentRoom.getClickedItem()); Registry.currentRoom.removeItem(); Registry.currentRoom.itemWasClicked(); } } // Kollar om spelaren rör sig utanför spelområdet if (IntersectMask(Registry.currentRoom.getMask()) != Vector2.Zero) { // Rättar till spelarens position så att man inte går utanför spelområdet (det icke-transparenta i masken) player.Stop(IntersectMask(Registry.currentRoom.getMask())); } } else if (stateOfGame == StateOfGame.menu) { menu.Update(gameTime, Window.ClientBounds); if (menu.ClickedOnNew) { stateOfGame = StateOfGame.game; } if (menu.ClickedOnOpen) { load(); } } // Ändrar musikvolymen om man pratar med folk if (Registry.pause) { MediaPlayer.Volume = 0.1f; // Låg volym } else if (!Registry.pause) { MediaPlayer.Volume = 0.25f; // Hög volym (MINA ÖRON) } mouseState = Mouse.GetState(); base.Update(gameTime); }
public GameState(StateOfGame state) : this(state, null) { }
public GameState(StateOfGame state, object data) { StateOfGame = state; Data = data; }
private void load() { Registry.load(this); foreach (Item item in Registry.itemsInInventory) { Item itemToBeAdded = new Item(); itemToBeAdded.loadNewItem(item); itemToBeAdded.Initialize(Content.Load<Texture2D>(@itemToBeAdded.TextureString)); player.addItem(itemToBeAdded); } player.position = Registry.playerPosition; Registry.currentRoom.LoadContent(this); stateOfGame = StateOfGame.game; }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // När spelet är inaktivt eller pausat går det inte att göra saker (duh) if (this.IsActive && !Registry.pause) { wait = false; Mousecontrol.update(); } else { wait = true; } if (stateOfGame == StateOfGame.game) { player.Update(this, gameTime, Window.ClientBounds); Registry.changingRoom = false; Registry.currentRoom.Update(gameTime, Window.ClientBounds); //Muskontroll if (!player.InventoryInUse && Registry.currentRoom.isItemClickedInRoom()) { Sprite item = Registry.currentRoom.getClickedItem().getSprite(); if (Mousecontrol.inProximityToItem(item.Position, item.FrameSize)) { player.addItem(Registry.currentRoom.getClickedItem()); Registry.currentRoom.removeItem(); Registry.currentRoom.itemWasClicked(); } } // Kollar om spelaren rör sig utanför spelområdet if (IntersectMask(Registry.currentRoom.getMask()) != Vector2.Zero) { // Rättar till spelarens position så att man inte går utanför spelområdet (det icke-transparenta i masken) player.Stop(IntersectMask(Registry.currentRoom.getMask())); } } else if (stateOfGame == StateOfGame.menu) { menu.Update(gameTime, Window.ClientBounds); if (menu.ClickedOnNew) stateOfGame = StateOfGame.game; if (menu.ClickedOnOpen) load(); } // Ändrar musikvolymen om man pratar med folk if (Registry.pause) { MediaPlayer.Volume = 0.1f; // Låg volym } else if (!Registry.pause) { MediaPlayer.Volume = 0.25f; // Hög volym (MINA ÖRON) } mouseState = Mouse.GetState(); base.Update(gameTime); }