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(); 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(); 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(); } break; } } } } } } } private Card GetCard(GameObject card_obj) { if (!this.m_CardobjPair.ContainsKey(card_obj)) { Card component = card_obj.GetComponent(); 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 m_ProcessList = new List(); private Dictionary m_CardAnimeDic = new Dictionary(); public float CardTimer; private Dictionary m_CardobjPair = new Dictionary(); public class CardAnimeData { public string MotionName = string.Empty; public List StartTime = new List(); public List CardSetTime = new List(); public List SwitchTime = new List(); } }