123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- public class Reel : MonoBehaviour
- {
- private void Awake()
- {
- this.state = 0;
- this.childList = base.transform.gameObject.GetComponentsInChildren<ReelScroll>();
- this.sManager = GameObject.Find("SlotManager").GetComponent<SlotManager>();
- this.childList[0].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0f, 0f));
- this.childList[1].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0f, 0f));
- this.startTime = 0f;
- this.keepTime = 0f;
- this.isSlide = false;
- this.time = 0f;
- this.slipStopNo = 0;
- this.slipNoToOffset = 0f;
- this.dontStopPlace = new List<int>();
- this.dontStopSymbol = new List<int>();
- }
- private void Update()
- {
- if (this.state == 2 || this.isSlide)
- {
- this.time = Time.time - this.startTime + this.keepTime;
- this.scroll = Mathf.Repeat(this.time * this.speed, 1f);
- this.offset = new Vector2(0f, this.scroll);
- this.childList[0].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", this.offset);
- this.childList[1].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", this.offset);
- }
- this.StateCheck();
- }
- private void StateCheck()
- {
- if (this.state == 1)
- {
- this.speed = 1.2f;
- this.state = 2;
- this.startTime = Time.time;
- }
- if (this.state == 3)
- {
- int num = (int)(this.scroll / 0.04761905f + this.slip);
- float num2 = (float)num / 21f;
- this.reelNo = num + 9;
- if (this.reelNo > 21)
- {
- this.reelNo -= 21;
- }
- this.symbolNo = SlotManager.reelArray[this.id, 21 - this.reelNo];
- if (this.sManager.fixedWinSymbol == -1 && this.sManager.reachFlg)
- {
- int num3 = 0;
- using (List<int>.Enumerator enumerator = this.sManager.reachLine.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- switch (enumerator.Current)
- {
- case 1:
- this.dontStopPlace.Add(0);
- this.dontStopSymbol.Add(this.sManager.reachSymbolList[num3]);
- break;
- case 2:
- this.dontStopPlace.Add(-1);
- this.dontStopSymbol.Add(this.sManager.reachSymbolList[num3]);
- break;
- case 3:
- this.dontStopPlace.Add(1);
- this.dontStopSymbol.Add(this.sManager.reachSymbolList[num3]);
- break;
- case 4:
- this.dontStopPlace.Add(this.id - 1);
- this.dontStopSymbol.Add(this.sManager.reachSymbolList[num3]);
- break;
- case 5:
- this.dontStopPlace.Add(1 - this.id);
- this.dontStopSymbol.Add(this.sManager.reachSymbolList[num3]);
- break;
- }
- num3++;
- }
- }
- }
- this.state = 4;
- }
- if (this.state == 4)
- {
- if (this.symbolNo == 6 && this.id == 0 && !this.isSlide && !this.sManager.isChanceMode && this.sManager.normalCount <= 20)
- {
- this.slip = 3f;
- }
- int num4 = 0;
- foreach (int num5 in this.dontStopSymbol)
- {
- if (num5 != 3)
- {
- for (;;)
- {
- int num6 = (int)(this.scroll / 0.04761905f + this.slip);
- float num7 = (float)num6 / 21f;
- int num8 = num6 + 9 - this.dontStopPlace[num4];
- if (num8 > 21)
- {
- num8 -= 21;
- }
- else if (num8 <= 0)
- {
- num8 += 21;
- }
- if (num5 != SlotManager.reelArray[this.id, 21 - num8] || this.sManager.fixedWinSymbol != -1)
- {
- break;
- }
- this.slip += 1f;
- }
- }
- num4++;
- }
- if (!this.isSlide)
- {
- this.slipStopNo = (int)(this.scroll / 0.04761905f + this.slip);
- this.slipNoToOffset = (float)this.slipStopNo / 21f;
- if (this.sManager.fixedWinSymbol != -1)
- {
- for (int i = 0; i < 12; i++)
- {
- this.slipStopNo = (int)(this.scroll / 0.04761905f + (float)i + 1f);
- this.slipNoToOffset = (float)this.slipStopNo / 21f;
- this.reelNo = this.slipStopNo + 9 - (this.sManager.fixedLine - 1);
- if (this.reelNo > 21)
- {
- this.reelNo -= 21;
- }
- if (SlotManager.reelArray[this.id, 21 - this.reelNo] == this.sManager.fixedWinSymbol)
- {
- break;
- }
- }
- }
- this.isSlide = true;
- }
- if (this.isSlide)
- {
- this.slipNoToOffset = (float)this.slipStopNo / 21f;
- if (this.slipNoToOffset >= 1f)
- {
- this.slipNoToOffset -= 1f;
- }
- if (this.scroll >= this.slipNoToOffset)
- {
- this.offset = new Vector2(0f, this.slipNoToOffset);
- this.childList[0].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", this.offset);
- this.childList[1].GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", this.offset);
- if (this.sManager.fixedLine != -1)
- {
- this.reelNo = this.slipStopNo + 9;
- }
- else
- {
- this.reelNo = this.slipStopNo + 9;
- }
- if (this.reelNo > 21)
- {
- this.reelNo -= 21;
- }
- this.symbolNo = SlotManager.reelArray[this.id, 21 - this.reelNo];
- this.isSlide = false;
- }
- }
- if (!this.isSlide)
- {
- this.speed = 0f;
- this.slip = 1f;
- this.keepTime = this.time;
- this.state = 0;
- this.slipStopNo = 0;
- this.slipNoToOffset = 0f;
- this.dontStopPlace = new List<int>();
- this.dontStopSymbol = new List<int>();
- }
- }
- if (this.state == 0)
- {
- this.state = 5;
- }
- }
- public void ChangeState(int newState)
- {
- this.state = newState;
- }
- public const int STATE_STOP = 0;
- public const int STATE_PUSH_START = 1;
- public const int STATE_START = 2;
- public const int STATE_PUSH_STOP = 3;
- public const int STATE_STOP_WAIT = 4;
- public const int STATE_WAIT = 5;
- public int state;
- public int id;
- public int reelNo;
- public float slip = 1f;
- private int symbolNo;
- private float time;
- private float keepTime;
- private float startTime;
- [Range(0f, 10f)]
- public float speed = 10f;
- public int spriteCount = 2;
- private Vector3 spriteSize;
- private Vector3 stopPosition;
- public ReelScroll[] childList;
- private float scroll;
- private Vector2 offset;
- private SlotManager sManager;
- private bool isSlide;
- private int slipStopNo;
- private float slipNoToOffset;
- private List<int> dontStopSymbol;
- private List<int> dontStopPlace;
- }
|