private void SetGameOver() { state = Game_state.Over; game_over.Visibility = Visibility.Visible; play.Visibility = Visibility.Collapsed; quit.Visibility = Visibility.Collapsed; score.Visibility = Visibility.Visible; score_value.Visibility = Visibility.Visible; }
private void SetMenu() { state = Game_state.Menu; game_over.Visibility = Visibility.Collapsed; play.Visibility = Visibility.Visible; quit.Visibility = Visibility.Visible; score.Visibility = Visibility.Collapsed; score_value.Visibility = Visibility.Collapsed; selected = play; }
public void SetGame() { state = Game_state.Game; play.Visibility = Visibility.Collapsed; quit.Visibility = Visibility.Collapsed; game_over.Visibility = Visibility.Collapsed; score.Visibility = Visibility.Visible; score_value.Visibility = Visibility.Visible; world.ResetPoints(); }
// Start is called before the first frame update void Start() { gamestate = GameObject.Find("Canvas").GetComponent <Game_state>(); }
protected override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) this.Exit(); mouse = Mouse.GetState(); mouse_point = new Point(mouse.X, mouse.Y); switch (current_state) { case Game_state.title: { if (play_btn.is_clicked(mouse)) { current_state = Game_state.level1; MediaPlayer.Play(in_game); } if (help_btn.is_clicked(mouse)) { current_state = Game_state.help; } if (exit_btn.is_clicked(mouse)) { this.Exit(); } } break; case Game_state.help: { if (back_btn.is_clicked(mouse)) { current_state = Game_state.title; } } break; case Game_state.level1: { if(Keyboard.GetState().IsKeyDown(Keys.F1) && !in_game_help) { in_game_help = true; } if (in_game_help && back_btn.is_clicked(mouse)) { in_game_help = false; } } break; case Game_state.level2: { if (Keyboard.GetState().IsKeyDown(Keys.F1) && !in_game_help) { in_game_help = true; } if (in_game_help && back_btn.is_clicked(mouse)) { in_game_help = false; } } break; case Game_state.level3: { if (Keyboard.GetState().IsKeyDown(Keys.F1) && !in_game_help) { in_game_help = true; } if (in_game_help && back_btn.is_clicked(mouse)) { in_game_help = false; } } break; case Game_state.winning: { if (restart_btn.is_clicked(mouse)) { go_manager.enemies.Clear(); Game1.current_state = Game1.Game_state.level1; ui.level = 1; go_manager.interactive_towers.Clear(); go_manager.enemy_wave_start = false; go_manager.enemy_wave_full = false; ui.score = 0; ui.gold = 50; ui.base_hp = 20; ui.enemies_killed = 0; go_manager.enemy_amount = 0; go_manager.tower_placed_amount = 0; } } break; case Game_state.game_over: { if (restart_btn.is_clicked(mouse)) { go_manager.enemies.Clear(); Game1.current_state = Game1.Game_state.level1; ui.level = 1; go_manager.interactive_towers.Clear(); go_manager.enemy_wave_start = false; go_manager.enemy_wave_full = false; ui.score = 0; ui.gold = 50; ui.base_hp = 20; ui.enemies_killed = 0; go_manager.enemy_amount = 0; go_manager.tower_placed_amount = 0; } } break; } //Updates all instances play_btn.Update(mouse); help_btn.Update(mouse); exit_btn.Update(mouse); back_btn.Update(mouse); restart_btn.Update(mouse); go_manager.Update(go_manager.layer); old_mouse = mouse; base.Update(gameTime); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); //Loads textures title_bkg = Content.Load<Texture2D>(@"Textures\bkg2"); help_bkg = Content.Load<Texture2D>(@"Textures\help_bkg1"); gameover_bkg = Content.Load<Texture2D>(@"Textures\go1"); winning_bkg = Content.Load<Texture2D>(@"Textures\fullscreen_bkg2"); sheet_tex = Content.Load<Texture2D>(@"Textures\Spritesheet1"); road_tex = Content.Load<Texture2D>(@"Textures\road"); grass_tex = Content.Load<Texture2D>(@"Textures\grass"); //Particle Manager textures p_textures = new List<Texture2D>(); p_textures.Add(Content.Load<Texture2D>(@"Textures\exp0")); p_textures.Add(Content.Load<Texture2D>(@"Textures\exp1")); p_textures.Add(Content.Load<Texture2D>(@"Textures\exp3")); //Loads sounds and music title_song = Content.Load<Song>(@"Sounds\td"); in_game = Content.Load<Song>(@"Sounds\td_ingame"); explosion = Content.Load<SoundEffect>(@"Sounds\118-Fire02"); //Create instances of objects play_btn = new Button(sheet_tex, new Vector2(220, 250), new Rectangle(0,79, 328, 46)); help_btn = new Button(sheet_tex, new Vector2(215, 350), new Rectangle(0, 124, 350, 48)); back_btn = new Button(sheet_tex, new Vector2(1050, 660), new Rectangle(295, 174, 200, 48)); exit_btn = new Button(sheet_tex, new Vector2(250, 450), new Rectangle(0, 171, 288, 48)); restart_btn = new Button(sheet_tex, new Vector2(250, 560), new Rectangle(0, 780, 288, 150)); ui = new UI_Handle(sheet_tex, new Vector2(1070, 0)); go_manager = new Game_object_Manager(sheet_tex, Vector2.Zero, GraphicsDevice, road_tex, ui); //Loads fonts Font = Content.Load<SpriteFont>("font"); //Starts playing music and sets different bools for it MediaPlayer.Play(title_song); MediaPlayer.IsRepeating = true; current_state = Game_state.title; }