void Awake() { if (instance == null) { instance = this; } }
// Update is called once per frame void Update() { int count = RuntimeGameDataManager.GetCount(); countText.text = count.ToString(); if (RuntimeGameDataManager.IsWin()) { winText.text = "You Win!"; } }
// When this game object intersects a collider with 'is trigger' checked, // store a reference to that collider in a variable named 'other'.. void OnTriggerEnter(Collider other) { // ..and if the game object we intersect has the tag 'Pick Up' assigned to it.. if (other.gameObject.CompareTag("Pick Up")) { // Make the other game object (the pick up) inactive, to make it disappear other.gameObject.SetActive(false); // Add one to the score variable 'count' //count = count + 1; // Run the 'SetCountText()' function (see below) //SetCountText (); // step 0 RuntimeGameDataManager.AddCount(1); // step 1 } }
// Update is called once per frame void _UpdateData() { // observer pattern int uiDataStamp = RuntimeGameDataManager.GetDataStamp(); if (uiDataStamp != _uiDataStamp) { _uiDataStamp = uiDataStamp; // update ui data stamp int count = RuntimeGameDataManager.GetCount(); countText.text = count.ToString(); if (RuntimeGameDataManager.IsWin()) { winText.text = "You Win!"; } } }