Пример #1
0
        public static void InitialiseHashGrid(int seed)
        {
            var state = Random.state;

            Random.InitState(seed);

            hashGrid = new HexHash[HashGridSize * HashGridSize];
            for (var i = 0; i < hashGrid.Length; i++)
            {
                hashGrid[i] = HexHash.Create();
            }

            Random.state = state; // restore original state unaltered by explicit seed
        }
        private Transform PickPrefab(HexCell cell, HexHash hash)
        {
            var options = new Dictionary <float, Transform>
            {
                [hash.A] = PickPrefab(UrbanPrefabs, cell.UrbanLevel, hash.A, hash.D),
                [hash.B] = PickPrefab(FarmPrefabs, cell.FarmLevel, hash.B, hash.D),
                [hash.C] = PickPrefab(ForestPrefabs, cell.ForestLevel, hash.C, hash.D)
            };

            var odds = new[] { hash.A, hash.B, hash.C };

            Array.Sort(odds);
            foreach (var o in odds)
            {
                if (options[o])
                {
                    return(options[o]);
                }
            }
            return(null);
        }