Skip to content

Commit f223e6b

Browse files
committed
Updated with a message about needing more coins or winning
1 parent 88fcdb2 commit f223e6b

6 files changed

Lines changed: 47 additions & 1 deletion

File tree

4.91 KB
Binary file not shown.

Example-UnityScript/Assets/Materials/New Material.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
3.15 KB
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class EndPoint : MonoBehaviour {
6+
void OnTriggerEnter(Collider other) {
7+
// Find the game controller
8+
GameController gc = GameObject.FindGameObjectWithTag ("GameController").GetComponent<GameController> ();
9+
10+
gc.ReachedEndPoint ();
11+
}
12+
}

Example-UnityScript/Assets/Scripts/EndPoint.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example-UnityScript/Assets/Scripts/GameController.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public class GameController : MonoBehaviour {
1010

1111
// UI Element to display score
1212
public Text scoreHUD;
13+
public Text messageBox;
14+
15+
float messageBoxClearTime = 0.0f;
1316

1417
// Stats for player
1518
public int score = 0;
@@ -24,7 +27,9 @@ void Start () {
2427

2528
// Update is called once per frame
2629
void Update () {
27-
30+
if (Time.time > messageBoxClearTime) {
31+
messageBox.text = "";
32+
}
2833
}
2934

3035
/// <summary>
@@ -67,4 +72,13 @@ public void FoundCoin() {
6772
score += 100;
6873
UpdateScoreDisplay();
6974
}
75+
76+
public void ReachedEndPoint() {
77+
if (score < 200) {
78+
messageBox.text = "Go find coins";
79+
} else {
80+
messageBox.text = "YOU WIN!";
81+
}
82+
messageBoxClearTime = Time.time + 2.5f;
83+
}
7084
}

0 commit comments

Comments
 (0)