/// <summary> /// Podmiana gry na now¹ instancjê /// </summary> public void LoadNewGame() { player.Points = 0; player.Dynamite = 0; player.Rackets = 0; totalMinutes = 0; totalSeconds = 0; game_map = new Map.Map(tile_size, map_width, map_height, this.Content, player); MediaPlayer.Resume(); if (!player.AudioSettings.IsMuted) { MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; } else { MediaPlayer.Volume = 0; } IsPaused = false; }
/// <summary> /// Podmiana gry na zapisan¹ instancjê /// </summary> /// <param name="game_state_data_to_load">Dane zapisanej gry</param> /// <param name="data_index">Indeks zapisanej gry</param> public void LoadSavedGame(GameState.GameStateData game_state_data_to_load, int data_index) { data_to_load = game_state_data_to_load; this.data_index = data_index; this.player.Dynamite = data_to_load.Dynamites[data_index]; this.player.Points = data_to_load.Points[data_index]; this.player.Rackets = data_to_load.Rackets[data_index]; totalMinutes = data_to_load.TotalMinutes[data_index]; totalSeconds = data_to_load.TotalSeconds[data_index]; game_map = new Map.Map(tile_size, map_width, map_height, data_to_load.GameMaps[data_index], this.Content, player); MediaPlayer.Resume(); if (!player.AudioSettings.IsMuted) { MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; } else { MediaPlayer.Volume = 0; } IsPaused = false; }
/// <summary> /// Konstruktor ³aduj¹cy zapisan¹ grê /// </summary> /// <param name="player">Instancja gracza</param> /// <param name="game_state_data_to_load">Dane stany gry do ³adowania</param> /// <param name="data_index">Indeks danych w tablicy stanów gry</param> public void SavedGame(Player player, GameState.GameStateData game_state_data_to_load, int data_index) { this.player = player; data_to_load = game_state_data_to_load; if (data_to_load.Count != 0) { game_map = new Map.Map(tile_size, map_width, map_height, data_to_load.GameMaps[data_index], this.Content, player); } music = Content.Load <Song>("Audio\\background_music"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(music); if (!player.AudioSettings.IsMuted) { MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; } else { MediaPlayer.Volume = 0; } MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; this.data_index = data_index; this.player.Dynamite = data_to_load.Dynamites[data_index]; this.player.Points = data_to_load.Points[data_index]; this.player.Rackets = data_to_load.Rackets[data_index]; totalMinutes = data_to_load.TotalMinutes[data_index]; totalSeconds = data_to_load.TotalSeconds[data_index]; Form.Invoke(new Action(() => Form.game_panel.playerName.Text = player.Name)); graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings; System.Windows.Forms.Control.FromHandle(Window.Handle).VisibleChanged += MainGame_VisibleChanged; System.Windows.Forms.Control.FromHandle(Form.Handle).KeyUp += new System.Windows.Forms.KeyEventHandler(Game_KeyUp); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyPress += new System.Windows.Forms.KeyPressEventHandler(Game_KeyPress); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyDown += new System.Windows.Forms.KeyEventHandler(Game_Key); System.Windows.Forms.Control.FromHandle(Form.Handle).PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(Game_PreviewKeyDown); IsMouseVisible = true; isStarted = true; }
/// <summary> /// Konstruktor dla nowej gry /// </summary> /// <param name="player">Instancja gracza</param> public void NewGame(Player player) { this.player = player; game_map = new Map.Map(tile_size, map_width, map_height, this.Content, player, Form.ChoosenLevel); music = Content.Load <Song>("Audio\\background_music"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(music); if (!player.AudioSettings.IsMuted) { MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; } else { MediaPlayer.Volume = 0; } Form.setPlayerName(player.Name); graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings; System.Windows.Forms.Control.FromHandle(Window.Handle).VisibleChanged += MainGame_VisibleChanged; System.Windows.Forms.Control.FromHandle(Form.Handle).KeyUp += new System.Windows.Forms.KeyEventHandler(Game_KeyUp); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyPress += new System.Windows.Forms.KeyPressEventHandler(Game_KeyPress); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyDown += new System.Windows.Forms.KeyEventHandler(Game_Key); IsMouseVisible = true; isStarted = true; }
/// <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 (!IsPaused) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed) this.Exit(); updateLabel(gameTime.TotalGameTime.Minutes - lastUpdateMinutes, gameTime.TotalGameTime.Seconds - lastUpdateSeconds); game_map.Update(gameTime); if (key_pressed == System.Windows.Forms.Keys.None) { if (move) { // if (gameTime.TotalGameTime.Milliseconds % 20 == 0) // vandal.SetFinalPosition(game_map); move = false; game_map.MoveVandal(direction.none); } } else if (key_pressed == player.KeyboardSettings.Up) { if (gameTime.TotalGameTime.Milliseconds % 20 == 0) game_map.MoveVandal(direction.up); } else if (key_pressed == player.KeyboardSettings.Down) { if (gameTime.TotalGameTime.Milliseconds % 20 == 0) game_map.MoveVandal(direction.down); } else if (key_pressed == player.KeyboardSettings.Left) { if (gameTime.TotalGameTime.Milliseconds % 20 == 0) { game_map.MoveVandal(direction.left); } } else if (key_pressed == player.KeyboardSettings.Right) { if (gameTime.TotalGameTime.Milliseconds % 20 == 0) game_map.MoveVandal(direction.right); } else if (key_pressed == player.KeyboardSettings.Block) { if (gameTime.TotalGameTime.Milliseconds % 20 == 0) game_map.GetVandal().changeDirectionToNext(game_map); } else if (key_pressed == player.KeyboardSettings.Dynamite) { if (player.Dynamite > 0) { game_map.GetVandal().LeftDynamite(game_map, gameTime); key_pressed = System.Windows.Forms.Keys.None; } else { SoundEffect null_sound = Content.Load<SoundEffect>("Audio\\null_sound"); SoundEffect.MasterVolume = (float)player.AudioSettings.SoundVolume; null_sound.Play(); } } else if (key_pressed == player.KeyboardSettings.Pause) { PauseGame(); } else if (key_pressed == player.KeyboardSettings.Racket) { if (player.Rackets > 0) game_map.GetVandal().AttackWithRacket(game_map); else { SoundEffect.MasterVolume = (float)player.AudioSettings.SoundVolume; SoundEffect null_sound = Content.Load<SoundEffect>("Audio\\null_sound"); null_sound.Play(); } } // vandal.LoadCurrentTexture(game_map); if (game_map.GetVandal().level_up) { int current_level = game_map.gameLevel; if (current_level < 5) { game_map = new Map.Map(tile_size, map_width, map_height, this.Content, player,current_level + 1); } else { SaveHighScore(); Win(); } } } if (!game_map.GetVandal().is_alive) { SaveHighScore(); GameOver(); } else { base.Update(gameTime); lastUpdateMinutes = gameTime.TotalGameTime.Minutes; lastUpdateSeconds = gameTime.TotalGameTime.Seconds; } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); setMapDimension(); if (data_to_load.Count != 0) { game_map = new Map.Map(tile_size, map_width, map_height, data_to_load.GameMaps[data_index], this.Content, player); } else { game_map = new Map.Map(tile_size, map_width, map_height, this.Content, player); } music = Content.Load<Song>("Audio\\background_music"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(music); MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; }
/// <summary> /// Podmiana gry na zapisan¹ instancjê /// </summary> /// <param name="game_state_data_to_load">Dane zapisanej gry</param> /// <param name="data_index">Indeks zapisanej gry</param> public void LoadSavedGame(GameState.GameStateData game_state_data_to_load, int data_index) { data_to_load = game_state_data_to_load; this.data_index = data_index; this.player.Dynamite = data_to_load.Dynamites[data_index]; this.player.Points = data_to_load.Points[data_index]; this.player.Rackets = data_to_load.Rackets[data_index]; totalMinutes = data_to_load.TotalMinutes[data_index]; totalSeconds = data_to_load.TotalSeconds[data_index]; game_map = new Map.Map(tile_size, map_width, map_height, data_to_load.GameMaps[data_index], this.Content, player); MediaPlayer.Resume(); MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; IsPaused = false; }
/// <summary> /// Podmiana gry na now¹ instancjê /// </summary> public void clearGameState() { player.Points = 0; player.Dynamite = 0; player.Rackets = 0; totalMinutes = 0; totalSeconds = 0; game_map = new Map.Map(tile_size, map_width, map_height, this.Content, player); MediaPlayer.Resume(); MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; IsPaused = false; }
/// <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) { if (isStarted) { // Allows the game to exit if (!IsPaused) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed) this.Exit(); updateLabel(gameTime.TotalGameTime.Minutes - lastUpdateMinutes, gameTime.TotalGameTime.Seconds - lastUpdateSeconds); game_map.Update(gameTime); lastUpdateMinutes = gameTime.TotalGameTime.Minutes; lastUpdateSeconds = gameTime.TotalGameTime.Seconds; if (key_pressed == System.Windows.Forms.Keys.None) { if (move) { move = false; game_map.MoveVandal(direction.none); } } else if (key_pressed == player.KeyboardSettings.Up) { game_map.MoveVandal(direction.up); } else if (key_pressed == player.KeyboardSettings.Down) { game_map.MoveVandal(direction.down); } else if (key_pressed == player.KeyboardSettings.Left) { game_map.MoveVandal(direction.left); } else if (key_pressed == player.KeyboardSettings.Right) { game_map.MoveVandal(direction.right); } else if (key_pressed == player.KeyboardSettings.Block) { game_map.GetVandal().changeDirectionToNext(game_map); } else if (key_pressed == player.KeyboardSettings.Dynamite) { if (player.Dynamite > 0) { game_map.GetVandal().LeftDynamite(game_map, gameTime); key_pressed = System.Windows.Forms.Keys.None; } else { SoundEffect null_sound = Content.Load<SoundEffect>("Audio\\null_sound"); if (!player.AudioSettings.IsMuted) { SoundEffect.MasterVolume = (float)player.AudioSettings.SoundVolume; null_sound.Play(); } } } else if (key_pressed == player.KeyboardSettings.Pause) { PauseGame(); } else if (key_pressed == player.KeyboardSettings.Racket) { if (player.Rackets > 0) game_map.GetVandal().AttackWithRacket(game_map); else { SoundEffect null_sound = Content.Load<SoundEffect>("Audio\\null_sound"); if (!player.AudioSettings.IsMuted) { SoundEffect.MasterVolume = (float)player.AudioSettings.SoundVolume; null_sound.Play(); } } } if (game_map.GetVandal().level_up) { int current_level = game_map.gameLevel; if (current_level < 5) { //aktualizacja maksymalnego dopuszczalnego pzoiomu gry if (player.MaxEnabledLevel < current_level + 1) { player.MaxEnabledLevel = current_level + 1; Form.choose_level_panel.EnableTillLevel(player.MaxEnabledLevel); } //ustawianie poziomu inteligencji - jest ta funkcjonalnosc jest wlaczona if (player.CheckIntelligence) { if (player.Points < 500 * current_level) player.IntelligenceLevel = 0; if (player.Points >= 500 * current_level && player.Points < 900 * current_level) player.IntelligenceLevel = 1; else player.IntelligenceLevel = 2; } game_map = new Map.Map(tile_size, map_width, map_height, this.Content, player, current_level + 1); } else { SaveHighScore(); Win(); } } } if (!game_map.GetVandal().is_alive) { IsPaused = true; SaveHighScore(); GameOver(); game_map.GetVandal().is_alive = true; } { base.Update(gameTime); lastUpdateMinutes = gameTime.TotalGameTime.Minutes; lastUpdateSeconds = gameTime.TotalGameTime.Seconds; } } }
/// <summary> /// Konstruktor �aduj�cy zapisan� gr� /// </summary> /// <param name="player">Instancja gracza</param> /// <param name="game_state_data_to_load">Dane stany gry do �adowania</param> /// <param name="data_index">Indeks danych w tablicy stan�w gry</param> public void SavedGame(Player player, GameState.GameStateData game_state_data_to_load, int data_index) { this.player = player; data_to_load = game_state_data_to_load; if (data_to_load.Count != 0) game_map = new Map.Map(tile_size, map_width, map_height, data_to_load.GameMaps[data_index], this.Content, player); music = Content.Load<Song>("Audio\\background_music"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(music); if (!player.AudioSettings.IsMuted) MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; else MediaPlayer.Volume = 0; MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; this.data_index = data_index; this.player.Dynamite = data_to_load.Dynamites[data_index]; this.player.Points = data_to_load.Points[data_index]; this.player.Rackets = data_to_load.Rackets[data_index]; totalMinutes = data_to_load.TotalMinutes[data_index]; totalSeconds = data_to_load.TotalSeconds[data_index]; Form.Invoke(new Action(() => Form.game_panel.playerName.Text = player.Name)); graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings; System.Windows.Forms.Control.FromHandle(Window.Handle).VisibleChanged += MainGame_VisibleChanged; System.Windows.Forms.Control.FromHandle(Form.Handle).KeyUp += new System.Windows.Forms.KeyEventHandler(Game_KeyUp); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyPress += new System.Windows.Forms.KeyPressEventHandler(Game_KeyPress); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyDown += new System.Windows.Forms.KeyEventHandler(Game_Key); System.Windows.Forms.Control.FromHandle(Form.Handle).PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(Game_PreviewKeyDown); IsMouseVisible = true; isStarted = true; }
/// <summary> /// Konstruktor dla nowej gry /// </summary> /// <param name="player">Instancja gracza</param> public void NewGame(Player player) { this.player = player; game_map = new Map.Map(tile_size, map_width, map_height, this.Content, player, Form.ChoosenLevel); music = Content.Load<Song>("Audio\\background_music"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(music); if (!player.AudioSettings.IsMuted) MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; else MediaPlayer.Volume = 0; Form.setPlayerName(player.Name); graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings; System.Windows.Forms.Control.FromHandle(Window.Handle).VisibleChanged += MainGame_VisibleChanged; System.Windows.Forms.Control.FromHandle(Form.Handle).KeyUp += new System.Windows.Forms.KeyEventHandler(Game_KeyUp); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyPress += new System.Windows.Forms.KeyPressEventHandler(Game_KeyPress); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyDown += new System.Windows.Forms.KeyEventHandler(Game_Key); IsMouseVisible = true; isStarted = true; }
public virtual void Update(GameTime gametime, Map map) { }
public virtual void onCollisionDetected(Map map, MapObject map_object) { }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); game_map = new Map.Map(Form.ViewportSize.Width, Form.ViewportSize.Height,this.Content,player); vandal = new Characters.Vandal(this.Content, new Rectangle(0, 0, 50, 50),Form.ViewportSize.Width,Form.ViewportSize.Height); }
/// <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) { if (isStarted) { // Allows the game to exit if (!IsPaused) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { this.Exit(); } updateLabel(gameTime.TotalGameTime.Minutes - lastUpdateMinutes, gameTime.TotalGameTime.Seconds - lastUpdateSeconds); game_map.Update(gameTime); lastUpdateMinutes = gameTime.TotalGameTime.Minutes; lastUpdateSeconds = gameTime.TotalGameTime.Seconds; if (key_pressed == System.Windows.Forms.Keys.None) { if (move) { move = false; game_map.MoveVandal(direction.none); } } else if (key_pressed == player.KeyboardSettings.Up) { game_map.MoveVandal(direction.up); } else if (key_pressed == player.KeyboardSettings.Down) { game_map.MoveVandal(direction.down); } else if (key_pressed == player.KeyboardSettings.Left) { game_map.MoveVandal(direction.left); } else if (key_pressed == player.KeyboardSettings.Right) { game_map.MoveVandal(direction.right); } else if (key_pressed == player.KeyboardSettings.Block) { game_map.GetVandal().changeDirectionToNext(game_map); } else if (key_pressed == player.KeyboardSettings.Dynamite) { if (player.Dynamite > 0) { game_map.GetVandal().LeftDynamite(game_map, gameTime); key_pressed = System.Windows.Forms.Keys.None; } else { SoundEffect null_sound = Content.Load <SoundEffect>("Audio\\null_sound"); if (!player.AudioSettings.IsMuted) { SoundEffect.MasterVolume = (float)player.AudioSettings.SoundVolume; null_sound.Play(); } } } else if (key_pressed == player.KeyboardSettings.Pause) { PauseGame(); } else if (key_pressed == player.KeyboardSettings.Racket) { if (player.Rackets > 0) { game_map.GetVandal().AttackWithRacket(game_map); } else { SoundEffect null_sound = Content.Load <SoundEffect>("Audio\\null_sound"); if (!player.AudioSettings.IsMuted) { SoundEffect.MasterVolume = (float)player.AudioSettings.SoundVolume; null_sound.Play(); } } } if (game_map.GetVandal().level_up) { int current_level = game_map.gameLevel; if (current_level < 5) { //aktualizacja maksymalnego dopuszczalnego pzoiomu gry if (player.MaxEnabledLevel < current_level + 1) { player.MaxEnabledLevel = current_level + 1; Form.choose_level_panel.EnableTillLevel(player.MaxEnabledLevel); } //ustawianie poziomu inteligencji - jest ta funkcjonalnosc jest wlaczona if (player.CheckIntelligence) { if (player.Points < 500 * current_level) { player.IntelligenceLevel = 0; } if (player.Points >= 500 * current_level && player.Points < 900 * current_level) { player.IntelligenceLevel = 1; } else { player.IntelligenceLevel = 2; } } game_map = new Map.Map(tile_size, map_width, map_height, this.Content, player, current_level + 1); } else { SaveHighScore(); Win(); } } } if (!game_map.GetVandal().is_alive) { IsPaused = true; SaveHighScore(); GameOver(); game_map.GetVandal().is_alive = true; } { base.Update(gameTime); lastUpdateMinutes = gameTime.TotalGameTime.Minutes; lastUpdateSeconds = gameTime.TotalGameTime.Seconds; } } }