Exemplo n.º 1
0
        private void spawnSheep(Utils.RandomProvider random, Vector3 position, int foodLevel, int voice)
        {
            Debug.Log($"spawn position: {position}");
            var sheep = GameObject.Instantiate(sheepPrefab, position, UnityEngine.Random.rotation);

            sheep.random    = random;
            sheep.foodEaten = foodLevel;
            if (voice >= 0)
            {
                sheep.setVoice(voice);
            }
        }
Exemplo n.º 2
0
        private void spawnInitialSheep(WorldData world, Utils.RandomProvider random)
        {
            Debug.Log($"spawning {initialSheepCount} sheep");
            IslandData island      = world.islands[0];
            Vector3    spawnOrigin = island.topsideBounds.center;
            float      maxRadius   = island.topsideBounds.max.magnitude * 0.75f;

            for (int i = 0; i < initialSheepCount; i++)
            {
                int     attempts = 0;
                Vector3 position = Vector3.positiveInfinity;
                while (attempts < 5 && position.x == float.PositiveInfinity)
                {
                    float spawnRadius = random.getFloat(maxRadius);
                    position = Utils.RandomUtils.RandomNavSphere(random, spawnOrigin, spawnRadius, -1);
                    attempts++;
                }
                if (position.x != float.PositiveInfinity)
                {
                    spawnSheep(random, position, 0, -1);
                }
            }
        }