Exemplo n.º 1
0
 public Fire(IDamageListener listener, float fireRate)
 {
     this.listener = listener;
     audio         = listener.GetGameObject.GetComponent <AudioManager>();
     this.fireRate = fireRate;
     lastFire      = GameTime.GetTime();
 }
    public void Damage(int amount, IDamageListener listener)
    {
        Attribute shield = GetAttribute(AttributeType.SHIELD);

        if (shield.Value > 0)
        {
            if (listener != null)
            {
                listener.DamageListener(DamageEvents.HIT, gameObject);
            }

            shield.Value--;
            //PopUp.ShowText(transform.position, "1", 0, Color.blue);
        }
        else
        {
            Attribute health = GetAttribute(AttributeType.HEALTH);
            health.Value -= amount;

            if (listener == null)
            {
                return;
            }

            if (health.Value < 1)
            {
                listener.DamageListener(DamageEvents.KILL, gameObject);
            }
            else
            {
                listener.DamageListener(DamageEvents.HIT, gameObject);
            }
            //PopUp.ShowText(transform.position, amount.ToString(), 0, Color.red);
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// It is used for damaging the asteroid
    /// </summary>
    /// <param name="amount">amount of damage</param>
    /// <param name="onDead">a function called when the asteroid is destroed</param>
    public void Damage(int amount, IDamageListener listener)
    {
        health.Value -= amount;

        if (listener != null)
        {
            listener.DamageListener(DamageEvents.HIT, gameObject);
        }

        /*PopUp popup = GameManager.ObjectPooler.Get(EntityType.DAMAGEPOPUP).GetComponent<PopUp>();
         * popup.Initialize(transform.position, amount.ToString(), Color.white);*/
        PopUp.ShowText(transform.position, amount.ToString(), 0.5f, Color.white, PopUpAnimation.GRAVITY);
    }
Exemplo n.º 4
0
    public void Damage(int amount, IDamageListener resultListener)
    {
        health.Value -= amount;

        PopUp.ShowText(transform.position, amount.ToString(), 0.5f, Color.white, PopUpAnimation.GRAVITY);

        if (resultListener == null)
        {
            return;
        }

        if (health.Value > 0)
        {
            resultListener.DamageListener(DamageEvents.HIT, gameObject);
        }
        else if (health.Value < 1)
        {
            resultListener.DamageListener(DamageEvents.KILL, gameObject);
        }
    }
Exemplo n.º 5
0
 public void NotifyDamage(IDamageListener listener)
 => listener.ListenDamage(value);
Exemplo n.º 6
0
 public Damage(IDamageListener listener)
 {
     this.listener = listener;
 }
Exemplo n.º 7
0
 // Use this for initialization
 public void RegisterListener(IDamageListener listener)
 {
     listeners.Add(listener);
 }
 public void SetDamageListener(IDamageListener listener)
 {
     damageListener = listener;
 }