예제 #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);
            }
        }
    }
예제 #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);
    }
예제 #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);
    }
예제 #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);
    }
예제 #5
0
 void Start()
 {
     weaponZoom = GetComponent <WeaponZoom>();
     weapon     = GetComponent <Weapon>();
 }