Exemplo n.º 1
0
        public override void Attack(IAttacker attacker, Vector3 direction)
        {
            if (!IsAvailableToShoot)
            {
                return;
            }
            IEnumerable <RaycastHit> allhits = GetAllHits(transform.position, direction);

            allhits = allhits.Except(allhits.Where(hit => attacker.Equals(hit.transform.GetComponent <IAttacker>())));
            foreach (RaycastHit hit in allhits)
            {
                IHitable target = hit.collider.gameObject.GetComponent <IHitable>();
                if (target != null)
                {
                    HitArgs hitInfo = HitArgs.CreateBuilder().SetDirection(direction).SetAttacker(attacker).SetDamage(this);
                    target.GetStrike(hitInfo);
                }
                else
                {
                    HitAnimation(hit.point);
                }
            }
            ShotAnimation();
            ShotSound();
            lastShot = Time.time;
        }