public PerksContainerState(PerksContainer instance) { perksSaved = new List <string>(); for (int i = 0; i < instance.allPerks.Count; i++) { perksSaved.Add(instance.allPerks[i].perk.name + PerksContainer.paramsKey + instance.allPerks[i].level.ToString()); } }
void OnPerkLevelChange(PerksContainer container, int oldLevel) { // tell the static behaviors for (int i = 0; i < perk.perkBehaviors.Length; i++) { perk.perkBehaviors[i].OnPerkLevelChange(container, perk, oldLevel, level); } // tell the runtime scripts for (int i = 0; i < perkScripts.Count; i++) { perkScripts[i].OnPerkLevelChange(perk, oldLevel, level); } }
public void OnPerkRemoved(PerksContainer container) { for (int i = 0; i < perk.perkBehaviors.Length; i++) { perk.perkBehaviors[i].OnPerkRemoved(container, perk, level); } for (int i = 0; i < perkScripts.Count; i++) { perkScripts[i].OnPerkRemoved(perk, level); MonoBehaviour.Destroy(perkScripts[i]); } perkScripts.Clear(); }
void OnPerkGiven(PerksContainer container) { for (int i = 0; i < perk.perkBehaviors.Length; i++) { perk.perkBehaviors[i].OnPerkGiven(container, perk); } for (int i = 0; i < perk.perkScripts.Length; i++) { PerkScript scriptInstance = perk.perkScripts[i].MakeCopyOnGameObject(container.gameObject); scriptInstance.OnPerkGiven(perk); perkScripts.Add(scriptInstance); } }
public void OnPerkUpdate(PerksContainer container, float deltaTime) { if (level > 0) { for (int i = 0; i < perk.perkBehaviors.Length; i++) { perk.perkBehaviors[i].OnPerkUpdate(container, perk, level, deltaTime); } // update the runtime scripts attached to this perk for (int i = 0; i < perkScripts.Count; i++) { perkScripts[i].OnPerkUpdate(perk, level, deltaTime); } } }
public void SetLevel(PerksContainer container, int newLevel) { bool clamped = false; if (newLevel > perk.maxLevels) { clamped = true; newLevel = perk.maxLevels; } if (level != newLevel) { if (clamped) { Debug.LogWarning(perk.name + ", capping level to: " + perk.maxLevels); } int oldLevel = level; level = newLevel; OnPerkLevelChange(container, oldLevel); } }
public PerkHolder(PerksContainer container, Perk perk) { this.perk = perk; level = 1; OnPerkGiven(container); }
public abstract void OnPerkUpdate(PerksContainer perksContainer, Perk perk, int level, float deltaTime);
public abstract void OnPerkRemoved(PerksContainer perksContainer, Perk perk, int level);
public abstract void OnPerkGiven(PerksContainer perksContainer, Perk perk);
public abstract void OnPerkLevelChange(PerksContainer perksContainer, Perk perk, int oldLevel, int newLevel);