ContinuousController.cs 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using UnityEngine;
  9. using UnityEngine.Events;
  10. using UnityEngine.EventSystems;
  11. using UnityEngine.SceneManagement;
  12. using Hashtable = ExitGames.Client.Photon.Hashtable;
  13. public class ContinuousController : MonoBehaviour
  14. {
  15. [Header("game language")]
  16. // public Language language;
  17. [Header("Game version")]
  18. public float GameVer;
  19. [Header("ignore updates")]
  20. public bool IgnoreUpdate;
  21. [Header("card list")]
  22. public CEntity_Base[] CardList = new CEntity_Base[] { };
  23. [Header("Card list sorted by card ID")]
  24. public CEntity_Base[] SortedCardList = new CEntity_Base[] { };
  25. [Header("Card back image")]
  26. public Sprite ReverseCard;
  27. public Sprite ReverseCard_Digitama;
  28. [Header("SE prefab")]
  29. public SoundObject soundObject;
  30. [Header("deck code encryption")]
  31. public ShuffleDeckCode ShuffleDeckCode;
  32. DeckData _battleDeckData = null;
  33. public DeckData BattleDeckData
  34. {
  35. get
  36. {
  37. return _battleDeckData;
  38. }
  39. set
  40. {
  41. _battleDeckData = value;
  42. if (value != null)
  43. {
  44. LastBattleDeckData = value;
  45. }
  46. }
  47. }
  48. public DeckData LastBattleDeckData { get; private set; } = null;
  49. public bool NeedUpdate { get; set; }
  50. public bool isRandomMatch { get; set; }
  51. [HideInInspector] public List<SkillInfo> nullSkillInfos = null;
  52. public String GameVerString => Application.version;//GameVer.ToString(CultureInfo.InvariantCulture);
  53. #region Key for property to save deck data for battle
  54. public static string DeckDataPropertyKey => "BattleDeckData";
  55. #endregion
  56. #region Key for the property that stores the player name data
  57. public static string PlayerNameKey => "PlayerNameKey";
  58. #endregion
  59. #region Key for the property that stores the win count data
  60. public static string WinCountKey => "WinCountKey";
  61. #endregion
  62. [Header("Player name character limit")]
  63. public int PlayerNameMaxLength;
  64. #region Call up a scene for data storage
  65. public static IEnumerator LoadCoroutine()
  66. {
  67. if (instance == null)
  68. {
  69. SceneManager.LoadSceneAsync("ContinuousControllerScene", LoadSceneMode.Additive);
  70. while (instance == null)
  71. {
  72. yield return null;
  73. }
  74. instance.Init();
  75. }
  76. }
  77. #endregion
  78. #region List of Deck Recipes
  79. public List<DeckData> DeckDatas { get; set; } = new List<DeckData>();
  80. #endregion
  81. #region Deck Recipe Key
  82. public string DeckDatasPlayerPrefsKey { get { return "DeckDatas3"; } }
  83. #endregion
  84. public CEntity_Base DiaboromonToken { get; private set; }
  85. public CEntity_Base AmonToken { get; private set; }
  86. public CEntity_Base UmonToken { get; private set; }
  87. public CEntity_Base FujitsumonToken { get; private set; }
  88. public CEntity_Base GyuukimonToken { get; private set; }
  89. public CEntity_Base KoHagurumonToken { get; private set; }
  90. public CEntity_Base FamiliarToken { get; private set; }
  91. public CEntity_Base VoleeZerdruckenToken { get; private set; }
  92. public CardRestriction BanList { get; private set; } = new CardRestriction(new List<CardLimitCount>(), new List<BannedPair>());
  93. void LoadBanList()
  94. {
  95. BanList = DataBase.ENGBanList;
  96. }
  97. async Task CreateTokenData()
  98. {
  99. DiaboromonToken = new CEntity_Base()
  100. {
  101. cardColors = new List<CardColor>() { CardColor.White },
  102. PlayCost = 14,
  103. Level = 6,
  104. CardName_JPN = "ディアボロモン",
  105. CardName_ENG = "Diaboromon",
  106. Form_JPN = new List<string>() { "究極体" },
  107. Form_ENG = new List<string>() { "Mega" },
  108. Attribute_JPN = new List<string>() { "不明" },
  109. Attribute_ENG = new List<string>() { "Unknown" },
  110. Type_JPN = new List<string>() { "種族不明" },
  111. Type_ENG = new List<string>() { "Unidentified" },
  112. CardSpriteName = "BT2-082-token",
  113. cardKind = CardKind.Digimon,
  114. DP = 3000,
  115. };
  116. await DiaboromonToken.GetCardSprite();
  117. AmonToken = new CEntity_Base()
  118. {
  119. cardColors = new List<CardColor>() { CardColor.Red },
  120. PlayCost = -1,
  121. Level = 0,
  122. CardName_JPN = "紅炎のアモン",
  123. CardName_ENG = "Amon of Crimson Flame",
  124. Form_JPN = new List<string>(),
  125. Form_ENG = new List<string>(),
  126. Attribute_JPN = new List<string>(),
  127. Attribute_ENG = new List<string>(),
  128. Type_JPN = new List<string>(),
  129. Type_ENG = new List<string>(),
  130. CardSpriteName = "BT14-018-token-red",
  131. cardKind = CardKind.Digimon,
  132. DP = 6000,
  133. CardEffectClassName = "Bushiagumon_BT4_038"
  134. };
  135. await AmonToken.GetCardSprite();
  136. UmonToken = new CEntity_Base()
  137. {
  138. cardColors = new List<CardColor>() { CardColor.Yellow },
  139. PlayCost = -1,
  140. Level = 0,
  141. CardName_JPN = "蒼雷のウモン",
  142. CardName_ENG = "Umon of Blue Thunder",
  143. Form_JPN = new List<string>(),
  144. Form_ENG = new List<string>(),
  145. Attribute_JPN = new List<string>(),
  146. Attribute_ENG = new List<string>(),
  147. Type_JPN = new List<string>(),
  148. Type_ENG = new List<string>(),
  149. CardSpriteName = "BT14-018-token-yellow",
  150. cardKind = CardKind.Digimon,
  151. DP = 6000,
  152. CardEffectClassName = "Koemon_BT1_031"
  153. };
  154. await UmonToken.GetCardSprite();
  155. FujitsumonToken = new CEntity_Base()
  156. {
  157. cardColors = new List<CardColor>() { CardColor.Purple },
  158. PlayCost = -1,
  159. Level = 0,
  160. CardName_JPN = "フジツモン",
  161. CardName_ENG = "Fujitsumon",
  162. Form_JPN = new List<string>(),
  163. Form_ENG = new List<string>(),
  164. Attribute_JPN = new List<string>(),
  165. Attribute_ENG = new List<string>(),
  166. Type_JPN = new List<string>(),
  167. Type_ENG = new List<string>(),
  168. CardSpriteName = "EX5-058-token",
  169. cardKind = CardKind.Digimon,
  170. DP = 3000,
  171. CardEffectClassName = "Fujitsumon_EX5_058_token"
  172. };
  173. await FujitsumonToken.GetCardSprite();
  174. GyuukimonToken = new CEntity_Base()
  175. {
  176. cardColors = new List<CardColor>() { CardColor.Purple },
  177. PlayCost = 7,
  178. Level = 5,
  179. CardName_JPN = "ギュウキモン",
  180. CardName_ENG = "Gyuukimon",
  181. Form_JPN = new List<string>() { "究極の" },
  182. Form_ENG = new List<string>() { "Ultimate" },
  183. Attribute_JPN = new List<string>() { "ウイルス" },
  184. Attribute_ENG = new List<string>() { "Virus" },
  185. Type_JPN = new List<string>() { "ダークアニマル" },
  186. Type_ENG = new List<string>() { "Dark Animal" },
  187. CardSpriteName = "LM-018-token",
  188. cardKind = CardKind.Digimon,
  189. DP = 3000,
  190. };
  191. await GyuukimonToken.GetCardSprite();
  192. KoHagurumonToken = new CEntity_Base()
  193. {
  194. cardColors = new List<CardColor>() { CardColor.Black },
  195. PlayCost = -1,
  196. Level = 0,
  197. CardName_JPN = "",
  198. CardName_ENG = "KoHagurumon",
  199. Form_JPN = new List<string>(),
  200. Form_ENG = new List<string>(),
  201. Attribute_JPN = new List<string>(),
  202. Attribute_ENG = new List<string>(),
  203. Type_JPN = new List<string>(),
  204. Type_ENG = new List<string>(),
  205. CardSpriteName = "BT16-052-token",
  206. cardKind = CardKind.Digimon,
  207. DP = 1000,
  208. CardEffectClassName = "KoHagurumon_BT16_052_token"
  209. };
  210. await KoHagurumonToken.GetCardSprite();
  211. FamiliarToken = new CEntity_Base()
  212. {
  213. cardColors = new List<CardColor>() { CardColor.Yellow },
  214. PlayCost = -1,
  215. Level = 0,
  216. CardName_JPN = "",
  217. CardName_ENG = "Familiar",
  218. Form_JPN = new List<string>(),
  219. Form_ENG = new List<string>(),
  220. Attribute_JPN = new List<string>(),
  221. Attribute_ENG = new List<string>(),
  222. Type_JPN = new List<string>(),
  223. Type_ENG = new List<string>(),
  224. CardSpriteName = "EX7-030-token",
  225. cardKind = CardKind.Digimon,
  226. DP = 3000,
  227. CardEffectClassName = "Familiar_EX7_030_token"
  228. };
  229. await FamiliarToken.GetCardSprite();
  230. VoleeZerdruckenToken = new CEntity_Base()
  231. {
  232. cardColors = new List<CardColor>() { CardColor.Purple },
  233. PlayCost = -1,
  234. Level = 4,
  235. CardName_JPN = "",
  236. CardName_ENG = "Volée & Zerdrücken",
  237. Form_JPN = new List<string>(),
  238. Form_ENG = new List<string>(),
  239. Attribute_JPN = new List<string>(),
  240. Attribute_ENG = new List<string>(),
  241. Type_JPN = new List<string>(),
  242. Type_ENG = new List<string>(),
  243. CardSpriteName = "EX7-058-token",
  244. cardKind = CardKind.Digimon,
  245. DP = 5000,
  246. CardEffectClassName = "VoléeZerdrücken_EX7_030_token"
  247. };
  248. await VoleeZerdruckenToken.GetCardSprite();
  249. }
  250. public static ContinuousController instance = null;
  251. private void Awake()
  252. {
  253. instance = this;
  254. }
  255. public async void Init()
  256. {
  257. Application.targetFrameRate = 60;
  258. int random = RandomUtility.getRamdom();
  259. UnityEngine.Random.InitState(random);
  260. Debug.Log($"Game Initialize - random number sequence initialization,InitState:{random}");
  261. Sprite reverseCardSprite = await StreamingAssetsUtility.GetSprite("card_back_main");
  262. if (reverseCardSprite != null)
  263. {
  264. ReverseCard = reverseCardSprite;
  265. }
  266. Sprite reverseDigieggCardSprite = await StreamingAssetsUtility.GetSprite("card_back_sub");
  267. if (reverseDigieggCardSprite != null)
  268. {
  269. ReverseCard_Digitama = reverseDigieggCardSprite;
  270. }
  271. LoadBanList();
  272. // deck data
  273. //DeckDatas = PlayerPrefsUtil.LoadList<DeckData>(DeckDatasPlayerPrefsKey);
  274. LoadDeckLists();
  275. GetComponent<StarterDeck>().SetStarterDecks();
  276. // player data
  277. LoadPlayerName();
  278. LoadWinCount();
  279. // game play
  280. LoadAutoEffectOrder();
  281. LoadAutoDeckBottomOrder();
  282. LoadAutoDeckTopOrder();
  283. LoadAutoMinDigivolutionCost();
  284. LoadAutoMaxCardCount();
  285. LoadAutoHatch();
  286. LoadShowCutInAnimation();
  287. LoadReverseOpponentsCards();
  288. LoadTurnSuspendedCards();
  289. LoadCheckBeforeEndingSelection();
  290. LoadSuspendedCardsDirectionIsLeft();
  291. //Graphics
  292. LoadShowBackgroundParticle();
  293. // Sound
  294. LoadVolume();
  295. // ServerRegion
  296. LoadServerRegion();
  297. // Language
  298. LoadLanguage();
  299. await CreateTokenData();
  300. DontDestroyOnLoad(gameObject);
  301. }
  302. [Obsolete("This is obsolete, switching to save files")]
  303. public void ModifyAllDeckDatas()
  304. {
  305. List<DeckData> tempDeckDatas = new List<DeckData>();
  306. foreach (DeckData deckData in DeckDatas)
  307. {
  308. tempDeckDatas.Add(deckData);
  309. }
  310. foreach (DeckData deckData in tempDeckDatas)
  311. {
  312. if (deckData.AllDeckCards().Count == 0)
  313. {
  314. DeckDatas.Remove(deckData);
  315. }
  316. }
  317. for (int i = 0; i < DeckDatas.Count; i++)
  318. {
  319. //DeckData deckData = new DeckData(DeckData.GetDeckCode(DeckDatas[i].DeckName, DeckData.SortedDeckCardsList(DeckDatas[i].DeckCards()), DeckData.SortedDeckCardsList(DeckDatas[i].DigitamaDeckCards()), DeckDatas[i].KeyCard));
  320. DeckData deckData = DeckDatas[i];
  321. DeckDatas[i] = deckData.ModifiedDeckData();
  322. }
  323. SaveDeckDatas();
  324. }
  325. [Obsolete("This is obsolete, switching to save files")]
  326. public void SaveDeckDatas()
  327. {
  328. PlayerPrefsUtil.SaveList(DeckDatasPlayerPrefsKey, DeckDatas);
  329. PlayerPrefs.Save();
  330. }
  331. public void SaveDeckData(DeckData data)
  332. {
  333. string savePath = StreamingAssetsUtility.GetStreamingAssetPath("Decks", false);
  334. File.WriteAllText($"{savePath}/{data.DeckName}_{data.DeckID}.txt", DeckCodeUtility.GetDeckBuilderFile(data));
  335. }
  336. public void RenameDeck(DeckData data, string newName)
  337. {
  338. string savePath = StreamingAssetsUtility.GetStreamingAssetPath("Decks", false);
  339. if (File.Exists($"{savePath}/{data.DeckName}_{data.DeckID}.txt"))
  340. {
  341. File.Move($"{savePath}/{data.DeckName}_{data.DeckID}.txt", $"{savePath}/{newName}_{data.DeckID}.txt");
  342. data.DeckName = newName;
  343. SaveDeckData(data);
  344. }
  345. else
  346. data.DeckName = newName;
  347. }
  348. public void DeleteDeck(DeckData data)
  349. {
  350. string filePath = StreamingAssetsUtility.GetStreamingAssetPath("Decks", false);
  351. if (!Directory.Exists(filePath))
  352. return;
  353. if (!File.Exists($"{filePath}/{data.DeckName}_{data.DeckID}.txt"))
  354. return;
  355. File.Delete($"{filePath}/{data.DeckName}_{data.DeckID}.txt");
  356. }
  357. public void DeleteAllDecks()
  358. {
  359. foreach(DeckData data in DeckDatas)
  360. {
  361. DeleteDeck(data);
  362. }
  363. }
  364. public void LoadDeckLists()
  365. {
  366. string loadPath = StreamingAssetsUtility.GetStreamingAssetPath("Decks", false);
  367. if (!Directory.Exists(loadPath))
  368. return;
  369. string[] deckLists = Directory.GetFiles(loadPath);
  370. foreach(string deckPath in deckLists)
  371. {
  372. string fileName = Path.GetFileNameWithoutExtension(deckPath);
  373. if (!fileName.Contains("_"))
  374. continue;
  375. string deckList = File.ReadAllText(deckPath);
  376. StreamReader sr = new StreamReader(deckPath);
  377. string deckName = sr.ReadLine().Replace("Name: ", "");
  378. int KeyCard = int.Parse(sr.ReadLine().Replace("Key Card: ", ""));
  379. int SortValue = int.Parse(sr.ReadLine().Replace("Sort Index: ", ""));
  380. sr.Close();
  381. string deck = deckList.Substring(deckList.IndexOf("//"));
  382. //Debug.Log(deckName);
  383. if(SortValue < 0)
  384. SortValue = 0;
  385. CreateDeckFromFile(fileName.Split("_")[1], deckName, KeyCard, deck, SortValue);
  386. }
  387. DeckDatas = DeckDatas.OrderBy(x => x.DeckName).ToList();
  388. }
  389. private void CreateDeckFromFile(string id, string name, int keyID, string deckCode, int index = 0)
  390. {
  391. List<CEntity_Base> AllDeckCards = DeckCodeUtility.GetAllDeckCardsFromDeckBuilderDeckCode(deckCode);
  392. if (AllDeckCards.Count == 0)
  393. {
  394. AllDeckCards = DeckCodeUtility.GetAllDeckCardsFromTTSDeckCode(deckCode);
  395. }
  396. List<CEntity_Base> deckCards = new List<CEntity_Base>();
  397. List<CEntity_Base> digitamaDeckCards = new List<CEntity_Base>();
  398. foreach (CEntity_Base cEntity_Base in AllDeckCards)
  399. {
  400. if (cEntity_Base.cardKind == CardKind.DigiEgg)
  401. {
  402. digitamaDeckCards.Add(cEntity_Base);
  403. }
  404. else
  405. {
  406. deckCards.Add(cEntity_Base);
  407. }
  408. }
  409. Debug.Log($"Create Deck From File: {name}");
  410. DeckData deckData = (new DeckData(DeckData.GetDeckCode(name, deckCards, digitamaDeckCards, null),id)).ModifiedDeckData();
  411. deckData.KeyCardId = keyID;
  412. deckData.DeckName = name;
  413. deckData.SortValue = index;
  414. DeckDatas.Insert(index, deckData);
  415. }
  416. #region Player Name
  417. string _playerName;
  418. string _playerNameKey = "PlayerName";
  419. public string PlayerName
  420. {
  421. get
  422. {
  423. if (string.IsNullOrEmpty(_playerName))
  424. {
  425. return "Player";
  426. }
  427. return _playerName;
  428. }
  429. set
  430. {
  431. _playerName = DeckData.ValidateDeckName(value);
  432. }
  433. }
  434. public void SavePlayerName(string playerName)
  435. {
  436. PlayerName = playerName;
  437. PlayerPrefs.SetString(_playerNameKey, playerName);
  438. PlayerPrefs.Save();
  439. }
  440. public void LoadPlayerName()
  441. {
  442. if (PlayerPrefs.HasKey(_playerNameKey))
  443. {
  444. PlayerName = PlayerPrefs.GetString(_playerNameKey);
  445. }
  446. if (string.IsNullOrEmpty(PlayerName))
  447. {
  448. PlayerName = "Player";
  449. }
  450. }
  451. #endregion
  452. #region number of victories
  453. public int WinCount { get; set; }
  454. string _winCountKey = "WinCount";
  455. public void SaveWinCount()
  456. {
  457. PlayerPrefs.SetInt(_winCountKey, WinCount);
  458. PlayerPrefs.Save();
  459. }
  460. public void LoadWinCount()
  461. {
  462. if (PlayerPrefs.HasKey(_winCountKey))
  463. {
  464. WinCount = PlayerPrefs.GetInt(_winCountKey);
  465. }
  466. }
  467. #endregion
  468. #region Auto effect order
  469. [HideInInspector] public bool autoEffectOrder = false;
  470. string _autoEffectOrderKey = "AutoEffectOrder";
  471. public void SaveAutoEffectOrder()
  472. {
  473. PlayerPrefsUtil.SetBool(_autoEffectOrderKey, autoEffectOrder);
  474. PlayerPrefs.Save();
  475. }
  476. public void LoadAutoEffectOrder()
  477. {
  478. autoEffectOrder = PlayerPrefsUtil.GetBool(_autoEffectOrderKey, false);
  479. }
  480. #endregion
  481. #region Auto deck bottom order
  482. [HideInInspector] public bool autoDeckBottomOrder = false;
  483. string _autoDeckBottomOrderKey = "AutoDeckBottomOrder";
  484. public void SaveAutoDeckBottomOrder()
  485. {
  486. PlayerPrefsUtil.SetBool(_autoDeckBottomOrderKey, autoDeckBottomOrder);
  487. PlayerPrefs.Save();
  488. }
  489. public void LoadAutoDeckBottomOrder()
  490. {
  491. autoDeckBottomOrder = PlayerPrefsUtil.GetBool(_autoDeckBottomOrderKey, false);
  492. }
  493. #endregion
  494. #region Auto deck top order
  495. [HideInInspector] public bool autoDeckTopOrder = false;
  496. string _autoDeckTopOrderKey = "AutoDeckTopOrder";
  497. public void SaveAutoDeckTopOrder()
  498. {
  499. PlayerPrefsUtil.SetBool(_autoDeckTopOrderKey, autoDeckTopOrder);
  500. PlayerPrefs.Save();
  501. }
  502. public void LoadAutoDeckTopOrder()
  503. {
  504. autoDeckTopOrder = PlayerPrefsUtil.GetBool(_autoDeckTopOrderKey, false);
  505. }
  506. #endregion
  507. #region Auto min digivolution cost
  508. [HideInInspector] public bool autoMinDigivolutionCost = false;
  509. string _autoMinDigivolutionCostKey = "AutoMinDigivolutionCost";
  510. public void SaveAutoMinDigivolutionCost()
  511. {
  512. PlayerPrefsUtil.SetBool(_autoMinDigivolutionCostKey, autoMinDigivolutionCost);
  513. PlayerPrefs.Save();
  514. }
  515. public void LoadAutoMinDigivolutionCost()
  516. {
  517. autoMinDigivolutionCost = PlayerPrefsUtil.GetBool(_autoMinDigivolutionCostKey, false);
  518. }
  519. #endregion
  520. #region Auto max card count
  521. [HideInInspector] public bool autoMaxCardCount = false;
  522. string _autoMaxCardCountKey = "AutoMaxCardCount";
  523. public void SaveAutoMaxCardCount()
  524. {
  525. PlayerPrefsUtil.SetBool(_autoMaxCardCountKey, autoMaxCardCount);
  526. PlayerPrefs.Save();
  527. }
  528. public void LoadAutoMaxCardCount()
  529. {
  530. autoMaxCardCount = PlayerPrefsUtil.GetBool(_autoMaxCardCountKey, false);
  531. }
  532. #endregion
  533. #region Auto hatch
  534. [HideInInspector] public bool autoHatch = false;
  535. string _autoHatchKey = "AutoHatch";
  536. public void SaveAutoHatch()
  537. {
  538. PlayerPrefsUtil.SetBool(_autoHatchKey, autoHatch);
  539. PlayerPrefs.Save();
  540. }
  541. public void LoadAutoHatch()
  542. {
  543. autoHatch = PlayerPrefsUtil.GetBool(_autoHatchKey, false);
  544. }
  545. #endregion
  546. #region Show CutIn Animation
  547. [HideInInspector] public bool showCutInAnimation = false;
  548. string _showCutInAnimationKey = "ShowCutInAnimation";
  549. public void SaveShowCutInAnimation()
  550. {
  551. PlayerPrefsUtil.SetBool(_showCutInAnimationKey, showCutInAnimation);
  552. PlayerPrefs.Save();
  553. }
  554. public void LoadShowCutInAnimation()
  555. {
  556. //TODO: Setting default to false, to fix animation syncing bug, MB
  557. showCutInAnimation = false;
  558. //showCutInAnimation = PlayerPrefsUtil.GetBool(_showCutInAnimationKey, true);
  559. }
  560. #endregion
  561. #region Reverse opponents' cards
  562. [HideInInspector] public bool reverseOpponentsCards = false;
  563. string _reverseOpponentsCardsKey = "ReverseOpponentsCards";
  564. public void SaveReverseOpponentsCards()
  565. {
  566. PlayerPrefsUtil.SetBool(_reverseOpponentsCardsKey, reverseOpponentsCards);
  567. PlayerPrefs.Save();
  568. }
  569. public void LoadReverseOpponentsCards()
  570. {
  571. reverseOpponentsCards = PlayerPrefsUtil.GetBool(_reverseOpponentsCardsKey, false);
  572. }
  573. #endregion
  574. #region Turn suspended cards
  575. [HideInInspector] public bool turnSuspendedCards = false;
  576. string _turnSuspendedCardsKey = "TurnSuspendedCards";
  577. public void SaveTurnSuspendedCards()
  578. {
  579. PlayerPrefsUtil.SetBool(_turnSuspendedCardsKey, turnSuspendedCards);
  580. PlayerPrefs.Save();
  581. }
  582. public void LoadTurnSuspendedCards()
  583. {
  584. turnSuspendedCards = PlayerPrefsUtil.GetBool(_turnSuspendedCardsKey, true);
  585. }
  586. #endregion
  587. #region Check before ending selection
  588. [HideInInspector] public bool checkBeforeEndingSelection = false;
  589. string _checkBeforeEndingSelectionKey = "CheckBeforeEndingSelection";
  590. public void SaveCheckBeforeEndingSelection()
  591. {
  592. PlayerPrefsUtil.SetBool(_checkBeforeEndingSelectionKey, checkBeforeEndingSelection);
  593. PlayerPrefs.Save();
  594. }
  595. public void LoadCheckBeforeEndingSelection()
  596. {
  597. checkBeforeEndingSelection = PlayerPrefsUtil.GetBool(_checkBeforeEndingSelectionKey, true);
  598. }
  599. #endregion
  600. #region Suspended cards' direction is left
  601. [HideInInspector] public bool suspendedCardsDirectionIsLeft = false;
  602. string _suspendedCardsDirectionIsLeftKey = "SuspendedCardsDirectionIsLeft";
  603. public void SaveSuspendedCardsDirectionIsLeft()
  604. {
  605. PlayerPrefsUtil.SetBool(_suspendedCardsDirectionIsLeftKey, suspendedCardsDirectionIsLeft);
  606. PlayerPrefs.Save();
  607. }
  608. public void LoadSuspendedCardsDirectionIsLeft()
  609. {
  610. suspendedCardsDirectionIsLeft = PlayerPrefsUtil.GetBool(_suspendedCardsDirectionIsLeftKey, true);
  611. }
  612. #endregion
  613. #region Show background particle
  614. [HideInInspector] public bool showBackgroundParticle = false;
  615. string _showBackgroundParticleKey = "ShowBackgroundParticle";
  616. public void SaveShowBackgroundParticle()
  617. {
  618. PlayerPrefsUtil.SetBool(_showBackgroundParticleKey, showBackgroundParticle);
  619. PlayerPrefs.Save();
  620. }
  621. public void LoadShowBackgroundParticle()
  622. {
  623. showBackgroundParticle = PlayerPrefsUtil.GetBool(_showBackgroundParticleKey, true);
  624. }
  625. #endregion
  626. #region Sound volume
  627. public float BGMVolume { get; set; }
  628. public float SEVolume { get; set; }
  629. public void SetBGMVolume(float BGMVolume)
  630. {
  631. this.BGMVolume = BGMVolume;
  632. PlayerPrefs.SetFloat("BGMVolume", BGMVolume);
  633. PlayerPrefs.Save();
  634. }
  635. public void SetSEVolume(float SEVolume)
  636. {
  637. this.SEVolume = SEVolume;
  638. PlayerPrefs.SetFloat("SEVolume", SEVolume);
  639. PlayerPrefs.Save();
  640. }
  641. public void ChangeBGMVolume(AudioSource audioSource)
  642. {
  643. audioSource.volume = BGMVolume * 0.25f * 0.8f;
  644. }
  645. public void ChangeSEVolume(AudioSource audioSource)
  646. {
  647. audioSource.volume = SEVolume * 0.5f * 0.8f;
  648. }
  649. void LoadVolume()
  650. {
  651. BGMVolume = 0.5f;
  652. SEVolume = 0.5f;
  653. if (PlayerPrefs.HasKey("BGMVolume"))
  654. {
  655. BGMVolume = PlayerPrefs.GetFloat("BGMVolume");
  656. }
  657. if (PlayerPrefs.HasKey("SEVolume"))
  658. {
  659. SEVolume = PlayerPrefs.GetFloat("SEVolume");
  660. }
  661. }
  662. #endregion
  663. #region Server region
  664. [HideInInspector] public string serverRegion = "us";
  665. string _serverRegionKey = "ServerRegion";
  666. public void SaveServerRegion()
  667. {
  668. PlayerPrefs.SetString(_serverRegionKey, serverRegion);
  669. PlayerPrefs.Save();
  670. }
  671. public void LoadServerRegion()
  672. {
  673. serverRegion = PlayerPrefs.GetString(_serverRegionKey, "us");
  674. }
  675. public string LastConnectServerRegion = "";
  676. #endregion
  677. #region Language
  678. [HideInInspector] public Language language = Language.ENG;
  679. string _languageKey = "Language";
  680. public void SaveLanguage()
  681. {
  682. PlayerPrefs.SetString(_languageKey, language.ToString());
  683. PlayerPrefs.Save();
  684. }
  685. public void LoadLanguage()
  686. {
  687. language = (Language)Enum.Parse(typeof(Language), PlayerPrefs.GetString(_languageKey, "ENG"));
  688. }
  689. #endregion
  690. #region PlaySE(AudioClip clip)
  691. public SoundObject PlaySE(AudioClip clip)
  692. {
  693. SoundObject _soundObject = Instantiate(soundObject);
  694. _soundObject.PlaySE(clip);
  695. return _soundObject;
  696. }
  697. #endregion
  698. #region カードIndexからカードを取得
  699. public CEntity_Base getCardEntityByCardID(int cardIndex)
  700. {
  701. int searchIndex = cardIndex - 1;
  702. int count = 0;
  703. do
  704. {
  705. if (count != 0)
  706. {
  707. searchIndex += (int)Math.Pow(-1, count % 2) * count / 2;
  708. }
  709. if (0 <= searchIndex)
  710. {
  711. if (searchIndex <= SortedCardList.Length - 1)
  712. {
  713. CEntity_Base cEntity_Base = SortedCardList[searchIndex];
  714. if (cEntity_Base != null)
  715. {
  716. if (cEntity_Base.CardIndex == cardIndex)
  717. {
  718. return cEntity_Base;
  719. }
  720. }
  721. }
  722. else
  723. {
  724. for (int i = 0; i < 300; i++)
  725. {
  726. CEntity_Base cEntity_Base = SortedCardList[SortedCardList.Length - 1 - i];
  727. if (cEntity_Base != null)
  728. {
  729. if (cEntity_Base.CardIndex == cardIndex)
  730. {
  731. return cEntity_Base;
  732. }
  733. }
  734. }
  735. return null;
  736. }
  737. }
  738. if (count != 0)
  739. {
  740. searchIndex -= (int)Math.Pow(-1, count % 2) * count / 2;
  741. }
  742. count++;
  743. }
  744. while (count <= 20);
  745. return null;
  746. }
  747. #endregion
  748. public Coroutine LoadingTextCoroutine;
  749. bool _endBattle = false;
  750. public void EndBattle()
  751. {
  752. if (!_endBattle)
  753. {
  754. _endBattle = true;
  755. StartCoroutine(EndBattleCoroutine());
  756. }
  757. }
  758. public IEnumerator EndBattleCoroutine()
  759. {
  760. if (Opening.instance == null)
  761. {
  762. yield break;
  763. }
  764. Opening.instance.openingObject.SetActive(true);
  765. //yield return StartCoroutine(Opening.instance.LoadingObject_Unload.StartLoading("Now Loading"));
  766. //Camera camera1 = Camera.main;
  767. //Destroy(camera1.gameObject);
  768. //yield return null;
  769. isAI = false;
  770. int random = RandomUtility.getRamdom();
  771. UnityEngine.Random.InitState(random);
  772. Debug.Log($"random number sequence initialization, InitState:{random}");
  773. var unload = SceneManager.UnloadSceneAsync("BattleScene");
  774. yield return unload;
  775. yield return Resources.UnloadUnusedAssets();
  776. yield return StartCoroutine(Opening.instance.LoadingObject_Unload.StartLoading("Now Loading"));
  777. //Opening.instance.MainCamera.gameObject.SetActive(true);
  778. foreach (Camera camera in Opening.instance.openingCameras)
  779. {
  780. camera.gameObject.SetActive(true);
  781. }
  782. Opening.instance.LoadingObject_light.gameObject.SetActive(false);
  783. yield return ContinuousController.instance.StartCoroutine(PhotonUtility.SetPlayerName());
  784. if (isRandomMatch)
  785. {
  786. Debug.Log("Unload from Random Match");
  787. yield return StartCoroutine(Opening.instance.battle.lobbyManager_RandomMatch.CloseLobbyCoroutine());
  788. yield return StartCoroutine(Opening.instance.battle.selectBattleMode.SetUpSelectBattleModeCoroutine());
  789. }
  790. else
  791. {
  792. Debug.Log("Unload from Room Match");
  793. yield return StartCoroutine(Opening.instance.battle.roomManager.Init(true));
  794. yield return new WaitForSeconds(0.1f);
  795. }
  796. yield return new WaitWhile(() => GManager.instance != null);
  797. Opening.instance.LoadingObject.gameObject.SetActive(false);
  798. yield return StartCoroutine(Opening.instance.LoadingObject_Unload.EndLoading());
  799. _endBattle = false;
  800. if (!isRandomMatch)
  801. {
  802. Hashtable PlayerProp = PhotonNetwork.LocalPlayer.CustomProperties;
  803. if (PlayerProp.TryGetValue("isBattle", out object value))
  804. {
  805. PlayerProp["isBattle"] = false;
  806. }
  807. else
  808. {
  809. PlayerProp.Add("isBattle", false);
  810. }
  811. PhotonNetwork.LocalPlayer.SetCustomProperties(PlayerProp);
  812. }
  813. Scene newScene = SceneManager.GetSceneByName("Opening");
  814. SceneManager.SetActiveScene(newScene);
  815. for (int i = 0; i < 3; i++)
  816. {
  817. yield return new WaitForSeconds(0.1f);
  818. EventSystem.current.SetSelectedGameObject(Opening.instance.battle.selectBattleMode.transform.GetChild(0).gameObject);
  819. //Debug.Log("フォーカスを設定");
  820. }
  821. //GUI.UnfocusWindow();
  822. yield return null;
  823. //StartCoroutine(DestroyEffectCoroutine());
  824. if (Opening.instance.OpeningBGM != null)
  825. {
  826. if (!Opening.instance.OpeningBGM.isPlaying)
  827. {
  828. Opening.instance.OpeningBGM.StartPlayBGM(Opening.instance.bgm);
  829. }
  830. }
  831. }
  832. private void Update()
  833. {
  834. #if UNITY_WINDOWS
  835. if (Input.GetKey(KeyCode.Escape))
  836. {
  837. Application.Quit();
  838. }
  839. #endif
  840. }
  841. int _frameCount = 0;
  842. int _updateFrame = 40;
  843. void LateUpdate()
  844. {
  845. #region Update only once every few frames
  846. _frameCount++;
  847. if (_frameCount < _updateFrame)
  848. {
  849. return;
  850. }
  851. else
  852. {
  853. _frameCount = 0;
  854. }
  855. #endregion
  856. if (PhotonNetwork.InRoom)
  857. {
  858. if (!isAI)
  859. {
  860. bool notEnterOther = false;
  861. if (PhotonNetwork.PlayerList.Length == 1)
  862. {
  863. if (GManager.instance != null)
  864. {
  865. notEnterOther = true;
  866. }
  867. }
  868. if (notEnterOther)
  869. {
  870. if (PhotonNetwork.CurrentRoom.MaxPlayers != 1)
  871. {
  872. PhotonNetwork.CurrentRoom.MaxPlayers = 1;
  873. }
  874. }
  875. else
  876. {
  877. if (PhotonNetwork.CurrentRoom.MaxPlayers != 2)
  878. {
  879. PhotonNetwork.CurrentRoom.MaxPlayers = 2;
  880. }
  881. }
  882. }
  883. }
  884. }
  885. public bool isAI { get; set; } = false;
  886. //Flag that the sharing of the random number sequence is over.
  887. public bool DoneSetRandom { get; set; } = false;
  888. public bool CanSetRandom { get; set; } = false;
  889. [PunRPC]
  890. public void SetRandom(int random)
  891. {
  892. StartCoroutine(SetRandomCoroutine(random));
  893. }
  894. IEnumerator SetRandomCoroutine(int random)
  895. {
  896. yield return new WaitWhile(() => !CanSetRandom);
  897. UnityEngine.Random.InitState(random);
  898. DoneSetRandom = true;
  899. Debug.Log($"random number sequence initialization,InitState:{random}");
  900. }
  901. }
  902. #region Manage random numbers
  903. public static class RandomUtility
  904. {
  905. private static System.Random random;
  906. public static int getRamdom()
  907. {
  908. int _max = 1500000000;
  909. if (random == null)
  910. {
  911. random = new System.Random((int)DateTime.Now.Ticks);
  912. }
  913. return random.Next(0, _max);
  914. }
  915. #region IsSucceedProbability(float Probability)
  916. public static bool IsSucceedProbability(float Probability)
  917. {
  918. if (Probability >= 1)
  919. {
  920. return true;
  921. }
  922. if (Probability <= 0)
  923. {
  924. return false;
  925. }
  926. float random = UnityEngine.Random.Range(0f, 1f);
  927. if (random <= Probability)
  928. {
  929. return true;
  930. }
  931. return false;
  932. }
  933. #endregion
  934. #region Shuffle the deck
  935. public static List<CEntity_Base> ShuffledDeckCards(List<CEntity_Base> DeckCards)
  936. {
  937. List<CEntity_Base> CardDatas = new List<CEntity_Base>();
  938. CardDatas.AddRange(DeckCards);
  939. // The initial value of the integer n is the number of cards in the deck
  940. int n = CardDatas.Count;
  941. while (n > 0)
  942. {
  943. n--;
  944. // Random index from 0 to i (inclusive)
  945. int k = UnityEngine.Random.Range(0, n + 1);
  946. // Swap elements at indices i and k
  947. CEntity_Base temp = CardDatas[n];
  948. CardDatas[n] = CardDatas[k];
  949. CardDatas[k] = temp;
  950. }
  951. return CardDatas;
  952. }
  953. public static List<CardSource> ShuffledDeckCards(List<CardSource> DeckCards)
  954. {
  955. List<CardSource> CardDatas = new List<CardSource>();
  956. CardDatas.AddRange(DeckCards);
  957. // The initial value of the integer n is the number of cards in the deck
  958. int n = CardDatas.Count;
  959. while (n > 0)
  960. {
  961. n--;
  962. // Random index from 0 to i (inclusive)
  963. int k = UnityEngine.Random.Range(0, n + 1);
  964. // Swap elements at indices i and k
  965. CardSource temp = CardDatas[n];
  966. CardDatas[n] = CardDatas[k];
  967. CardDatas[k] = temp;
  968. }
  969. return CardDatas;
  970. }
  971. #endregion
  972. }
  973. #endregion
  974. #region Manage connections to Photon
  975. public class PhotonUtility
  976. {
  977. #region Disconnected from Photon
  978. public static IEnumerator DisconnectCoroutine()
  979. {
  980. #region Exit Room
  981. if (PhotonNetwork.InRoom)
  982. {
  983. PhotonNetwork.LeaveRoom();
  984. }
  985. yield return new WaitWhile(() => PhotonNetwork.InRoom);
  986. #endregion
  987. #region Exit from the lobby
  988. if (PhotonNetwork.InLobby)
  989. {
  990. PhotonNetwork.LeaveLobby();
  991. }
  992. yield return new WaitWhile(() => PhotonNetwork.InLobby);
  993. #endregion
  994. #region Disconnected from Photon
  995. if (PhotonNetwork.IsConnected)
  996. {
  997. PhotonNetwork.Disconnect();
  998. }
  999. yield return new WaitWhile(() => PhotonNetwork.IsConnected);
  1000. #endregion
  1001. }
  1002. #endregion
  1003. #region Connect to Photon server
  1004. public static IEnumerator ConnectToMasterServerCoroutine()
  1005. {
  1006. if (!PhotonNetwork.IsConnected || ContinuousController.instance.LastConnectServerRegion != ContinuousController.instance.serverRegion)
  1007. {
  1008. if (PhotonNetwork.IsConnected)
  1009. {
  1010. yield return ContinuousController.instance.StartCoroutine(DisconnectCoroutine());
  1011. yield return new WaitWhile(() => PhotonNetwork.IsConnected);
  1012. }
  1013. PhotonNetwork.NetworkingClient.AppId = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime;
  1014. PhotonNetwork.ConnectToRegion(ContinuousController.instance.serverRegion);
  1015. PhotonNetwork.NickName = ContinuousController.instance.PlayerName;
  1016. PhotonNetwork.GameVersion = ContinuousController.instance.GameVerString;
  1017. ContinuousController.instance.LastConnectServerRegion = ContinuousController.instance.serverRegion;
  1018. }
  1019. yield return new WaitWhile(() => !PhotonNetwork.IsConnectedAndReady);
  1020. }
  1021. #endregion
  1022. #region Connect to Photon Server and Lobby
  1023. public static IEnumerator ConnectToLobbyCoroutine()
  1024. {
  1025. #region Connect to Photon server
  1026. yield return ContinuousController.instance.StartCoroutine(ConnectToMasterServerCoroutine());
  1027. #endregion
  1028. #region Save player name to custom properties
  1029. yield return ContinuousController.instance.StartCoroutine(SetPlayerName());
  1030. #endregion
  1031. #region Save the number of wins to a custom property
  1032. Hashtable hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1033. object value;
  1034. hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1035. if (hash.TryGetValue(ContinuousController.WinCountKey, out value))
  1036. {
  1037. hash[ContinuousController.WinCountKey] = ContinuousController.instance.WinCount;
  1038. }
  1039. else
  1040. {
  1041. hash.Add(ContinuousController.WinCountKey, ContinuousController.instance.WinCount);
  1042. }
  1043. PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
  1044. while (true)
  1045. {
  1046. Hashtable _hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1047. if (_hash.TryGetValue(ContinuousController.WinCountKey, out value))
  1048. {
  1049. if ((int)value == ContinuousController.instance.WinCount)
  1050. {
  1051. break;
  1052. }
  1053. }
  1054. yield return null;
  1055. }
  1056. #endregion
  1057. #region Connect to Lobby
  1058. if (!PhotonNetwork.InLobby)
  1059. {
  1060. PhotonNetwork.JoinLobby();
  1061. }
  1062. yield return new WaitWhile(() => !PhotonNetwork.InLobby);
  1063. yield return new WaitUntil(() => PhotonNetwork.InLobby && PhotonNetwork.IsConnectedAndReady);
  1064. #endregion
  1065. }
  1066. #endregion
  1067. #region Save player name to properties
  1068. public static IEnumerator SetPlayerName()
  1069. {
  1070. Hashtable hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1071. object value;
  1072. hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1073. if (hash.TryGetValue(ContinuousController.PlayerNameKey, out value))
  1074. {
  1075. hash[ContinuousController.PlayerNameKey] = ContinuousController.instance.PlayerName;
  1076. }
  1077. else
  1078. {
  1079. hash.Add(ContinuousController.PlayerNameKey, ContinuousController.instance.PlayerName);
  1080. }
  1081. PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
  1082. while (true)
  1083. {
  1084. Hashtable _hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1085. if (_hash.TryGetValue(ContinuousController.PlayerNameKey, out value))
  1086. {
  1087. if ((string)value == ContinuousController.instance.PlayerName)
  1088. {
  1089. break;
  1090. }
  1091. }
  1092. yield return null;
  1093. }
  1094. }
  1095. #endregion
  1096. #region Save deck data to custom properties
  1097. public static IEnumerator SignUpBattleDeckData()
  1098. {
  1099. Hashtable hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1100. if (hash.TryGetValue(ContinuousController.DeckDataPropertyKey, out object value))
  1101. {
  1102. hash[ContinuousController.DeckDataPropertyKey] = ContinuousController.instance.BattleDeckData.GetThisDeckCode();
  1103. }
  1104. else
  1105. {
  1106. Debug.Log($"SIGN UP BATTLE DECK: {ContinuousController.DeckDataPropertyKey}");
  1107. Debug.Log($"SIGN UP BATTLE DECK: {ContinuousController.instance.BattleDeckData.GetThisDeckCode()}");
  1108. hash.Add(ContinuousController.DeckDataPropertyKey, ContinuousController.instance.BattleDeckData.GetThisDeckCode());
  1109. }
  1110. //Debug.Log($"バトルデッキデータ登録,KeyCard:{ContinuousController.instance.BattleDeckData.KeyCard.CardName_JPN}");
  1111. PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
  1112. while (true)
  1113. {
  1114. Hashtable _hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1115. if (_hash.TryGetValue(ContinuousController.DeckDataPropertyKey, out value))
  1116. {
  1117. if ((string)value == ContinuousController.instance.BattleDeckData.GetThisDeckCode())
  1118. {
  1119. break;
  1120. }
  1121. }
  1122. yield return null;
  1123. }
  1124. }
  1125. #endregion
  1126. #region Remove custom properties from deck data
  1127. public static IEnumerator DeleteBattleDeckData()
  1128. {
  1129. Hashtable hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1130. if (hash.TryGetValue(ContinuousController.DeckDataPropertyKey, out object value))
  1131. {
  1132. hash.Remove(ContinuousController.DeckDataPropertyKey);
  1133. }
  1134. PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
  1135. while (true)
  1136. {
  1137. Hashtable _hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1138. if (!_hash.TryGetValue(ContinuousController.DeckDataPropertyKey, out value))
  1139. {
  1140. break;
  1141. }
  1142. yield return null;
  1143. }
  1144. }
  1145. #endregion
  1146. }
  1147. #endregion
  1148. public enum Language
  1149. {
  1150. ENG,
  1151. JPN,
  1152. }