123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- using System;
- using System.Collections;
- using UnityEngine;
- public class Card : MonoBehaviour
- {
- public bool IsMoveend
- {
- get
- {
- return this.m_IsMoveend;
- }
- }
- private void Reset()
- {
- this.m_MyRenderer = base.GetComponent<MeshRenderer>();
- }
- private void PosYFixed()
- {
- Vector3 position = base.transform.position;
- position.y = this.EndPosition.y;
- base.transform.position = position;
- }
- private IEnumerator CardMove()
- {
- this.m_MyRenderer.enabled = false;
- float timer = this.InitTime;
- while (timer <= this.StartTime)
- {
- timer += Time.deltaTime;
- yield return null;
- }
- this.m_MyRenderer.enabled = true;
- BlackjackGame.Instance.CardSe.Play();
- bool is_player = base.transform.parent == BjPlayer.Instance.CurrentHand.transform;
- Vector3 orijin_pos = base.transform.position;
- bool hand_switch = false;
- for (;;)
- {
- timer += Time.deltaTime;
- if (!hand_switch)
- {
- hand_switch = (timer > this.SwitchTime);
- base.transform.position = BjMotionControl.Instance.LeftHandPos();
- float num = this.StartTime + (this.SwitchTime - this.StartTime) / 2f;
- float t = KasaiUtility.SinRate01(timer - num, this.SwitchTime - num, false, false);
- this.m_OpenTime = this.SwitchTime - num;
- if (this.CurrentState == Card.CardState.FlipUp)
- {
- base.transform.eulerAngles = Vector3.Lerp(CardDeck.Instance.FlipdownAngle, CardDeck.Instance.FlipupAngle, t);
- }
- }
- else
- {
- Vector3 position = BjMotionControl.Instance.RightHandPos();
- float num2 = KasaiUtility.SinRate01(timer - this.SwitchTime, this.CardSetTime - this.SwitchTime, false, false);
- this.m_IsMoveend = (timer > this.CardSetTime);
- if (is_player)
- {
- position.x -= CardDeck.Instance.RightOffset * num2;
- }
- else if (BjPlayer.Instance.IsturnEnd)
- {
- this.m_IsMoveend = (Dealer.Instance.LastCardPos.z < position.z);
- position.z = Mathf.Min(Dealer.Instance.LastCardPos.z, position.z);
- }
- base.transform.position = position;
- if (this.m_IsMoveend)
- {
- break;
- }
- }
- this.PosYFixed();
- yield return null;
- }
- this.PosYFixed();
- BlackjackGame.Instance.DealQueue.CardTimer = timer;
- this.MovingCallback(base.gameObject);
- yield break;
- yield break;
- }
- private IEnumerator CardOpen()
- {
- float timer = this.InitTime;
- if (this.CurrentState != Card.CardState.Open)
- {
- yield break;
- }
- bool near_hand = false;
- for (;;)
- {
- if (!near_hand)
- {
- near_hand = (timer > this.StartTime);
- if (near_hand)
- {
- BlackjackGame.Instance.CardSe.Play();
- }
- }
- else
- {
- base.transform.position = BjMotionControl.Instance.LeftHandPos();
- float t = KasaiUtility.SinRate01(timer - this.StartTime, this.m_OpenTime, false, false);
- base.transform.eulerAngles = Vector3.Lerp(CardDeck.Instance.FlipdownAngle, CardDeck.Instance.FlipupAngle, t);
- if (timer > this.CardSetTime)
- {
- break;
- }
- }
- this.PosYFixed();
- yield return null;
- timer += Time.deltaTime;
- }
- this.PosYFixed();
- Dealer.Instance.SetCardOffset();
- if (this.OpenCallback != null)
- {
- this.OpenCallback(base.gameObject);
- }
- yield break;
- yield break;
- }
- public void MoveToPosition(Card.FinishedMoving callback)
- {
- if (this.m_IsMoveend)
- {
- return;
- }
- base.transform.eulerAngles = CardDeck.Instance.FlipdownAngle;
- this.MovingCallback = callback;
- base.StartCoroutine(this.CardMove());
- }
- public void Open(Card.FinishedOpen callback)
- {
- this.OpenCallback = callback;
- this.CurrentState = Card.CardState.Open;
- base.StartCoroutine(this.CardOpen());
- }
- public const float m_CardWidth = 0.035f;
- public const float m_CardHeight = 0.05f;
- private Card.FinishedOpen OpenCallback;
- private Card.FinishedMoving MovingCallback;
- private bool m_IsMoveend;
- [HideInInspector]
- public Card.CardState CurrentState;
- [HideInInspector]
- public Vector3 EndPosition;
- [HideInInspector]
- public Transform CardSet;
- [HideInInspector]
- public CardData CardData;
- [SerializeField]
- [HideInInspector]
- private MeshRenderer m_MyRenderer;
- [HideInInspector]
- public float InitTime;
- [HideInInspector]
- public float StartTime;
- [HideInInspector]
- public float CardSetTime;
- [HideInInspector]
- public float SwitchTime;
- private float m_OpenTime;
- public enum CardState
- {
- FlipUp,
- FlipDown,
- Open
- }
- public delegate void FinishedMoving(GameObject card);
- public delegate void FinishedOpen(GameObject card);
- }
|