// Use this for initialization void Start() { //initialTimer = Time.time; //get plant data myPlantData = this.gameObject.GetComponent <PlantData>(); myPlantData.SetSpeed(); initialPlantSize = myPlantData.gameObject.transform.localScale.x; //get soil data if (SoilOfThePlant) { mySoils = SoilOfThePlant.GetComponent <Soils>(); initialTimer = Time.time - mySoils.mySoilsData.plant_time; } //Debug.Log("mySoils.mySoilsData.plant_time:" + mySoils.mySoilsData.plant_time); //Debug.Log("myPlantData.timeBeforeMature:" + myPlantData.timeBeforeMature+ " myPlantData.timeBeforeFruit:" + myPlantData.timeBeforeFruit + " myPlantData.timeToGatherFruit:" + myPlantData.timeToGatherFruit + " myPlantData.timeBeforeDeath:" + myPlantData.timeBeforeDeath+ " myPlantData.fruitCycles:"+ myPlantData.fruitCycles); if (myPlantData && mySoils.mySoilsData.plant_time == 0) { currentCycle = 1; //# this should be improved //myPlantData.lifetime = ((myPlantData.timeBeforeMature + myPlantData.timeBeforeFruit + myPlantData.timeToGatherFruit) * myPlantData.fruitCycles + myPlantData.timeBeforeDeath)- mySoils.mySoilsData.plant_time; myPlantData.lifetime = ((myPlantData.timeBeforeMature + myPlantData.timeBeforeFruit + myPlantData.timeToGatherFruit) * myPlantData.fruitCycles + myPlantData.timeBeforeDeath); mySoils.mySoilsData.plant_name = myPlantData.plantPrefabName; } else if (myPlantData && mySoils.mySoilsData.plant_time > 0) { myPlantData.lifetime = ((myPlantData.timeBeforeMature + myPlantData.timeBeforeFruit + myPlantData.timeToGatherFruit) * myPlantData.fruitCycles + myPlantData.timeBeforeDeath); mySoils.mySoilsData.plant_name = myPlantData.plantPrefabName; } else { Debug.Log("No plant data found for " + this.gameObject.name); } startDone = true; //update plant happiness state and related appearance InvokeRepeating("UpdatePlantAppearanceHappiness", 0.0f, 1.0f); //Debug.Log("current time:" + Time.time + " initialTimer:" + initialTimer+ " myPlantData.lifetime:" + myPlantData.lifetime); }