Example #1
0
 public HexDirections RotateDirection(HexDirections currentDir, HexRotation rotation)
 {
     if (rotation == HexRotation.Right)
     {
         var newDir = (int)currentDir + 1;
         if (newDir == 6)
         {
             newDir = 0;
         }
         return((HexDirections)newDir);
     }
     else if (rotation == HexRotation.Left)
     {
         var newDir = (int)currentDir - 1;
         if (newDir == -1)
         {
             newDir = 5;
         }
         return((HexDirections)newDir);
     }
     else
     {
         throw new Exception("Invalid rotation!");
     }
 }
Example #2
0
 public IEnumerable <MapCell> TargetArea(MapCell center, HexRotation pieceRot)
 {
     return(TargetArea(center.loc, pieceRot).Select(map.CellAt));
 }
Example #3
0
    private int ClearFogDirectionReturnObstacleDept(Vector3Int position, HexDirections direction, HexRotation rotation, int range,
                                                    int deptOfKnownObstacle, List <Vector3Int> addVisableToList)
    {
        bool       shouldTurn = true;
        int        dept       = 0;
        Vector3Int currentPos = position;

        for (int i = 0; i < range; i++)
        {
            if (shouldTurn)
            {
                dept++;
                if (dept == deptOfKnownObstacle)
                {
                    return(dept);
                }
                var tempdir = RotateDirection(direction, rotation);
                currentPos = GetNextCellInDirection(currentPos, tempdir);
                if (_obstaclesTileMap.HasTile(currentPos))
                {
                    _fogOfWarTileMap.SetTile(currentPos, null);
                    addVisableToList.Add(currentPos);
                    return(dept);
                }
                else
                {
                    _fogOfWarTileMap.SetTile(currentPos, null);
                    addVisableToList.Add(currentPos);
                    shouldTurn = false;
                }
            }
            //turned last iteration
            else
            {
                currentPos = GetNextCellInDirection(currentPos, direction);
                if (_obstaclesTileMap.HasTile(currentPos))
                {
                    _fogOfWarTileMap.SetTile(currentPos, null);
                    addVisableToList.Add(currentPos);
                    return(dept);
                }
                else
                {
                    _fogOfWarTileMap.SetTile(currentPos, null);
                    addVisableToList.Add(currentPos);
                    shouldTurn = true;
                }
            }
        }
        return(int.MaxValue);
    }
Example #4
0
 public IEnumerable <HexCoords> TargetArea(HexCoords center, HexRotation pieceRot)
 {
     return(cells.Keys
            .Select(x => x.Rotate(pieceRot))
            .Select(x => x + center));
 }