ContinuousController.cs 43 KB

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