示例#1
0
    IEnumerator FlowerRoutine(LinkedListNode <FlowerNeeds> needLink)
    {
        yield return(new WaitForSeconds(timeBeforeNeeding));

        currentNeeds = needLink.Value;
        for (float timer = timeBeforeDying; timer >= 0; timer -= Time.deltaTime)
        {
            if (currentNeeds == FlowerNeeds.Nothing)
            {
                flowerLevel++;
                break;
            }
            yield return(null);
        }
        if (currentNeeds != FlowerNeeds.Nothing)
        {
            Die();
        }
        if (needLink.Next != null)
        {
            StartCoroutine(FlowerRoutine(needLink.Next));
        }
    }
示例#2
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     print("collided with " + collider.gameObject.name);
     if (currentNeeds == FlowerNeeds.Fertilizer && collider.gameObject.tag == "Fertilizer")
     {
         currentNeeds = FlowerNeeds.Nothing;
         Destroy(collider.gameObject);
     }
     if (currentNeeds == FlowerNeeds.Water && collider.gameObject.tag == "Water")
     {
         currentNeeds = FlowerNeeds.Nothing;
         Destroy(collider.gameObject);
     }
     if (currentNeeds == FlowerNeeds.Shovel && collider.gameObject.tag == "Shovel")
     {
         currentNeeds = FlowerNeeds.Nothing;
         Destroy(collider.gameObject);
     }
     if (currentNeeds == FlowerNeeds.Sunlight && collider.gameObject.tag == "Sunlight")
     {
         currentNeeds = FlowerNeeds.Nothing;
         Destroy(collider.gameObject);
     }
 }