Ejemplo n.º 1
0
        public void Hit(HitInfo hitInfo)
        {
            // see if they blocked
            var wasBlocked = false;

            if (weaponController.IsBlocking)
            {
                var hitDirection = hitInfo.Point - transform.position;
                hitDirection.Normalize();
                var angle = Vector2.Angle(mouseDirection, hitDirection);
                //Debug.Log("mousedir: " + mouseDirection + " projectiledir: " + hitDirection + " angle: " + angle);
                if (angle <= 90)
                {
                    wasBlocked = true;
                    Debug.Log("you blocked");
                }
            }

            int damage = defenseInfo.CalculateFinalDamage(hitInfo.Damage);

            // move to calculate
            damage  = wasBlocked ? (damage / 2) : damage;
            Health -= damage;
            Debug.Log("dmg: " + damage);
        }
Ejemplo n.º 2
0
        public void Hit(HitInfo hitInfo)
        {
            if (health <= 0)
            {
                return;
            }

            int damage = defenseInfo.CalculateFinalDamage(hitInfo.Damage);

            health -= damage;

            Debug.Log("You hit " + name + " for " + damage + "!");

            if (health <= 0)
            {
                if (hitInfo.Source == HitInfo.HitSources.Player)
                {
                    Player.PlayerController.Instance.statController.AddExperience(experience);
                }

                Debug.Log("You killed " + name + "!");
                Die();
            }
        }