Exemple #1
0
    // -------------------------------------------------------------------------------

    private void Start()
    {
        mSeedShip = GameManager.Instance.SeedShip;

        // Randomly generate some plants for non-home planetoids!
        if (!IsHomePlanetoid && mPlants.Count == 0)
        {
            Universe     universe     = Universe.Instance;
            PlantManager plantManager = PlantManager.Instance;

            // Randomly spawn some plants
            int numPlantsToSpawn = Random.Range(universe.PlanetoidMinNumPlants, universe.PlanetoidMaxNumPlants);
            for (int i = 0; i < numPlantsToSpawn; i++)
            {
                var plantData = plantManager.GetRandomPlantData(PlanetoidType);

                Vector3 spawnPosition;
                Vector3 spawnNormal;

                if (PlanetoidObjectSpawnHelper.Instance.GetRandomSpawnPosOnPlanetoid(plantData.BaseRadius, out spawnPosition, out spawnNormal))
                {
                    var newPlant = plantManager.SpawnPlant(plantData.PlantType, spawnPosition, this, spawnNormal, false);

                    // Random chance that the plant will start off fully grown
                    if (Random.value >= 0.9f)
                    {
                        newPlant.SetFullyGrown();
                    }
                }
                else
                {
                    Debug.LogWarning("Couldn't find anywhere to spawn plant " + i + " of " + numPlantsToSpawn + " on " + this);
                }
            }
        }
    }