Exemple #1
0
        public HexTile GetNeighbor(Direction direction)
        {
            int deltaX = 0, deltaY = 0, deltaZ = 0;

            switch (direction)
            {
            case Direction.North:
                deltaY = 1;
                deltaZ = -1;
                break;

            case Direction.NorthWest:
                deltaX = -1;
                deltaY = 1;
                break;

            case Direction.SouthWest:
                deltaX = -1;
                deltaZ = 1;
                break;

            case Direction.South:
                deltaY = -1;
                deltaZ = 1;
                break;

            case Direction.SouthEast:
                deltaX = 1;
                deltaY = -1;
                break;

            case Direction.NorthEast:
                deltaX = 1;
                deltaZ = -1;
                break;

            default:
                break;
            }

            var vector = new Vector(this.Position.X + deltaX, this.Position.Y + deltaY, this.Position.Z + deltaZ);

            return(HexTile.FromPosition(vector));
        }