Beispiel #1
0
        /// <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();
        }
Beispiel #2
0
 /// <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();
 }