Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. enum State{
  7. Playing,
  8. Stay,
  9. }
  10.  
  11. public class GameController : MonoBehaviour {
  12. public Button coinbt;
  13. public Button[] coinicon;
  14. public int coin = 100;
  15. public Text cointext;
  16.  
  17. public int[] yakuvalue;
  18. public Text[] yakutext;
  19.  
  20. int odds = 0;
  21.  
  22.  
  23.  
  24. public Button[] stopbt;
  25. public Button playbt;
  26.  
  27. public GameObject[] reels;
  28. ReelController[] rc = new ReelController[3];
  29.  
  30. int[] lineL,lineC,lineR;
  31. int stopline_len = 3;
  32. State state = State.Stay;
  33.  
  34.  
  35. void Start () {
  36. for (int i = 0; i < yakutext.Length; i++) {
  37. yakutext[i].text = yakuvalue[i]+"×0";
  38. }
  39.  
  40.  
  41. cointext.text = "Coin:" + coin;
  42. for (int i = 0; i < 3; i++) {
  43. rc[i] = reels [i].GetComponent<ReelController> ();
  44. }
  45.  
  46. }
  47.  
  48.  
  49. void Update () {
  50. if (stopline_len == 3 && state == State.Playing) {
  51. state = State.Stay;
  52. Chack ();
  53. for (int i = 0; i < coinicon.Length; i++) {
  54. coinicon [i].interactable = false;
  55. }
  56. coinbt.interactable = true;
  57. odds = 0;
  58. yakutxtUpdate ();
  59. }
  60.  
  61. if (state == State.Stay && odds != 0) { //Coinを1つでも投入するとプレイできる
  62. playbt.interactable = true;
  63. }
  64.  
  65. }
  66.  
  67. public void Play(){ //Playボタンを押した時の動作
  68. playbt.interactable = false;
  69. stopline_len = 0;
  70. state = State.Playing;
  71. for (int i = 0; i < 3; i++) {
  72. rc [i].Reel_Move ();
  73. stopbt [i].interactable = true;
  74. }
  75.  
  76. }
  77.  
  78. public void Stopbt_f(int id){
  79. stopbt [id].interactable = false;
  80. }
  81.  
  82.  
  83. public void SetLineL(int[] line){
  84. lineL = new int[3];
  85. lineL = line;
  86. stopline_len++;
  87. }
  88. public void SetLineC(int[] line){
  89. lineC = new int[3];
  90. lineC = line;
  91. stopline_len++;
  92. }
  93. public void SetLineR(int[] line){
  94. lineR = new int[3];
  95. lineR = line;
  96. stopline_len++;
  97. }
  98.  
  99.  
  100. public void Chack(){
  101. for(int i = 0;i<3;i++){
  102. if (lineL [i] == lineC [i] &&lineC[i] == lineR[i]) {
  103. switch (i) {
  104. case 0:
  105. Debug.Log ("一番下のラインが揃ったよ。");
  106. break;
  107. case 1:
  108. Debug.Log ("真ん中のラインが揃ったよ。");
  109. break;
  110. case 2:
  111. Debug.Log ("一番上のラインが揃ったよ。");
  112. break;
  113. default:
  114. Debug.Log ("設定ミスでは???");
  115. break;
  116. }
  117.  
  118. Debug.Log(yakuvalue [lineL [i]]*odds+"yen");
  119. coin += yakuvalue [lineL [i]]*odds;
  120. cointext.text = "Coin:" + coin;
  121. }
  122. }
  123.  
  124. if (lineL [0] == lineC [1] && lineC [1] == lineR [2]) {
  125. Debug.Log ("ラインの左下がりが揃ったよ。");
  126.  
  127. Debug.Log(yakuvalue [lineL [0]]*odds+"yen");
  128. coin += yakuvalue [lineL [0]]*odds;
  129. cointext.text = "Coin:" + coin;
  130. }
  131. if (lineL [2] == lineC [1] && lineC [1] == lineR [0]) {
  132. Debug.Log ("ラインの右上がりが揃ったよ。");
  133.  
  134. Debug.Log(yakuvalue [lineL [2]]*odds+"yen");
  135. coin += yakuvalue [lineL [2]]*odds;
  136. cointext.text = "Coin:" + coin;
  137. }
  138. }
  139.  
  140.  
  141.  
  142. public void Buy(){
  143. if (coin <= 0) { //コインがないならリターンする
  144. return;
  145. }
  146.  
  147. if (odds != 2) {
  148. coin--;
  149. odds++;
  150. coinicon [odds - 1].interactable = true;
  151. yakutxtUpdate ();
  152. } else { //odds == 2
  153. coin--;
  154. odds = 3;
  155. coinicon [2].interactable = true;
  156. coinbt.interactable = false;
  157. yakutxtUpdate ();
  158. }
  159.  
  160. cointext.text = "Coin:" + coin;
  161. }
  162.  
  163.  
  164. void yakutxtUpdate(){
  165. for (int i = 0; i < yakutext.Length; i++) {
  166. yakutext[i].text = yakuvalue[i]+"×"+odds;
  167. }
  168. }
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement