Server.Movement.Movement.Offset C# (CSharp) Méthode

Offset() public static méthode

public static Offset ( Direction d, int &x, int &y ) : void
d Direction
x int
y int
Résultat void
		public static void Offset( Direction d, ref int x, ref int y )
		{
			switch ( d & Direction.Mask )
			{
				case Direction.North: --y; break;
				case Direction.South: ++y; break;
				case Direction.West:  --x; break;
				case Direction.East:  ++x; break;
				case Direction.Right: ++x; --y; break;
				case Direction.Left:  --x; ++y; break;
				case Direction.Down:  ++x; ++y; break;
				case Direction.Up:    --x; --y; break;
			}
		}
	}

Usage Example

Exemple #1
0
        public void Advance(ref Point3D p, int index)
        {
            if (m_Path != null && m_Path.Success)
            {
                Direction[] dirs = m_Path.Directions;

                if (index >= 0 && index < dirs.Length)
                {
                    int x = p.X, y = p.Y;

                    CalcMoves.Offset(dirs[index], ref x, ref y);

                    p.X = x;
                    p.Y = y;
                }
            }
        }