SunsetHigh.Character.move C# (CSharp) Method

move() public method

public move ( Direction dir, float elapsed, bool collide = true ) : bool
dir Direction
elapsed float
collide bool
return bool
        public override bool move(Direction dir, float elapsed, bool collide = true)
        {
            this.setDirection(dir);
            return base.move(dir, elapsed, collide);
        }

Same methods

Character::move ( float angle, float elapsed, bool collide = true ) : bool

Usage Example

Exemplo n.º 1
0
 /// <summary>
 /// Ts Character movement in 8 directions; call this method in the Game's update
 /// cycle (AFTER calling KeyboardManager.update())
 /// </summary>
 /// <param name="character">The character to control (presumably main character)</param>
 /// <param name="elapsed">The time that elapsed since the last update</param>
 public static void handleCharacterMovement(Character character, float elapsed)
 {
     nullCheck();
     int dirFlags = 0;
     if (KeyboardManager.isKeyDown(keyTypes[(int)KeyInputType.MoveNorth]))
         dirFlags |= 1;
     if (KeyboardManager.isKeyDown(keyTypes[(int)KeyInputType.MoveSouth]))
         dirFlags |= 2;
     if (KeyboardManager.isKeyDown(keyTypes[(int)KeyInputType.MoveEast]))
         dirFlags |= 4;
     if (KeyboardManager.isKeyDown(keyTypes[(int)KeyInputType.MoveWest]))
         dirFlags |= 8;
     Direction xaxis = Direction.Undefined;
     Direction yaxis = Direction.Undefined;
     if ((dirFlags & 1) > 0 ^ (dirFlags & 2) > 0)
     {
         if ((dirFlags & 1) > 0) yaxis = Direction.North;
         else yaxis = Direction.South;
     }
     if ((dirFlags & 4) > 0 ^ (dirFlags & 8) > 0)
     {
         if ((dirFlags & 4) > 0) xaxis = Direction.East;
         else xaxis = Direction.West;
     }
     if (!xaxis.Equals(Direction.Undefined) && !yaxis.Equals(Direction.Undefined))
     {
         if (yaxis.Equals(Direction.North))
             if (xaxis.Equals(Direction.East))
                 character.move(Direction.NorthEast, elapsed);
             else
                 character.move(Direction.NorthWest, elapsed);
         else
             if (xaxis.Equals(Direction.East))
                 character.move(Direction.SouthEast, elapsed);
             else
                 character.move(Direction.SouthWest, elapsed);
     }
     else if (!xaxis.Equals(Direction.Undefined))
     {
         character.move(xaxis, elapsed);
     }
     else if (!yaxis.Equals(Direction.Undefined))
     {
         character.move(yaxis, elapsed);
     }
 }