void Start() { NightLight.SetActive(false); DoorEffectObj.SetActive(false); DayBtn.SetActive(false); FirefliesObj.SetActive(false); this.gameObject.SetActive(false); }
IEnumerator SetTimeFalseActive() { this.GetComponent <Animation>().clip = ShowRemove; this.GetComponent <Animation>().Play(); yield return(new WaitForSeconds(0.5f)); this.GetComponent <Animation>().clip = ShowOut; this.gameObject.SetActive(false); if ((GlobalValue.Map == 1) || ((GlobalValue.Map == 2)) || (GlobalValue.Map == 3)) { DayBtn.SetActive(false);//按鈕切換晚上鍵 NightBtn.SetActive(true); DayLight.SetActive(true);//燈光切換白天 NightLight.SetActive(false); PollenObj.SetActive(true); //開啟棉絮 FirefliesObj.SetActive(false); //關閉螢火蟲 DoorObj.SetActive(false); //門消失 DoorEffectObj.SetActive(true); //開啟傳送門效果 } else if (GlobalValue.Map == 0) { DayBtn.SetActive(false);//按鈕切換晚上鍵 NightBtn.SetActive(true); DayLight.SetActive(true);//燈光切換白天 NightLight.SetActive(false); PollenObj.SetActive(true); //開啟棉絮 FirefliesObj.SetActive(false); //關閉螢火蟲 DoorObj.SetActive(true); //門開啟 DoorEffectObj.SetActive(false); //傳送門效果關閉 } else if (GlobalValue.Map == 4) { DayBtn.SetActive(true);//按鈕切換白天鍵 NightBtn.SetActive(false); DayLight.SetActive(false);//燈光切換晚上 NightLight.SetActive(true); PollenObj.SetActive(false); //關閉棉絮 FirefliesObj.SetActive(true); //開啟螢火蟲 DoorObj.SetActive(true); //門開啟 DoorEffectObj.SetActive(false); //傳送門效果關閉 } }
void Update() { if (hasGameStarted) { DayLight.Rotate(DayLight.right, SunSpeed * Time.deltaTime, Space.World); NightLight.Rotate(NightLight.right, SunSpeed * Time.deltaTime, Space.World); if (!IsDayLight() && bDay) { bDay = false; UnityEventManager.TriggerEvent("DayTime", false); DayLight.gameObject.SetActive(false); } else if (IsDayLight() && !bDay) { bDay = true; UnityEventManager.TriggerEvent("DayTime", true); DayLight.gameObject.SetActive(true); } } }