Esempio n. 1
0
    public void ApplyUpgrade(Tower tower, int buffIndex, Buff buff)
    {
        if (buffIndex >= tower.m_Buffs.Length)
        {
            Buff[] buffArray = new Buff[buffIndex + 1];

            for (int i = 0; i < tower.m_Buffs.Length; i++)
            {
                buffArray[i] = tower.m_Buffs[i];
            }

            tower.m_Buffs = buffArray;
        }

        for (int i = 0; i < tower.m_Buffs.Length; i++)
        {
            if (tower.m_Buffs[i] != null && buff.GetType().Equals(tower.m_Buffs[i].GetType()))
            {
                // This type of buff already exists on this tower, so remove the old one
                tower.m_Buffs[i] = null;
            }
        }

        tower.m_Buffs[buffIndex] = Instantiate(buff);

        if (tower.m_Template == null && m_TowerInfoPanel.gameObject.activeSelf)
        {
            // This buff was added to a template and the tower info panel is open
            m_TowerInfoPanel.Refresh();
        }
    }