protected List <HexSpriteTileInfo> CreateRandomCenterIndexes() { List <HexSpriteTileInfo> hexSpriteTiles = new List <HexSpriteTileInfo>(); System.Random cellRandomizer; cellRandomizer = new System.Random(X * Y); HexSpriteTileInfo t = new HexSpriteTileInfo(false, hexTileSet); int randomTileIndex; if (cellRandomizer.Next(100) < 70 && hexTileSet.centerHexTiles.Length > 2) { randomTileIndex = cellRandomizer.Next(3); } else { randomTileIndex = cellRandomizer.Next(hexTileSet.centerHexTiles.Length); } t.AddIndex(randomTileIndex); hexSpriteTiles.Add(t); return(hexSpriteTiles); }
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; } } }