Example #1
0
    public void DealDamage(GameObject col)
    {
        if (col.layer == 9 || col.layer == 10)         //9 = Player / 10 = Enemy
        {
            //Save that a target has been hit
            targetsHit++;

            //Push the target back based on the received position
            //col.rigidbody.AddForce((col.transform.position - position).normalized * force, ForceMode.Impulse);

            //Grabs the targets HealthHandler and deal damage (if one exists)
            healthHandler = col.GetComponent <HealthHandler>();
            if (healthHandler != null)
            {
                totalDamage = damage + damageBonus;
                if (favoredTargetStatus != Lists.Status.None)
                {
                    if (healthHandler.afflictedStatus.Contains(favoredTargetStatus))
                    {
                        totalDamage *= GlobalVars.bonusDamageMultiplier;
                    }
                }
                healthHandler.TakeDamage(totalDamage);
                if (countCombo)
                {
                    ComboHandler.Instance.AddCombo();
                }

                if (applyStatus != Lists.Status.None)
                {
                    switch (applyStatus)
                    {
                    case Lists.Status.DOTed:
                        healthHandler.ApplyDot(totalDamage * 0.2f);
                        break;

                    case Lists.Status.Feared:
                        healthHandler.ApplyFear(statusDuration);
                        break;

                    case Lists.Status.Rooted:
                        healthHandler.ApplyRoot(statusDuration);
                        break;

                    case Lists.Status.Silenced:
                        healthHandler.ApplySilence(statusDuration);
                        break;

                    case Lists.Status.Slowed:
                        healthHandler.ApplySlow(statusDuration);
                        break;

                    case Lists.Status.Stunned:
                        break;
                    }
                }
            }

            //Checks for slow motion effect

            /*
             * if (slowMotion)
             * {
             *      if (targetsHit >= slowMotionReq)
             *              EffectsHandler.Call.SlowTime();
             * }
             *
             * //Checks for camera shaking
             * if (shakeCamera)
             *      EffectsHandler.ShakeCamera(shakeCameraIntensity);*/
        }
    }