Esempio n. 1
0
    void Update()
    {
        if (isDead)
        {
            return;
        }

        float lifeToUpdate = life + GetLifeUpdateValue();

        DecreasePlantAttributes();

        if (lifeToUpdate > maxLife)
        {
            SetLife(maxLife);
        }
        else if (lifeToUpdate < 0)
        {
            SetLife(0);
        }
        else
        {
            SetLife(lifeToUpdate);
        }
        if (life == 0)
        {
            var plantData = PlantAttributsEventLogger.toJson(plant, getBiomaState().biomaAttributes, plantAttributes);
            EventLogger.Get().Log(new EventModel(LogEventType.PLANT_DIED, plant.name, plantData));
            foreach (var attribute in plant.specs)
            {
                GetComponent <PlantController>().RemoveAttributeNeeded(attribute.Key);
            }
            isDead = true;
        }
        //Debug.Log(plant.name + ": " + life);
    }
Esempio n. 2
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Plant"))
     {
         if (gameObject.CompareTag("SOIL_NUTRIENTS"))
         {
             other.GetComponent <PlantState>().IncreaseSoilNutrients();
         }
         else if (gameObject.CompareTag("SOIL_HUMIDITY"))
         {
             other.GetComponent <PlantState>().IncreaseSoilHumidity();
         }
         else if (gameObject.CompareTag("REMOVE"))
         {
             var plantName = other.gameObject.GetComponent <PlantController>().plant.name;
             Destroy(other.gameObject);
             EventLogger.Get().Log(new EventModel(LogEventType.PLANT_REMOVED, plantName));
         }
         Destroy(gameObject);
     }
 }