private bool CheckDamage(Collider other, AttackPoint pts)
        {
            Damageable d = other.GetComponent <Damageable>();

            if (d == null)
            {
                return(false);
            }

            if (d.gameObject == m_Owner)
            {
                return(true);
            }

            if ((targetLayers.value & (1 << other.gameObject.layer)) == 0)
            {
                return(false);
            }



            Damageable.DamageMessage data;

            data.amount       = damage;
            data.damager      = this;
            data.direction    = m_Direction.normalized;
            data.damageSource = m_Owner.transform.position;
            data.throwing     = m_IsThrowingHit;
            data.stopCamera   = false;

            d.ApplyDamage(data);

            if (hitParticlePrefab != null)
            {
                m_ParticlesPool[m_CurrentParticle].transform.position = pts.attackRoot.transform.position;
                m_ParticlesPool[m_CurrentParticle].time = 0;
                m_ParticlesPool[m_CurrentParticle].Play();
                m_CurrentParticle = (m_CurrentParticle + 1) % PARTICLE_COUNT;
            }

            return(true);
        }
        private void OnTriggerStay(Collider other)
        {
            if ((damagedLayers.value & 1 << other.gameObject.layer) == 0)
            {
                return;
            }

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

            if (d != null && timer > delay && d.currentHitPoints < d.maxHitPoints)
            {
                timer = 0f;
                d.currentHitPoints += amount;
                print(d.currentHitPoints);
            }
            else
            {
                timer += Time.deltaTime;
            }
        }
예제 #3
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);
            }
        }
 // Use this for initialization
 void Start()
 {
     m_Animator = GetComponent <Animator>();
     ttp        = GetComponent <TurnToPlayer>();
     damageable = GetComponent <Damageable>();
 }
 void OnEnable()
 {
     m_Damageable = GetComponent <Damageable>();
     m_Damageable.isInvulnerable = true;
 }