Пример #1
0
        private GridItem(short tileType, ItemRotation tileRotation, short structureType, ItemRotation objectRotation, int health)
        {
            _tileType      = tileType;
            _structureType = structureType;
            _health        = health;

            _rotation = (byte)((byte)tileRotation | ((byte)objectRotation) << 4);
        }
Пример #2
0
 public int2 Rotate(int2 position, ItemRotation rotation)
 {
     return(rotation switch
     {
         ItemRotation.Clockwise => int2(position.y, Width - 1 - position.x),
         ItemRotation.Reversed => int2(Width - 1 - position.x, Height - 1 - position.y),
         ItemRotation.CounterClockwise => int2(Height - 1 - position.y, position.x),
         _ => int2(position.x, position.y)
     });
Пример #3
0
 protected static int GetRotationDegrees(ItemRotation rot)
 {
     if (rot == ItemRotation.R0)
     {
         return(0);
     }
     if (rot == ItemRotation.R270)
     {
         return(270);
     }
     if (rot == ItemRotation.R90)
     {
         return(90);
     }
     return(180);
 }
Пример #4
0
    public static float2 Direction(this ItemRotation rotation)
    {
        switch (rotation)
        {
        case ItemRotation.None:
            return(float2(0, 1));

        case ItemRotation.CounterClockwise:
            return(float2(-1, 0));

        case ItemRotation.Reversed:
            return(float2(0, -1));

        case ItemRotation.Clockwise:
            return(float2(1, 0));

        default:
            throw new ArgumentOutOfRangeException(nameof(rotation), rotation, null);
        }
    }
Пример #5
0
    public static char Arrow(this ItemRotation rot)
    {
        switch (rot)
        {
        case ItemRotation.None:
            return('\u2191');

        case ItemRotation.Clockwise:
            return('\u2192');

        case ItemRotation.Reversed:
            return('\u2193');

        case ItemRotation.CounterClockwise:
            return('\u2190');

        default:
            throw new ArgumentOutOfRangeException(nameof(rot), rot, null);
        }
    }
Пример #6
0
    public static float2 Rotate(this float2 v, ItemRotation rotation)
    {
        switch (rotation)
        {
        case ItemRotation.None:
            return(v);

        case ItemRotation.CounterClockwise:
            return(float2(-v.y, v.x));

        case ItemRotation.Reversed:
            return(float2(-v.x, -v.y));

        case ItemRotation.Clockwise:
            return(float2(v.y, -v.x));

        default:
            throw new ArgumentOutOfRangeException(nameof(rotation), rotation, null);
        }
    }
Пример #7
0
 /// <summary> Creates a new GridItem that represents a tile with the given object added to it. </summary>
 public GridItem AddStructure(short structureType, ItemRotation objectRotation, int health)
 => new GridItem(_tileType, TileRotation, structureType, objectRotation, health);
Пример #8
0
 public GridItem(short tileType, ItemRotation tileRotation)
     : this(tileType, tileRotation, 0, ItemRotation.None, 0)
 {
 }