Esempio n. 1
0
    //function to update equippable icons
    public void UpdateEquipIcons(Attachments.Slot slot)
    {
        //switch to find the current selection & attachment type
        GameObject         selection;
        List <Attachments> type;
        bool isBooster = false;

        switch (slot)
        {
        default:
        case Attachments.Slot.Weapon:
            selection = weaponSelection;
            type      = weapon;
            break;

        case Attachments.Slot.Armour:
            selection = armourSelection;
            type      = armour;
            break;

        case Attachments.Slot.Wheels:
            selection = wheelSelection;
            type      = wheels;
            break;

        case Attachments.Slot.Boosters:
            selection = booster1Selection;
            type      = booster;
            isBooster = true;
            break;
        }

        //clears out all currently instantiated in the selection
        if (isBooster == true)
        {
            foreach (Transform child in booster2Selection.transform)
            {
                Destroy(child.gameObject);
            }
        }

        foreach (Transform child in selection.transform)
        {
            Destroy(child.gameObject);
        }

        //instantiate all equip icons in the selection
        if (isBooster == true)
        {
            foreach (Attachments equippable in type)
            {
                CreateIcon(equippable, booster2Selection);
            }
        }

        foreach (Attachments equippable in type)
        {
            CreateIcon(equippable, selection);
        }
    }
Esempio n. 2
0
    //function used whenever equipment gets changed
    public void ChangeEquipment(Attachments newEquip)
    {
        Attachments.Slot slot = newEquip.GetSlot();

        //checks the slot of the new attachment and equips the new equipment to the corresponding slot
        switch (slot)
        {
        default:
        case Attachments.Slot.Weapon:
            currentlyEquipped[0] = newEquip;
            break;

        case Attachments.Slot.Armour:
            currentlyEquipped[1] = newEquip;
            break;

        case Attachments.Slot.Wheels:
            currentlyEquipped[2] = newEquip;
            break;
        }
    }