public static void AddAbility(int prefabID, int replacePrefabID = -1) //called from perk to add new ability { if (instance == null) { return; } int replaceIdx = -1; if (replacePrefabID >= 0) { for (int i = 0; i < instance.abilityList.Count; i++) { if (instance.abilityList[i].prefabID == replacePrefabID) { replaceIdx = i; break; } } } Ability newAbility = AbilityDB.GetPrefab(prefabID).Clone(); if (replaceIdx < 0) { instance.abilityList.Add(newAbility); newAbility.Init(instance.abilityList.Count - 1, instance.transform); } else { instance.abilityList[replaceIdx] = newAbility; newAbility.Init(replaceIdx, instance.transform); } TDTK.OnNewAbility(newAbility); }
public void _AddNewAbility(Ability ab) { for (int i = 0; i < abilityList.Count; i++) { if (ab.ID == abilityList[i].ID) { return; } } Ability ability = ab.Clone(); ability.Init(); abilityList.Add(ability); TDTK.OnNewAbility(ability); }