Ejemplo n.º 1
0
    public void Apply(KeepController keep)
    {
        var initialHealth = Health;
        var initialAmmo   = Ammo;

        if (!keep.Dead)
        {
            keep.Health += Health;
            if (keep.Health > keep.MaxHealth)
            {
                Health      = keep.Health - keep.MaxHealth;
                keep.Health = keep.MaxHealth;
            }
            else
            {
                Health = 0;
            }

            keep.Ammo += Ammo;
            Ammo       = 0;
        }

        if (Health < initialHealth || Ammo < initialAmmo)
        {
            var sound = Instantiate(SoundPrefab, transform.position, transform.rotation);
            sound.name = SoundPrefab.name;
            Destroy(sound, 1f);
        }

        if (Health <= 0 && Ammo <= 0)
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 2
0
 void Start()
 {
     Keep = GameObject.Find("Keep").GetComponent <KeepController>();
 }