public void Initialize() { base.Image = GameScreen.Instance.NpcHelperTexture; this.currentFrame = Vector2.Zero; base.Animation = new Animation(base.position, base.AmountOfFrames, base.Image); // base.Animation.AnimationImage = base.Image; NpcHelperHandler.AddSprite(this); }
public void Initialize() { base.Image = GameScreen.Instance.NpcSorcererTexture; base.DrawRect = new Rectangle((int)base.Position.X, (int)base.Position.Y, (int)(base.Image.Width / base.AmountOfFrames.X), (int)(base.Image.Height / base.AmountOfFrames.Y)); this.reactRect = base.DrawRect; this.reactRect.Width += 20; this.reactRect.Height += 20; elapsedTime = GameSettings.TIME_TO_RENT_AGAIN; base.Animation = new Animation(base.Position, base.AmountOfFrames, base.Image); NpcHelperHandler.AddSprite(this); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); SpriteBatch.Begin(); if (GameState != 0 && videoColor.A != 255) { SceneryHandler.Instance.Draw(); // Scenery DropHandler.Instance.Draw(); // Drop ShotsHandler.Instance.Draw(); // Shots Player.Instance.Draw(); // Player MonstersHandler.Instance.Draw(gameTime); // Monsters MarketDialogHandler.Instance.Draw(); // Market dialog Toolbar.InventorySlots.Instance.Draw(); // Inventory Toolbar.SystemMsg.Instance.DrawText(); // System messages Toolbar.HP.Instance.Draw(); // HP bar NpcHelperHandler.Draw(); InfoBoxes.Instance.Draw(); // Pop-up info boxes GameOverHandler.Instance.Draw(); SpriteBatch.Draw(CursorTexture, cursorPos, Color.White); // draws cursor } if (videoColor.A > 1) { SpriteBatch.Draw(videoTexture, new Vector2(0, 0), videoColor); // Intro Video } SpriteBatch.End(); base.Draw(gameTime); }
protected override void Update(GameTime gameTime) { MouseState = Mouse.GetState(); cursorPos = new Vector2(MouseState.X, MouseState.Y); // cursor update KeyboardState = Keyboard.GetState(); // Allows the game to exit if (KeyboardState.IsKeyDown(Keys.Escape)) { this.Exit(); } switch (GameState) { case 0: // Video Intro if (videoPlayer.State != MediaState.Stopped) { videoTexture = videoPlayer.GetTexture(); } else { MediaPlayer.Play(inGameMusic); MediaPlayer.IsRepeating = true; GameState = 1; } break; case 1: // Game Started if (videoColor.A > 1) { videoColor.A -= 2; } // Checks for Pause if (KeyboardState.IsKeyDown(Keys.P) && KeyboardStatePrevious.IsKeyUp(Keys.P)) { MediaPlayer.Pause(); GameState = 2; } Player.Instance.Update(gameTime); MonstersHandler.Instance.Update(gameTime); DropHandler.Instance.Update(gameTime); ShotsHandler.Instance.UpdateShots(gameTime, KeyboardState); Toolbar.InventorySlots.Instance.Update(gameTime, MouseState); Toolbar.SystemMsg.Instance.GetLastMessages(); Toolbar.HP.Instance.Update(gameTime); InfoBoxes.Instance.Update(gameTime, MouseState); ElixirsHandler.Instance.Update(gameTime); // updates elixir reuse time Well.Instance.Update(gameTime); // updates well reuse time MarketDialogHandler.Instance.Update(MouseState, MouseStatePrevious); GameOverHandler.Instance.Update(gameTime); NpcHelperHandler.Update(gameTime); break; case 2: // Paused // Checks for Resume if (KeyboardState.IsKeyDown(Keys.P) && KeyboardStatePrevious.IsKeyUp(Keys.P)) { MediaPlayer.Resume(); GameState = 1; } Toolbar.HP.Instance.Update(gameTime); InfoBoxes.Instance.Update(gameTime, MouseState); MarketDialogHandler.Instance.Update(MouseState, MouseStatePrevious); break; case 3: // Game Over if (MediaPlayer.Queue.ActiveSong == inGameMusic) { MediaPlayer.Play(gameOverMusic); } InfoBoxes.Instance.Update(gameTime, MouseState); break; } this.KeyboardStatePrevious = KeyboardState; this.MouseStatePrevious = MouseState; base.Update(gameTime); }
public override void Update(GameTime gameTime) { if (this.isActive) { this.frameCounter += (int)gameTime.ElapsedGameTime.TotalMilliseconds; if (this.frameCounter > GameSettings.ACTIVE_TIME) { this.frameCounter = 0; this.isActive = false; } if (Player.Instance.Direction == DirectionsEnum.East) { base.position.X = Player.Instance.DestinationPosition.X - 40; base.position.Y = Player.Instance.DestinationPosition.Y - 40; this.currentFrame.Y = 2; } else if (Player.Instance.Direction == DirectionsEnum.North) { base.position.X = Player.Instance.DestinationPosition.X; base.position.Y = Player.Instance.DestinationPosition.Y + 10; this.currentFrame.Y = 3; } else if (Player.Instance.Direction == DirectionsEnum.South) { base.position.X = Player.Instance.DestinationPosition.X; base.position.Y = Player.Instance.DestinationPosition.Y - 50; this.currentFrame.Y = 0; } else if (Player.Instance.Direction == DirectionsEnum.West) { base.position.X = Player.Instance.DestinationPosition.X + 10; base.position.Y = Player.Instance.DestinationPosition.Y - 40; this.currentFrame.Y = 1; } this.DrawRect = new Rectangle((int)base.position.X, (int)base.position.Y, (int)(base.Image.Width / base.AmountOfFrames.X), (int)(base.Image.Height / base.AmountOfFrames.Y)); this.reactRect = new Rectangle(this.DrawRect.X - 100, this.DrawRect.Y - 100, this.DrawRect.Width + 100, this.DrawRect.Height + 100); foreach (Monsters.Monster monster in Handlers.MonstersHandler.Instance.SpawnedMobs) { if (monster.DestinationPosition.Intersects(reactRect) && this.frameCounter % 600 == 0) { FireBall fireBall = new FireBall(new Vector2(8, 1), new Vector2(this.DrawRect.X + this.DrawRect.Width / 2, this.DrawRect.Y + this.DrawRect.Height / 2), monster); fireBall.isActive = true; NpcHelperHandler.AddSprite(fireBall); break; } } this.currentFrame.X = base.Animation.CurrentFrame.X; base.Animation.Position = base.position; base.Animation.CurrentFrame = this.currentFrame; base.Animation.Update(gameTime); } else { if (GameScreen.Instance.KeyboardState.IsKeyDown(Keys.Enter)) { this.DrawRect = new Rectangle(Player.Instance.DestinationPosition.X, Player.Instance.DestinationPosition.Y, (int)(base.Image.Width / base.AmountOfFrames.X), (int)(base.Image.Height / base.AmountOfFrames.Y)); this.reactRect = new Rectangle(this.DrawRect.X - 10, this.DrawRect.Y - 10, this.DrawRect.Width + 10, this.DrawRect.Height + 10); NpcHelperHandler.DoReaction <ImPlayer>(this); this.reactRect = Rectangle.Empty; } } }