public AbilityBase CreateAbility(FAbilityTagContainer inTag, AbilitySystemComponent systemComponent) { if (m_AbilityMaps.TryGetValue(inTag, out AbilityEditorData abilityEditorData) && abilityEditorData.AbilityScript != null) { AbilityBase ability = systemComponent.TryGetAbility(inTag); if (ability == null) { ability = System.Activator.CreateInstance(abilityEditorData.AbilityScript.GetClass()) as AbilityBase; } ability.InitAbility(systemComponent, abilityEditorData); return(ability); } return(null); }
public void InitAbility(int index) { if (index < 0) { return; } //Debug.Log(abilityManager.allAbilities[0].gameObject.name); GameObject temp = Instantiate(abilityManager.allAbilities[index].gameObject, thisTransform.position, Quaternion.identity) as GameObject; //instantiera spellen, sen sköter den resten temp.transform.SetParent(thisTransform); AbilityBase tempType = temp.GetComponent <AbilityBase>(); //sortera dem if (tempType is PassiveAbility) { passiveAbilities.Add(temp.GetComponent <PassiveAbility>()); temp.transform.position = auraPosition.position; } else if (tempType is OnHitAbility) { onHitAbilities.Add(temp.GetComponent <OnHitAbility>()); temp.transform.position = onHitPosition.position; } else if (tempType is OnAttackAbility) { onAttackAbilities.Add(temp.GetComponent <OnAttackAbility>()); temp.transform.position = onAttackPosition.position; } else if (tempType is CastAbility) { castAbilities.Add(temp.GetComponent <CastAbility>()); temp.transform.position = castPosition.position; } allAbilities.Add(tempType); //lägg till den i den sammansatta listan tempType.InitAbility(thisTransform); }