Beispiel #1
0
        protected override void BlockUpdate()
        {
            timeSinceFire += Time.deltaTime;

            if (!Target?.GetTargetValid() ?? false)
            {
                Target = null;
            }

            if (Target == null)
            {
                var shipAngle = Parent.Transform.right.ToVector2().GetAngle();
                RotateTowards(shipAngle);
                return;
            }

            // Rotate the turret to the target
            var currentPosition = transform.position.ToVector2();
            var difference      = Target.GetPosition(currentPosition) - currentPosition;
            var targetAngle     = difference.GetAngle();

            RotateTowards(targetAngle);

            var currentAngle = turret.rotation.eulerAngles.z;

            if (WithinFiringFrustum(currentAngle, targetAngle) && timeSinceFire > data.FiringRate)
            {
                timeSinceFire = 0f;
                Fire();
            }
        }
Beispiel #2
0
 public void SetTarget(IWeaponTarget target)
 {
     foreach (var turret in this)
     {
         turret.SetTarget(target);
     }
 }
Beispiel #3
0
        public override bool Shoot(IWeaponTarget target)
        {
            this.ShootCalled = true;

            this.Target = target;

            return(true);
        }
Beispiel #4
0
    public void OnHit(GameObject other)
    {
        IWeaponTarget target = other.GetComponent <IWeaponTarget>();

        if (target == null)
        {
            return;
        }

        if (!FriendFactions.Contains(target.GetCharacaterFaction()))
        {
            HitInfo.StunDirection = other.transform.position - transform.position;
            target.ApplyHit(HitInfo);
        }
    }
 public override bool Shoot(IWeaponTarget target)
 {
     return(target.LandShot());
 }
Beispiel #6
0
 public void SetTarget(IWeaponTarget target)
 {
     turretBehaviour.Target = target;
 }
 public abstract bool Shoot(IWeaponTarget target);