Пример #1
0
 private void RemoveHealth(int id)
 {
     if (_healths.Remove(id))
     {
         OnKilled?.Invoke(id);
     }
 }
Пример #2
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////
        #region Methods
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Kill this entity
        /// </summary>
        public void Kill()
        {
            IsAlive = false;

            // Call event handler, if one has been set
            OnKilled?.Invoke(this, EventArgs.Empty);
        }
Пример #3
0
        private void Kill()
        {
            OnKilled?.Invoke(Id);

            OnKilled = null;
            OnDamage = null;
        }
Пример #4
0
        public void Kill(Vector2 position, float force)
        {
            Debug.Assert(_isAlive);

            DisableBody();
            _isAlive = false;

            OnKilled?.Invoke(this, null);
        }
Пример #5
0
    public void Kill()
    {
        OnKilled?.Invoke();
        var sprite   = GetComponent <SpriteRenderer>();
        var sequence = DOTween.Sequence();

        sequence
        .Append(sprite.DOFade(0f, 0.2f))
        .AppendCallback(() => Destroy(gameObject));
    }
Пример #6
0
        public void DealDamage(int damage)
        {
            health = Mathf.Max(health - damage, 0);

            if (health == 0)
            {
                OnKilled?.Invoke(enemyData);

                Destroy(gameObject);
            }
        }
Пример #7
0
 public void Kill(CreatureObject killer)
 {
     lock (this)
     {
         if (_dead)
         {
             return;
         }
         _dead = true;
     }
     OnKilled?.Invoke(killer);
 }
Пример #8
0
        public void TakeDamage(int amount)
        {
            CurHp -= amount;
            if (CurHp < 0)
            {
                CurHp = 0;
            }

            OnDamage?.Invoke(CurHp, MaxHp);

            if (CurHp == 0)
            {
                OnKilled?.Invoke(Id);
            }
        }
Пример #9
0
    public void Kill(Vector3 force)
    {
        transform.parent = null;

        _rb.isKinematic = false;
        _rb.useGravity  = true;
        _col.isTrigger  = false;

        foreach (MeshRenderer renderer in _models)
        {
            renderer.gameObject.layer = 0;
        }

        _rb.AddForce(force, ForceMode.Impulse);
        if (OnKilled != null)
        {
            OnKilled.Invoke();
        }
    }
Пример #10
0
    public void Damage(int damageAmount)
    {
        for (int i = hearts.Count - 1; i >= 0; i--)
        {
            var heart = hearts[i];
            if (damageAmount > heart.GetHeartFragments())
            {
                damageAmount -= heart.GetHeartFragments();
                heart.Damage(heart.GetHeartFragments());
            }
            else
            {
                heart.Damage(damageAmount);
                break;
            }
        }

        OnDamaged?.Invoke(this, EventArgs.Empty);

        if (IsDead())
        {
            OnKilled?.Invoke(this, EventArgs.Empty);
        }
    }
Пример #11
0
 private void RaiseOnKilledEvent()
 {
     OnKilled?.Invoke(this, new System.EventArgs());
 }
Пример #12
0
 public static void MonsterKilled(User.User user, IMonster monster)
 {
     OnKilled?.Invoke(user, monster);
 }
Пример #13
0
 public virtual void Kill()
 {
     OnKilled?.Invoke();
 }
Пример #14
0
 private void KillFighter()
 {
     OnKilled?.Invoke(gameObject.name, lastDamagedByFighterID);
     Destroy(gameObject);
 }
Пример #15
0
 private void RaiseOnKilledEvent() // Function to notify other classes that the entity died
 {
     OnKilled?.Invoke(this, new System.EventArgs());
 }
Пример #16
0
 private void RaiseOnKilledEvent()
 {
     //If there are any subscribers to OnKilled event, raise the event. Any subscribers will know if
     //a livingentity gets killed
     OnKilled?.Invoke(this, new System.EventArgs());
 }