CEntity_Base.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using System;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. [CreateAssetMenu(menuName = "Create/CEntity_Base")]
  7. public class CEntity_Base : ScriptableObject
  8. {
  9. public int CardIndex = 0;
  10. public List<CardColor> cardColors = new List<CardColor>();
  11. public int PlayCost = -1;
  12. public List<EvoCost> EvoCosts = new List<EvoCost>();
  13. public int Level = 0;
  14. public string CardName_JPN = "";
  15. public string CardName_ENG = "";
  16. public List<string> Form_JPN = new List<string>();
  17. public List<string> Form_ENG = new List<string>();
  18. public List<string> Attribute_JPN = new List<string>();
  19. public List<string> Attribute_ENG = new List<string>();
  20. public List<string> Type_JPN = new List<string>();
  21. public List<string> Type_ENG = new List<string>();
  22. public string CardSpriteName = "";
  23. public CardKind cardKind = CardKind.Digimon;
  24. [TextArea] public string EffectDiscription_JPN = "";
  25. [TextArea] public string EffectDiscription_ENG = "";
  26. [TextArea] public string InheritedEffectDiscription_JPN = "";
  27. [TextArea] public string InheritedEffectDiscription_ENG = "";
  28. [TextArea] public string SecurityEffectDiscription_JPN = "";
  29. [TextArea] public string SecurityEffectDiscription_ENG = "";
  30. public string CardEffectClassName = "";
  31. public int DP = 0;
  32. public Rarity rarity;
  33. public int OverflowMemory = 0;
  34. public int LinkDP = 0;
  35. [TextArea] public string LinkEffect = "";
  36. [TextArea] public string LinkRequirement = "";
  37. public bool HasInhetitedEffect => !string.IsNullOrEmpty(InheritedEffectDiscription_ENG) && !InheritedEffectDiscription_ENG.Equals("-");
  38. public bool HasSecutiryEffect => !string.IsNullOrEmpty(SecurityEffectDiscription_ENG) && !SecurityEffectDiscription_ENG.Equals("-");
  39. public string CardID = "";
  40. public int MaxCountInDeck = 4;
  41. public bool HasLoadStarted { get; set; } = false;
  42. public Sprite CardSprite { get; set; } = null;
  43. public async Task LoadCardImage()
  44. {
  45. if (String.IsNullOrEmpty(CardSpriteName))
  46. {
  47. return;
  48. }
  49. if (HasLoadStarted)
  50. {
  51. return;
  52. }
  53. HasLoadStarted = true;
  54. Sprite sprite = await StreamingAssetsUtility.GetSprite(CardSpriteName, isCard: true);
  55. CardSprite = sprite;
  56. }
  57. public async Task<Sprite> GetCardSprite()
  58. {
  59. if (!HasLoadStarted)
  60. {
  61. await LoadCardImage();
  62. }
  63. return CardSprite;
  64. }
  65. public bool IsACE => OverflowMemory >= 1;
  66. public bool IsStandardValid => true;
  67. #region regulation mark
  68. public string RegulationMark
  69. {
  70. get
  71. {
  72. string regulationMark = "";
  73. switch (GetParseByHyphen(CardSpriteName)[0])
  74. {
  75. case "ST1":
  76. regulationMark = "00";
  77. break;
  78. case "ST2":
  79. regulationMark = "00";
  80. break;
  81. case "ST3":
  82. regulationMark = "00";
  83. break;
  84. case "ST4":
  85. regulationMark = "00";
  86. break;
  87. case "ST5":
  88. regulationMark = "00";
  89. break;
  90. case "ST6":
  91. regulationMark = "00";
  92. break;
  93. case "ST7":
  94. regulationMark = "01";
  95. break;
  96. case "ST8":
  97. regulationMark = "01";
  98. break;
  99. case "ST9":
  100. regulationMark = "01";
  101. break;
  102. case "ST10":
  103. regulationMark = "01";
  104. break;
  105. case "ST11":
  106. regulationMark = "01";
  107. break;
  108. case "ST12":
  109. regulationMark = "02";
  110. break;
  111. case "ST13":
  112. regulationMark = "02";
  113. break;
  114. case "ST14":
  115. regulationMark = "02";
  116. break;
  117. case "BT1":
  118. regulationMark = "00";
  119. break;
  120. case "BT2":
  121. regulationMark = "00";
  122. break;
  123. case "BT3":
  124. regulationMark = "00";
  125. break;
  126. case "BT4":
  127. regulationMark = "00";
  128. break;
  129. case "BT5":
  130. regulationMark = "00";
  131. break;
  132. case "BT6":
  133. regulationMark = "01";
  134. break;
  135. case "BT7":
  136. regulationMark = "01";
  137. break;
  138. case "BT8":
  139. regulationMark = "01";
  140. break;
  141. case "BT9":
  142. regulationMark = "01";
  143. break;
  144. case "BT10":
  145. regulationMark = "02";
  146. break;
  147. case "BT11":
  148. regulationMark = "02";
  149. break;
  150. case "BT12":
  151. regulationMark = "02";
  152. break;
  153. case "BT13":
  154. regulationMark = "02";
  155. break;
  156. case "EX1":
  157. regulationMark = "01";
  158. break;
  159. case "EX2":
  160. regulationMark = "01";
  161. break;
  162. case "EX3":
  163. regulationMark = "02";
  164. break;
  165. case "EX4":
  166. regulationMark = "02";
  167. break;
  168. case "RB1":
  169. regulationMark = "02";
  170. break;
  171. }
  172. return regulationMark;
  173. }
  174. }
  175. #endregion
  176. #region �Z�b�gID
  177. public string SetID
  178. {
  179. get
  180. {
  181. if (GetParseByHyphen(CardSpriteName).Length >= 1)
  182. {
  183. return GetParseByHyphen(CardSpriteName)[0];
  184. }
  185. return "";
  186. }
  187. }
  188. #endregion
  189. #region whether it is permanent card
  190. public bool IsPermanent => cardKind == CardKind.Digimon || cardKind == CardKind.Tamer || cardKind == CardKind.DigiEgg;
  191. #endregion
  192. #region �J�[�hIndex���f�b�L�R�[�h�ɗp���镶����ɕϊ�(256�i��)
  193. public string CardIndex_String
  194. {
  195. get
  196. {
  197. string CardID_String = ConvertBinaryNumber.IntToNString(CardIndex, DeckData.m);
  198. while (CardID_String.Length < DeckData.CardKindCellLength)
  199. {
  200. CardID_String = $"0{CardID_String}";
  201. }
  202. return CardID_String;
  203. }
  204. }
  205. #endregion
  206. #region �J�[�h�摜�����A���_�[�o�[�ŋ�؂�
  207. public static string[] GetParseByUnderBar(string CardImageName)
  208. {
  209. string[] parseByUnderBar = new string[] { CardImageName };
  210. if (CardImageName.Contains('_'))
  211. {
  212. parseByUnderBar = CardImageName.Split('_');
  213. }
  214. return parseByUnderBar;
  215. }
  216. #endregion
  217. #region �J�[�h�摜�����n�C�t���ŋ�؂�
  218. public static string[] GetParseByHyphen(string CardImageName)
  219. {
  220. string[] parseByHyphen = new string[] { CardImageName };
  221. if (CardImageName.Contains('-'))
  222. {
  223. parseByHyphen = CardImageName.Split('-');
  224. }
  225. return parseByHyphen;
  226. }
  227. #endregion
  228. #region �f�b�L�ɂ���Ɠ��J�[�hID�̃J�[�h�������Ă��閇��
  229. public int SameCardIDCount(List<CEntity_Base> DeckCards)
  230. {
  231. return DeckCards.Count((cEntity_Base) => cEntity_Base.CardID == CardID);
  232. }
  233. #endregion
  234. #region �p��������
  235. public bool isParallel
  236. {
  237. get
  238. {
  239. if (!string.IsNullOrEmpty(CardSpriteName))
  240. {
  241. string s = CardSpriteName.Replace(CardID, "");
  242. if (!string.IsNullOrEmpty(s))
  243. {
  244. if (s.Contains("_P"))
  245. {
  246. return true;
  247. }
  248. }
  249. }
  250. return false;
  251. }
  252. }
  253. #endregion
  254. #region ���x�������‚�
  255. public bool HasLevel
  256. {
  257. get
  258. {
  259. if (Level == 0)
  260. {
  261. return false;
  262. }
  263. if (cardKind != CardKind.Digimon && cardKind != CardKind.DigiEgg)
  264. {
  265. return false;
  266. }
  267. return true;
  268. }
  269. }
  270. #endregion
  271. #region Whether the card has any cost
  272. public bool HasCost => PlayCost >= 0;
  273. #endregion
  274. #region Wheter the card has play cost
  275. public bool HasPlayCost => cardKind != CardKind.Option && PlayCost >= 0;
  276. #endregion
  277. #region Wheter the card has use cost
  278. public bool HasUseCost => cardKind == CardKind.Option && PlayCost >= 0;
  279. #endregion
  280. }
  281. public enum CardKind
  282. {
  283. Digimon,
  284. Tamer,
  285. Option,
  286. DigiEgg,
  287. }
  288. [Serializable]
  289. public class EvoCost : IEquatable<EvoCost>
  290. {
  291. public CardColor CardColor;
  292. public int Level;
  293. public int MemoryCost;
  294. public bool Equals(EvoCost other)
  295. {
  296. if (other is null)
  297. {
  298. return false;
  299. }
  300. if (object.ReferenceEquals(this, other))
  301. {
  302. return true;
  303. }
  304. return CardColor.Equals(other.CardColor) && Level.Equals(other.Level) && MemoryCost.Equals(other.MemoryCost);
  305. }
  306. public override int GetHashCode() => CardColor.GetHashCode() ^ Level.GetHashCode() + MemoryCost.GetHashCode();
  307. }
  308. public enum CardColor
  309. {
  310. Red,
  311. Blue,
  312. Yellow,
  313. Green,
  314. White,
  315. Black,
  316. Purple,
  317. None,
  318. }
  319. public enum Rarity
  320. {
  321. C,
  322. U,
  323. R,
  324. SR,
  325. SEC,
  326. P,
  327. None,
  328. }