Esempio n. 1
0
 // Update is called once per frame
 void Update()
 {
     if (firing)
     {
         if (LaserBeamWeaponSystem.CurrentTarget != targetTransform)
         {
             LaserBeamWeaponSystem.CurrentTarget = targetTransform;
         }
         LaserBeamWeaponSystem.FireLaser();
     }
     else
     {
         if (LaserBeamWeaponSystem.LaserFiring)
         {
             LaserBeamWeaponSystem.StopLaserFire();
         }
     }
 }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (HasLaserBeamWeapon)
        {
            if (LaserBeamWeaponSystem.LaserBeamActive)
            {
                CanRotate = false;
            }
            else
            {
                CanRotate = true;
            }
        }

        if (CurrentTargetTransform != null)
        {
            float distanceToTarget = Vector3.Distance(CurrentTargetTransform.position, YRotationTransform.position);
            if (distanceToTarget < MinimumTargetDistance)
            {
                CurrentTargetTransform = null;
                if (HasLaserBeamWeapon)
                {
                    if (LaserBeamWeaponSystem.LaserFiring)
                    {
                        LaserBeamWeaponSystem.StopLaserFire();
                    }
                    LaserBeamWeaponSystem.CurrentTarget = null;
                }
            }
            else
            {
                if (CanRotate)
                {
                    TrackPosition(CurrentTargetTransform.position);
                    // Rotate Turret
                    XRotationEulers             = new Vector3(TargetXAngle, YRotationTransform.rotation.eulerAngles.y, 0);
                    XRotationTransform.rotation = Quaternion.Euler(XRotationEulers);
                }

                // Fire Laser Beam
                if (AimingAtTarget)
                {
                    if (HasLaserBeamWeapon)
                    {
                        if (LaserBeamWeaponSystem.CurrentTarget != CurrentTargetTransform)
                        {
                            LaserBeamWeaponSystem.CurrentTarget = CurrentTargetTransform;
                        }
                        LaserBeamWeaponSystem.FireLaser();
                    }
                }
            }
        }
        else
        {
            // Get Random Target
            Transform newTargetTransform = WSP_TargetManager.GlobalAccess.GetRandomTargetFromList(YRotationTransform.position, MinimumTargetDistance * 2);
            if (newTargetTransform != null)
            {
                CurrentTargetTransform = newTargetTransform;
            }
        }
    }