Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4.  
  5. public class PinSetter : MonoBehaviour {
  6. public Text pinCountDisplay;
  7. bool ballEnteredBox = false;
  8.  
  9. // Use this for initialization
  10. void Start () {
  11.  
  12. }
  13.  
  14. // Update is called once per frame
  15. void Update () {
  16.  
  17. pinCountDisplay.text = CountStanding().ToString();
  18.  
  19. }
  20.  
  21. int CountStanding(){
  22. int standing = 0;
  23. foreach (Pin pin in GameObject.FindObjectsOfType<Pin>()){
  24. if (pin.IsStanding()){
  25. standing++;
  26. }
  27. }
  28. return standing;
  29. }
  30.  
  31. void OnTriggerExit(Collider col)
  32. {
  33. GameObject thingLeft = col.gameObject;
  34. if (thingLeft.GetComponent<Pin>())
  35. {
  36. print("Pin Left");
  37. Destroy(thingLeft);
  38. }
  39. if (thingLeft.GetComponent<Ball>())
  40. {
  41. pinCountDisplay.material.color = Color.green;
  42. }
  43. }
  44.  
  45. void OnTriggerEnter(Collider col) {
  46. GameObject thingHit = col.gameObject;
  47. if (thingHit.GetComponent <Ball>())
  48. {
  49. pinCountDisplay.color = Color.red;
  50. ballEnteredBox = true;
  51. }
  52.  
  53. }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement