EditDeck.cs 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348
  1. using DG.Tweening;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. using UnityEngine.Events;
  7. using UnityEngine.EventSystems;
  8. using UnityEngine.UI;
  9. public class EditDeck : MonoBehaviour
  10. {
  11. [Header("Deck creation object")]
  12. public GameObject CreateDeckObject;
  13. [Header("card prefab")]
  14. public CardPrefab_CreateDeck cardPrefab_CreateDeck;
  15. [Header("card pool scroll rect")]
  16. public ScrollRect CardPoolScroll;
  17. [Header("Deck card scroll rect")]
  18. public ScrollRect DeckScroll;
  19. [Header("Deck card number display text")]
  20. public Text DeckCountText;
  21. [Header("loading object")]
  22. public LoadingObject LoadingObjec;
  23. [Header("Card details display")]
  24. public DetailCard_DeckEditor DetailCard;
  25. [Header("filter")]
  26. public FilterCardList filterCardList;
  27. /*
  28. [Header("フィルターパネル")]
  29. public FilterPanel filterPanel;
  30. */
  31. [Header("Deck name input field")]
  32. public InputField DeckNameInputField;
  33. //Deck data being edited
  34. public DeckData EdittingDeckData { get; set; }
  35. bool _isFromSelectDeck = false;
  36. public UnityAction EndEditAction;
  37. public int DisplayPageIndex = 0;
  38. public Button UpDisplayPageIndexButton;
  39. public Button DownDisplayPageIndexButton;
  40. public Text ShowDisplayPageIndexText;
  41. public LoadingObject isSearchingObject;
  42. [Header("Page switching SE")]
  43. public AudioClip SwitchPageSE;
  44. [Header("Card classification display")]
  45. [SerializeField] CardDistribution cardDistribution;
  46. int _maxDisplayPageIndex;
  47. string _oldDeckName = "";
  48. List<CEntity_Base> _oldDeckCards = new List<CEntity_Base>();
  49. List<CEntity_Base> _oldDigitamaDeckCards = new List<CEntity_Base>();
  50. int _oldKeyCardId = -1;
  51. bool _isFromClipboard = false;
  52. private void Start()
  53. {
  54. #if !UNITY_EDITOR && UNITY_ANDROID
  55. CardPoolScroll.content.GetComponent<GridLayoutGroup>().constraintCount = 5;
  56. #endif
  57. }
  58. void CheckButtonEnabled()
  59. {
  60. UpDisplayPageIndexButton.interactable = DisplayPageIndex < _maxDisplayPageIndex;
  61. UpDisplayPageIndexButton.transform.GetChild(0).gameObject.SetActive(DisplayPageIndex < _maxDisplayPageIndex);
  62. DownDisplayPageIndexButton.interactable = DisplayPageIndex > 0;
  63. DownDisplayPageIndexButton.transform.GetChild(0).gameObject.SetActive(DisplayPageIndex > 0);
  64. ShowDisplayPageIndexText.text = $"{DisplayPageIndex + 1}/{_maxDisplayPageIndex + 1}";
  65. CardPoolScroll.verticalNormalizedPosition = 1;
  66. }
  67. public void UpDisplayPageIndex()
  68. {
  69. ContinuousController.instance.PlaySE(SwitchPageSE);
  70. DisplayPageIndex++;
  71. if (DisplayPageIndex > _maxDisplayPageIndex)
  72. {
  73. DisplayPageIndex = _maxDisplayPageIndex;
  74. }
  75. SetCardData();
  76. CheckButtonEnabled();
  77. ReflectDeckData();
  78. }
  79. public void DownDisplayPageIndex()
  80. {
  81. ContinuousController.instance.PlaySE(SwitchPageSE);
  82. DisplayPageIndex--;
  83. if (DisplayPageIndex < 0)
  84. {
  85. DisplayPageIndex = 0;
  86. }
  87. SetCardData();
  88. CheckButtonEnabled();
  89. ReflectDeckData();
  90. }
  91. List<List<CEntity_Base>> SprittedCardLists = new List<List<CEntity_Base>>();
  92. //List<CEntity_Base> ActiveCardList = new List<CEntity_Base>();
  93. IEnumerator SetSprittedCardLists()
  94. {
  95. SprittedCardLists = new List<List<CEntity_Base>>();
  96. for (int i = 0; i < _maxDisplayPageIndex + 1; i++)
  97. {
  98. SprittedCardLists.Add(new List<CEntity_Base>());
  99. }
  100. List<CEntity_Base> cEntity_Bases = new List<CEntity_Base>();
  101. foreach (CEntity_Base cEntity_Base in ContinuousController.instance.CardList)
  102. {
  103. if (MatchCondition(cEntity_Base))
  104. {
  105. cEntity_Bases.Add(cEntity_Base);
  106. }
  107. }
  108. for (int i = 0; i < cEntity_Bases.Count; i++)
  109. {
  110. CEntity_Base cEntity_Base = cEntity_Bases[i];
  111. int Quotient = i / _cardPoolPrefabs.Count;
  112. if (0 <= Quotient && Quotient < SprittedCardLists.Count)
  113. {
  114. SprittedCardLists[Quotient].Add(cEntity_Base);
  115. }
  116. }
  117. yield return null;
  118. }
  119. void SetCardData()
  120. {
  121. for (int i = 0; i < _cardPoolPrefabs.Count; i++)
  122. {
  123. if (i < SprittedCardLists[DisplayPageIndex].Count)
  124. {
  125. _cardPoolPrefabs[i].isActive = true;
  126. _cardPoolPrefabs[i].SetUpCardPrefab_CreateDeck(SprittedCardLists[DisplayPageIndex][i]);
  127. }
  128. else
  129. {
  130. _cardPoolPrefabs[i].isActive = false;
  131. }
  132. }
  133. }
  134. #region Card details display
  135. public void OffDetailCard()
  136. {
  137. DetailCard.OffDetailCard();
  138. }
  139. public void OnDetailCard(CEntity_Base cEntity_Base)
  140. {
  141. if (isDragging)
  142. {
  143. return;
  144. }
  145. DetailCard.SetUpDetailCard(cEntity_Base);
  146. }
  147. #endregion
  148. int _frameCount = 0;
  149. int _updateFrame = 3;
  150. private void Update()
  151. {
  152. #region Updates only once every few frames
  153. _frameCount++;
  154. if (_frameCount < _updateFrame)
  155. {
  156. return;
  157. }
  158. else
  159. {
  160. _frameCount = 0;
  161. }
  162. #endregion
  163. ShowOnlyVisibleObjects();
  164. if (EdittingDeckData != null)
  165. {
  166. TrialDrawButton.gameObject.SetActive(EdittingDeckData.DeckCards().Count >= 1);
  167. ClearDeckButton.gameObject.SetActive(EdittingDeckData.AllDeckCards().Count >= 1);
  168. }
  169. }
  170. #region Show only visible cards
  171. public void ShowOnlyVisibleObjects()
  172. {
  173. if (DoneSetUp)
  174. {
  175. foreach (CardPrefab_CreateDeck cardPrefab_CreateDeck in _cardPoolPrefabs)
  176. {
  177. if (!cardPrefab_CreateDeck.isActive)
  178. {
  179. cardPrefab_CreateDeck.gameObject.SetActive(false);
  180. }
  181. else
  182. {
  183. cardPrefab_CreateDeck.gameObject.SetActive(true);
  184. if (!((RectTransform)cardPrefab_CreateDeck.transform).IsVisibleFrom(Opening.instance.MainCamera))
  185. {
  186. cardPrefab_CreateDeck.CardImage.transform.parent.gameObject.SetActive(false);
  187. }
  188. else
  189. {
  190. cardPrefab_CreateDeck.CardImage.transform.parent.gameObject.SetActive(true);
  191. if (cardPrefab_CreateDeck.cEntity_Base != null)
  192. {
  193. //if (cardPrefab_CreateDeck.cEntity_Base.CardSprite != null)
  194. {
  195. cardPrefab_CreateDeck.ShowCardImage();
  196. }
  197. }
  198. }
  199. }
  200. }
  201. }
  202. }
  203. #endregion
  204. public bool isEditting { get; set; } = false;
  205. #region Close deck editing screen
  206. public void OnClickCompleteEditButton()
  207. {
  208. ContinuousController.instance.PlaySE(Opening.instance.DecisionSE);
  209. ContinuousController.instance.StartCoroutine(CloseCreateDeckCoroutine(false));
  210. }
  211. public void OnClickCancelEditButton()
  212. {
  213. ContinuousController.instance.PlaySE(Opening.instance.CancelSE);
  214. ContinuousController.instance.StartCoroutine(CloseCreateDeckCoroutine(true));
  215. }
  216. public IEnumerator CloseCreateDeckCoroutine(bool Canceled)
  217. {
  218. isEditting = false;
  219. yield return ContinuousController.instance.StartCoroutine(LoadingObjec.StartLoading("Now Loading"));
  220. Opening.instance.OffYesNoObjects();
  221. Opening.instance.deck.trialDraw.Close();
  222. Opening.instance.deck.deckListPanel.Close();
  223. for (int i = 0; i < Opening.instance.deck.selectDeck.deckInfoPrefabParentScroll.content.childCount; i++)
  224. {
  225. CreateNewDeckButton createNewDeckButton = Opening.instance.deck.selectDeck.deckInfoPrefabParentScroll.content.GetChild(i).GetComponent<CreateNewDeckButton>();
  226. if (createNewDeckButton != null)
  227. {
  228. createNewDeckButton.CreateNewDeckWayObject.Close_(false);
  229. break;
  230. }
  231. }
  232. if (Canceled)
  233. {
  234. EdittingDeckData.DeckCardIDs = DeckData.GetDeckCardCodes(DeckData.SortedDeckCardsList(_oldDeckCards));
  235. EdittingDeckData.DigitamaDeckCardIDs = DeckData.GetDeckCardCodes(DeckData.SortedDeckCardsList(_oldDigitamaDeckCards));
  236. EdittingDeckData.DeckName = _oldDeckName;
  237. EdittingDeckData.KeyCardId = _oldKeyCardId;
  238. }
  239. if (!EdittingDeckData.AllDeckCards().Contains(EdittingDeckData.KeyCard))
  240. {
  241. EdittingDeckData.KeyCardId = -1;
  242. }
  243. #region not save if deck is empty or canceled when importing from clipboard
  244. if (EdittingDeckData != null && (EdittingDeckData.DeckCards().Count == 0 && EdittingDeckData.DigitamaDeckCards().Count == 0 || (Canceled && _isFromClipboard)))
  245. {
  246. ContinuousController.instance.DeckDatas.Remove(EdittingDeckData);
  247. }
  248. #endregion
  249. ContinuousController.instance.SaveDeckDatas();
  250. for (int i = 0; i < DeckScroll.content.childCount; i++)
  251. {
  252. Destroy(DeckScroll.content.GetChild(i).gameObject);
  253. }
  254. if (!Canceled)
  255. {
  256. EdittingDeckData.DeckCardIDs = DeckData.GetDeckCardCodes(DeckData.SortedDeckCardsList(EdittingDeckData.DeckCards()));
  257. EdittingDeckData.DigitamaDeckCardIDs = DeckData.GetDeckCardCodes(DeckData.SortedDeckCardsList(EdittingDeckData.DigitamaDeckCards()));
  258. }
  259. foreach (CardPrefab_CreateDeck cardPrefab_CreateDeck in _cardPoolPrefabs)
  260. {
  261. if (cardPrefab_CreateDeck._OnEnterCoroutine != null)
  262. {
  263. cardPrefab_CreateDeck.StopCoroutine(cardPrefab_CreateDeck._OnEnterCoroutine);
  264. cardPrefab_CreateDeck._OnEnterCoroutine = null;
  265. }
  266. cardPrefab_CreateDeck.StopAllCoroutines();
  267. cardPrefab_CreateDeck.gameObject.SetActive(false);
  268. }
  269. yield return new WaitUntil(() => DeckScroll.content.childCount == 0);
  270. yield return new WaitForSeconds(0.1f);
  271. CreateDeckObject.SetActive(false);
  272. #region ひとつ前の画面をセットアップ
  273. if (_isFromSelectDeck)
  274. {
  275. Opening.instance.deck.selectDeck.ResetDeckInfoPanel();
  276. yield return ContinuousController.instance.StartCoroutine(Opening.instance.deck.selectDeck.SetDeckList(false));
  277. for (int i = 0; i < Opening.instance.deck.selectDeck.deckInfoPrefabParentScroll.content.childCount; i++)
  278. {
  279. if (Opening.instance.deck.selectDeck.deckInfoPrefabParentScroll.content.GetChild(i).GetComponent<DeckInfoPrefab>() != null)
  280. {
  281. if (Opening.instance.deck.selectDeck.deckInfoPrefabParentScroll.content.GetChild(i).GetComponent<DeckInfoPrefab>().thisDeckData == EdittingDeckData)
  282. {
  283. if (Opening.instance.deck.selectDeck.deckInfoPrefabParentScroll.content.GetChild(i).GetComponent<DeckInfoPrefab>().thisDeckData != null)
  284. {
  285. if (Opening.instance.deck.selectDeck.deckInfoPrefabParentScroll.content.GetChild(i).GetComponent<DeckInfoPrefab>().thisDeckData.DeckCards().Count > 0)
  286. {
  287. Opening.instance.deck.selectDeck.deckInfoPrefabParentScroll.content.GetChild(i).GetComponent<DeckInfoPrefab>().OnClick_DeckInfoPrefab(false);
  288. }
  289. }
  290. }
  291. }
  292. }
  293. if (EdittingDeckData != null)
  294. {
  295. ContinuousController.instance.BattleDeckData = EdittingDeckData;
  296. }
  297. }
  298. else
  299. {
  300. Opening.instance.battle.selectBattleDeck.ResetDeckInfoPanel();
  301. yield return ContinuousController.instance.StartCoroutine(Opening.instance.battle.selectBattleDeck.SetDeckList(false));
  302. for (int i = 0; i < Opening.instance.battle.selectBattleDeck.deckInfoPrefabParentScroll.content.childCount; i++)
  303. {
  304. if (Opening.instance.battle.selectBattleDeck.deckInfoPrefabParentScroll.content.GetChild(i).GetComponent<DeckInfoPrefab>() != null)
  305. {
  306. if (Opening.instance.battle.selectBattleDeck.deckInfoPrefabParentScroll.content.GetChild(i).GetComponent<DeckInfoPrefab>().thisDeckData == EdittingDeckData)
  307. {
  308. Opening.instance.battle.selectBattleDeck.deckInfoPrefabParentScroll.content.GetChild(i).GetComponent<DeckInfoPrefab>().OnClick_DeckInfoPrefab(false);
  309. }
  310. }
  311. }
  312. }
  313. #endregion
  314. EndEditAction?.Invoke();
  315. EndEditAction = null;
  316. yield return ContinuousController.instance.StartCoroutine(LoadingObjec.EndLoading());
  317. }
  318. #endregion
  319. #region Open deck editing screen
  320. public void SetUpCreateDeck(DeckData deckData, bool isFromSelectDeck, bool isFromClipboard = false)
  321. {
  322. if (deckData == null)
  323. {
  324. return;
  325. }
  326. _isFromClipboard = isFromClipboard;
  327. Opening.instance.OffYesNoObjects();
  328. Opening.instance.deck.trialDraw.Close();
  329. Opening.instance.deck.deckListPanel.Close();
  330. _oldDeckName = deckData.DeckName;
  331. _oldDeckCards = new List<CEntity_Base>();
  332. foreach (CEntity_Base cEntity_Base in deckData.DeckCards())
  333. {
  334. _oldDeckCards.Add(cEntity_Base);
  335. }
  336. _oldDigitamaDeckCards = new List<CEntity_Base>();
  337. foreach (CEntity_Base cEntity_Base in deckData.DigitamaDeckCards())
  338. {
  339. _oldDigitamaDeckCards.Add(cEntity_Base);
  340. }
  341. _oldKeyCardId = deckData.KeyCardId;
  342. _checkCoverCoroutine = null;
  343. this._isFromSelectDeck = isFromSelectDeck;
  344. DisplayPageIndex = 0;
  345. SetCardData();
  346. CheckButtonEnabled();
  347. isSearchingObject.Off();
  348. ContinuousController.instance.StartCoroutine(SetUpCreateDeckCoroutine(deckData));
  349. }
  350. public IEnumerator SetUpCreateDeckCoroutine(DeckData deckData)
  351. {
  352. yield return ContinuousController.instance.StartCoroutine(LoadingObjec.StartLoading("Now Loading"));
  353. yield return new WaitForSeconds(0.1f);
  354. for (int i = 0; i < draggable_CardParent.childCount; i++)
  355. {
  356. Destroy(draggable_CardParent.GetChild(i).gameObject);
  357. }
  358. DraggingCover.SetActive(false);
  359. CardPoolScroll.verticalNormalizedPosition = 1;
  360. DeckScroll.verticalNormalizedPosition = 1;
  361. deckData.DeckCardIDs = DeckData.GetDeckCardCodes(DeckData.SortedDeckCardsList(deckData.DeckCards()));
  362. deckData.DigitamaDeckCardIDs = DeckData.GetDeckCardCodes(DeckData.SortedDeckCardsList(deckData.DigitamaDeckCards()));
  363. EdittingDeckData = deckData;
  364. ContinuousController.instance.SaveDeckDatas();
  365. OffDetailCard();
  366. for (int i = 0; i < DeckScroll.content.childCount; i++)
  367. {
  368. Destroy(DeckScroll.content.GetChild(i).gameObject);
  369. }
  370. yield return new WaitUntil(() => DeckScroll.content.childCount == 0);
  371. for (int i = 0; i < DeckScroll.viewport.childCount; i++)
  372. {
  373. if (i != 0)
  374. {
  375. Destroy(DeckScroll.viewport.GetChild(i).gameObject);
  376. }
  377. }
  378. yield return new WaitUntil(() => DeckScroll.viewport.childCount == 1);
  379. _maxDisplayPageIndex = (ContinuousController.instance.CardList.Length - 1) / _cardPoolPrefabs.Count;
  380. if (deckData != null)
  381. {
  382. List<CEntity_Base> DeckCards = new List<CEntity_Base>();
  383. foreach (CEntity_Base cEntity_Base in deckData.AllDeckCards())
  384. {
  385. DeckCards.Add(cEntity_Base);
  386. }
  387. foreach (CEntity_Base cEntity_Base in DeckCards)
  388. {
  389. CreateDeckCard(cEntity_Base);
  390. }
  391. }
  392. CreateDeckObject.SetActive(true);
  393. foreach (CardPrefab_CreateDeck _CardPrefab_CreateDeck in _cardPoolPrefabs)
  394. {
  395. _CardPrefab_CreateDeck.isActive = true;
  396. if (_CardPrefab_CreateDeck._OnEnterCoroutine != null)
  397. {
  398. _CardPrefab_CreateDeck.StopCoroutine(_CardPrefab_CreateDeck._OnEnterCoroutine);
  399. _CardPrefab_CreateDeck._OnEnterCoroutine = null;
  400. }
  401. }
  402. filterCardList.Init(() => ContinuousController.instance.StartCoroutine(ShowPoolCard_MatchCondition()));
  403. DeckNameInputField.onEndEdit.RemoveAllListeners();
  404. DeckNameInputField.text = EdittingDeckData.DeckName;
  405. DeckNameInputField.onEndEdit.AddListener(OnEndEdit);
  406. yield return ContinuousController.instance.StartCoroutine(SetSprittedCardLists());
  407. SetCardData();
  408. CheckButtonEnabled();
  409. ReflectDeckData();
  410. cardDistribution.SetCardDistribution(EdittingDeckData);
  411. yield return new WaitForSeconds(0.1f);
  412. for (int i = 0; i < DeckScroll.content.childCount; i++)
  413. {
  414. DeckScroll.content.GetChild(i).GetComponent<CardPrefab_CreateDeck>().ShowCardImage();
  415. }
  416. yield return StartCoroutine(LoadingObjec.EndLoading());
  417. isEditting = true;
  418. }
  419. public void OnEndEdit(string text)
  420. {
  421. string deckName = text;
  422. deckName = DeckData.ValidateDeckName(deckName);
  423. EdittingDeckData.DeckName = deckName;
  424. DeckNameInputField.onEndEdit.RemoveAllListeners();
  425. DeckNameInputField.text = deckName;
  426. DeckNameInputField.onEndEdit.AddListener(OnEndEdit);
  427. }
  428. #endregion
  429. public List<CardPrefab_CreateDeck> CardPoolCardPrefabs_CreateDeck = new List<CardPrefab_CreateDeck>();
  430. #region Initialize the deck editing screen at the start of the game
  431. public List<CardPrefab_CreateDeck> cardPoolPrefabs_all = new List<CardPrefab_CreateDeck>();
  432. List<CardPrefab_CreateDeck> _cardPoolPrefabs = new List<CardPrefab_CreateDeck>();
  433. bool DoneSetUp { get; set; } = false;
  434. public IEnumerator InitEditDeck()
  435. {
  436. cardDistribution.Init();
  437. for (int i = 0; i < CardPoolScroll.content.childCount; i++)
  438. {
  439. CardPrefab_CreateDeck cardPrefab_CreateDeck = CardPoolScroll.content.GetChild(i).GetComponent<CardPrefab_CreateDeck>();
  440. if (cardPrefab_CreateDeck != null)
  441. {
  442. CardPoolCardPrefabs_CreateDeck.Add(cardPrefab_CreateDeck);
  443. }
  444. }
  445. for (int i = 0; i < DeckScroll.content.childCount; i++)
  446. {
  447. Destroy(DeckScroll.content.GetChild(i).gameObject);
  448. }
  449. foreach (CardPrefab_CreateDeck cardPrefab_CreateDeck in cardPoolPrefabs_all)
  450. {
  451. if (cardPrefab_CreateDeck.gameObject.activeSelf)
  452. {
  453. cardPrefab_CreateDeck.gameObject.SetActive(false);
  454. }
  455. }
  456. for (int i = 0; i < cardPoolPrefabs_all.Count; i++)
  457. {
  458. if (i < ContinuousController.instance.CardList.Length)
  459. {
  460. CardPrefab_CreateDeck _cardPrefab_CreateDeck = cardPoolPrefabs_all[i];
  461. _cardPoolPrefabs.Add(_cardPrefab_CreateDeck);
  462. CEntity_Base cEntity_Base = ContinuousController.instance.CardList[i];
  463. foreach (ScrollRect _scroll in _cardPrefab_CreateDeck.scroll)
  464. {
  465. _scroll.content = CardPoolScroll.content;
  466. _scroll.viewport = CardPoolScroll.viewport;
  467. _scroll.enabled = false;
  468. }
  469. _cardPrefab_CreateDeck.OnClickAction = () =>
  470. {
  471. StartCoroutine(AddDeckCardCoroutine_OnClick(_cardPrefab_CreateDeck));
  472. };
  473. _cardPrefab_CreateDeck.OnBeginDragAction = (cardPrefab_CreateDeck) => { StartCoroutine(OnBeginDrag(cardPrefab_CreateDeck)); };
  474. _cardPrefab_CreateDeck.OnEnterAction = (cardPrefab) =>
  475. {
  476. OnDetailCard(_cardPrefab_CreateDeck.cEntity_Base);
  477. };
  478. }
  479. }
  480. yield return ContinuousController.instance.StartCoroutine(SetSprittedCardLists());
  481. yield return new WaitForSeconds(0.1f);
  482. DoneSetUp = true;
  483. }
  484. #endregion
  485. #region Changed deck content changes to UI
  486. public void ReflectDeckData()
  487. {
  488. if (EdittingDeckData != null)
  489. {
  490. //Turn on covers for cards that cannot be included in the deck
  491. if (_checkCoverCoroutine != null)
  492. {
  493. StopCoroutine(_checkCoverCoroutine);
  494. }
  495. _checkCoverCoroutine = StartCoroutine(CheckCoverIEnumerator());
  496. SetDeckCountText();
  497. }
  498. }
  499. Coroutine _checkCoverCoroutine = null;
  500. IEnumerator CheckCoverIEnumerator()
  501. {
  502. foreach (CardPrefab_CreateDeck cardPrefab_CreateDeck in _cardPoolPrefabs)
  503. {
  504. yield return null;
  505. cardPrefab_CreateDeck.CheckCover(EdittingDeckData);
  506. }
  507. }
  508. #endregion
  509. #region Show deck number text
  510. public void SetDeckCountText()
  511. {
  512. DeckCountText.text = $"{EdittingDeckData.DeckCards().Count}+{EdittingDeckData.DigitamaDeckCards().Count}/50+5";
  513. if (EdittingDeckData.IsValidDeckData())
  514. {
  515. DeckCountText.color = new Color32(69, 255, 69, 255);
  516. }
  517. else
  518. {
  519. DeckCountText.color = new Color32(255, 64, 64, 255);
  520. }
  521. }
  522. #endregion
  523. #region Generate cards for deck
  524. public CardPrefab_CreateDeck CreateDeckCard(CEntity_Base cEntity_Base)
  525. {
  526. CardPrefab_CreateDeck _cardPrefab_CreateDeck = Instantiate(cardPrefab_CreateDeck, DeckScroll.content);
  527. SetUpDeckCard(_cardPrefab_CreateDeck, cEntity_Base);
  528. return _cardPrefab_CreateDeck;
  529. }
  530. public void SetUpDeckCard(CardPrefab_CreateDeck _cardPrefab_CreateDeck, CEntity_Base cEntity_Base)
  531. {
  532. foreach (ScrollRect _scroll in _cardPrefab_CreateDeck.scroll)
  533. {
  534. _scroll.content = DeckScroll.content;
  535. _scroll.viewport = DeckScroll.viewport;
  536. }
  537. _cardPrefab_CreateDeck.SetUpCardPrefab_CreateDeck(cEntity_Base);
  538. _cardPrefab_CreateDeck.ShowCardImage();
  539. _cardPrefab_CreateDeck.OnClickAction = () =>
  540. {
  541. StartCoroutine(RemoveDeckCardCoroutine_OnClick(_cardPrefab_CreateDeck));
  542. };
  543. _cardPrefab_CreateDeck.OnBeginDragAction = (cardPrefab_CreateDeck) => { StartCoroutine(OnBeginDrag(cardPrefab_CreateDeck)); };
  544. _cardPrefab_CreateDeck.OnEnterAction = (cardPrefab) =>
  545. {
  546. OnDetailCard(cEntity_Base);
  547. cardPrefab.SetupAddRemoveButton(EdittingDeckData);
  548. };
  549. _cardPrefab_CreateDeck.OnExitAction = (cardPrefab) =>
  550. {
  551. cardPrefab.OffAddRemoveButton();
  552. };
  553. _cardPrefab_CreateDeck.Parent.localScale = new Vector3(0.76f, 0.76f, 0.76f);
  554. _cardPrefab_CreateDeck.OnClickAddButtonAction = (cardPrefab) => StartCoroutine(AddDeckCardCoroutine_OnClick(cardPrefab));
  555. _cardPrefab_CreateDeck.OnClickRemoveButtonAction = (cardPrefab) => StartCoroutine(RemoveDeckCardCoroutine_OnClick(cardPrefab));
  556. }
  557. #endregion
  558. #region Display only cards that meet search/filter conditions
  559. bool MatchCondition(CEntity_Base cEntity_Base)
  560. {
  561. if (!filterCardList.OnlyContainsName()(cEntity_Base))
  562. {
  563. return false;
  564. }
  565. if (!filterCardList.OnlyContainsColor()(cEntity_Base))
  566. {
  567. return false;
  568. }
  569. if (!filterCardList.OnlyMatchRarity()(cEntity_Base))
  570. {
  571. return false;
  572. }
  573. if (!filterCardList.OnlyMatchCardKind()(cEntity_Base))
  574. {
  575. return false;
  576. }
  577. if (!filterCardList.OnlyMatchCardSet()(cEntity_Base))
  578. {
  579. return false;
  580. }
  581. if (!filterCardList.OnlyMatchPlayCost()(cEntity_Base))
  582. {
  583. return false;
  584. }
  585. if (!filterCardList.OnlyMatchLevel()(cEntity_Base))
  586. {
  587. return false;
  588. }
  589. if (!filterCardList.OnlyMatchSpecialCardKind()(cEntity_Base))
  590. {
  591. return false;
  592. }
  593. if (!filterCardList.OnlyMatchParallelCondition()(cEntity_Base))
  594. {
  595. return false;
  596. }
  597. return true;
  598. }
  599. public IEnumerator ShowPoolCard_MatchCondition()
  600. {
  601. DraggingCover.SetActive(true);
  602. DisplayPageIndex = 0;
  603. _maxDisplayPageIndex = (ContinuousController.instance.CardList.Count((cEntity_Base) => MatchCondition(cEntity_Base)) - 1) / _cardPoolPrefabs.Count;
  604. yield return ContinuousController.instance.StartCoroutine(SetSprittedCardLists());
  605. SetCardData();
  606. CheckButtonEnabled();
  607. ReflectDeckData();
  608. DraggingCover.SetActive(false);
  609. for (int i = 0; i < CardPoolCardPrefabs_CreateDeck.Count; i++)
  610. {
  611. CardPrefab_CreateDeck cardPrefab_CreateDeck = CardPoolCardPrefabs_CreateDeck[i];
  612. if (cardPrefab_CreateDeck != null)
  613. {
  614. cardPrefab_CreateDeck.uIShiny.enabled = false;
  615. if (cardPrefab_CreateDeck._OnEnterCoroutine != null)
  616. {
  617. cardPrefab_CreateDeck.StopCoroutine(cardPrefab_CreateDeck._OnEnterCoroutine);
  618. cardPrefab_CreateDeck._OnEnterCoroutine = null;
  619. }
  620. cardPrefab_CreateDeck.StopAllCoroutines();
  621. }
  622. }
  623. }
  624. #endregion
  625. #region Manipulating card objects
  626. [Header("draggable card object")]
  627. public Draggable_Card draggable_CardPrefab;
  628. [Header("draggable card object parent")]
  629. public Transform draggable_CardParent;
  630. [Header("Deck card dropArea")]
  631. public DropArea DeckCardsDropArea;
  632. [Header("card pool dropArea")]
  633. public DropArea CardPoolDropArea;
  634. [Header("Cover while dragging")]
  635. public GameObject DraggingCover;
  636. [Header("Coordinates of the disappearing deck card")]
  637. public Transform DisappearDeckCardTransform;
  638. //Is it draggable?
  639. public bool CanDrag { get; set; } = true;
  640. //Whether you are dragging
  641. public bool isDragging { get; set; } = false;
  642. #region Generate draggable objects
  643. public Draggable_Card CreateDraggable_Card()
  644. {
  645. Draggable_Card draggable_Card = Instantiate(draggable_CardPrefab, draggable_CardParent);
  646. draggable_Card.DefaultParent = draggable_CardParent;
  647. draggable_Card.transform.localScale = new Vector3(1, 1, 1);
  648. draggable_Card.CardImage.color = new Color(1, 1, 1, 1);
  649. return draggable_Card;
  650. }
  651. #endregion
  652. #region At the start of drag
  653. public IEnumerator OnBeginDrag(CardPrefab_CreateDeck _cardPrefab_CreateDeck)
  654. {
  655. if (_cardPrefab_CreateDeck.transform.parent == CardPoolScroll.content)
  656. {
  657. if (!DeckBuildingRule.CanAddCard(_cardPrefab_CreateDeck.cEntity_Base, EdittingDeckData))
  658. {
  659. yield break;
  660. }
  661. }
  662. if (Input.GetMouseButton(1))
  663. {
  664. yield break;
  665. }
  666. if (!isDragging && CanDrag)
  667. {
  668. Draggable_Card draggable_Card = CreateDraggable_Card();
  669. SetStartDrag(_cardPrefab_CreateDeck, draggable_Card);
  670. draggable_Card.OnDropAction = (dropAreas) => { OnEndDrag(dropAreas, _cardPrefab_CreateDeck, draggable_Card); };
  671. draggable_Card.OnDragAction = (dropAreas) =>
  672. {
  673. DeckCardsDropArea.OnPointerExit();
  674. CardPoolDropArea.OnPointerExit();
  675. if (_cardPrefab_CreateDeck.transform.parent == DeckScroll.content)
  676. {
  677. if (dropAreas.Count((dropArea) => dropArea == CardPoolDropArea) > 0)
  678. {
  679. CardPoolDropArea.OnPointerEnter();
  680. }
  681. }
  682. else if (_cardPrefab_CreateDeck.transform.parent == CardPoolScroll.content)
  683. {
  684. if (dropAreas.Count((dropArea) => dropArea == DeckCardsDropArea) > 0)
  685. {
  686. DeckCardsDropArea.OnPointerEnter();
  687. }
  688. }
  689. };
  690. if (_cardPrefab_CreateDeck.transform.parent == DeckScroll.content)
  691. {
  692. DeckCardsDropArea.OffDropPanel();
  693. CardPoolDropArea.OnDropPanel();
  694. _cardPrefab_CreateDeck.HideDeckCardTab();
  695. _cardPrefab_CreateDeck.OffAddRemoveButton();
  696. }
  697. else if (_cardPrefab_CreateDeck.transform.parent == CardPoolScroll.content)
  698. {
  699. DeckCardsDropArea.OnDropPanel();
  700. CardPoolDropArea.OffDropPanel();
  701. }
  702. DeckScroll.enabled = false;
  703. for (int i = 0; i < DeckScroll.content.childCount; i++)
  704. {
  705. foreach (ScrollRect scroll in DeckScroll.content.GetChild(i).GetComponent<CardPrefab_CreateDeck>().scroll)
  706. {
  707. scroll.enabled = false;
  708. }
  709. }
  710. CardPoolScroll.enabled = false;
  711. for (int i = 0; i < _cardPoolPrefabs.Count; i++)
  712. {
  713. foreach (ScrollRect scroll in _cardPoolPrefabs[i].scroll)
  714. {
  715. scroll.enabled = false;
  716. }
  717. }
  718. }
  719. }
  720. public void SetStartDrag(CardPrefab_CreateDeck _cardPrefab_CreateDeck, Draggable_Card draggable_Card)
  721. {
  722. isDragging = true;
  723. CanDrag = false;
  724. DraggingCover.SetActive(true);
  725. draggable_Card.SetUpDraggable_Card(_cardPrefab_CreateDeck.cEntity_Base, _cardPrefab_CreateDeck.transform.position);
  726. }
  727. #endregion
  728. #region At the end of dragging
  729. public void OnEndDrag(List<DropArea> dropAreas, CardPrefab_CreateDeck _cardPrefab_CreateDeck, Draggable_Card draggable_Card)
  730. {
  731. DeckCardsDropArea.OffDropPanel();
  732. CardPoolDropArea.OffDropPanel();
  733. StartCoroutine(OnEndDragCoroutine(dropAreas, _cardPrefab_CreateDeck, draggable_Card));
  734. DeckScroll.enabled = true;
  735. for (int i = 0; i < DeckScroll.content.childCount; i++)
  736. {
  737. foreach (ScrollRect scroll in DeckScroll.content.GetChild(i).GetComponent<CardPrefab_CreateDeck>().scroll)
  738. {
  739. scroll.enabled = true;
  740. }
  741. }
  742. CardPoolScroll.enabled = true;
  743. for (int i = 0; i < _cardPoolPrefabs.Count; i++)
  744. {
  745. foreach (ScrollRect scroll in _cardPoolPrefabs[i].scroll)
  746. {
  747. scroll.enabled = true;
  748. }
  749. }
  750. }
  751. IEnumerator OnEndDragCoroutine(List<DropArea> dropAreas, CardPrefab_CreateDeck _cardPrefab_CreateDeck, Draggable_Card draggable_Card)
  752. {
  753. if (_cardPrefab_CreateDeck.transform.parent == DeckScroll.content)
  754. {
  755. if (dropAreas.Count((dropArea) => dropArea == CardPoolDropArea) > 0)
  756. {
  757. yield return StartCoroutine(RemoveDeckCardCoroutine(_cardPrefab_CreateDeck, draggable_Card));
  758. }
  759. else
  760. {
  761. _cardPrefab_CreateDeck.ShowCardImage();
  762. }
  763. }
  764. else if (_cardPrefab_CreateDeck.transform.parent == CardPoolScroll.content)
  765. {
  766. if (dropAreas.Count((dropArea) => dropArea == DeckCardsDropArea) > 0)
  767. {
  768. yield return StartCoroutine(AddDeckCardCoroutine(_cardPrefab_CreateDeck, draggable_Card));
  769. }
  770. }
  771. Reset_EndDrag(draggable_Card);
  772. }
  773. public void Reset_EndDrag(Draggable_Card draggable_Card)
  774. {
  775. isDragging = false;
  776. DestroyImmediate(draggable_Card.gameObject);
  777. CanDrag = true;
  778. DraggingCover.SetActive(false);
  779. }
  780. #endregion
  781. float _addCardAnimationTime = 0.01f;
  782. #region Animation to add cards to deck when dropped
  783. IEnumerator AddDeckCardCoroutine(CardPrefab_CreateDeck _cardPrefab_CreateDeck, Draggable_Card draggable_Card)
  784. {
  785. if (!DeckBuildingRule.CanAddCard(_cardPrefab_CreateDeck.cEntity_Base, EdittingDeckData))
  786. {
  787. yield break;
  788. }
  789. ContinuousController.instance.PlaySE(Opening.instance.DrawSE);
  790. for (int i = 0; i < CardPoolCardPrefabs_CreateDeck.Count; i++)
  791. {
  792. CardPrefab_CreateDeck cardPrefab_CreateDeck = CardPoolCardPrefabs_CreateDeck[i];
  793. if (cardPrefab_CreateDeck != null)
  794. {
  795. cardPrefab_CreateDeck.uIShiny.enabled = false;
  796. cardPrefab_CreateDeck.OffAddRemoveButton();
  797. }
  798. }
  799. yield return StartCoroutine(AddDeckCards(_cardPrefab_CreateDeck.cEntity_Base));
  800. List<CEntity_Base> DeckCards = new List<CEntity_Base>();
  801. foreach (CEntity_Base cEntity_Base in EdittingDeckData.AllDeckCards())
  802. {
  803. DeckCards.Add(cEntity_Base);
  804. }
  805. Debug.Log("ADDED EDITTING DECK DATA ENTITIES TO DECK CARDS LIST: " + DeckCards.Count);
  806. int index = DeckCards.IndexOf(_cardPrefab_CreateDeck.cEntity_Base) + DeckCards.Count((cEntity_Base) => cEntity_Base == _cardPrefab_CreateDeck.cEntity_Base) - 1;
  807. Debug.Log("GETTING INDEX OF LAST ADDED CARD: " + index);
  808. CardPrefab_CreateDeck newCardPrefab = CreateDeckCard(_cardPrefab_CreateDeck.cEntity_Base);
  809. newCardPrefab.HideDeckCardTab();
  810. newCardPrefab.transform.SetSiblingIndex(index);
  811. List<CardPrefab_CreateDeck> cardPrefabs = new List<CardPrefab_CreateDeck>();
  812. for (int i = 0; i < DeckScroll.content.childCount; i++)
  813. {
  814. CardPrefab_CreateDeck cardPrefab = DeckScroll.content.GetChild(i).GetComponent<CardPrefab_CreateDeck>();
  815. if (cardPrefab != null)
  816. {
  817. cardPrefabs.Add(cardPrefab);
  818. if (cardPrefab.AddRemoveButtonParent.activeSelf)
  819. {
  820. cardPrefab.OffAddRemoveButton();
  821. cardPrefab.SetupAddRemoveButton(EdittingDeckData);
  822. }
  823. }
  824. }
  825. foreach (CardPrefab_CreateDeck cardPrefab in cardPrefabs)
  826. {
  827. cardPrefab.transform.SetParent(null);
  828. }
  829. foreach (CEntity_Base cEntity_Base in EdittingDeckData.AllDeckCards())
  830. {
  831. for (int i = 0; i < cardPrefabs.Count; i++)
  832. {
  833. if (cardPrefabs[i].cEntity_Base == cEntity_Base)
  834. {
  835. cardPrefabs[i].transform.SetParent(DeckScroll.content);
  836. cardPrefabs.Remove(cardPrefabs[i]);
  837. break;
  838. }
  839. }
  840. }
  841. yield return new WaitForSeconds(Time.deltaTime);
  842. bool end = false;
  843. var sequence = DOTween.Sequence();
  844. sequence
  845. .Append(draggable_Card.transform.DOMove(newCardPrefab.transform.position, _addCardAnimationTime))
  846. .Join(draggable_Card.transform.DOScale(new Vector3(0.5f, 0.5f, 0.5f), _addCardAnimationTime))
  847. .AppendCallback(() => end = true);
  848. sequence.Play();
  849. yield return new WaitWhile(() => !end);
  850. end = false;
  851. yield return new WaitForSeconds(_addCardAnimationTime);
  852. newCardPrefab.ShowCardImage();
  853. draggable_Card.gameObject.SetActive(false);
  854. }
  855. #endregion
  856. #region Animation to remove cards on drop
  857. IEnumerator RemoveDeckCardCoroutine(CardPrefab_CreateDeck _cardPrefab_CreateDeck, Draggable_Card draggable_Card)
  858. {
  859. ContinuousController.instance.PlaySE(Opening.instance.DrawSE);
  860. bool end = false;
  861. yield return StartCoroutine(RemoveDeckCards(_cardPrefab_CreateDeck.cEntity_Base));
  862. var sequence = DOTween.Sequence();
  863. sequence
  864. .Append(draggable_Card.transform.DOMove(DisappearDeckCardTransform.position, _addCardAnimationTime))
  865. .Join(draggable_Card.transform.DOScale(new Vector3(0.5f, 0.5f, 0.5f), _addCardAnimationTime))
  866. .AppendCallback(() => end = true);
  867. sequence.Play();
  868. yield return new WaitWhile(() => !end);
  869. end = false;
  870. yield return new WaitForSeconds(_addCardAnimationTime);
  871. draggable_Card.gameObject.SetActive(false);
  872. if (_cardPrefab_CreateDeck.transform.parent != CardPoolScroll.content)
  873. {
  874. DestroyImmediate(_cardPrefab_CreateDeck.gameObject);
  875. }
  876. }
  877. #endregion
  878. #region Add card to deck animation when right-clicking
  879. public IEnumerator AddDeckCardCoroutine_OnClick(CardPrefab_CreateDeck _cardPrefab_CreateDeck)
  880. {
  881. if (!DeckBuildingRule.CanAddCard(_cardPrefab_CreateDeck.cEntity_Base, EdittingDeckData))
  882. {
  883. yield break;
  884. }
  885. Draggable_Card draggable_Card = CreateDraggable_Card();
  886. SetStartDrag(_cardPrefab_CreateDeck, draggable_Card);
  887. draggable_Card.IsDragging = false;
  888. yield return StartCoroutine(AddDeckCardCoroutine(_cardPrefab_CreateDeck, draggable_Card));
  889. Reset_EndDrag(draggable_Card);
  890. }
  891. #endregion
  892. #region Animation to remove cards from deck when right-clicking
  893. public IEnumerator RemoveDeckCardCoroutine_OnClick(CardPrefab_CreateDeck _cardPrefab_CreateDeck)
  894. {
  895. Draggable_Card draggable_Card = CreateDraggable_Card();
  896. _cardPrefab_CreateDeck.HideDeckCardTab();
  897. SetStartDrag(_cardPrefab_CreateDeck, draggable_Card);
  898. draggable_Card.IsDragging = false;
  899. yield return StartCoroutine(RemoveDeckCardCoroutine(_cardPrefab_CreateDeck, draggable_Card));
  900. Reset_EndDrag(draggable_Card);
  901. }
  902. #endregion
  903. #region add cards to deck
  904. public IEnumerator AddDeckCards(CEntity_Base cEntity_Base)
  905. {
  906. if (!DeckBuildingRule.CanAddCard(cEntity_Base, EdittingDeckData))
  907. {
  908. yield break;
  909. }
  910. EdittingDeckData.AddCard(cEntity_Base);
  911. EdittingDeckData.DeckCardIDs = DeckData.GetDeckCardCodes(DeckData.SortedDeckCardsList(EdittingDeckData.DeckCards()));
  912. EdittingDeckData.DigitamaDeckCardIDs = DeckData.GetDeckCardCodes(DeckData.SortedDeckCardsList(EdittingDeckData.DigitamaDeckCards()));
  913. ReflectDeckData();
  914. cardDistribution.SetCardDistribution(EdittingDeckData);
  915. }
  916. #endregion
  917. #region remove cards from deck
  918. public IEnumerator RemoveDeckCards(CEntity_Base cEntity_Base)
  919. {
  920. if (cEntity_Base.cardKind == CardKind.DigiEgg)
  921. {
  922. if (EdittingDeckData.DigitamaDeckCards().Count((cardData) => cardData.CardID == cEntity_Base.CardID) <= 0)
  923. {
  924. yield break;
  925. }
  926. }
  927. else
  928. {
  929. if (EdittingDeckData.DeckCards().Count((cardData) => cardData.CardID == cEntity_Base.CardID) <= 0)
  930. {
  931. yield break;
  932. }
  933. }
  934. EdittingDeckData.RemoveCard(cEntity_Base);
  935. EdittingDeckData.DeckCardIDs = DeckData.GetDeckCardCodes(DeckData.SortedDeckCardsList(EdittingDeckData.DeckCards()));
  936. EdittingDeckData.DigitamaDeckCardIDs = DeckData.GetDeckCardCodes(DeckData.SortedDeckCardsList(EdittingDeckData.DigitamaDeckCards()));
  937. ReflectDeckData();
  938. cardDistribution.SetCardDistribution(EdittingDeckData);
  939. }
  940. #endregion
  941. #endregion
  942. public void OnPointerEnterBackground()
  943. {
  944. List<CardPrefab_CreateDeck> cardPrefabs = new List<CardPrefab_CreateDeck>();
  945. for (int i = 0; i < DeckScroll.content.childCount; i++)
  946. {
  947. CardPrefab_CreateDeck cardPrefab = DeckScroll.content.GetChild(i).GetComponent<CardPrefab_CreateDeck>();
  948. if (cardPrefab != null)
  949. {
  950. cardPrefabs.Add(cardPrefab);
  951. }
  952. }
  953. foreach (CardPrefab_CreateDeck cardPrefab in cardPrefabs)
  954. {
  955. if (cardPrefab != null)
  956. {
  957. cardPrefab._OnExit();
  958. }
  959. }
  960. }
  961. public Button TrialDrawButton;
  962. public void OnClickTrial5DrawButton()
  963. {
  964. Opening.instance.deck.trialDraw.Off();
  965. ContinuousController.instance.PlaySE(Opening.instance.DecisionSE);
  966. ContinuousController.instance.StartCoroutine(Opening.instance.deck.trialDraw.SetUpTrialDraw(EdittingDeckData.DeckCards()));
  967. }
  968. public Button ClearDeckButton;
  969. public void OnClickClearDeckButton()
  970. {
  971. List<UnityAction> Commands = new List<UnityAction>()
  972. {
  973. () =>
  974. {
  975. ContinuousController.instance.StartCoroutine(ClearDeckCoroutine());
  976. IEnumerator ClearDeckCoroutine()
  977. {
  978. DraggingCover.SetActive(true);
  979. List<CEntity_Base> cEntity_Bases = new List<CEntity_Base>();
  980. foreach(CEntity_Base cEntity_Base in EdittingDeckData.DeckCards())
  981. {
  982. cEntity_Bases.Add(cEntity_Base);
  983. }
  984. foreach(CEntity_Base cEntity_Base in EdittingDeckData.DigitamaDeckCards())
  985. {
  986. cEntity_Bases.Add(cEntity_Base);
  987. }
  988. foreach(CEntity_Base cEntity_Base in cEntity_Bases)
  989. {
  990. yield return ContinuousController.instance.StartCoroutine(RemoveDeckCards(cEntity_Base));
  991. }
  992. for (int i = 0; i < DeckScroll.content.childCount; i++)
  993. {
  994. Destroy(DeckScroll.content.GetChild(i).gameObject);
  995. }
  996. yield return new WaitWhile(() => DeckScroll.content.childCount >= 1);
  997. DraggingCover.SetActive(false);
  998. }
  999. },
  1000. null,
  1001. };
  1002. List<string> CommandTexts = new List<string>()
  1003. {
  1004. LocalizeUtility.GetLocalizedString(
  1005. EngMessage: "Yes",
  1006. JpnMessage: "はい"
  1007. ),
  1008. LocalizeUtility.GetLocalizedString(
  1009. EngMessage: "No",
  1010. JpnMessage: "いいえ"
  1011. ),
  1012. };
  1013. Opening.instance.SetUpActiveYesNoObject(
  1014. Commands,
  1015. CommandTexts,
  1016. LocalizeUtility.GetLocalizedString(
  1017. EngMessage: "Remove all cards from the deck?",
  1018. JpnMessage: "全てのカードをデッキから除きますか?"
  1019. ),
  1020. true);
  1021. }
  1022. public void OnClickSetDeckIconButton()
  1023. {
  1024. ContinuousController.instance.StartCoroutine(Opening.instance.deck.deckListPanel.SetUpDeckListPanel(
  1025. EdittingDeckData,
  1026. OnClick,
  1027. LocalizeUtility.GetLocalizedString(
  1028. EngMessage: "Choose a deck icon card.",
  1029. JpnMessage: "デッキアイコン選択"
  1030. )));
  1031. void OnClick(CEntity_Base cEntity_Base)
  1032. {
  1033. EdittingDeckData.KeyCardId = cEntity_Base.CardIndex;
  1034. Opening.instance.deck.deckListPanel.Close();
  1035. Opening.instance.PlayDecisionSE();
  1036. }
  1037. }
  1038. }