コード例 #1
0
    // Use this for initialization
    void Start()
    {
        activeWeaponType = Constants.Pistol;
        activeGun        = pistol;

        gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag));
    }
コード例 #2
0
 // 2
 private void pickupAssaultRifleAmmo()
 {
     ammo.AddAmmo(Constants.AssaultRifle, 50);
     gameUI.SetPickUpText("Assault rifle ammo picked up + 50 ammo");
     if (gunEquipper.GetActiveWeapon().tag == Constants.AssaultRifle)
     {
         gameUI.SetAmmoText(ammo.GetAmmo(Constants.AssaultRifle));
     }
 }
コード例 #3
0
 void loadWeapon(GameObject weapon)
 {
     pistol.SetActive(false);
     assaultRifle.SetActive(false);
     shotgun.SetActive(false);
     weapon.SetActive(true);
     activeGun = weapon;
     gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag));
 }
コード例 #4
0
 private void PickupPistolAmmo()
 {
     ammo.AddAmmo(Constants.Pistol, 20);
     gameUI.SetPickUpText("Pistol ammo picked up + 20 ammo");
     if (gunEquipper.GetActiveWeapon().tag == Constants.Pistol)
     {
         gameUI.SetAmmoText(ammo.GetAmmo(Constants.Pistol));
     }
 }
コード例 #5
0
 void Update()
 {
     DisplayAmmo();
     if (Input.GetMouseButtonDown(0) && canShoot)
     {
         if (ammoSlot.GetAmmo(ammoType) > 0)
         {
             StartCoroutine(Shoot());
         }
     }
 }
コード例 #6
0
    private IEnumerator Shoot()
    {
        canShoot = false;

        if (ammo.GetAmmo(type) > 0)
        {
            ammo.ReduceAmmo(type);
            UpdateUI();
            ProcessRaycast();
            PlayMuzzleFlash();
        }

        yield return(new WaitForSeconds(secondsBetweenShots));

        canShoot = true;
    }
コード例 #7
0
ファイル: GunEquipper.cs プロジェクト: Tninja1337/Penguins
    private void loadWeapon(GameObject weapon)
    {
        sniper.SetActive(false);

        weapon.SetActive(true);
        activeGun = weapon;
        gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag));
    }
コード例 #8
0
ファイル: Player.cs プロジェクト: Tninja1337/Penguins
 private void pickupSniperAmmo()
 {
     ammo.AddAmmo(Constants.Sniper, 5);
     gameUI.SetPickupText("Pickup: Ammo +5");
     if (gunEquipper.GetActiveWeapon().tag == Constants.Sniper)
     {
         gameUI.SetAmmoText(ammo.GetAmmo(Constants.Sniper));
     }
 }
コード例 #9
0
ファイル: Weapon.cs プロジェクト: louisgirard/Zombie-Killer
 void Update()
 {
     if (CrossPlatformInputManager.GetButtonDown("Fire1") && canShoot)
     {
         if (ammoSlot.GetAmmo(ammoType) > 0)
         {
             StartCoroutine(Shoot());
         }
     }
 }
コード例 #10
0
    //load the correct weapon
    private void SelectWeapon(GameObject weapon)
    {
        //set all as inactive
        Pistol.SetActive(false);
        AssaultRifle.SetActive(false);
        Shotgun.SetActive(false);

        weapon.SetActive(true);
        activeGun = weapon;
        gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag));
    }
コード例 #11
0
    private void loadWeapon(GameObject weapon)
    {
        // Set all weapons inactive
        pistol.SetActive(false);
        assaultRifle.SetActive(false);
        shotgun.SetActive(false);

        // Activate the given weapon
        weapon.SetActive(true);
        activeGun = weapon;

        // Set the ammo UI element appropriately
        gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag));
    }
コード例 #12
0
 private void processHit(GameObject hitObject)
 {
     if (hitObject.GetComponent <Player>() != null)
     {
         hitObject.GetComponent <Player>().TakeDamage(damage);
     }
     if (hitObject.GetComponent <Robot>() != null)
     {
         if (ammo.GetAmmo(tag) > 0)
         {
             hitObject.GetComponent <Robot>().TakeDamage(damage);
         }
     }
 }
コード例 #13
0
    private void loadWeapon(GameObject weapon)
    {
        //disables all guns
        pistol.SetActive(false);
        assaultRifle.SetActive(false);
        shotgun.SetActive(false);
        rocket.SetActive(false);

        //enables gun the player wants to switch to
        weapon.SetActive(true);
        activeGun = weapon;

        gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag));
    }
コード例 #14
0
    private void Ammo(Ammo ammoValue)
    {
        for (int i = 0; i < inventory.weapons.Count; ++i)
        {
            if (inventory.weapons[i].weaponType == ammoValue.GetAmmoType())
            {
                var getAmmo = ammoValue.GetAmmo();

                inventory.weapons[i].ammo += getAmmo;

                ammoUI.text = "Ammo: " + inventory.weapons[i].ammo;

                audioSource.clip = ammoValue.GetAudioClip();

                audioSource.Play();

                setMessage.SetMessage("Picked Up Ammo");

                return;
            }
        }

        setMessage.SetMessage("You do not have this weapon");
    }
コード例 #15
0
 // Update is called once per frame
 void Update()
 {
     text.text = ammoSlot.GetAmmo(ammoType).ToString();
 }