ContinuousController.cs 41 KB

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