public void AddAbilityText(AbilityText abilityText)
    {
        GameObject popup          = Instantiate(announcementBox, gameObject.GetComponentInParent <Transform>());
        int        newType        = abilityText.TextType;
        int        totalOfType    = 0;
        bool       abilityUpdated = false;

        AbilityInventory.Add(abilityText);
        foreach (AbilityText a in AbilityInventory)
        {
            if (a.TextType == newType)
            {
                totalOfType++;
            }
        }
        if (totalOfType >= abilityTotals[newType])
        {
            if (UnlockAbility != null)
            {
                UnlockAbility.Invoke(newType);
            }
            for (int i = 0; i < AbilityInventory.Count; i++)
            {
                if (AbilityInventory[i].TextType == newType)
                {
                    if (!abilityUpdated)
                    {
                        AbilityInventory[i].BaseText        = abilityNames[newType];
                        AbilityInventory[i].DescriptionText = abilityDescriptions[newType];
                        abilityUpdated = true;
                        popup.GetComponentInChildren <Text>().text = "You have unlocked " + AbilityInventory[i].DisplayText;
                    }
                    else
                    {
                        AbilityInventory.Remove(AbilityInventory[i]);
                        i--;
                    }
                }
            }
        }
        else
        {
            popup.GetComponentInChildren <Text>().text = "You got " + abilityText.DisplayText;
        }
    }
예제 #2
0
    void Start()
    {
        abilityMethods = new UnlockAbility[] {
            AbilityUnlock1,
            AbilityUnlock2,
            AbilityUnlock3,
            AbilityUnlock4,
            AbilityUnlock5
        };
        abilityIndex = 0;

        fabMethods = new UnlockAbility[] {
            FabUnlock1,
            FabUnlock2,
            FabUnlock3,
            FabUnlock4,
            FabUnlock5
        };

        player = GameObject.FindGameObjectWithTag ("Player");
        windowRect = new Rect ((Screen.width / 2 - width / 2), 200, width, height);
        errorRect = new Rect ((Screen.width / 2 - width / 2), 200, width, height);
    }