Exemple #1
0
        public override List <HexSpriteTileInfo> CalculateHexTiles(
            bool n, bool ne, bool se, bool s,
            bool sw, bool nw, HexTileSet hexTileSet)
        {
            HashSet <int> indexes = new HashSet <int>();

            indexes = HexTileSet.IndexesFromNeighbors(n, ne, se, s, sw, nw);

            return(CalculateHexTiles(indexes, hexTileSet));
        }
Exemple #2
0
 public virtual List <HexSpriteTileInfo> CalculateHexTiles(bool n, bool ne, bool se, bool s, bool sw, bool nw, HexTileSet hexTileSet)
 {
     throw new NotImplementedException();
 }
Exemple #3
0
 public HexSpriteTileInfo(bool isCornerTile, HexTileSet hexTileSet)
 {
     _isCornerTile = isCornerTile;
     _hexTileSet   = hexTileSet;
 }
Exemple #4
0
        protected static void FillTileSpriteIndexes(HexSpriteTileInfo t, HashSet <int> indexes, HexTileSet hexTileSet)
        {
            if (hexTileSet.HasAdditional3WeightSprites && indexes.Count == 6)
            {
                t.AddIndexes(0, 1, 2);
                indexes.Remove(0);
                indexes.Remove(1);
                indexes.Remove(2);
                return;
            }

            int startIndex = indexes.First();
            int step       = 1;

            for (int i = 0; i < 5; i++)
            {
                bool isCurrentIndexTrue = indexes.Contains(startIndex);

                if (!isCurrentIndexTrue)
                {
                    break;
                }

                startIndex -= step;

                //make iteration cycled
                if (startIndex > 5) // must be lesser 5
                {
                    startIndex = 0;
                }

                if (startIndex < 0) // must be bigger 2
                {
                    startIndex = 5;
                }
            }

            int index = startIndex;

            while (t.CanAddMoreIndexes) //max 3 indexes
            {
                bool isCurrentIndexTrue = indexes.Contains(index);

                if (isCurrentIndexTrue)
                {
                    t.AddIndex(index);
                    indexes.Remove(index);
                }
                else
                {
                    if (!t.HasNoAnyIndex)
                    {
                        break;
                    }
                }

                index += step; //nextStep

                //make iteration cycled
                if (index > 5) // must be lesser 5
                {
                    index = 0;
                }

                if (index < 0) // must be bigger 2
                {
                    index = 5;
                }
            }
        }
Exemple #5
0
        protected static List <HexSpriteTileInfo> CalculateHexTiles(HashSet <int> indexes, HexTileSet hexTileSet)
        {
            List <HexSpriteTileInfo> hexSpriteTiles = new List <HexSpriteTileInfo>();

            int iterationCount = 0;

            while (indexes.Count > 0)
            {
                HexSpriteTileInfo t = new HexSpriteTileInfo(true, hexTileSet);
                FillTileSpriteIndexes(t, indexes, hexTileSet);

                hexSpriteTiles.Add(t);

                iterationCount++;
                if (iterationCount > 100)
                {
                    throw new System.Exception();
                }
            }

            if (hexTileSet.HasAdditional3WeightSprites && hexSpriteTiles.Count > 2)
            {
                HexSpriteTileInfo t = new HexSpriteTileInfo(true, hexTileSet);
                t.FullCell = true;
                if (hexSpriteTiles[0].StarterIndex == 0)
                {
                    t.AddIndexes(new int[] { 0, 2, 4 });
                }
                else
                {
                    t.AddIndexes(new int[] { 1, 3, 5 });
                }

                hexSpriteTiles.Clear();

                hexSpriteTiles.Add(t);
            }

            return(hexSpriteTiles);
        }