ContinuousController.cs 42 KB

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