/// <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); // Use this.Content to load your game content here GameContent = new GameContent(Content); GraphicsManager.PreferredBackBufferWidth = Constants.SCREEN_WIDTH; GraphicsManager.PreferredBackBufferHeight = Constants.SCREEN_HEIGHT; GraphicsManager.ApplyChanges(); _player = Player.Instance(); WraithOne = new Wraith(2, "Bane Fang the Mad", 200, 200, Constants.PLAYER_WIDTH, Constants.PLAYER_HEIGHT, Constants.SPRITE_SCALE, new Direction(180.0f), 30); WraithTwo = new Wraith(3, "Snot Maggot", 420, 300, Constants.PLAYER_WIDTH, Constants.PLAYER_HEIGHT, Constants.SPRITE_SCALE, new Direction(180.0f), 100); WraithThree = new Wraith(1, "Gore Rot the Quick", 820, 300, Constants.PLAYER_WIDTH, Constants.PLAYER_HEIGHT, Constants.SPRITE_SCALE, new Direction(180.0f), 20); WraithFour = new Wraith(1, "Wraith Four", 2000, 2000, Constants.PLAYER_WIDTH, Constants.PLAYER_HEIGHT, Constants.SPRITE_SCALE, new Direction(180.0f), 20); WraithOne.SetAlignment(Actor.Alignment.NEUTRAL); WraithTwo.SetAlignment(Actor.Alignment.HOSTILE); WraithThree.SetAlignment(Actor.Alignment.FRIENDLY); WraithFour.SetAlignment(Actor.Alignment.HOSTILE); UserInterface = UserInterface.Instance(); TargetingSystem = TargetingSystem.Instance(); EntityContainer.Add(_player); EntityContainer.Add(WraithOne); EntityContainer.Add(WraithTwo); EntityContainer.Add(WraithThree); EntityContainer.Add(WraithFour); //ObstacleTest = new CollisionBox(590, 390, 50, 50); //ObstacleTest.GetPrimRectangle().SetColor(Color.Red); WorldCamera = new OrthographicCamera(GraphicsDevice); TransformMatrix = WorldCamera.GetViewMatrix(); }
public static void HandleInput() { UpdateKeyboardState(); UpdateMouseState(); KeyboardState keyboardState = Keyboard.GetState(); MouseState mouseState = Mouse.GetState(); Player player = Player.Instance(); bool isRunning = Keyboard.GetState().IsKeyDown(Keys.LeftShift); if (IsValidMovementKey(keyboardState)) { int dx = 0; int dy = 0; // North if (Keyboard.GetState().IsKeyDown(Keys.W)) { dy = -1; } // East if (Keyboard.GetState().IsKeyDown(Keys.D)) { dx = 1; } // South if (Keyboard.GetState().IsKeyDown(Keys.S)) { dy = 1; } // West if (Keyboard.GetState().IsKeyDown(Keys.A)) { dx = -1; } InputHandler.TranslateMovement(dx, dy, isRunning); } if (IsKeyPressed(Keys.OemOpenBrackets)) { player.SetState(Player.ActorState.IN_COMBAT); } if (IsKeyPressed(Keys.OemCloseBrackets)) { player.SetState(Player.ActorState.NORMAL); } if (IsKeyPressed(Keys.T)) { Blink(); } if (IsKeyPressed(Keys.G)) { player.RemoveHitPoints(10); } if (IsKeyPressed(Keys.H)) { player.SetHitPoints(player.GetHitPoints() / 2); } if (IsKeyPressed(Keys.L)) { Player.AddLevel(); } if (IsKeyPressed(Keys.I) && !(UserInterface.InventoryPanel.IsDisplayed())) { UserInterface.InventoryPanel.SetDisplayed(true); } else if (IsKeyPressed(Keys.I) && UserInterface.InventoryPanel.IsDisplayed()) { UserInterface.InventoryPanel.SetDisplayed(false); } if (IsKeyPressed(Keys.C) && !(UserInterface.CharacterPanel.IsDisplayed())) { UserInterface.CharacterPanel.SetDisplayed(true); } else if (IsKeyPressed(Keys.C) && UserInterface.CharacterPanel.IsDisplayed()) { UserInterface.CharacterPanel.SetDisplayed(false); } //if (IsKeyPressed(Keys.Q)) //{ // JustCombat.UserInterface.CoolDownTimer.Start(2.5f); //} if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { JustCombat.TargetingSystem.Release(); } if (IsKeyPressed(Keys.F5)) { if (JustCombat.UserInterface.InDebugMode()) { JustCombat.UserInterface.SetDebug(false); } else { JustCombat.UserInterface.SetDebug(true); } Console.WriteLine("Debug toggled."); } if (keyboardState.IsKeyDown(Keys.OemPeriod)) { OrthographicCamera camera = JustCombat.WorldCamera; JustCombat.TransformMatrix = camera.GetViewMatrix(); camera.ZoomIn(0.1f); } if (keyboardState.IsKeyDown(Keys.OemComma)) { OrthographicCamera camera = JustCombat.WorldCamera; JustCombat.TransformMatrix = camera.GetViewMatrix(); camera.ZoomOut(0.1f); } if (IsKeyPressed(Keys.OemPlus)) { Player.Instance().AddXP(300); } if (keyboardState.IsKeyDown(Keys.OemCloseBrackets)) { Player.Instance().AddXP(300); } if (RightButtonPressed()) { Entity entity = TargetingSystem.Instance().GetCurrentTarget(); if (entity != null) { if (entity is Actor) { Actor victim = (Actor)(entity); victim.RemoveHitPoints(13); } } } }