public override void Initialize(LDBlock _data) { GridPos = (Vector2Int)Grid.WorldToCell(transform.position); transform.position = Grid.CellToWorld((Vector3Int)GridPos); Grid.setOccupied((Vector3Int)GridPos, true); Animator = GetComponentInChildren <Animator>(); AbilitySystem = new AbilitySystem(this); CharacterDataTemplate Data = CharacterDataTemplate.Load(); Data.GetMonsterStartingAttributes(Role) .ForEach(Entry => AbilitySystem.RegisterAttribute(Entry.Attribute, Entry.Value)); Data.GetMonsterAbilities(Role) .ForEach(Ability => AbilitySystem.GrantAbility(Ability)); Data.GetMonsterStartingEffects(Role) .ForEach(Effect => AbilitySystem.TryApplyEffectToSelf(Effect)); AbilitySystem.RegisterOnAttributeChanged(Attribute.Health, OnDamageTaken); CurrentHealth = AbilitySystem.GetAttributeValue(Attribute.Health).Value; AbilitySystem.RegisterOnAttributeChanged(Attribute.MaxHealth, UpdateMaxHealth); MaxHealth = AbilitySystem.GetAttributeValue(Attribute.MaxHealth).Value; AbilitySystem .GetGrantedAbilityTypes() .ForEach(Ability => { if (!Ability.Is(TypeTag.MoveAbility)) { MainAbility = Ability; } }); }
public void LoadAbilities(AbilitySystem ability_owner) { m_GamePlayUI.gameObject.SetActive(true); Owner = ability_owner; List <TypeTag> type_tags = ability_owner.GetGrantedAbilityTypes(); for (int i = 0; i < m_ActionButtons.Length; i++) { Button button = m_ActionButtons[i]; if (type_tags.Count > i && i > 0) { TypeTag ability_tag = type_tags[i]; button.GetComponent <Image>().sprite = ability_tag.Icon; button.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = ability_tag.Name; m_AbilityButtonMapping.Add(i, ability_tag); } else { button.gameObject.SetActive(false); } } }