public void Attack() { Vector2 direction = CalculateTargetPosition(transform.position, projectile.GetComponent <Projectile>().speed, target.position, targetRigidbody.velocity) - (Vector2)transform.position; transform.rotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg); Attack(hasSpread ? MathHelpers.AddDegreeSpread(direction, spread) : direction); }
public bool Attack(Vector2 direction) { timeToShoot -= Time.deltaTime; if (timeToShoot <= 0f) { if (hasSpread) { direction = MathHelpers.AddDegreeSpread(direction, spread); } foreach (Gun gun in guns) { gun.Attack(direction); } StartReloading(); return(true); } return(false); }
protected void Attack(Vector2 direction) { if (hasSpread) { direction = MathHelpers.AddDegreeSpread(direction, spread); } if (gunsDischargeSynchronized) { if (guns[currentGroup].Attack(direction)) { currentGroup = (currentGroup + 1) % guns.Count; } } else { foreach (GunGroup gunGroup in guns) { gunGroup.Attack(direction); } } }