Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- public class PinSetter : MonoBehaviour {
- public Text pinCountDisplay;
- bool ballEnteredBox = false;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- pinCountDisplay.text = CountStanding().ToString();
- }
- int CountStanding(){
- int standing = 0;
- foreach (Pin pin in GameObject.FindObjectsOfType<Pin>()){
- if (pin.IsStanding()){
- standing++;
- }
- }
- return standing;
- }
- void OnTriggerExit(Collider col)
- {
- GameObject thingLeft = col.gameObject;
- if (thingLeft.GetComponent<Pin>())
- {
- print("Pin Left");
- Destroy(thingLeft);
- }
- if (thingLeft.GetComponent<Ball>())
- {
- pinCountDisplay.material.color = Color.green;
- }
- }
- void OnTriggerEnter(Collider col) {
- GameObject thingHit = col.gameObject;
- if (thingHit.GetComponent <Ball>())
- {
- pinCountDisplay.color = Color.red;
- ballEnteredBox = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement