Reel.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Reel : MonoBehaviour
  5. {
  6. private void Awake()
  7. {
  8. this.state = 0;
  9. this.childList = base.transform.gameObject.GetComponentsInChildren<ReelScroll>();
  10. this.sManager = GameObject.Find("SlotManager").GetComponent<SlotManager>();
  11. this.childList[0].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0f, 0f));
  12. this.childList[1].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0f, 0f));
  13. this.startTime = 0f;
  14. this.keepTime = 0f;
  15. this.isSlide = false;
  16. this.time = 0f;
  17. this.slipStopNo = 0;
  18. this.slipNoToOffset = 0f;
  19. this.dontStopPlace = new List<int>();
  20. this.dontStopSymbol = new List<int>();
  21. }
  22. private void Update()
  23. {
  24. if (this.state == 2 || this.isSlide)
  25. {
  26. this.time = Time.time - this.startTime + this.keepTime;
  27. this.scroll = Mathf.Repeat(this.time * this.speed, 1f);
  28. this.offset = new Vector2(0f, this.scroll);
  29. this.childList[0].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", this.offset);
  30. this.childList[1].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", this.offset);
  31. }
  32. this.StateCheck();
  33. }
  34. private void StateCheck()
  35. {
  36. if (this.state == 1)
  37. {
  38. this.speed = 1.2f;
  39. this.state = 2;
  40. this.startTime = Time.time;
  41. }
  42. if (this.state == 3)
  43. {
  44. int num = (int)(this.scroll / 0.04761905f + this.slip);
  45. float num2 = (float)num / 21f;
  46. this.reelNo = num + 9;
  47. if (this.reelNo > 21)
  48. {
  49. this.reelNo -= 21;
  50. }
  51. this.symbolNo = SlotManager.reelArray[this.id, 21 - this.reelNo];
  52. if (this.sManager.fixedWinSymbol == -1 && this.sManager.reachFlg)
  53. {
  54. int num3 = 0;
  55. using (List<int>.Enumerator enumerator = this.sManager.reachLine.GetEnumerator())
  56. {
  57. while (enumerator.MoveNext())
  58. {
  59. switch (enumerator.Current)
  60. {
  61. case 1:
  62. this.dontStopPlace.Add(0);
  63. this.dontStopSymbol.Add(this.sManager.reachSymbolList[num3]);
  64. break;
  65. case 2:
  66. this.dontStopPlace.Add(-1);
  67. this.dontStopSymbol.Add(this.sManager.reachSymbolList[num3]);
  68. break;
  69. case 3:
  70. this.dontStopPlace.Add(1);
  71. this.dontStopSymbol.Add(this.sManager.reachSymbolList[num3]);
  72. break;
  73. case 4:
  74. this.dontStopPlace.Add(this.id - 1);
  75. this.dontStopSymbol.Add(this.sManager.reachSymbolList[num3]);
  76. break;
  77. case 5:
  78. this.dontStopPlace.Add(1 - this.id);
  79. this.dontStopSymbol.Add(this.sManager.reachSymbolList[num3]);
  80. break;
  81. }
  82. num3++;
  83. }
  84. }
  85. }
  86. this.state = 4;
  87. }
  88. if (this.state == 4)
  89. {
  90. if (this.symbolNo == 6 && this.id == 0 && !this.isSlide && !this.sManager.isChanceMode && this.sManager.normalCount <= 20)
  91. {
  92. this.slip = 3f;
  93. }
  94. int num4 = 0;
  95. foreach (int num5 in this.dontStopSymbol)
  96. {
  97. if (num5 != 3)
  98. {
  99. for (;;)
  100. {
  101. int num6 = (int)(this.scroll / 0.04761905f + this.slip);
  102. float num7 = (float)num6 / 21f;
  103. int num8 = num6 + 9 - this.dontStopPlace[num4];
  104. if (num8 > 21)
  105. {
  106. num8 -= 21;
  107. }
  108. else if (num8 <= 0)
  109. {
  110. num8 += 21;
  111. }
  112. if (num5 != SlotManager.reelArray[this.id, 21 - num8] || this.sManager.fixedWinSymbol != -1)
  113. {
  114. break;
  115. }
  116. this.slip += 1f;
  117. }
  118. }
  119. num4++;
  120. }
  121. if (!this.isSlide)
  122. {
  123. this.slipStopNo = (int)(this.scroll / 0.04761905f + this.slip);
  124. this.slipNoToOffset = (float)this.slipStopNo / 21f;
  125. if (this.sManager.fixedWinSymbol != -1)
  126. {
  127. for (int i = 0; i < 12; i++)
  128. {
  129. this.slipStopNo = (int)(this.scroll / 0.04761905f + (float)i + 1f);
  130. this.slipNoToOffset = (float)this.slipStopNo / 21f;
  131. this.reelNo = this.slipStopNo + 9 - (this.sManager.fixedLine - 1);
  132. if (this.reelNo > 21)
  133. {
  134. this.reelNo -= 21;
  135. }
  136. if (SlotManager.reelArray[this.id, 21 - this.reelNo] == this.sManager.fixedWinSymbol)
  137. {
  138. break;
  139. }
  140. }
  141. }
  142. this.isSlide = true;
  143. }
  144. if (this.isSlide)
  145. {
  146. this.slipNoToOffset = (float)this.slipStopNo / 21f;
  147. if (this.slipNoToOffset >= 1f)
  148. {
  149. this.slipNoToOffset -= 1f;
  150. }
  151. if (this.scroll >= this.slipNoToOffset)
  152. {
  153. this.offset = new Vector2(0f, this.slipNoToOffset);
  154. this.childList[0].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", this.offset);
  155. this.childList[1].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", this.offset);
  156. if (this.sManager.fixedLine != -1)
  157. {
  158. this.reelNo = this.slipStopNo + 9;
  159. }
  160. else
  161. {
  162. this.reelNo = this.slipStopNo + 9;
  163. }
  164. if (this.reelNo > 21)
  165. {
  166. this.reelNo -= 21;
  167. }
  168. this.symbolNo = SlotManager.reelArray[this.id, 21 - this.reelNo];
  169. this.isSlide = false;
  170. }
  171. }
  172. if (!this.isSlide)
  173. {
  174. this.speed = 0f;
  175. this.slip = 1f;
  176. this.keepTime = this.time;
  177. this.state = 0;
  178. this.slipStopNo = 0;
  179. this.slipNoToOffset = 0f;
  180. this.dontStopPlace = new List<int>();
  181. this.dontStopSymbol = new List<int>();
  182. }
  183. }
  184. if (this.state == 0)
  185. {
  186. this.state = 5;
  187. }
  188. }
  189. public void ChangeState(int newState)
  190. {
  191. this.state = newState;
  192. }
  193. public const int STATE_STOP = 0;
  194. public const int STATE_PUSH_START = 1;
  195. public const int STATE_START = 2;
  196. public const int STATE_PUSH_STOP = 3;
  197. public const int STATE_STOP_WAIT = 4;
  198. public const int STATE_WAIT = 5;
  199. public int state;
  200. public int id;
  201. public int reelNo;
  202. public float slip = 1f;
  203. private int symbolNo;
  204. private float time;
  205. private float keepTime;
  206. private float startTime;
  207. [Range(0f, 10f)]
  208. public float speed = 10f;
  209. public int spriteCount = 2;
  210. private Vector3 spriteSize;
  211. private Vector3 stopPosition;
  212. public ReelScroll[] childList;
  213. private float scroll;
  214. private Vector2 offset;
  215. private SlotManager sManager;
  216. private bool isSlide;
  217. private int slipStopNo;
  218. private float slipNoToOffset;
  219. private List<int> dontStopSymbol;
  220. private List<int> dontStopPlace;
  221. }