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