// Use this for initialization void Start() { NPCdatabase = FindObjectOfType(typeof(MockNPCDB)) as MockNPCDB; dialogDB = FindObjectOfType(typeof(MockNPCDialog)) as MockNPCDialog; if (this.name.Contains("Emily")) { myself = NPCdatabase.Emily; } else if (this.name.Contains("Riley")) { myself = NPCdatabase.Riley; } else if (this.name.Contains("Tyler")) { myself = NPCdatabase.Tyler; } else if (this.name.Contains("Lily")) { myself = NPCdatabase.Lily; } friendshipPoints = myself.friendship; alreadygifted = myself.gifted; firstTalked = myself.talked; }
// This is the function where the time is reseted each day //not only reseting time values but reseting the soil, //checking the state of our crops and reseting the player stamina public void resetDay() { crops = parent.GetComponentsInChildren <CropBehaviour> (); allTrees = FindObjectsOfType <TreeBehaviour> (); for (int i = 0; i < s.getSoil().Count; i++) { if (s.getSoil() [i].soilType == Soil.SoilTypes.PLOWED || s.getSoil() [i].soilType == Soil.SoilTypes.WATERED) { s.getSoil() [i].soilType = Soil.SoilTypes.NOTPLOWED; s.getSoil() [i].getSoil().GetComponent <Renderer> ().material = notPlowed; } if ((s.getSoil() [i].soilType == Soil.SoilTypes.WATEREDANDPLATED || s.getSoil()[i].soilType == Soil.SoilTypes.PLANTED)) { s.getSoil() [i].soilType = Soil.SoilTypes.PLANTED; s.getSoil() [i].getSoil().GetComponent <Renderer> ().material = plowed; } } for (int i = 0; i < crops.Length; i++) { if (!crops [i].watered && !crops[i].state.Equals(Crops.cropStates.HARVEST)) { if (crops [i].state.Equals(Crops.cropStates.SEED)) { crops [i].dayToS1 += 1; crops [i].dayToS2 += 1; crops [i].dayToHarvest += 1; } if (crops [i].state.Equals(Crops.cropStates.ST1)) { crops [i].dayToS2 += 1; crops [i].dayToHarvest += 1; } if (crops [i].state.Equals(Crops.cropStates.ST2)) { crops [i].dayToHarvest += 1; } crops [i].dry = true; } else { crops [i].dry = false; crops [i].growing(); } } stamina = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerStamina> (); if (stamina.fainted) { stamina.staminaSlider.value = 50; stamina.currentStamina = 50; } else { stamina.staminaSlider.value = 100; stamina.currentStamina = 100; } foreach (TreeBehaviour howManyDays in allTrees) { howManyDays.daysToNextStage -= 1; howManyDays.growingTree(); } MockNPCDB allNpc = FindObjectOfType(typeof(MockNPCDB)) as MockNPCDB; allNpc.Emily.gifted = false; allNpc.Emily.talked = false; allNpc.Riley.gifted = false; allNpc.Riley.talked = false; allNpc.Lily.gifted = false; allNpc.Lily.talked = false; allNpc.Tyler.gifted = false; allNpc.Tyler.talked = false; for (int i = 0; i < spawnFarmAreas.transform.childCount; i++) { for (int j = 0; j < spawnFarmAreas.transform.GetChild(i).childCount; j++) { Destroy(spawnFarmAreas.transform.GetChild(i).GetChild(j).gameObject); } spawnFarmAreas.transform.GetChild(i).GetComponent <SpawnItemsManager> ().spawnedItems = new List <GameObject> (); spawnFarmAreas.transform.GetChild(i).GetComponent <SpawnItemsManager> ().Spawn(); } for (int i = 0; i < spawnRoadAreas.transform.childCount; i++) { for (int j = 0; j < spawnRoadAreas.transform.GetChild(i).childCount; j++) { Destroy(spawnRoadAreas.transform.GetChild(i).GetChild(j).gameObject); } spawnRoadAreas.transform.GetChild(i).GetComponent <SpawnItemsManager> ().spawnedItems = new List <GameObject> (); spawnRoadAreas.transform.GetChild(i).GetComponent <SpawnItemsManager> ().Spawn(); } seconds = 0.0f; hour = 6.0f; day = day + 1; setWeather(); }