//=================================================================================================================== private void open(bool instantly, System.DateTime currentTime) { //Remember the timer in this room has reached 0. timeReached = true; //Create a new room, set its timer to end next year. GameObject r = Instantiate(roomPrefab, transform.position + new Vector3(0, 0, 8), Quaternion.identity) as GameObject; RoomCtrl rCtrl = r.GetComponent <RoomCtrl>(); rCtrl.setName(roomNumber + 1); rCtrl.setEndTime(endTime.AddYears(1), currentTime); // rCtrl.tick(currentTime); //Open this room's door. if (instantly) { GetComponentInChildren <Animator>().SetTrigger("AlreadyOpen"); } else { GetComponentInChildren <Animator>().SetTrigger("Open"); aSource.PlayOneShot(doorDing); } display.text = "000:00:00:00"; }
void Start() { lobbyCtrl = LobbyObject.GetComponent <LobbyCtrl>(); loginCtrl = LoginObject.GetComponent <LoginCtrl>(); roomCtrl = RoomObject.GetComponent <RoomCtrl>(); LobbyObject.SetActive(false); RoomObject.SetActive(false); SocketStart(); }
//=================================================================================================================== private IEnumerator Start() { //Try to GET the current time. WWW www = new WWW(URL); yield return(www); //If get fails, try again every 3 seconds. while (!string.IsNullOrEmpty(www.error)) { yield return(new WaitForSeconds(3)); www = new WWW(URL); yield return(www); } //Get some components. GameObject g = GameObject.FindWithTag("Player"); move = g.GetComponent <MoveCtrl>(); blur = g.GetComponentInChildren <UnityStandardAssets.ImageEffects.BlurOptimized>(); // Prepare received data. TimeJson timeJson = new TimeJson(); JsonUtility.FromJsonOverwrite(www.text, timeJson); //Unix timestamp is seconds past epoch System.DateTime dtDateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); string currentDate = dtDateTime.AddSeconds(timeJson.timestamp - timeJson.gmtOffset).ToLocalTime().ToString(); //Set up current time and end time. System.DateTime currentTime = System.DateTime.Parse(currentDate); System.DateTime startTime = new System.DateTime(1991, 5, 8, 15, 15, 0); //Build the first room. GameObject r = Instantiate(roomPrefab, Vector3.zero, Quaternion.identity) as GameObject; RoomCtrl rCtrl = r.GetComponent <RoomCtrl>(); rCtrl.setEndTime(startTime.AddYears(1), currentTime); rCtrl.setName(0); //Pass the current time to the time controller, it'll take it from here. GetComponent <TimeCtrl>().setCurrentTime(currentTime); //Tell the UI that we are ready, we can start the game. GameObject.FindWithTag("UI").GetComponent <UICtrl>().Ready = true; }