Beispiel #1
0
 private void Damage(MessageTypes.Damage message)
 {
     if (message.Target == gameObject.tag)
     {
         hp -= message.Value;
         Debug.Log(hp);
     }
 }
Beispiel #2
0
    void Update()
    {
        attackCounter -= Time.deltaTime;
        if (attackCounter <= 0)
        {
            var message = new MessageTypes.Damage()
            {
                // Why this works
                // But Value = _Damage * Time.deltaTime; Send always 1 dmg instead of 100?
                Value  = _Damage,
                Sender = gameObject.tag,
                Target = _target
            };

            var objects = Utility.OverlapSphere(transform.position, _DamageRadius);

            MessageDispatcher.Send(message, objects);
            attackCounter = _attackDeley;
        }
    }