Beispiel #1
0
        private void OnUpgradeSkill(Event a_Event, params object[] a_Params)
        {
            IUsesSkills unit       = a_Params[0] as IUsesSkills;
            int         skillIndex = (int)a_Params[1];

            if (unit == null || unit.GetHashCode() != GetHashCode() || m_SkillPrefabs.Count == 0)
            {
                return;
            }

            Skill skill = unit.skills[skillIndex];

            ICastable <IUsesSkills> castable = m_SkillPrefabs[skillIndex].GetComponent <ICastable <IUsesSkills> >();

            ++skill.level;
            skill.skillData.cost = castable.baseCost + (skill.level - 1) * castable.costGrowth;

            skill.skillData.damage      = castable.baseDamage + (skill.level - 1) * castable.damageGrowth;
            skill.skillData.maxCooldown = castable.baseMaxCooldown - (skill.level - 1) * castable.maxCooldownGrowth;

            skill.skillData.description = castable.UpdateDescription(skill);

            --m_StoredSkillUpgrades;
            if (m_StoredSkillUpgrades != 0)
            {
                Publisher.self.DelayedBroadcast(Event.UnitCanUpgradeSkill, this);
            }
        }
Beispiel #2
0
        private void OnUseSkill(Event a_Event, params object[] a_Params)
        {
            IUsesSkills unit = a_Params[0] as IUsesSkills;

            if (unit == null)
            {
                return;
            }

            int skillIndex = (int)a_Params[1];

            if (unit.GetHashCode() != GetHashCode() ||
                m_Skills.Count <= skillIndex ||
                m_Skills[skillIndex].level <= 0 ||
                !(m_Skills[skillIndex].remainingCooldown <= 0.0f) ||
                !(m_Skills[skillIndex].skillData.cost <= m_Mana))
            {
                return;
            }

            GameObject newObject             = Instantiate(m_Skills[skillIndex].skillPrefab);
            ICastable <IUsesSkills> newSkill = newObject.GetComponent <ICastable <IUsesSkills> >();

            newSkill.parent    = this;
            newSkill.skillData = m_Skills[skillIndex].skillData.Clone();

            mana -= m_Skills[skillIndex].skillData.cost;

            m_Skills[skillIndex].PutOnCooldown();
        }