123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- [Serializable]
- public class DealQueue
- {
- public DealQueue.CardAnimeData nCardAnimData
- {
- get
- {
- if (this.m_CardAnimeDic.ContainsKey(BjMotionControl.Instance.nMotionName))
- {
- return this.m_CardAnimeDic[BjMotionControl.Instance.nMotionName];
- }
- return null;
- }
- }
- public void Init()
- {
- string text = "cardanime_data.nei";
- if (!GameUty.FileSystem.IsExistentFile(text))
- {
- NDebug.Assert("表がありません。" + text, false);
- }
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
- {
- using (CsvParser csvParser = new CsvParser())
- {
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, text + "\nopen failed.");
- for (int i = 1; i < csvParser.max_cell_y; i++)
- {
- if (csvParser.IsCellToExistData(0, i))
- {
- string cellAsString = csvParser.GetCellAsString(0, i);
- for (int j = 0; j < csvParser.max_cell_x; j++)
- {
- switch (j)
- {
- case 0:
- this.m_CardAnimeDic.Add(cellAsString, new DealQueue.CardAnimeData());
- this.m_CardAnimeDic[cellAsString].MotionName = cellAsString;
- break;
- case 1:
- this.m_CardAnimeDic[cellAsString].StartTime = (from ch in csvParser.GetCellAsString(j, i).Split(new char[]
- {
- '\n'
- })
- select GameUty.MillisecondToSecond(int.Parse(ch))).ToList<float>();
- break;
- case 2:
- this.m_CardAnimeDic[cellAsString].CardSetTime = (from ch in csvParser.GetCellAsString(j, i).Split(new char[]
- {
- '\n'
- })
- select GameUty.MillisecondToSecond(int.Parse(ch))).ToList<float>();
- break;
- case 3:
- if (csvParser.IsCellToExistData(j, i))
- {
- this.m_CardAnimeDic[cellAsString].SwitchTime = (from ch in csvParser.GetCellAsString(j, i).Split(new char[]
- {
- '\n'
- })
- select GameUty.MillisecondToSecond(int.Parse(ch))).ToList<float>();
- }
- break;
- }
- }
- }
- }
- }
- }
- }
- private Card GetCard(GameObject card_obj)
- {
- if (!this.m_CardobjPair.ContainsKey(card_obj))
- {
- Card component = card_obj.GetComponent<Card>();
- NDebug.Assert(component, string.Format("オブジェクト:{0}にCardコンポーネントが付いてません", card_obj.name));
- this.m_CardobjPair.Add(card_obj, component);
- }
- return this.m_CardobjPair[card_obj];
- }
- public void DealCard(GameObject card)
- {
- if (this.m_ProcessList.Any((GameObject obj) => !obj))
- {
- this.m_ProcessList.Clear();
- }
- this.Queue(card);
- if (this.m_ProcessList.Count == 1)
- {
- this.ProcessNow(card);
- }
- }
- private void ProcessNow(GameObject card)
- {
- card.SetActive(true);
- this.CardMove(card);
- }
- private void Queue(GameObject card)
- {
- if (this.nCardAnimData != null)
- {
- int value = (!BjPlayer.Instance.IsturnEnd) ? this.m_ProcessList.Count : (Dealer.Instance.CardNum - 3);
- Card card2 = this.GetCard(card);
- card2.StartTime = this.nCardAnimData.StartTime[Mathf.Clamp(value, 0, this.nCardAnimData.StartTime.Count - 1)];
- card2.CardSetTime = this.nCardAnimData.CardSetTime[Mathf.Clamp(value, 0, this.nCardAnimData.CardSetTime.Count - 1)];
- if (this.nCardAnimData.SwitchTime.Count > 0)
- {
- card2.SwitchTime = this.nCardAnimData.SwitchTime[Mathf.Clamp(value, 0, this.nCardAnimData.SwitchTime.Count - 1)];
- }
- }
- this.m_ProcessList.Add(card);
- }
- public void CardOpen(GameObject cardGameObject)
- {
- Card card = this.GetCard(cardGameObject);
- card.InitTime = this.CardTimer;
- this.DealCard(cardGameObject);
- card.Open(new Card.FinishedOpen(this.OnFinishedMoving));
- }
- private void CardMove(GameObject cardGameobject)
- {
- Card card = this.GetCard(cardGameobject);
- if (card.IsMoveend)
- {
- return;
- }
- card.InitTime = this.CardTimer;
- card.MoveToPosition(new Card.FinishedMoving(this.OnFinishedMoving));
- }
- private void OnFinishedMoving(GameObject card)
- {
- this.DistributeCard();
- }
- public void DistributeCard()
- {
- if (this.m_ProcessList.Count > 0)
- {
- this.m_ProcessList.RemoveAt(0);
- }
- if (this.m_ProcessList.Count > 0)
- {
- this.ProcessNow(this.m_ProcessList[0]);
- }
- else
- {
- this.CardTimer = 0f;
- this.m_CardobjPair.Clear();
- }
- }
- public List<GameObject> m_ProcessList = new List<GameObject>();
- private Dictionary<string, DealQueue.CardAnimeData> m_CardAnimeDic = new Dictionary<string, DealQueue.CardAnimeData>();
- public float CardTimer;
- private Dictionary<GameObject, Card> m_CardobjPair = new Dictionary<GameObject, Card>();
- public class CardAnimeData
- {
- public string MotionName = string.Empty;
- public List<float> StartTime = new List<float>();
- public List<float> CardSetTime = new List<float>();
- public List<float> SwitchTime = new List<float>();
- }
- }
|