Пример #1
0
    void Update()
    {
        if (Input.GetAxis("SwitchWeapon") > 0 && availWeapons > 1)
        {
            nextWeapon = currentWeapon + 1;

            if (nextWeapon >= totalWeapons)
            {
                nextWeapon = 0;
            }
            while (weaponSlots[nextWeapon] == null)
            {
                ++nextWeapon;
            }
        }
        else if (Input.GetAxis("SwitchWeapon") < 0 && availWeapons > 1)
        {
            nextWeapon = currentWeapon - 1;

            if (nextWeapon < 0)
            {
                nextWeapon = totalWeapons - 1;
            }

            while (weaponSlots[nextWeapon] == null)
            {
                --nextWeapon;
            }
        }
        else
        {
            nextWeapon = currentWeapon;
        }

        if (nextWeapon != currentWeapon)
        {
            if (currentWeapon == 2 && sniperRifleScript.altFire)
            {
                sniperRifleScript.ZoomToggle();
            }
            currentWeapon = nextWeapon;
            currentWeaponScript.enabled = false;
            currentWeaponScript         = weaponSlots[currentWeapon];
            currentWeaponScript.enabled = true;
        }
    }
Пример #2
0
    protected void Start()
    {
        weaponSlots        = new Weapon_Stats[totalWeapons];
        assaultRifleScript = AssaultRifle.GetComponent <ARV80_Rifle>();
        sniperRifleScript  = SniperRifle.GetComponent <S107_SniperRifle>();

        // Populate list of weapons
        for (int i = 0; i < totalWeapons; ++i)
        {
            weaponSlots[i] = null;
        }
        weaponSlots[0] = assaultRifleScript;
        availWeapons   = 1;

        // Set initial weapon
        currentWeaponScript         = weaponSlots[0];
        currentWeaponScript.enabled = true;
    }
Пример #3
0
    public void SetCurrentWeapon(string weapon)
    {
        switch (weapon)
        {
        case "AssaultRifle":
            currentWeapon = 0;
            currentWeaponScript.enabled = false;
            currentWeaponScript         = weaponSlots[currentWeapon];
            currentWeaponScript.enabled = true;
            return;

        case "SniperRifle":
            currentWeapon = 2;
            currentWeaponScript.enabled = false;
            currentWeaponScript         = weaponSlots[currentWeapon];
            currentWeaponScript.enabled = true;
            return;
        }
    }
Пример #4
0
    void Update()
    {
        if( Input.GetAxis("SwitchWeapon") > 0 && availWeapons > 1 ) {
            nextWeapon = currentWeapon + 1;

            if ( nextWeapon >= totalWeapons) {
                nextWeapon = 0;
            }
            while ( weaponSlots[nextWeapon] == null ) {
                ++nextWeapon;
            }
        } else if( Input.GetAxis("SwitchWeapon") < 0 && availWeapons > 1 ) {
            nextWeapon = currentWeapon - 1;

            if ( nextWeapon < 0 ) {
                nextWeapon = totalWeapons - 1;
            }

            while ( weaponSlots[nextWeapon] == null) {
                --nextWeapon;
            }
        } else {
            nextWeapon = currentWeapon;
        }

        if ( nextWeapon != currentWeapon ) {

            if( currentWeapon == 2 && sniperRifleScript.altFire ) {
                sniperRifleScript.ZoomToggle();
            }
            currentWeapon = nextWeapon;
            currentWeaponScript.enabled = false;
            currentWeaponScript = weaponSlots[currentWeapon];
            currentWeaponScript.enabled = true;
        }
    }
Пример #5
0
    protected void Start()
    {
        weaponSlots = new Weapon_Stats[totalWeapons];
        assaultRifleScript = AssaultRifle.GetComponent<ARV80_Rifle>();
        sniperRifleScript = SniperRifle.GetComponent<S107_SniperRifle>();

        // Populate list of weapons
        for (int i=0; i<totalWeapons; ++i) {
            weaponSlots[i] = null;
        }
        weaponSlots[0] = assaultRifleScript;
        availWeapons = 1;

        // Set initial weapon
        currentWeaponScript = weaponSlots[0];
        currentWeaponScript.enabled = true;
    }
Пример #6
0
 public void SetCurrentWeapon( string weapon )
 {
     switch (weapon) {
         case "AssaultRifle":
             currentWeapon = 0;
             currentWeaponScript.enabled = false;
             currentWeaponScript = weaponSlots[currentWeapon];
             currentWeaponScript.enabled = true;
             return;
         case "SniperRifle":
             currentWeapon = 2;
             currentWeaponScript.enabled = false;
             currentWeaponScript = weaponSlots[currentWeapon];
             currentWeaponScript.enabled = true;
             return;
     }
 }