// Called by Ellen's Damageable when she is hurt.
        public void OnReceiveMessage(MessageType type, object sender, object data)
        {
            switch (type)
            {
            case MessageType.DAMAGED:
            {
                Damageable.DamageMessage damageData = (Damageable.DamageMessage)data;
                Damaged(damageData);
            }
            break;

            case MessageType.DEAD:
            {
                Damageable.DamageMessage damageData = (Damageable.DamageMessage)data;
                Die(damageData);
            }
            break;
            }
        }
예제 #2
0
        private void OnTriggerStay(Collider other)
        {
            if ((damagedLayers.value & 1 << other.gameObject.layer) == 0)
            {
                return;
            }

            Damageable d = other.GetComponentInChildren <Damageable>();

            if (d != null && !d.isInvulnerable)
            {
                Damageable.DamageMessage message = new Damageable.DamageMessage
                {
                    damageSource = transform.position,
                    damager      = this,
                    amount       = amount,
                    direction    = (other.transform.position - transform.position).normalized,
                    throwing     = false
                };

                d.ApplyDamage(message);
            }
        }