IEnumerator countdown() { while (true) { yield return(null); if (timeRemainingSec < countdownTimes.Peek()) { SimplePool.Spawn(CountdownPrefab, Vector3.zero).GetComponent <TimerCountdown>().count = countdownTimes.Dequeue().ToString(); } timeRemainingSec -= Time.deltaTime; if (timeRemainingSec < 0) { timeRemainingSec = 0; setTime(); //stuffs if (!GetComponentInParent <Score>().GameEnd()) { //overtime! UITimer.text = overtime; UITimer.alignment = TextAnchor.MiddleCenter; SimplePool.Spawn(OvertimeCountdownPrefab, Vector3.zero).GetComponent <TimerCountdown>().count = overtime; Observers.Post(new OvertimeMessage()); //and VFX } running = false; yield break; } else { setTime(); } } }
// Update is called once per frame void OnCollisionEnter2D(Collision2D other) { if (!other.collider.CompareTag(Tags.puck)) { return; } other.gameObject.GetComponent <PuckFX>().Hide(); PlayGoalFX(); Observers.Post(new GoalScoredMessage(mySide)); }
public void SliderUpdate() { if (slider == null) { return; //this gets called when everything loads, before start } //update visuals int newValue = (int)(100 * slider.value); SliderPercentLabel.text = (newValue).ToString() + '%'; //update data PlayerPrefs.SetInt(optionString, newValue); PlayerPrefs.Save(); Observers.Post(new Message(optionString)); }
void Start() { if (NetworkNode.node != null) { NetworkNode.node.Subscribe(this); } Observers.Post(new GameEndMessage(this, gameEndTime)); //sends this object around, elements add their data to this object Observers.Clear(GameEndMessage.classMessageType, GoalScoredMessage.classMessageType); //Callback.FireAndForget(() => { Application.LoadLevel(Tags.Scenes.select); Destroy(this); }, gameEndTime, this, mode: Callback.Mode.REALTIME); Callback.FireForUpdate(() => Pause.pause(), this); Callback.FireAndForget(() => { Pause.unPause(); SpawnEndScreen(); }, gameEndTime, this, mode: Callback.Mode.REALTIME); /* * if (leftScore < rightScore) * Instantiate(witchesVictoryPrefab).transform.SetParent(canvas, false); * else if (leftScore > rightScore) * Instantiate(aliensVictoryPrefab).transform.SetParent(canvas, false); */ }