Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        activeWeaponType = Constants.Pistol;
        activeGun        = pistol;

        gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag));
    }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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));
 }
Exemplo n.º 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));
     }
 }
Exemplo n.º 5
0
 void Update()
 {
     DisplayAmmo();
     if (Input.GetMouseButtonDown(0) && canShoot)
     {
         if (ammoSlot.GetAmmo(ammoType) > 0)
         {
             StartCoroutine(Shoot());
         }
     }
 }
Exemplo n.º 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;
    }
Exemplo n.º 7
0
    private void loadWeapon(GameObject weapon)
    {
        sniper.SetActive(false);

        weapon.SetActive(true);
        activeGun = weapon;
        gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag));
    }
Exemplo n.º 8
0
 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));
     }
 }
Exemplo n.º 9
0
 void Update()
 {
     if (CrossPlatformInputManager.GetButtonDown("Fire1") && canShoot)
     {
         if (ammoSlot.GetAmmo(ammoType) > 0)
         {
             StartCoroutine(Shoot());
         }
     }
 }
Exemplo n.º 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));
    }
Exemplo n.º 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));
    }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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));
    }
Exemplo n.º 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");
    }
Exemplo n.º 15
0
 // Update is called once per frame
 void Update()
 {
     text.text = ammoSlot.GetAmmo(ammoType).ToString();
 }