public void UpdateCharacterCard(CharacterStats characterStats, bool isDismiss) { CVCard cacheCard = _cacheCharacterList.Find(x => x._id == characterStats._id); if (isDismiss) { //Object need exist, in order to delete it if (cacheCard == null) { Debug.LogError("CVCard Object not found"); return; } _cacheCharacterList.Remove(cacheCard); UtilityMethod.SafeDestroy(cacheCard); } else { CVCard newCVCard = UpdateCardInfo(characterStats, cacheCard); if (cacheCard == null) { _cacheCharacterList.Add(newCVCard); } } UpdateBodyState(); }
public void RenewAllCVCard(List <CharacterStats> characterStats, System.Action <CharacterStats> CharacterClickEvent) { this.CharacterClickEvent = CharacterClickEvent; UtilityMethod.ClearChildObject(characterBody); _cacheCharacterList.Clear(); foreach (CharacterStats stat in characterStats) { CVCard cvCard = UpdateCardInfo(stat, null); _cacheCharacterList.Add(cvCard); } UpdateBodyState(); }
public void UpdateCharacterCard(CharacterStats characterStats) { CVCard cacheCard = _cacheCharacterList.Find(x => x._id == characterStats._id); if (cacheCard == null) { Debug.LogError("CVCard Object not found"); return; } cacheCard.hireIcon.enabled = true; cacheCard.button.interactable = false; UpdateBodyState(); }
private CVCard UpdateCardInfo(CharacterStats stat, CVCard cvCard) { if (cvCard == null) { var CVCardObj = UtilityMethod.CreateObjectToParent(characterBody, cvcardPrefab); cvCard = CVCardObj.GetComponent <CVCard>(); } cvCard._id = stat._id; cvCard.icon.sprite = this.spriteManager.FindSprite(stat.icon_name, ParameterFlag.SpriteTag.Character); cvCard.titleText.text = stat.full_name; cvCard.button.onClick.RemoveAllListeners(); cvCard.button.onClick.AddListener(delegate { if (this.CharacterClickEvent != null) { this.CharacterClickEvent(stat); } }); return(cvCard); }