Exemplo n.º 1
0
        private void Damage(Collision collision)
        {
            HealthSystem healthSystem = collision.gameObject.GetComponent <HealthSystem>();

            if (healthSystem)
            {
                healthSystem.TakeDamage(damageCaused);
            }
            Destroy(gameObject, DESTROY_DELAY);
        }
Exemplo n.º 2
0
 private void DealAoeDamage()
 {
     Collider[] hits = Physics.OverlapSphere(gameObject.transform.position, (config as WhirlwindConfig).GetRadius());
     foreach (Collider hit in hits)
     {
         HealthSystem enemyHealth = hit.gameObject.GetComponent <HealthSystem>();
         if (enemyHealth)
         {
             enemyHealth.TakeDamage((config as WhirlwindConfig).GetDamage());
         }
     }
 }
Exemplo n.º 3
0
        public override void Use(GameObject target = null)
        {
            HealthSystem health = target.GetComponent <HealthSystem>();

            if (health)
            {
                health.TakeDamage((config as PowerAttackConfig).GetExtraDamage());
            }

            PlayParticleEffect();
            PlayAbilitySound();
            PlayAnimation();
        }
Exemplo n.º 4
0
        private void DealRadialDamage(GameObject target)
        {
            float damageToDeal = (config as AreaEffectConfig).GetDamageToEachTarget();

            RaycastHit[] targetsHit = Physics.SphereCastAll(
                transform.position,
                (config as AreaEffectConfig).GetEffectRadius(),
                Vector3.up,
                (config as AreaEffectConfig).GetEffectRadius()
                );
            foreach (var targetHit in targetsHit)
            {
                HealthSystem hitDamageable = targetHit.collider.gameObject.GetComponent <HealthSystem>();
                bool         hitPlayer     = targetHit.collider.gameObject.GetComponent <PlayerControl>();
                if (!hitPlayer && hitDamageable != null)
                {
                    hitDamageable.TakeDamage(damageToDeal);
                }
            }
        }
Exemplo n.º 5
0
        void OnCollisionEnter(Collision collision)
        {
            GameObject   target       = collision.gameObject;
            HealthSystem healthSystem = target.GetComponent <HealthSystem>();
            SlowMotion   slowMotion   = Camera.main.GetComponent <SlowMotion>();

            if (healthSystem)
            {
                healthSystem.TakeDamage(damageToDeal);
                slowMotion.SlowTime();
                ParticleUtility.PlayParticleEffect(
                    target.transform,
                    particleEffectPrefab,
                    target.transform.position,
                    ParticleUtility.PARTICLE_STD_Y_OFFSET
                    );
            }


            Destroy(gameObject);
        }
        private void DealRadialDamage()
        {
            float radius = (config as AreaAttackConfig).GetRadius();

            RaycastHit[] raycastHits = Physics.SphereCastAll(
                transform.position, radius, Vector3.up, radius
                );

            foreach (RaycastHit hit in raycastHits)
            {
                if (hit.collider.gameObject != gameObject)
                {
                    HealthSystem damagable = hit.collider.gameObject.GetComponent <HealthSystem>();
                    if (damagable != null)
                    {
                        float damageToDeal = (config as AreaAttackConfig).GetDamageToEachTarget();
                        damagable.TakeDamage(damageToDeal);
                    }
                }
            }
        }
Exemplo n.º 7
0
        IEnumerator DamageAfterDelay(float damageDelay)
        {
            yield return(new WaitForSeconds(damageDelay));

            currentTarget.TakeDamage(CalculateHitProbability(characterStats.GetDamage(), currentTarget));
        }