/// <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); _board.LoadContent(Content); _towerTextures.Add(Tower.Ground, Content.Load <Texture2D>("Case")); _towerTextures.Add(Tower.RangeGround, Content.Load <Texture2D>("Range")); _towerTextures.Add(Tower.Tower1, Content.Load <Texture2D>(@"Tower/Tower1")); _towerTextures.Add(Tower.Tower2, Content.Load <Texture2D>(@"Tower/Tower2")); _towerTextures.Add(Tower.Freeze, Content.Load <Texture2D>(@"Tower/Freeze")); _towerTextures.Add(Tower.Start, Content.Load <Texture2D>("Start")); _towerTextures.Add(Tower.Base, Content.Load <Texture2D>("Base")); _towerTextures.Add(Tower.Direction, Content.Load <Texture2D>("Arrow")); _font = Content.Load <SpriteFont>("Font"); _informationTexture = Content.Load <Texture2D>("Information"); ShipGroup.LoadContent(Content); _menu.LoadContent(Content, _graphics.GraphicsDevice); _statusBar.LoadContent(Content, _graphics.GraphicsDevice); _infoPanel.LoadContent(Content, _graphics.GraphicsDevice); }
public void LaunchWave(Textures.Ship ship) { _ships = new ShipGroup(ship, _path.ToList(), 10, 10, new Point(Cell.Start.X, Cell.Start.Y)); }
/// <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) { InputEvent.Update(); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || InputEvent.KeyboardClick(Keys.Escape)) { if (CircularMenu.Opened) { _menu.Close(); } else { _board.Running = false; Exit(); } } //Stop if (InputEvent.KeyboardClick(Keys.OemQuotes, ClickEvent.OnPressed)) { ShipGroup.SpeedIndex = 0; } //Speed 0.5 -> 10 else if (InputEvent.KeyboardClick(Keys.D1)) { ShipGroup.SpeedIndex = 1; } else if (InputEvent.KeyboardClick(Keys.D2)) { ShipGroup.SpeedIndex = 2; } else if (InputEvent.KeyboardClick(Keys.D3)) { ShipGroup.SpeedIndex = 3; } else if (InputEvent.KeyboardClick(Keys.D4)) { ShipGroup.SpeedIndex = 4; } else if (InputEvent.KeyboardClick(Keys.D5)) { ShipGroup.SpeedIndex = 5; } //Speed - 1 else if (InputEvent.KeyboardClick(Keys.D6)) { ShipGroup.SpeedIndex--; } //Speed + 1 else if (InputEvent.KeyboardClick(Keys.D7)) { ShipGroup.SpeedIndex++; } if (InputEvent.KeyboardClick(Keys.F10)) { if (_fancyMouse) { IsMouseVisible = !IsMouseVisible; } } ShipGroup.StaticUpdate(); _board.Update(); if (_board.SelectedCell != null) { if (_infoPanel.Opened) { if (InputEvent.MouseClick(MouseButton.Left)) { _infoPanel.Close(); } } else if (!CircularMenu.Opened) { if (InputEvent.MouseClick(MouseButton.Left, ClickEvent.OnPressed)) { _menu.Clear(); _menu.Add(new MenuElement(_towerTextures[Tower.Direction], () => { }, "Retour", "")); _menu.AddRange(_board.SelectedCell.InnerCell.Menu.Select( menu => new MenuElement(_towerTextures[menu.Texture], () => { if (menu.Money < 0) { if (!_player.CanWithDraw(-menu.Money)) { return; } _player.WithDraw(-menu.Money); } else { _player.Put(menu.Money); } menu.Action(_board.SelectedCell, _player)(); }, menu.Text, menu.Money + _player.Currency))); if (_board.SelectedCell.InnerCell is TowerCell) { var cell = _board.SelectedCell.InnerCell as TowerCell; _menu.Add(new MenuElement(_informationTexture, () => _infoPanel.View(new InformationElement(_towerTextures[cell.Texture], cell.Name)) , "Information", "")); } var open = InputEvent.MousePosition(); if (open.X < _menu.Size / 2) { open.X = _menu.Size / 2; } else if (open.X > _width - _menu.Size / 2) { open.X = _width - _menu.Size / 2; } if (open.Y < _menu.Size / 2) { open.Y = _menu.Size / 2; } else if (open.Y > _height - _menu.Size / 2) { open.Y = _height - _menu.Size / 2; } _menu.Open(open); } } else { if (InputEvent.MouseState.LeftButton == ButtonState.Pressed && InputEvent.MouseClick(MouseButton.Right)) { _menu.Close(); } else if (InputEvent.MouseClick(MouseButton.Left)) { _menu.Close()(); _board.RecalculatePath(); } } } _statusBar.Update(); base.Update(gameTime); }