//change day to night and vice versa //run through opponent list and ensure all village take an action //if day, display the villages that have perished //if night, lower poison level of well by 1 //water levels of all villages, and player village decrease by one public IEnumerator ChangeTime() { needText = false; springMusicBoxScript.FadeOutMusic(); summerMusicBoxScript.FadeOutMusic(); fallMusicBoxScript.FadeOutMusic(); winterMusicBoxScript.FadeOutMusic(); nightMusicBoxScript.FadeOutMusic(); //fadeOut; FadeToBlack(); //freeze player movement; Vector3 oldCursorPosition = myCursor.transform.position; myCursor.GetComponent <CursorScript> ().Freeze(); myCursor.transform.position = new Vector3(-1000, -1000, -1000); //PAUSE THE GAME, changes to visuals should take place after this point yield return(new WaitForSeconds(duration)); notificationText.text = ""; wellScript.ShootNotification(); //notification text tempText = ""; if (myPlayerVillageScript.GetPlayerVisit()) { if (isDay) { tempText += "while gathering water, agents from the following\nvillages were spotted:\n "; } else { tempText += "while poisoning the well, agents from the\nfollowing villages were spotted:\n "; } } if (dayNumber == 0 && !isDay) { OpponentsMakeDecisionsNight(); } if (isDay) { CommitDecisionsDay(); } else if (!isDay) { CommitDecisionsNight(); } FadeFromBlack(); //update dayNumber, bring the sun back up, etc. if (!isDay) { dayNumber++; dayNumberSeason++; if (dayNumberSeason >= seasonLength * 4) { dayNumberSeason = 0; } } //update day text if (!isDay) { dayNumberText.text = "day " + dayNumber; } else { dayNumberText.text = "night " + dayNumber; } //NOW OPERATING ON NEXT STAGE isDay = !isDay; //consume water before updating population according to growth if (!isDay) { foreach (GameObject opponent in opponentList) { VillageScript opponentScript = opponent.GetComponent <VillageScript> (); opponentScript.ConsumeWater(); opponentScript.UpdatePopulation(); } //player consume water myPlayerVillageScript.ConsumeWater(); myPlayerVillageScript.UpdatePopulation(); } //remove destroyed villages from the list for (int j = opponentList.Count - 1; j > -1; --j) { if (opponentList [j].GetComponent <VillageScript> ().GetPopulation() < 20) { //add in proper death later needText = true; //tempText += opponentList[j].GetComponent<VillageScript>().GetName() + " has perished.\n"; //Destroy (opponentList [j]); opponentList[j].GetComponent <VillageScript>().ActiviateDeathSprite(); opponentList.RemoveAt(j); opponents--; } } //advisors grab stuff here, poison chance if (isDay) { if (witchScript.ReadTheStars() > Random.Range(0, 100)) { guardScript.GetRealInfo(); } else { guardScript.GetFalseInfo(); } witchScript.UpdateWitchText(); } //villages make decision for next day if (isDay) { OpponentsMakeDecisionsDay(); } else if (!isDay) { OpponentsMakeDecisionsNight(); wellScript.processPoison(); } //advisors grab stuff here, drink chance if (!isDay) { if (witchScript.ReadTheStars() > Random.Range(0, 100)) { guardScript.GetRealInfo(); } else { guardScript.GetRealInfo(); guardScript.GetFalseInfo(); } witchScript.UpdateWitchText(); } //change background color according to season if (isDay) { if (dayNumberSeason / seasonLength == 0 || dayNumberSeason <= seasonLength) { camera.backgroundColor = springColor; springWeather.SetActive(true); winterWeather.SetActive(false); springMusicBoxScript.FadeInMusic(); seasonText.text = "spring"; for (int i = 0; i < trees.Length; i++) { trees [i].GetComponent <Renderer> ().material.color = springSummerTreeColor; } } else if ((dayNumberSeason) / seasonLength == 1) { summerWeather.SetActive(true); winterWeather.SetActive(false); summerMusicBoxScript.FadeInMusic(); camera.backgroundColor = summerColor; seasonText.text = "summer"; for (int i = 0; i < trees.Length; i++) { trees [i].GetComponent <Renderer> ().material.color = springSummerTreeColor; } } else if ((dayNumberSeason) / seasonLength == 2) { camera.backgroundColor = fallColor; winterWeather.SetActive(false); seasonText.text = "fall"; fallMusicBoxScript.FadeInMusic(); fallWeather.SetActive(true); for (int i = 0; i < trees.Length; i++) { trees [i].GetComponent <Renderer> ().material.color = fallTreeColor; } } else if ((dayNumberSeason) / seasonLength == 3) { camera.backgroundColor = winterColor; winterWeather.SetActive(false); seasonText.text = "winter"; winterWeather.SetActive(true); winterMusicBoxScript.FadeInMusic(); for (int i = 0; i < trees.Length; i++) { trees [i].GetComponent <Renderer> ().material.color = winterTreeColor; } } } else { springWeather.SetActive(false); summerWeather.SetActive(false); fallWeather.SetActive(false); nightMusicBoxScript.FadeInMusic(); camera.backgroundColor = nightColor; } if (opponents < 1) { SceneManager.LoadScene("Victory"); } myPlayerVillageScript.SetPlayerVisit(false); notificationText.text += tempText; //restore player movement myCursor.GetComponent <CursorScript> ().UnFreeze(); myCursor.transform.position = oldCursorPosition; //check for dying of thirst in opponentList if (!isDay) { for (int i = opponentList.Count - 1; i > -1; --i) { if (opponentList [i].GetComponent <VillageScript> ().GetWaterLevel() < 20) { //add in proper death later opponentList [i].GetComponent <VillageScript> ().MarkForDeath(); } } //check Decimation in Player if (!isDay) { if (myPlayerVillageScript.GetPopulation() < 20) { //add proper death later SceneManager.LoadScene("GameOver"); } } } //update death toll deathTollText.text = deathToll + " have died"; numberOfOpponentsPoisoned = 0; for (int i = 0; i < opponentList.Count; ++i) { if (opponentList [i].GetComponent <VillageScript> ().GetGro() < 0) { numberOfOpponentsPoisoned++; } } if (myPlayerVillageScript.GetGro() < 0) { numberOfOpponentsPoisoned++; } }