Exemplo n.º 1
0
    IEnumerator Reloading()
    {
        if (!is_Shotgun)
        {
            yield return(new WaitForSeconds(reload_Time));

            //count how many ammo spent
            int AU = gun_Total_Mag_Capacity - gun_current_Mag_Capacity;
            gun_current_Ammo        -= AU;
            gun_current_Mag_Capacity = gun_Total_Mag_Capacity;               //Refill mag
            the_Player_UI_HUD.AmmoUpdate(the_Player_Manager.current_Weapon); //Update UI
            currently_Reloading = false;
        }
        else
        {
            if (gun_current_Mag_Capacity < gun_Total_Mag_Capacity)
            {
                yield return(new WaitForSeconds(reload_Time));

                //count how many ammo spent
                gun_current_Ammo--;
                gun_current_Mag_Capacity++;
                the_Player_UI_HUD.AmmoUpdate(the_Player_Manager.current_Weapon);//Update UI
                StartCoroutine("Reloading");
            }
            else
            {
                currently_Reloading = false;
            }
        }
    }
    void SwitchWeapon(int i)
    {
        if (weapon_Inventory[0] != null && weapon_Inventory[1] != null)
        {
            //Switching Weapon
            switch (i)
            {
            case 0:
            {
                weapon_Inventory[0].gameObject.SetActive(true);
                weapon_Inventory[0].GetComponent <BaseGun>().weapon_Eqip = true;
                weapon_Inventory[1].GetComponent <BaseGun>().weapon_Eqip = false;
                weapon_Inventory[1].gameObject.SetActive(false);
                break;
            }

            case 1:
            {
                weapon_Inventory[0].gameObject.SetActive(false);
                weapon_Inventory[0].GetComponent <BaseGun>().weapon_Eqip = false;
                weapon_Inventory[1].gameObject.SetActive(true);
                weapon_Inventory[1].GetComponent <BaseGun>().weapon_Eqip = true;
                break;
            }
            }
        }
        //Update player weapon UI
        the_Player_UI_HUD.current_Weapon = weapon_Inventory[i];
        the_Player_UI_HUD.AmmoUpdate(i);
        the_Player_UI_HUD.WeaponNameUpdate(i);
    }
Exemplo n.º 3
0
    public void SetValue()
    {
        //ammo pool
        the_Player_Manager = FindObjectOfType <PlayerManager>();
        the_Ammo_Pool      = FindObjectOfType <AmmoPool>();

        gun_current_Mag_Capacity = gun_Total_Mag_Capacity;
        //set up Weapon UI
        the_Player_UI_HUD = FindObjectOfType <PlayerUIHUD>();
        the_Player_UI_HUD.current_Weapon = this;
        the_Player_UI_HUD.AmmoUpdate(the_Player_Manager.current_Weapon);
        the_Player_UI_HUD.WeaponNameUpdate(the_Player_Manager.current_Weapon);
    }