// Use this for initialization
 public void GenerateSeed(GameObject centerpoint, FlowerStats flowerstatz, int seednum)
 {
     if (seednum > 0)
     {
         GameObject seed = Instantiate(Seed, centerpoint.transform.position, Quaternion.identity, centerpoint.transform);
         seed.GetComponent <SeedScript>().GetSeedParentStats(flowerstatz);
         Debug.Log(seednum);
         if (seednum > 1)
         {
             for (int i = 1; i < seednum; i++)
             {
                 GameObject newflower = Instantiate(centerpoint, centerpoint.transform.position, Quaternion.identity);
                 for (int j = newflower.transform.childCount - 1; j >= 0; j--)
                 {
                     Destroy(newflower.transform.GetChild(j).gameObject);
                 }
                 seed = Instantiate(Seed, newflower.transform.position, Quaternion.identity, newflower.transform);
                 seed.GetComponent <SeedScript>().GetSeedParentStats(flowerstatz);
             }
         }
     }
     else
     {
         PetalDrawer[] petals;
         petals = centerpoint.GetComponentsInChildren <PetalDrawer>();
         foreach (PetalDrawer petal in petals)
         {
             //Debug.Log("trying to call petaldrawer");
             if (petal != null)
             {
                 petal.lifec = PetalDrawer.LifeCycle.dying;
             }
         }
     }
 }
    FlowerStats CreateFlowerStats()
    {
        FlowerStats flowerstatz = new FlowerStats();

        flowerstatz.flowertype       = MakeFlowerType(Random.value);
        flowerstatz.flowercolor      = MakeColor(Random.value);
        flowerstatz.foodpullfactor   = Random.Range(2f, 10f);
        flowerstatz.foodpulldistance = Random.Range(6f, 12f);
        flowerstatz.size             = Random.value * 0.8f + 0.5f;
        return(flowerstatz);
    }
    public IEnumerator GeneratePetal(int petalnum, GameObject centerpoint, FlowerStats flower)
    {
        if (centerpoint == null)
        {
            Vector3 position = new Vector3(Random.Range(-8f, 8f), Random.Range(5f, 9f), Random.Range(-2f, 5f));
            centerpoint = Instantiate(CenterPoint, position, Quaternion.identity);
            Flowers.Add(centerpoint);
            flower = CreateFlowerStats();
            while (!PositionOK)
            {
                CheckFlowerPosition();
                Debug.Log(PositionOK);
            }
        }
        int   rand      = Random.Range(0, 5000);
        float anglestep = 360f / petalnum;
        float angle     = 0;

        for (int i = 0; i < petalnum; i++)
        {
            GameObject petal = Instantiate(Petal, centerpoint.transform.position, Quaternion.Euler(0, 0, angle), centerpoint.transform);
            petal.GetComponent <PetalDrawer>().Randomseed = rand;
            angle += anglestep;
            if (flower != null)
            {
                if (centerpoint.GetComponent <AFlower>() == null)
                {
                    if (flower.flowertype == FlowerStats.FlowerType.triFlower)
                    {
                        centerpoint.AddComponent <TriFlower>();
                    }
                    else if (flower.flowertype == FlowerStats.FlowerType.bulbFlower)
                    {
                        centerpoint.AddComponent <BulbFlower>();
                    }
                    else if (flower.flowertype == FlowerStats.FlowerType.roundFlower)
                    {
                        centerpoint.AddComponent <RoundFlower>();
                    }
                }
                petal.GetComponent <PetalDrawer>().GetFlowerStats(flower);
                centerpoint.GetComponent <AFlower>().flowerstats = flower;
            }
            yield return(new WaitForSeconds(0.05f));
        }
    }
Example #4
0
 public void GetSeedParentStats(FlowerStats flowerstatz)
 {
     flowerstats = flowerstatz;
     //Debug.Log(flower);
 }
Example #5
0
 public void GetFlowerStats(FlowerStats flowerstatz)
 {
     flowerstats = flowerstatz;
 }