예제 #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());
 }