| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using WebSocketSharp;
- using UnityEngine;
- [CreateAssetMenu(menuName = "Create/CEntity_Base")]
- public class CEntity_Base : ScriptableObject
- {
- public int CardIndex = 0;
- public List<CardColor> cardColors = new List<CardColor>();
- public int PlayCost = -1;
- public List<EvoCost> EvoCosts = new List<EvoCost>();
- public int Level = 0;
- public string CardName_JPN = "";
- public string CardName_ENG = "";
- public List<string> Form_JPN = new List<string>();
- public List<string> Form_ENG = new List<string>();
- public List<string> Attribute_JPN = new List<string>();
- public List<string> Attribute_ENG = new List<string>();
- public List<string> Type_JPN = new List<string>();
- public List<string> Type_ENG = new List<string>();
- public string CardSpriteName = "";
- public List<CardKind> cardKind = new List<CardKind> { CardKind.Digimon };
- [TextArea] public string EffectDiscription_JPN = "";
- [TextArea] public string EffectDiscription_ENG = "";
- [TextArea] public string InheritedEffectDiscription_JPN = "";
- [TextArea] public string InheritedEffectDiscription_ENG = "";
- [TextArea] public string SecurityEffectDiscription_JPN = "";
- [TextArea] public string SecurityEffectDiscription_ENG = "";
- public string CardEffectClassName = "";
- public int DP = 0;
- public Rarity rarity;
- public int OverflowMemory = 0;
- public int LinkDP = 0;
- [TextArea] public string LinkEffect = "";
- [TextArea] public string LinkRequirement = "";
- [TextArea] public string dualEffect = "";
- public List<CardColor> OptionCardColorRequirements = new List<CardColor>();
- [TextArea] public string OptionEffect = "";
- public bool HasInhetitedEffect => !string.IsNullOrEmpty(InheritedEffectDiscription_ENG) && !InheritedEffectDiscription_ENG.Equals("-");
- public bool HasSecutiryEffect => !string.IsNullOrEmpty(SecurityEffectDiscription_ENG) && !SecurityEffectDiscription_ENG.Equals("-");
- public string CardID = "";
- public int MaxCountInDeck = 4;
- public bool HasLoadStarted { get; set; } = false;
- public Sprite CardSprite { get; set; } = null;
- public async Task LoadCardImage()
- {
- if (String.IsNullOrEmpty(CardSpriteName))
- {
- return;
- }
- if (HasLoadStarted)
- {
- return;
- }
- HasLoadStarted = true;
- Sprite sprite = await StreamingAssetsUtility.GetSprite(CardSpriteName, isCard: true);
- CardSprite = sprite;
- }
- public async Task<Sprite> GetCardSprite()
- {
- if (!HasLoadStarted) await LoadCardImage();
- return CardSprite;
- }
- public bool IsACE => OverflowMemory >= 1;
- public bool IsStandardValid => true;
- public bool IsDualCard => !String.IsNullOrEmpty(dualEffect);
- #region regulation mark
- public string RegulationMark
- {
- get
- {
- string regulationMark = "";
- switch (GetParseByHyphen(CardSpriteName)[0])
- {
- case "ST1":
- regulationMark = "00";
- break;
- case "ST2":
- regulationMark = "00";
- break;
- case "ST3":
- regulationMark = "00";
- break;
- case "ST4":
- regulationMark = "00";
- break;
- case "ST5":
- regulationMark = "00";
- break;
- case "ST6":
- regulationMark = "00";
- break;
- case "ST7":
- regulationMark = "01";
- break;
- case "ST8":
- regulationMark = "01";
- break;
- case "ST9":
- regulationMark = "01";
- break;
- case "ST10":
- regulationMark = "01";
- break;
- case "ST11":
- regulationMark = "01";
- break;
- case "ST12":
- regulationMark = "02";
- break;
- case "ST13":
- regulationMark = "02";
- break;
- case "ST14":
- regulationMark = "02";
- break;
- case "BT1":
- regulationMark = "00";
- break;
- case "BT2":
- regulationMark = "00";
- break;
- case "BT3":
- regulationMark = "00";
- break;
- case "BT4":
- regulationMark = "00";
- break;
- case "BT5":
- regulationMark = "00";
- break;
- case "BT6":
- regulationMark = "01";
- break;
- case "BT7":
- regulationMark = "01";
- break;
- case "BT8":
- regulationMark = "01";
- break;
- case "BT9":
- regulationMark = "01";
- break;
- case "BT10":
- regulationMark = "02";
- break;
- case "BT11":
- regulationMark = "02";
- break;
- case "BT12":
- regulationMark = "02";
- break;
- case "BT13":
- regulationMark = "02";
- break;
- case "EX1":
- regulationMark = "01";
- break;
- case "EX2":
- regulationMark = "01";
- break;
- case "EX3":
- regulationMark = "02";
- break;
- case "EX4":
- regulationMark = "02";
- break;
- case "RB1":
- regulationMark = "02";
- break;
- }
- return regulationMark;
- }
- }
- #endregion
- #region �Z�b�gID
- public string SetID
- {
- get
- {
- if (GetParseByHyphen(CardSpriteName).Length >= 1)
- {
- return GetParseByHyphen(CardSpriteName)[0];
- }
- return "";
- }
- }
- #endregion
- #region whether it is permanent card
- public bool IsPermanent => cardKind.Contains(CardKind.Digimon) || cardKind.Contains(CardKind.Tamer) || cardKind.Contains(CardKind.DigiEgg);
- #endregion
- #region �J�[�hIndex���f�b�L�R�[�h�ɗp���镶����ɕϊ�(256�i��)
- public string CardIndex_String
- {
- get
- {
- string CardID_String = ConvertBinaryNumber.IntToNString(CardIndex, DeckData.m);
- while (CardID_String.Length < DeckData.CardKindCellLength)
- {
- CardID_String = $"0{CardID_String}";
- }
- return CardID_String;
- }
- }
- #endregion
- #region �J�[�h�摜�����A���_�[�o�[�ŋ��
- public static string[] GetParseByUnderBar(string CardImageName)
- {
- string[] parseByUnderBar = new string[] { CardImageName };
- if (CardImageName.Contains('_'))
- {
- parseByUnderBar = CardImageName.Split('_');
- }
- return parseByUnderBar;
- }
- #endregion
- #region �J�[�h�摜�����n�C�t���ŋ��
- public static string[] GetParseByHyphen(string CardImageName)
- {
- string[] parseByHyphen = new string[] { CardImageName };
- if (CardImageName.Contains('-'))
- {
- parseByHyphen = CardImageName.Split('-');
- }
- return parseByHyphen;
- }
- #endregion
- #region �f�b�L�ɂ���Ɠ��J�[�hID�̃J�[�h�������Ă��閇��
- public int SameCardIDCount(List<CEntity_Base> DeckCards)
- {
- return DeckCards.Count((cEntity_Base) => cEntity_Base.CardID == CardID);
- }
- #endregion
- #region �p��������
- public bool isParallel
- {
- get
- {
- if (!string.IsNullOrEmpty(CardSpriteName))
- {
- string s = CardSpriteName.Replace(CardID, "");
- if (!string.IsNullOrEmpty(s))
- {
- if (s.Contains("_P"))
- {
- return true;
- }
- }
- }
- return false;
- }
- }
- #endregion
- #region ���x��������
- public bool HasLevel
- {
- get
- {
- if (Level == 0)
- {
- return false;
- }
- if (!cardKind.Contains(CardKind.Digimon) && !cardKind.Contains(CardKind.DigiEgg))
- {
- return false;
- }
- return true;
- }
- }
- #endregion
- #region Whether the card has any cost
- public bool HasCost => PlayCost >= 0;
- #endregion
- #region Wheter the card has play cost
- public bool HasPlayCost => !cardKind.Contains(CardKind.Option) && PlayCost >= 0;
- #endregion
- #region Wheter the card has use cost
- public bool HasUseCost => cardKind.Contains(CardKind.Option) && PlayCost >= 0;
- #endregion
- }
- public enum CardKind
- {
- Digimon,
- Tamer,
- Option,
- DigiEgg,
- }
- [Serializable]
- public class EvoCost : IEquatable<EvoCost>
- {
- public CardColor CardColor;
- public int Level;
- public int MemoryCost;
- public bool Equals(EvoCost other)
- {
- if (other is null)
- {
- return false;
- }
- if (object.ReferenceEquals(this, other))
- {
- return true;
- }
- return CardColor.Equals(other.CardColor) && Level.Equals(other.Level) && MemoryCost.Equals(other.MemoryCost);
- }
- public override int GetHashCode() => CardColor.GetHashCode() ^ Level.GetHashCode() + MemoryCost.GetHashCode();
- }
- public enum CardColor
- {
- Red,
- Blue,
- Yellow,
- Green,
- White,
- Black,
- Purple,
- None,
- }
- public enum Rarity
- {
- C,
- U,
- R,
- SR,
- SEC,
- P,
- None,
- }
|