示例#1
0
    /// Recreates the skill set based on the relevant factory.
    public virtual void Recreate()
    {
        // Clear all the skills.
        Skills.Clear();

        // Get skills from factories and place them into the skill set. Call once after creating the cursor object at the start of combat.
        foreach (ModuleFactory module in GetComponents <ModuleFactory>())
        {
            if (module.FactoryType == "Skill")
            {
                foreach (GameObject skill in module.Modules)
                {
                    if (skill == null)
                    {
                        Debug.LogError("Skill is null");
                    }
                    AddSkill(skill);
                }
            }
        }

        int offensiveIndex = 0;
        int defensiveIndex = 0;

        for (int i = 0; i < Skills.Count; i++)
        {
            // Makes the skill and gives passes a refence to the ship that this skill set belongs to.
            GameObject skill       = Skills[i];
            Ability    abilityBase = skill.GetComponent <Ability>();
            abilityBase.Ship = gameObject;

            // Adds GUI content for the palyer
            GameObject skillBar = Instantiate(SkillBarPrefab) as GameObject;
            SkillBar   script   = skillBar.GetComponent <SkillBar>();

            script.OffensiveSkillCount = offensiveCount;
            script.DefensiveSkillCount = Skills.Count - offensiveCount;

            if (abilityBase.isOffensive)
            {
                script.SkillIndex = offensiveIndex++;
            }
            else
            {
                script.SkillIndex = defensiveIndex++;
            }

            // Contorller is a reference to the ability (the skills super class), which the GUI object reads from.
            script.Controller = abilityBase;
            script.Init();
        }
    }
示例#2
0
 public void InitByScene()
 {
     m_SkillBar.Init();
 }