public bool AddToken(ITokenData token, byte count) { if (tokensImage.Count >= maxTokens) { return(false); } bool result = false; foreach (var item in tokensImage) { if (item.Name == token.Name) { result = true; break; } } if (result == false || token.IsSingle == false) { for (int i = 0; i < count; i++) { if (tokensImage.Count < maxTokens) { tokensImage.Add(TokenImage.CreatPrefab(token, transform)); } } return(true); } else { return(false); } }
private TokenImage SetToken(ITokenData token, Transform parent) { this.token = token; transform.SetParent(parent, false); transform.SetAsLastSibling(); GetComponent <Image>().sprite = token.Icon; name = token.Name; return(this); }
public override IEnumerable <ITokenData> ExtraData() { foreach (var prop in typeof(T).GetProperties()) { foreach (var attr in prop.GetCustomAttributes(typeof(ITokenDataAttribute), false).OfType <ITokenDataAttribute>()) { ITokenData ret = attr.TokenData; ret.Name = prop.Name; yield return(ret); } } foreach (var field in typeof(T).GetFields()) { foreach (var attr in field.GetCustomAttributes(typeof(ITokenDataAttribute), false).OfType <ITokenDataAttribute>()) { ITokenData ret = attr.TokenData; ret.Name = field.Name; yield return(ret); } } }
public static TokenImage CreatPrefab(ITokenData token, Transform parent) => Instantiate(Resources.Load <TokenImage>($"Card/TokenImage")).SetToken(token, parent);
public GerenciadorDeToken(ITokenData tokenData) { _TokenData = tokenData; }