示例#1
0
 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());
     }
 }
示例#2
0
 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);
     }
 }
示例#3
0
 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();
 }
示例#4
0
        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);
            }
        }
示例#5
0
        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);
                }
            }
        }
示例#6
0
        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);
            }
        }
示例#7
0
 public PerkHolder(PerksContainer container, Perk perk)
 {
     this.perk = perk;
     level     = 1;
     OnPerkGiven(container);
 }
示例#8
0
 public abstract void OnPerkUpdate(PerksContainer perksContainer, Perk perk, int level, float deltaTime);
示例#9
0
 public abstract void OnPerkRemoved(PerksContainer perksContainer, Perk perk, int level);
示例#10
0
 public abstract void OnPerkGiven(PerksContainer perksContainer, Perk perk);
示例#11
0
 public abstract void OnPerkLevelChange(PerksContainer perksContainer, Perk perk, int oldLevel, int newLevel);