ContinuousController.cs 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451
  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. CEntity_Base cEntity_Base = SortedCardList.First(entity => entity.CardIndex == cardIndex);
  724. return cEntity_Base;
  725. //TODO: REMOVE IN FUTURE
  726. /*do
  727. {
  728. if (count != 0)
  729. {
  730. searchIndex += (int)Math.Pow(-1, count % 2) * count / 2;
  731. }
  732. if (0 <= searchIndex)
  733. {
  734. if (searchIndex <= SortedCardList.Length - 1)
  735. {
  736. CEntity_Base cEntity_Base = SortedCardList[searchIndex];
  737. if (cEntity_Base != null)
  738. {
  739. if (cEntity_Base.CardIndex == cardIndex)
  740. {
  741. return cEntity_Base;
  742. }
  743. }
  744. }
  745. else
  746. {
  747. for (int i = 0; i < 300; i++)
  748. {
  749. CEntity_Base cEntity_Base = SortedCardList[SortedCardList.Length - 1 - i];
  750. if (cEntity_Base != null)
  751. {
  752. if (cEntity_Base.CardIndex == cardIndex)
  753. {
  754. return cEntity_Base;
  755. }
  756. }
  757. }
  758. return null;
  759. }
  760. }
  761. if (count != 0)
  762. {
  763. searchIndex -= (int)Math.Pow(-1, count % 2) * count / 2;
  764. }
  765. count++;
  766. }
  767. while (count <= 20);
  768. return null;*/
  769. }
  770. #endregion
  771. public Coroutine LoadingTextCoroutine;
  772. bool _endBattle = false;
  773. public void EndBattle()
  774. {
  775. if (!_endBattle)
  776. {
  777. _endBattle = true;
  778. StartCoroutine(EndBattleCoroutine());
  779. }
  780. }
  781. public IEnumerator EndBattleCoroutine()
  782. {
  783. if (Opening.instance == null)
  784. {
  785. yield break;
  786. }
  787. Opening.instance.openingObject.SetActive(true);
  788. //yield return StartCoroutine(Opening.instance.LoadingObject_Unload.StartLoading("Now Loading"));
  789. //Camera camera1 = Camera.main;
  790. //Destroy(camera1.gameObject);
  791. //yield return null;
  792. isAI = false;
  793. int random = RandomUtility.getRamdom();
  794. UnityEngine.Random.InitState(random);
  795. Debug.Log($"random number sequence initialization, InitState:{random}");
  796. var unload = SceneManager.UnloadSceneAsync("BattleScene");
  797. yield return unload;
  798. yield return Resources.UnloadUnusedAssets();
  799. yield return StartCoroutine(Opening.instance.LoadingObject_Unload.StartLoading("Now Loading"));
  800. //Opening.instance.MainCamera.gameObject.SetActive(true);
  801. foreach (Camera camera in Opening.instance.openingCameras)
  802. {
  803. camera.gameObject.SetActive(true);
  804. }
  805. Opening.instance.LoadingObject_light.gameObject.SetActive(false);
  806. yield return ContinuousController.instance.StartCoroutine(PhotonUtility.SetPlayerName());
  807. if (isRandomMatch)
  808. {
  809. Debug.Log("Unload from Random Match");
  810. yield return StartCoroutine(Opening.instance.battle.lobbyManager_RandomMatch.CloseLobbyCoroutine());
  811. yield return StartCoroutine(Opening.instance.battle.selectBattleMode.SetUpSelectBattleModeCoroutine());
  812. }
  813. else
  814. {
  815. Debug.Log("Unload from Room Match");
  816. yield return StartCoroutine(Opening.instance.battle.roomManager.Init(true));
  817. yield return new WaitForSeconds(0.1f);
  818. }
  819. yield return new WaitWhile(() => GManager.instance != null);
  820. Opening.instance.LoadingObject.gameObject.SetActive(false);
  821. yield return StartCoroutine(Opening.instance.LoadingObject_Unload.EndLoading());
  822. _endBattle = false;
  823. if (!isRandomMatch)
  824. {
  825. Hashtable PlayerProp = PhotonNetwork.LocalPlayer.CustomProperties;
  826. if (PlayerProp.TryGetValue("isBattle", out object value))
  827. {
  828. PlayerProp["isBattle"] = false;
  829. }
  830. else
  831. {
  832. PlayerProp.Add("isBattle", false);
  833. }
  834. PhotonNetwork.LocalPlayer.SetCustomProperties(PlayerProp);
  835. }
  836. Scene newScene = SceneManager.GetSceneByName("Opening");
  837. SceneManager.SetActiveScene(newScene);
  838. for (int i = 0; i < 3; i++)
  839. {
  840. yield return new WaitForSeconds(0.1f);
  841. EventSystem.current.SetSelectedGameObject(Opening.instance.battle.selectBattleMode.transform.GetChild(0).gameObject);
  842. //Debug.Log("フォーカスを設定");
  843. }
  844. //GUI.UnfocusWindow();
  845. yield return null;
  846. //StartCoroutine(DestroyEffectCoroutine());
  847. if (Opening.instance.OpeningBGM != null)
  848. {
  849. if (!Opening.instance.OpeningBGM.isPlaying)
  850. {
  851. Opening.instance.OpeningBGM.StartPlayBGM(Opening.instance.bgm);
  852. }
  853. }
  854. }
  855. private void Update()
  856. {
  857. #if UNITY_WINDOWS
  858. if (Input.GetKey(KeyCode.Escape))
  859. {
  860. Application.Quit();
  861. }
  862. #endif
  863. }
  864. int _frameCount = 0;
  865. int _updateFrame = 40;
  866. void LateUpdate()
  867. {
  868. #region Update only once every few frames
  869. _frameCount++;
  870. if (_frameCount < _updateFrame)
  871. {
  872. return;
  873. }
  874. else
  875. {
  876. _frameCount = 0;
  877. }
  878. #endregion
  879. if (PhotonNetwork.InRoom)
  880. {
  881. if (!isAI)
  882. {
  883. bool notEnterOther = false;
  884. if (PhotonNetwork.PlayerList.Length == 1)
  885. {
  886. if (GManager.instance != null)
  887. {
  888. notEnterOther = true;
  889. }
  890. }
  891. if (notEnterOther)
  892. {
  893. if (PhotonNetwork.CurrentRoom.MaxPlayers != 1)
  894. {
  895. PhotonNetwork.CurrentRoom.MaxPlayers = 1;
  896. }
  897. }
  898. else
  899. {
  900. if (PhotonNetwork.CurrentRoom.MaxPlayers != 2)
  901. {
  902. PhotonNetwork.CurrentRoom.MaxPlayers = 2;
  903. }
  904. }
  905. }
  906. }
  907. }
  908. public bool isAI { get; set; } = false;
  909. //Flag that the sharing of the random number sequence is over.
  910. public bool DoneSetRandom { get; set; } = false;
  911. public bool CanSetRandom { get; set; } = false;
  912. [PunRPC]
  913. public void SetRandom(int random)
  914. {
  915. StartCoroutine(SetRandomCoroutine(random));
  916. }
  917. IEnumerator SetRandomCoroutine(int random)
  918. {
  919. yield return new WaitWhile(() => !CanSetRandom);
  920. UnityEngine.Random.InitState(random);
  921. DoneSetRandom = true;
  922. Debug.Log($"random number sequence initialization,InitState:{random}");
  923. }
  924. }
  925. #region Manage random numbers
  926. public static class RandomUtility
  927. {
  928. private static System.Random random;
  929. public static int getRamdom()
  930. {
  931. int _max = 1500000000;
  932. if (random == null)
  933. {
  934. random = new System.Random((int)DateTime.Now.Ticks);
  935. }
  936. return random.Next(0, _max);
  937. }
  938. #region IsSucceedProbability(float Probability)
  939. public static bool IsSucceedProbability(float Probability)
  940. {
  941. if (Probability >= 1)
  942. {
  943. return true;
  944. }
  945. if (Probability <= 0)
  946. {
  947. return false;
  948. }
  949. float random = UnityEngine.Random.Range(0f, 1f);
  950. if (random <= Probability)
  951. {
  952. return true;
  953. }
  954. return false;
  955. }
  956. #endregion
  957. #region Shuffle the deck
  958. public static List<CEntity_Base> ShuffledDeckCards(List<CEntity_Base> DeckCards)
  959. {
  960. List<CEntity_Base> CardDatas = new List<CEntity_Base>();
  961. CardDatas.AddRange(DeckCards);
  962. // The initial value of the integer n is the number of cards in the deck
  963. int n = CardDatas.Count;
  964. while (n > 0)
  965. {
  966. n--;
  967. // Random index from 0 to i (inclusive)
  968. int k = UnityEngine.Random.Range(0, n + 1);
  969. // Swap elements at indices i and k
  970. CEntity_Base temp = CardDatas[n];
  971. CardDatas[n] = CardDatas[k];
  972. CardDatas[k] = temp;
  973. }
  974. return CardDatas;
  975. }
  976. public static List<CardSource> ShuffledDeckCards(List<CardSource> DeckCards)
  977. {
  978. List<CardSource> CardDatas = new List<CardSource>();
  979. CardDatas.AddRange(DeckCards);
  980. // The initial value of the integer n is the number of cards in the deck
  981. int n = CardDatas.Count;
  982. while (n > 0)
  983. {
  984. n--;
  985. // Random index from 0 to i (inclusive)
  986. int k = UnityEngine.Random.Range(0, n + 1);
  987. // Swap elements at indices i and k
  988. CardSource temp = CardDatas[n];
  989. CardDatas[n] = CardDatas[k];
  990. CardDatas[k] = temp;
  991. }
  992. return CardDatas;
  993. }
  994. #endregion
  995. }
  996. #endregion
  997. #region Manage connections to Photon
  998. public class PhotonUtility
  999. {
  1000. #region Disconnected from Photon
  1001. public static IEnumerator DisconnectCoroutine()
  1002. {
  1003. #region Exit Room
  1004. if (PhotonNetwork.InRoom)
  1005. {
  1006. PhotonNetwork.LeaveRoom();
  1007. }
  1008. yield return new WaitWhile(() => PhotonNetwork.InRoom);
  1009. #endregion
  1010. #region Exit from the lobby
  1011. if (PhotonNetwork.InLobby)
  1012. {
  1013. PhotonNetwork.LeaveLobby();
  1014. }
  1015. yield return new WaitWhile(() => PhotonNetwork.InLobby);
  1016. #endregion
  1017. #region Disconnected from Photon
  1018. if (PhotonNetwork.IsConnected)
  1019. {
  1020. PhotonNetwork.Disconnect();
  1021. }
  1022. yield return new WaitWhile(() => PhotonNetwork.IsConnected);
  1023. #endregion
  1024. }
  1025. #endregion
  1026. #region Connect to Photon server
  1027. public static IEnumerator ConnectToMasterServerCoroutine()
  1028. {
  1029. if (!PhotonNetwork.IsConnected || ContinuousController.instance.LastConnectServerRegion != ContinuousController.instance.serverRegion)
  1030. {
  1031. if (PhotonNetwork.IsConnected)
  1032. {
  1033. yield return ContinuousController.instance.StartCoroutine(DisconnectCoroutine());
  1034. yield return new WaitWhile(() => PhotonNetwork.IsConnected);
  1035. }
  1036. PhotonNetwork.NetworkingClient.AppId = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime;
  1037. PhotonNetwork.ConnectToRegion(ContinuousController.instance.serverRegion);
  1038. PhotonNetwork.NickName = ContinuousController.instance.PlayerName;
  1039. PhotonNetwork.GameVersion = ContinuousController.instance.GameVerString;
  1040. ContinuousController.instance.LastConnectServerRegion = ContinuousController.instance.serverRegion;
  1041. }
  1042. yield return new WaitWhile(() => !PhotonNetwork.IsConnectedAndReady);
  1043. }
  1044. #endregion
  1045. #region Connect to Photon Server and Lobby
  1046. public static IEnumerator ConnectToLobbyCoroutine()
  1047. {
  1048. #region Connect to Photon server
  1049. yield return ContinuousController.instance.StartCoroutine(ConnectToMasterServerCoroutine());
  1050. #endregion
  1051. #region Save player name to custom properties
  1052. yield return ContinuousController.instance.StartCoroutine(SetPlayerName());
  1053. #endregion
  1054. #region Save the number of wins to a custom property
  1055. Hashtable hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1056. object value;
  1057. hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1058. if (hash.TryGetValue(ContinuousController.WinCountKey, out value))
  1059. {
  1060. hash[ContinuousController.WinCountKey] = ContinuousController.instance.WinCount;
  1061. }
  1062. else
  1063. {
  1064. hash.Add(ContinuousController.WinCountKey, ContinuousController.instance.WinCount);
  1065. }
  1066. PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
  1067. while (true)
  1068. {
  1069. Hashtable _hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1070. if (_hash.TryGetValue(ContinuousController.WinCountKey, out value))
  1071. {
  1072. if ((int)value == ContinuousController.instance.WinCount)
  1073. {
  1074. break;
  1075. }
  1076. }
  1077. yield return null;
  1078. }
  1079. #endregion
  1080. #region Connect to Lobby
  1081. if (!PhotonNetwork.InLobby)
  1082. {
  1083. PhotonNetwork.JoinLobby();
  1084. }
  1085. yield return new WaitWhile(() => !PhotonNetwork.InLobby);
  1086. yield return new WaitUntil(() => PhotonNetwork.InLobby && PhotonNetwork.IsConnectedAndReady);
  1087. #endregion
  1088. }
  1089. #endregion
  1090. #region Save player name to properties
  1091. public static IEnumerator SetPlayerName()
  1092. {
  1093. Hashtable hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1094. object value;
  1095. hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1096. if (hash.TryGetValue(ContinuousController.PlayerNameKey, out value))
  1097. {
  1098. hash[ContinuousController.PlayerNameKey] = ContinuousController.instance.PlayerName;
  1099. }
  1100. else
  1101. {
  1102. hash.Add(ContinuousController.PlayerNameKey, ContinuousController.instance.PlayerName);
  1103. }
  1104. PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
  1105. while (true)
  1106. {
  1107. Hashtable _hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1108. if (_hash.TryGetValue(ContinuousController.PlayerNameKey, out value))
  1109. {
  1110. if ((string)value == ContinuousController.instance.PlayerName)
  1111. {
  1112. break;
  1113. }
  1114. }
  1115. yield return null;
  1116. }
  1117. }
  1118. #endregion
  1119. #region Save deck data to custom properties
  1120. public static IEnumerator SignUpBattleDeckData()
  1121. {
  1122. Hashtable hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1123. if (hash.TryGetValue(ContinuousController.DeckDataPropertyKey, out object value))
  1124. {
  1125. hash[ContinuousController.DeckDataPropertyKey] = ContinuousController.instance.BattleDeckData.GetThisDeckCode();
  1126. }
  1127. else
  1128. {
  1129. Debug.Log($"SIGN UP BATTLE DECK: {ContinuousController.DeckDataPropertyKey}");
  1130. Debug.Log($"SIGN UP BATTLE DECK: {ContinuousController.instance.BattleDeckData.GetThisDeckCode()}");
  1131. hash.Add(ContinuousController.DeckDataPropertyKey, ContinuousController.instance.BattleDeckData.GetThisDeckCode());
  1132. }
  1133. //Debug.Log($"バトルデッキデータ登録,KeyCard:{ContinuousController.instance.BattleDeckData.KeyCard.CardName_JPN}");
  1134. PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
  1135. while (true)
  1136. {
  1137. Hashtable _hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1138. if (_hash.TryGetValue(ContinuousController.DeckDataPropertyKey, out value))
  1139. {
  1140. if ((string)value == ContinuousController.instance.BattleDeckData.GetThisDeckCode())
  1141. {
  1142. break;
  1143. }
  1144. }
  1145. yield return null;
  1146. }
  1147. }
  1148. #endregion
  1149. #region Remove custom properties from deck data
  1150. public static IEnumerator DeleteBattleDeckData()
  1151. {
  1152. Hashtable hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1153. if (hash.TryGetValue(ContinuousController.DeckDataPropertyKey, out object value))
  1154. {
  1155. hash.Remove(ContinuousController.DeckDataPropertyKey);
  1156. }
  1157. PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
  1158. while (true)
  1159. {
  1160. Hashtable _hash = PhotonNetwork.LocalPlayer.CustomProperties;
  1161. if (!_hash.TryGetValue(ContinuousController.DeckDataPropertyKey, out value))
  1162. {
  1163. break;
  1164. }
  1165. yield return null;
  1166. }
  1167. }
  1168. #endregion
  1169. }
  1170. #endregion
  1171. public enum Language
  1172. {
  1173. ENG,
  1174. JPN,
  1175. }