public ShopKeeper(Vector2 position, Player play) : base(position, "Shop_Keeper") { FramesPerSecond = 10; //Adds all the players animations AddAnimation(12, 0, 0, "Down", 50, 50, new Vector2(0, 0)); AddAnimation(1, 0, 0, "IdleDown", 50, 50, new Vector2(0, 0)); AddAnimation(12, 50, 0, "Up", 50, 50, new Vector2(0, 0)); AddAnimation(1, 50, 0, "IdleUp", 50, 50, new Vector2(0, 0)); AddAnimation(8, 100, 0, "Left", 50, 50, new Vector2(0, 0)); AddAnimation(1, 100, 0, "IdleLeft", 50, 50, new Vector2(0, 0)); AddAnimation(8, 100, 8, "Right", 50, 50, new Vector2(0, 0)); AddAnimation(1, 100, 8, "IdleRight", 50, 50, new Vector2(0, 0)); AddAnimation(9, 150, 0, "AttackDown", 70, 80, new Vector2(0, 0)); AddAnimation(9, 230, 0, "AttackUp", 70, 80, new Vector2(-13, -27)); AddAnimation(9, 310, 0, "AttackLeft", 70, 70, new Vector2(-30, -5)); AddAnimation(9, 380, 0, "AttackRight", 70, 70, new Vector2(+15, -5)); //Plays our start animation PlayAnimation("IdleDown"); player = play; HitBox = new Rectangle((int)sPostion.X - 45, (int)sPostion.Y - 45, 90, 90); UI_Handler = Main.game.UI_Handler; // }
protected override void LoadContent() { Main.Set_Game_Location(this); spriteBatch = new SpriteBatch(GraphicsDevice); device = graphics.GraphicsDevice; map = new Map(Content); UI_Handler = new UserInterfaceHandler(Content, spriteBatch); player.LoadContent(Content); shop.LoadContent(Content); chat = new ChatBox_Handler(graphics, Content); userInput = new UserInput(graphics, spriteBatch, this, Content); scen = new scene(); WoodChopper_NPC.LoadContent(Content); // dij.Build(); enemy.LoadContent(Content); // dij = new Dijkstra(); // dij.Build(); }
public override void Update(GameTime gameTime) { newState = Mouse.GetState(); if (newState.RightButton == ButtonState.Pressed && oldState.RightButton == ButtonState.Released) { if (HitBox.Contains(newState.X, newState.Y)) { Right_Click = true; RightClick_Menu = new Rectangle(newState.X - 30, newState.Y, 100, 60); } } if (Right_Click) { if (new Rectangle(RightClick_Menu.X, RightClick_Menu.Y - 10, 75, 75).Contains(newState.X, newState.Y)) { Main.game.spriteBatch.Draw(Main.game.chat.Chat_Log_Texture, RightClick_Menu, Color.White); Rectangle rect1 = new Rectangle(RightClick_Menu.X, RightClick_Menu.Y + 0, 75, 20); Rectangle rect2 = new Rectangle(RightClick_Menu.X, RightClick_Menu.Y + 25, 75, 20); Main.game.spriteBatch.DrawString(Main.game.chat.Font, "Trade", new Vector2(rect1.X, rect1.Y), Color.White); if (rect1.Contains(newState.X, newState.Y)) { Main.game.spriteBatch.DrawString(Main.game.chat.Font, "Trade", new Vector2(rect1.X, rect1.Y), Color.Blue); newState = Mouse.GetState(); if (newState.LeftButton == ButtonState.Pressed && oldState.LeftButton == ButtonState.Released) { UI_Handler = Main.game.UI_Handler; UI_Handler.Change_Interface(7); Right_Click = false; } } Main.game.spriteBatch.DrawString(Main.game.chat.Font, "Cancel", new Vector2(rect2.X, rect2.Y), Color.White); if (rect2.Contains(newState.X, newState.Y)) { Main.game.spriteBatch.DrawString(Main.game.chat.Font, "Cancel", new Vector2(rect2.X, rect2.Y), Color.Blue); newState = Mouse.GetState(); if (newState.LeftButton == ButtonState.Pressed && oldState.LeftButton == ButtonState.Released) { Right_Click = false; } } } else { Right_Click = false; } } oldState = newState; // this reassigns the old state so that it is ready for next time if (gameTime.TotalGameTime > Current_Time + MouseButton_Delay) { walkable = true; Current_Time = gameTime.TotalGameTime; direction = rand.Next(0, 4); numbersteps = 40; } if (walkable && numbersteps > 0) { numbersteps--; switch (direction) { case 0: if (Main.game.scen.GetWalkable(new Vector2(RoundNum((int)sPostion.X), RoundNum((int)sPostion.Y - 10)))) { sDirection += new Vector2(0, -1); sPostion += new Vector2(0, -1); PlayAnimation("Up"); currentDir = myDirection.up; HitBox = new Rectangle((int)sPostion.X - 45, (int)sPostion.Y - 45, 90, 90); } break; case 1: if (Main.game.scen.GetWalkable(new Vector2(RoundNum((int)sPostion.X - 10), RoundNum((int)sPostion.Y)))) { sDirection += new Vector2(-1, 0); sPostion += new Vector2(-1, 0); PlayAnimation("Left"); currentDir = myDirection.left; HitBox = new Rectangle((int)sPostion.X - 45, (int)sPostion.Y - 45, 90, 90); } break; case 2: //Move char Down if (Main.game.scen.GetWalkable(new Vector2(RoundNum((int)sPostion.X), RoundNum((int)sPostion.Y + 10)))) { sDirection += new Vector2(0, 1); sPostion += new Vector2(0, 1); PlayAnimation("Down"); currentDir = myDirection.down; HitBox = new Rectangle((int)sPostion.X - 45, (int)sPostion.Y - 45, 90, 90); } break; case 3: //Move char Right if (Main.game.scen.GetWalkable(new Vector2(RoundNum((int)sPostion.X + 10), RoundNum((int)sPostion.Y)))) { sDirection += new Vector2(1, 0); sPostion += new Vector2(1, 0); PlayAnimation("Right"); currentDir = myDirection.right; HitBox = new Rectangle((int)sPostion.X - 45, (int)sPostion.Y - 45, 90, 90); } break; case 4: break; } } else { walkable = false; if (currentAnimation.Contains("Left")) { PlayAnimation("IdleLeft"); } if (currentAnimation.Contains("Right")) { PlayAnimation("IdleRight"); } if (currentAnimation.Contains("Up")) { PlayAnimation("IdleUp"); } if (currentAnimation.Contains("Down")) { PlayAnimation("IdleDown"); } currentDir = myDirection.none; } base.Update(gameTime); }