Пример #1
0
        void UpdateModel()
        {
            //model rotation

            if (radarEnabled)
            {
                if (rotationTransform && canScan)
                {
                    Vector3 direction;
                    if (locked)
                    {
                        direction =
                            Quaternion.AngleAxis(canTrackWhileScan ? currentAngle : lockScanAngle, referenceTransform.up) *
                            referenceTransform.forward;
                    }
                    else
                    {
                        direction = Quaternion.AngleAxis(currentAngle, referenceTransform.up) * referenceTransform.forward;
                    }

                    Vector3 localDirection =
                        Vector3.ProjectOnPlane(rotationTransform.parent.InverseTransformDirection(direction), Vector3.up);
                    if (localDirection != Vector3.zero)
                    {
                        rotationTransform.localRotation = Quaternion.Lerp(rotationTransform.localRotation,
                                                                          Quaternion.LookRotation(localDirection, Vector3.up), 10 * TimeWarp.fixedDeltaTime);
                    }
                }

                //lock turret
                if (lockingTurret && canLock)
                {
                    if (locked)
                    {
                        lockingTurret.AimToTarget(lockedTarget.predictedPosition, lockingPitch, lockingYaw);
                    }
                    else
                    {
                        lockingTurret.ReturnTurret();
                    }
                }
            }
            else
            {
                if (rotationTransform)
                {
                    rotationTransform.localRotation = Quaternion.Lerp(rotationTransform.localRotation,
                                                                      Quaternion.identity, 5 * TimeWarp.fixedDeltaTime);
                }

                if (lockingTurret)
                {
                    lockingTurret.ReturnTurret();
                }
            }
        }
Пример #2
0
		IEnumerator ShutdownRoutine()
		{
			weaponState = WeaponStates.PoweringDown;
			if(turret)
			{
				while(!turret.ReturnTurret()) //wait till turret has returned
				{
					yield return new WaitForFixedUpdate();
				}
			}

			if(hasDeployAnim)
			{
				deployState.enabled = true;
				deployState.speed = -1;
				while(deployState.normalizedTime > 0)
				{
					yield return null;
				}
				deployState.normalizedTime = 0;
				deployState.speed = 0;
				deployState.enabled = false;
			}

			weaponState = WeaponStates.Disabled;
		}
Пример #3
0
        IEnumerator ReturnRoutine()
        {
            if (deployed)
            {
                hasReturned = false;
                yield break;
            }

            yield return(new WaitForSeconds(0.25f));

            while (!turret.ReturnTurret())
            {
                yield return(new WaitForFixedUpdate());
            }

            hasReturned = true;
        }
Пример #4
0
        IEnumerator ReturnRoutine()
        {
            if (turretEnabled)
            {
                hasReturned = false;
                yield break;
            }

            yield return(new WaitForSeconds(0.25f));

            while (pausingAfterShot)
            {
                yield return(new WaitForFixedUpdate());
            }

            while (!turret.ReturnTurret())
            {
                UpdateMissilePositions();
                yield return(new WaitForFixedUpdate());
            }
        }