// Update is called once per frame void Update() { if (Input.GetKeyDown(key) && inCollision) { Debug.Log(this.gameObject + "bingo"); scorePort.AddScore(); ExitCollision(inCollision); } }
/// <summary> /// Adds points to the player's score. /// </summary> /// <param name="points"> Number of points to add </param> private void AddScore(int points) { score += points; reference.statistics.AddScore(points); if (scoreDisplay != null) { scoreDisplay.AddScore(points); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { SoundManager.SingletonInstance.PlaySE("itemget", false, 0.3f); scoreDisplay.AddScore(itemId); ScoreManager.SingletonInstance.AddItem(itemId, 1); Destroy(this.gameObject); } }
void OnTriggerEnter(Collider col) { if (col.tag == "Interactable") { Interactable box = col.GetComponent <Interactable>(); if (!box.scored) { scoreDisplay.AddScore(col.GetComponent <Interactable>().GetPoints); box.scored = true; box.Destroy(); } } }
void Update() { if (scoreDisplay == null) { GameObject canvas = GameObject.Find("ScoreCanvas"); scoreDisplay = canvas.GetComponent <ScoreDisplay>(); } else { for (int i = 0; i < names.Count; i++) { ScoreDisplay.Score score = new ScoreDisplay.Score(names[i], scores[i], i); scoreDisplay.AddScore(score); } scoreDisplay.DisplayScores(); Destroy(gameObject); } }