public AIPath(Npc npc, Game1 game, int[] path, int[] delays, Direction[] directions) { this.npc = npc; this.player = game.getPlayer(); this.collisionManager = game.getInputManager().getCollisionManager(); this.path = path; this.delays = delays; this.directions = directions; }
public InputManager(Game1 game, Player player, Level level, Target target, PlayerManager playerManager, Screen[] screens, MindRead mindRead) { this.game = game; this.player = player; this.level = level; this.target = target; this.playerManager = playerManager; this.mindRead = mindRead; this.collisionManager = new CollisionManager(player, level); this.velocity = player.getVelocity(); this.width = game.getWidth(); this.height = game.getHeight() - 40; this.font = game.getDropFont(); this.gameState = GameState.Normal; this.prevLevel = level; }
/// <summary> /// Handles how the power operates /// </summary> /// <param name="level">The level the power is activating on</param> public override void activate(Level level) { manager = level.getCollisionManager(); if (activated) { Vector2 destination; if (duration < 15) { switch (level.getPlayer().getDirection()) { case Direction.North: destination = new Vector2(level.getPlayer().getLocation().X, level.getPlayer().getLocation().Y - 6); level.getPlayer().setDestination(destination); if (level.getPlayer().getDestination().Y >= 0 && manager.isValid(level.getPlayer(), false)) { level.getPlayer().deriveY(-6); } break; case Direction.South: destination = new Vector2(level.getPlayer().getLocation().X, level.getPlayer().getLocation().Y + 6); level.getPlayer().setDestination(destination); if (level.getPlayer().getDestination().Y <= 416 && manager.isValid(level.getPlayer(), false)) { level.getPlayer().deriveY(6); } break; case Direction.West: destination = new Vector2(level.getPlayer().getLocation().X - 6, level.getPlayer().getLocation().Y); level.getPlayer().setDestination(destination); if (level.getPlayer().getDestination().X >= 0 && manager.isValid(level.getPlayer(), false)) { level.getPlayer().deriveX(-6); } break; case Direction.East: destination = new Vector2(level.getPlayer().getLocation().X + 6, level.getPlayer().getLocation().Y); level.getPlayer().setDestination(destination); if (level.getPlayer().getDestination().X <= 736 && manager.isValid(level.getPlayer(), false)) { level.getPlayer().deriveX(6); } break; } updateDuration(); } else { setActivated(false); } } updateCooldown(); }
/// <summary> /// Sets the input manager and player manager for the level /// </summary> /// <param name="inputManager">The InputManager instance to be set for the level</param> public void setInputManager(InputManager inputManager) { this.inputManager = inputManager; collisionManager = inputManager.getCollisionManager(); playerManager = inputManager.getPlayerManager(); }