public void SetPlantGrowthLevel(PlantGrowthLevel desiredGrowthLevel) { if (justPlanted != null) { justPlanted.gameObject.SetActive(desiredGrowthLevel == PlantGrowthLevel.JustPlanted); } seedling.gameObject.SetActive(desiredGrowthLevel == PlantGrowthLevel.Seedling); readyToHarvest.gameObject.SetActive(desiredGrowthLevel == PlantGrowthLevel.ReadyToHarvest); deadPlant.gameObject.SetActive(desiredGrowthLevel == PlantGrowthLevel.Dead); }
void CheckForDeathUpdate() { /* * if(currentGrowthLevel!= PlantGrowthLevel.JustPlanted && wateredAmount < -1.0f) * { * currentGrowthLevel = PlantGrowthLevel.Dead; * * } */ if (currentGrowthLevel != PlantGrowthLevel.Dead) { // bool plantShouldDie = (currentGrowthLevel != PlantGrowthLevel.JustPlanted && wateredAmount < thirstDeathLevel); bool plantShouldDie = (currentGrowthLevel == PlantGrowthLevel.Seedling && wateredAmount < THIRST_DEATH_LEVEL); if (plantShouldDie) { currentGrowthLevel = PlantGrowthLevel.Dead; SetPlantGrowthLevel(currentGrowthLevel); } } }
public void OnDayFinishPlant() { daysAlive++; float currentGrowthRate = GetGrowthRate(); growthCounter += currentGrowthRate; // --- Decrease watered amount ---------------- if (currentGrowthLevel != PlantGrowthLevel.JustPlanted && currentGrowthLevel != PlantGrowthLevel.Dead) { wateredAmount -= 1; } // Grow from seedling to ready to harvest if (currentGrowthLevel == PlantGrowthLevel.Seedling && growthCounter >= daysToBecomeReadyToHarvest) { currentGrowthLevel = PlantGrowthLevel.ReadyToHarvest; SetPlantGrowthLevel(currentGrowthLevel); if (collectibleCollider != null) { collectibleCollider.SetActive(true); } } // Grow from JustPlanted to seedling if (currentGrowthLevel == PlantGrowthLevel.JustPlanted && growthCounter >= daysToBecomeSeedling) { currentGrowthLevel = PlantGrowthLevel.Seedling; SetPlantGrowthLevel(currentGrowthLevel); } CheckForDeathUpdate(); //SET DEBUG VALUES TO OBSERVE IN INSPECTOR currentGrowthRateDBG = currentGrowthRate; }