void FixedUpdate()
    {
        if (radarNew != null)
        {
            if (defenceType == DefenceType.airDefence)
            {
                target = radarNew.airTarget;
            }

            if (defenceType == DefenceType.surfaceDefence)
            {
                target = radarNew.surfaceTarget;
            }

            if (defenceType == DefenceType.allDefence)
            {
                target = radarNew.allTarget;
            }

            if (target)
            {
                if (Time.time - startTime > wait && laserAim.foundObject == true)
                {
                    // Fire weapon.
                    launcher.Launch(target);
                }
                // Look at the target.
                transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(target.position - transform.position, transform.up), turnRate * Time.deltaTime);
            }
        }
        else
        {
            target = null;
        }
    }
 private void FireWeapon()
 {
     // Fire the next launcher, then put it back at the end of the queue.
     if (launchers[selectedLauncherGroup].Count > 0)
     {
         AALauncher temp = launchers[selectedLauncherGroup].Dequeue();
         temp.Launch(target, rigidbody.velocity);
         launchers[selectedLauncherGroup].Enqueue(temp);
     }
 }
Exemplo n.º 3
0
    void Update()
    {
        if (target != null)
        {
            // Look at the target.
            launchTransform.rotation = Quaternion.LookRotation(target.position - transform.position, Vector3.up);

            if (Time.time - startTime > wait)
            {
                launcher.Launch(target);
            }
        }
    }
    void FixedUpdate()
    {
        transform.Translate(0.0f, 0.0f, speed * Time.deltaTime);

        if (target != null)
        {
            // Look at the target.
            transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(target.position - transform.position, transform.up), turnRate * Time.deltaTime);

            // Fire missile.
            if (Time.time - startTime > wait)
            {
                launcher.Launch(target, transform.forward * speed);
            }
        }
    }
Exemplo n.º 5
0
        private void Update()
        {
            if (defence != null && defence.turretsIdle == false)
            {
                if (defenceType == DefenceType.airDefence)
                {
                    target = defence.airtargetTransform;
                }

                if (defenceType == DefenceType.surfaceDefence)
                {
                    target = defence.surfacetargetTransform;
                }

                if (defenceType == DefenceType.allDefence)
                {
                    target = defence.allTargetTransform;
                }

                if (target && Time.time - startTime > wait && laserAim.foundObject == true)
                {
                    launcher.Launch(target);
                }
            }
            else
            {
                target = null;
            }


            if (target == null)
            {
                targetLocked = false;
            }
            else
            {
                targetLocked = true;
            }
        }