ContinuousController.cs 41 KB

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