Esempio n. 1
0
		void Update()
		{
			if(HighLogic.LoadedSceneIsFlight && FlightGlobals.ready && !vessel.packed && vessel.IsControllable)
			{

				if(lowpassFilter)
				{
					if(InternalCamera.Instance && InternalCamera.Instance.isActive)
					{
						lowpassFilter.enabled = true;
					}
					else
					{
						lowpassFilter.enabled = false;
					}
				}
	
				if(weaponState == WeaponStates.Enabled && (TimeWarp.WarpMode != TimeWarp.Modes.HIGH || TimeWarp.CurrentRate == 1))
				{
					

					userFiring = (BDInputUtils.GetKey(BDInputSettingsFields.WEAP_FIRE_KEY) && (vessel.isActiveVessel || BDArmorySettings.REMOTE_SHOOTING) && !MapView.MapIsEnabled && !aiControlled);
					if((userFiring || autoFire) && (yawRange == 0 || (maxPitch-minPitch) == 0 || turret.TargetInRange(finalAimTarget, 10, float.MaxValue)))
					{
						if(eWeaponType == WeaponTypes.Ballistic || eWeaponType == WeaponTypes.Cannon)
						{
							finalFire = true;
							//Fire();
						}
					}
					else
					{
						if(spinDownAnimation) spinningDown = true;
						if(eWeaponType == WeaponTypes.Laser) audioSource.Stop();
						if(!oneShotSound && wasFiring)
						{
							audioSource.Stop();
							wasFiring = false;
							audioSource2.PlayOneShot(overheatSound);	
						}
					}
				}
				else
				{
					audioSource.Stop ();
					autoFire = false;
				}

				if(spinningDown && spinDownAnimation && hasFireAnimation)
				{
					if(fireState.normalizedTime>1) fireState.normalizedTime = 0;
					fireState.speed = fireAnimSpeed;
					fireAnimSpeed = Mathf.Lerp(fireAnimSpeed, 0, 0.04f);
				}
				
				
			}
		}
Esempio n. 2
0
 public override void OnUpdate()
 {
     if (HighLogic.LoadedSceneIsFlight)
     {
         if (readyToFire && deployed && (!weaponManager || weaponManager.selectedWeaponString != GetShortName()))
         {
             if (BDInputUtils.GetKeyDown(BDInputSettingsFields.WEAP_FIRE_KEY) && (vessel.isActiveVessel || BDArmorySettings.REMOTE_SHOOTING))
             {
                 FireRocket();
             }
         }
     }
 }
Esempio n. 3
0
        IEnumerator RecordKeyRoutine()
        {
            while (!valid)
            {
                if (mouseUp)
                {
                    string iString = BDInputUtils.GetInputString();
                    if (iString.Length > 0)
                    {
                        inputString = iString;
                        valid       = true;
                    }
                }

                if (Input.GetKeyUp(KeyCode.Mouse0))
                {
                    mouseUp = true;
                }
                yield return(null);
            }
        }
Esempio n. 4
0
        public override void OnUpdate()
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                if (readyToFire && deployed)
                {
                    if (returnRoutine != null)
                    {
                        StopCoroutine(returnRoutine);
                        returnRoutine = null;
                    }

                    if (weaponManager && weaponManager.guardMode && weaponManager.selectedWeaponString == GetShortName())
                    {
                        if (Time.time - autoFireStartTime < autoFireDuration)
                        {
                            float fireInterval = 0.5f;
                            if (autoRippleRate > 0)
                            {
                                fireInterval = 60f / autoRippleRate;
                            }
                            if (Time.time - lastAutoFiredTime > fireInterval)
                            {
                                FireRocket();
                                lastAutoFiredTime = Time.time;
                            }
                        }
                    }
                    else if ((!weaponManager ||
                              (weaponManager.selectedWeaponString == GetShortName() && !weaponManager.guardMode)))
                    {
                        if (BDInputUtils.GetKeyDown(BDInputSettingsFields.WEAP_FIRE_KEY) &&
                            (vessel.isActiveVessel || BDArmorySettings.REMOTE_SHOOTING))
                        {
                            FireRocket();
                        }
                    }
                }
            }
        }
        void UpdateKeyInputs()
        {
            if (!vessel.isActiveVessel)
            {
                return;
            }

            if (BDInputUtils.GetKey(BDInputSettingsFields.TGP_SLEW_LEFT))
            {
                slewInput.x = -1;
            }
            else if (BDInputUtils.GetKey(BDInputSettingsFields.TGP_SLEW_RIGHT))
            {
                slewInput.x = 1;
            }

            if (BDInputUtils.GetKey(BDInputSettingsFields.TGP_SLEW_UP))
            {
                slewInput.y = 1;
            }
            else if (BDInputUtils.GetKey(BDInputSettingsFields.TGP_SLEW_DOWN))
            {
                slewInput.y = -1;
            }

            if (BDInputUtils.GetKeyDown(BDInputSettingsFields.TGP_IN))
            {
                ZoomIn();
            }
            else if (BDInputUtils.GetKeyDown(BDInputSettingsFields.TGP_OUT))
            {
                ZoomOut();
            }

            if (BDInputUtils.GetKeyDown(BDInputSettingsFields.TGP_LOCK))
            {
                if (groundStabilized)
                {
                    ClearTarget();
                }
                else
                {
                    GroundStabilize();
                }
            }

            if (BDInputUtils.GetKeyDown(BDInputSettingsFields.TGP_NV))
            {
                ToggleNV();
            }

            if (groundStabilized && BDInputUtils.GetKeyDown(BDInputSettingsFields.TGP_SEND_GPS))
            {
                SendGPS();
            }

            if (BDInputUtils.GetKeyDown(BDInputSettingsFields.TGP_COM))
            {
                CoMLock = !CoMLock;
            }

            if (BDInputUtils.GetKeyDown(BDInputSettingsFields.TGP_RADAR))
            {
                radarLock = !radarLock;
            }

            if (BDInputUtils.GetKeyDown(BDInputSettingsFields.TGP_TURRETS))
            {
                if (slaveTurrets)
                {
                    UnslaveTurrets();
                }
                else
                {
                    SlaveTurrets();
                }
            }

            if (BDInputUtils.GetKeyDown(BDInputSettingsFields.TGP_TO_GPS))
            {
                PointToGPSTarget();
            }

            if (BDInputUtils.GetKeyDown(BDInputSettingsFields.TGP_RESET))
            {
                ResetCameraButton();
            }
        }