You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
3.2 KiB

  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. public class sceneController : MonoBehaviour {
  5. public GameObject player1;
  6. public GameObject player2;
  7. public GameObject player3;
  8. public GameObject player4;
  9. public levelController control;
  10. private int playerCount;
  11. public GameObject options;
  12. public bool paused = false;
  13. public GameObject confettiText;
  14. public GameObject scoreText;
  15. public playerId id1;
  16. public playerId id2;
  17. public playerId id3;
  18. public playerId id4;
  19. private playerController playerScript1;
  20. private playerController playerScript2;
  21. private playerController playerScript3;
  22. private playerController playerScript4;
  23. private bool exit = false;
  24. // Use this for initialization
  25. void Awake(){
  26. playerScript1 = player1.GetComponent<playerController> ();
  27. playerScript2 = player2.GetComponent<playerController> ();
  28. playerScript3 = player3.GetComponent<playerController> ();
  29. playerScript4 = player4.GetComponent<playerController> ();
  30. }
  31. void Start () {
  32. control = GameObject.FindGameObjectWithTag ("GameController").GetComponent<levelController> ();
  33. player1.SetActive (control.p1Enabled);
  34. player2.SetActive (control.p2Enabled);
  35. player3.SetActive (control.p3Enabled);
  36. player4.SetActive (control.p4Enabled);
  37. playerScript1.maxScore = control.maxScore;
  38. playerScript2.maxScore = control.maxScore;
  39. playerScript3.maxScore = control.maxScore;
  40. playerScript4.maxScore = control.maxScore;
  41. playerScript1.confettiOnHit = control.confetti;
  42. playerScript2.confettiOnHit = control.confetti;
  43. playerScript3.confettiOnHit = control.confetti;
  44. playerScript4.confettiOnHit = control.confetti;
  45. }
  46. // Update is called once per frame
  47. void Update () {
  48. if (Input.GetButtonDown("start")) {
  49. paused = !paused;
  50. }
  51. optionsSelect ();
  52. }
  53. public void optionsSelect(){
  54. if (paused) {
  55. Time.timeScale = 0.0f;
  56. options.SetActive (true);
  57. } else if (!paused) {
  58. Time.timeScale = 1.0f;
  59. options.SetActive (false);
  60. }
  61. if (exit) {
  62. Time.timeScale = 1.0f;
  63. Application.LoadLevel("Menu_Scene");
  64. }
  65. }
  66. public void confetti(float confettiAmount){
  67. control.confetti = Mathf.RoundToInt(confettiAmount);
  68. confettiText.GetComponent<Text> ().text = "" + Mathf.RoundToInt(confettiAmount);
  69. playerScript1.confettiOnHit = control.confetti;
  70. playerScript2.confettiOnHit = control.confetti;
  71. playerScript3.confettiOnHit = control.confetti;
  72. playerScript4.confettiOnHit = control.confetti;
  73. }
  74. public void sccore (float scoreMax){
  75. control.maxScore = Mathf.RoundToInt(scoreMax);
  76. scoreText.GetComponent<Text> ().text = "" + Mathf.RoundToInt(scoreMax);
  77. playerScript1.maxScore = control.maxScore;
  78. playerScript2.maxScore = control.maxScore;
  79. playerScript3.maxScore = control.maxScore;
  80. playerScript4.maxScore = control.maxScore;
  81. }
  82. public void mute (bool muted){
  83. if (muted)
  84. AudioListener.volume = 0.0f;
  85. else
  86. AudioListener.volume = 1.0f;
  87. }
  88. public void dispID (bool visible){
  89. id1.idVanishDisp = visible;
  90. id2.idVanishDisp = visible;
  91. id3.idVanishDisp = visible;
  92. id4.idVanishDisp = visible;
  93. }
  94. public void exitLevel (){
  95. Time.timeScale = 1.0f;
  96. exit = true;
  97. }
  98. public void resumeGame(){
  99. paused = false;
  100. }
  101. }