You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.0 KiB
34 lines
1.0 KiB
using Unity.FPS.Game;
|
|
using UnityEngine;
|
|
|
|
namespace Unity.FPS.Gameplay
|
|
{
|
|
public class AmmoPickup : Pickup
|
|
{
|
|
[Tooltip("Weapon those bullets are for")]
|
|
public WeaponController Weapon;
|
|
|
|
[Tooltip("Number of bullets the player gets")]
|
|
public int BulletCount = 30;
|
|
|
|
protected override void OnPicked(PlayerCharacterController byPlayer)
|
|
{
|
|
PlayerWeaponsManager playerWeaponsManager = byPlayer.GetComponent<PlayerWeaponsManager>();
|
|
if (playerWeaponsManager)
|
|
{
|
|
WeaponController weapon = playerWeaponsManager.HasWeapon(Weapon);
|
|
if (weapon != null)
|
|
{
|
|
weapon.AddCarriablePhysicalBullets(BulletCount);
|
|
|
|
AmmoPickupEvent evt = Events.AmmoPickupEvent;
|
|
evt.Weapon = weapon;
|
|
EventManager.Broadcast(evt);
|
|
|
|
PlayPickupFeedback();
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|