예제 #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;
        }
예제 #2
0
 public void GetStrike(HitArgs hit)
 {
     Debug.Log("[GameObject]:" + gameObject.name + " got " + hit._Weapon.Damage + " damage");
 }
예제 #3
0
 public HitArgsBuilder()
 {
     hit = new HitArgs();
 }