Exemple #1
0
        private static List <P_CubeCoords> GetRing(P_CubeCoords center, int radius)
        {
            List <P_CubeCoords> HexList = new List <P_CubeCoords>();
            P_CubeCoords        coord   = center;

            for (int i = 0; i < radius; i++)
            {
                coord = coord.DownLeft;
            }
            TileNeighborEnum dir = TileNeighborEnum.Right;
            int count            = 0;
            int steps            = radius;

            while (count < 6)
            {
                for (int i = 0; i < steps; i++)
                {
                    HexList.Add(coord);
                    coord = P_CubeCoords.StepForward(coord, dir);
                }
                dir = TurnCounterClockwise(dir);
                count++;
            }

            return(HexList);
        }
Exemple #2
0
 public static void MoveTileCursor(P_BattleMap battlemap, TileNeighborEnum direction, P_SelectionCursor cursor, ref int cursorindex)
 {
     if (battlemap.TheMap.ValidDirection(cursorindex, direction))
     {
         cursorindex  = battlemap.TheMap.NeighborIndex(cursorindex, direction);
         cursor.Owner = battlemap.TheMap.MyTiles[cursorindex];
     }
 }
        public int NeighborIndex(int tileindex, TileNeighborEnum direction)
        {
            switch (direction)
            {
            case TileNeighborEnum.UpLeft:
                if (validindex(CubeToIndex(IndexToCube(tileindex).UpLeft)))
                {
                    return(CubeToIndex(IndexToCube(tileindex).UpLeft));
                }
                throw new Exception("Tried to attain index of nonexistant tile!");

            case TileNeighborEnum.UpRight:
                if (validindex(CubeToIndex(IndexToCube(tileindex).UpRight)))
                {
                    return(CubeToIndex(IndexToCube(tileindex).UpRight));
                }
                throw new Exception("Tried to attain index of nonexistant tile!");

            case TileNeighborEnum.Left:
                if (validindex(CubeToIndex(IndexToCube(tileindex).Left)))
                {
                    return(CubeToIndex(IndexToCube(tileindex).Left));
                }
                throw new Exception("Tried to attain index of nonexistant tile!");

            case TileNeighborEnum.Right:
                if (validindex(CubeToIndex(IndexToCube(tileindex).Right)))
                {
                    return(CubeToIndex(IndexToCube(tileindex).Right));
                }
                throw new Exception("Tried to attain index of nonexistant tile!");

            case TileNeighborEnum.DownLeft:
                if (validindex(CubeToIndex(IndexToCube(tileindex).DownLeft)))
                {
                    return(CubeToIndex(IndexToCube(tileindex).DownLeft));
                }
                throw new Exception("Tried to attain index of nonexistant tile!");

            case TileNeighborEnum.DownRight:
                if (validindex(CubeToIndex(IndexToCube(tileindex).DownRight)))
                {
                    return(CubeToIndex(IndexToCube(tileindex).DownRight));
                }
                throw new Exception("Tried to attain index of nonexistant tile!");
            }
            throw new Exception("EAT A DICK");
        }
Exemple #4
0
        public static P_CubeCoords StepForward(P_CubeCoords point, TileNeighborEnum direction)
        {
            switch (direction)
            {
            case TileNeighborEnum.DownLeft:
                return(point.DownLeft);

            case TileNeighborEnum.DownRight:
                return(point.DownRight);

            case TileNeighborEnum.Right:
                return(point.Right);

            case TileNeighborEnum.UpRight:
                return(point.UpRight);

            case TileNeighborEnum.UpLeft:
                return(point.UpLeft);

            case TileNeighborEnum.Left:
                return(point.Left);
            }
            throw new Exception("What THE F**K did you just say to me????");
        }
Exemple #5
0
        private static TileNeighborEnum TurnCounterClockwise(TileNeighborEnum facing)
        {
            switch (facing)
            {
            case TileNeighborEnum.DownRight:
                return(TileNeighborEnum.Right);

            case TileNeighborEnum.DownLeft:
                return(TileNeighborEnum.DownRight);

            case TileNeighborEnum.Left:
                return(TileNeighborEnum.DownLeft);

            case TileNeighborEnum.UpLeft:
                return(TileNeighborEnum.Left);

            case TileNeighborEnum.UpRight:
                return(TileNeighborEnum.UpLeft);

            case TileNeighborEnum.Right:
                return(TileNeighborEnum.UpRight);
            }
            return(facing);
        }
        public bool ValidDirection(int tileindex, TileNeighborEnum direction)
        {
            switch (direction)
            {
            case TileNeighborEnum.UpLeft:
                if (!validindex(CubeToIndex(IndexToCube(tileindex).UpLeft)))
                {
                    return(false);
                }
                if (!this.IsLeftRow(this.NeighborIndex(tileindex, direction)) && this.IsLeftRow(tileindex))
                {
                    return(false);
                }
                return(true);

            case TileNeighborEnum.UpRight:
                if (!validindex(CubeToIndex(IndexToCube(tileindex).UpRight)))
                {
                    return(false);
                }
                if (!this.IsRightRow(this.NeighborIndex(tileindex, direction)) && this.IsRightRow(tileindex))
                {
                    return(false);
                }
                return(true);

            case TileNeighborEnum.Left:
                if (!validindex(CubeToIndex(IndexToCube(tileindex).Left)))
                {
                    return(false);
                }
                if (!this.IsLeftRow(this.NeighborIndex(tileindex, direction)) && this.IsLeftRow(tileindex))
                {
                    return(false);
                }
                return(true);

            case TileNeighborEnum.Right:
                if (!validindex(CubeToIndex(IndexToCube(tileindex).Right)))
                {
                    return(false);
                }
                if (!this.IsRightRow(this.NeighborIndex(tileindex, direction)) && this.IsRightRow(tileindex))
                {
                    return(false);
                }
                return(true);

            case TileNeighborEnum.DownLeft:
                if (!validindex(CubeToIndex(IndexToCube(tileindex).DownLeft)))
                {
                    return(false);
                }
                if (!this.IsLeftRow(this.NeighborIndex(tileindex, direction)) && this.IsLeftRow(tileindex))
                {
                    return(false);
                }
                return(true);

            case TileNeighborEnum.DownRight:
                if (!validindex(CubeToIndex(IndexToCube(tileindex).DownRight)))
                {
                    return(false);
                }
                if (!this.IsRightRow(this.NeighborIndex(tileindex, direction)) && this.IsRightRow(tileindex))
                {
                    return(false);
                }
                return(true);
            }
            return(false);
        }