Exemplo n.º 1
0
    void Start()
    {
        foreach (Weapon w in GetComponentsInChildren <Weapon>())
        {
            w.gameObject.SetActive(false);
            weapons.Add(w);
        }

        for (int i = 0; i < weapons.Count; i++)
        {
            if (i == 0)
            {
                weapons[i].gameObject.SetActive(true);
            }
            else
            {
                WeaponZoom weaponZoom = weapons[activeWeaponIndex].GetComponent <WeaponZoom>();
                if (weaponZoom != null)
                {
                    weaponZoom.ZoomOut();
                }

                weapons[i].gameObject.SetActive(false);
            }
        }
    }
Exemplo n.º 2
0
    private void CycleToNextWeapon()
    {
        WeaponZoom weaponZoom = weapons[activeWeaponIndex].GetComponent <WeaponZoom>();

        if (weaponZoom != null)
        {
            weaponZoom.ZoomOut();
        }

        weapons[activeWeaponIndex].gameObject.SetActive(false);

        if (weapons.Count == activeWeaponIndex + 1)
        {
            activeWeaponIndex = 0;
        }
        else
        {
            activeWeaponIndex++;
        }

        weapons[activeWeaponIndex].gameObject.SetActive(true);
    }
Exemplo n.º 3
0
    private void ActivateWeapon(int index)
    {
        if (index >= weapons.Count)
        {
            return;
        }
        if (index == activeWeaponIndex)
        {
            return;
        }

        WeaponZoom weaponZoom = weapons[activeWeaponIndex].GetComponent <WeaponZoom>();

        if (weaponZoom != null)
        {
            weaponZoom.ZoomOut();
        }
        weapons[activeWeaponIndex].gameObject.SetActive(false);

        activeWeaponIndex = index;
        weapons[activeWeaponIndex].gameObject.SetActive(true);
    }
Exemplo n.º 4
0
    private void CycleToPreviousWeapon()
    {
        WeaponZoom weaponZoom = weapons[activeWeaponIndex].GetComponent <WeaponZoom>();

        if (weaponZoom != null)
        {
            weaponZoom.ZoomOut();
        }

        weapons[activeWeaponIndex].gameObject.SetActive(false);

        if (activeWeaponIndex == 0)
        {
            activeWeaponIndex = weapons.Count - 1;
        }
        else
        {
            activeWeaponIndex--;
        }

        weapons[activeWeaponIndex].gameObject.SetActive(true);
    }