Beispiel #1
0
    void PickUpAmmo(PickupRespawn pickup)
    {
        int extraAmmo = pickup.GetComponent <AmmoPickup> ().Value;

        Base_Weapon ammoWeapon = currentWeapon;         // if lemon -- refill secondary : if weapon is full, return, else fill.

        if (currentWeapon.HasUnlimitedAmmo)
        {
            ammoWeapon = (currentWeapon == primaryWeapon ? secondaryWeapon : primaryWeapon);
        }

        if (ammoWeapon.IsFull)
        {
            return;
        }

        ammoWeapon.AddAmmo(extraAmmo);

        if (playerUI != null)
        {
            playerUI.UpdateAmmoCounter(currentWeapon.Ammo, currentWeapon.MaxAmmo);
        }

        pickup.StartRespawnTimer();
    }
Beispiel #2
0
    void PickUpWeapon(PickupRespawn pickup)
    {
        if (currentWeapon == primaryWeapon)
        {
            primaryWeapon = null;
        }
        else
        {
            secondaryWeapon = null;
        }

        Destroy(currentWeapon);
        currentWeapon = null;
        {
            GameObject temp = Instantiate(pickup.GetComponent <PickupGun> ().gun, transform);
            currentWeapon = temp.GetComponent <Base_Weapon> ();
        }

        if (primaryWeapon == null)
        {
            primaryWeapon = currentWeapon;
        }
        else
        {
            secondaryWeapon = currentWeapon;
        }

        currentWeapon.GetComponent <PlayerTag>().SetId(GetPlayerTag().Id);
        currentWeapon.GetComponent <PlayerTag>().SetTeam(GetPlayerTag().Team);

        UpdateAmmoUI(currentWeapon.Ammo, currentWeapon.MaxAmmo, !currentWeapon.HasUnlimitedAmmo);

        pickup.StartRespawnTimer();
    }
Beispiel #3
0
 private void OnTriggerEnter(Collider other)
 {
     //checking if the other object is the player
     if (other.gameObject.tag == "Player")
     {
         //getting the script information from the player
         Throw ammo = other.gameObject.GetComponent <Throw>();
         //checking if the player is at max ammo
         if (ammo.curAmmo < ammo.maxAmmo)
         {
             //calling the GainAmmo method passing the ammoAmount variable as an argument
             ammo.GainAmmo(ammoAmount);
             //getting the code for the item's respawn point then settign the got item bool to true
             PickupRespawn respawn = spawn.GetComponent <PickupRespawn>();
             respawn.itemGot = true;
             //removing the pickup
             Destroy(this.gameObject);
         }
     }
     if (other.gameObject.tag == "Enemy")
     {
         //getting the script information from the player
         EnemyThrow enemyAmmo = other.gameObject.GetComponent <EnemyThrow>();
         //checking if the player is at max ammo
         if (enemyAmmo.curAmmo < enemyAmmo.maxAmmo)
         {
             //calling the GainAmmo method passing the ammoAmount variable as an argument
             enemyAmmo.GainAmmo(ammoAmount);
             //getting the code for the item's respawn point then settign the got item bool to true
             PickupRespawn respawn = spawn.GetComponent <PickupRespawn>();
             respawn.itemGot = true;
             //removing the pickup
             Destroy(this.gameObject);
         }
     }
 }