void Start() { controller = FindObjectOfType <FuelControl>(); try { tank = transform.GetComponentInParent <Tank>(); if (tank.fuel > 0) { active = true; } } catch (System.NullReferenceException) { Destroy(flame); Destroy(this); } }
// Use this for initialization void Start() { scenario = new Scenario(); objectif = scenario.getObjectif(); Time.timeScale = 1; scriptIntroControl = this.GetComponent <IntroControl> (); scriptIntroControl.enabled = true; scriptIntroState = plane.GetComponent <IntroState> (); scriptIntroState.enabled = true; //intro script activation state = State.INTRO; scriptPlanePhysics = plane.GetComponent <PlanePhysics> (); scriptPlanePhysics.enabled = false; scriptSlidingBackground = backgrounds.GetComponent <SlidingBackground>(); scriptRandomObject = this.GetComponent <RandomObject> (); scriptRandomObject.enabled = false; scriptFuelControl = GetComponent <FuelControl>(); scriptFuelControl.enabled = true; prevY = scriptPlanePhysics.transform.position.y; isPause = false; guiBestScore.value = PlayerPrefs.GetInt(Constants.MAIN_GAME_HIGH_SCORE); tutoScript = tutoPref.GetComponent <GenericTutoScript>(); if (PlayerPrefs.GetInt(Constants.MAIN_GAME_ALREADY_PLAYED) == 0) { bouttonPause.GetComponent <Image> ().enabled = false; firstPlayTuto(); PlayerPrefs.SetInt(Constants.MAIN_GAME_ALREADY_PLAYED, 1); } else if (!scenario.isFinished()) { displayObjectif(); } }
void Awake() { fuel = GameObject.Find("fuel" + fuelCount); fuelCount++; fuelScript = fuel.GetComponent <FuelControl>(); }
// Use this for initialization void Start() { scenario = new Scenario (); objectif = scenario.getObjectif(); Time.timeScale = 1; scriptIntroControl = this.GetComponent<IntroControl> (); scriptIntroControl.enabled = true; scriptIntroState = plane.GetComponent<IntroState> (); scriptIntroState.enabled = true; //intro script activation state = State.INTRO; scriptPlanePhysics = plane.GetComponent<PlanePhysics> (); scriptPlanePhysics.enabled = false; scriptSlidingBackground = backgrounds.GetComponent<SlidingBackground>(); scriptRandomObject = this.GetComponent<RandomObject> (); scriptRandomObject.enabled = false; scriptFuelControl = GetComponent<FuelControl>(); scriptFuelControl.enabled = true; prevY = scriptPlanePhysics.transform.position.y; isPause = false; guiBestScore.value = PlayerPrefs.GetInt (Constants.MAIN_GAME_HIGH_SCORE); tutoScript = tutoPref.GetComponent<GenericTutoScript>(); if (PlayerPrefs.GetInt (Constants.MAIN_GAME_ALREADY_PLAYED) == 0) { bouttonPause.GetComponent<Image> ().enabled = false; firstPlayTuto (); PlayerPrefs.SetInt (Constants.MAIN_GAME_ALREADY_PLAYED, 1); } else if (! scenario.isFinished()){ displayObjectif(); } }
void Start() { controller = FindObjectOfType <FuelControl>(); rb = GetComponent <Rigidbody2D>(); }
public void Update() { Tacn.InEngineBrake = false; foreach (var brakePosition in EngineBrakeEnableBrakeNotches) { if (brakePosition == AtsSimulationEnvironment.Instance.ControlHandle.BrakePosition) { Tacn.InEngineBrake = true; break; } } if (AtsSimulationEnvironment.Instance.ControlHandle.IsAppliedEmergencyBrake) { AtsSimulationEnvironment.Instance.ControlHandle.TractionPosition = 0; } Tacn.InNotch = AtsSimulationEnvironment.Instance.ControlHandle.TractionPosition; Tacn.InReverser = AtsSimulationEnvironment.Instance.ControlHandle.ReverserPosition; FuelControl.InRpm = Tacn.OutRpm; FuelControl.InNotch = Tacn.OutNotch; FuelControl.InFuelInjectionCurrent = Tacn.OutFuelInjectionCurrent; FuelControl.Update(AtsSimulationEnvironment.Instance.DeltaTime); var injectionCurrentGain = ElectricGovernor.OutGain; var fuelInjectionCurrent = FuelControl.OutFuelCurrent * injectionCurrentGain; var targetRpm = fuelInjectionCurrent * MaximumRpm; EngineDelay.U = targetRpm; EngineDelay.Tp = Tacn.OutEngineDelayTp; if ((Tacn.CurrentDrivingState == Transmission.DrivingState.Brake) || (Tacn.CurrentDrivingState == Transmission.DrivingState.Drive)) { if ((Tacn.CurrentGearPosition == Transmission.GearPositionState.Mission1) || (Tacn.CurrentGearPosition == Transmission.GearPositionState.Mission2)) { EngineDelay.Reset(Tacn.OutRpm); } } EngineDelay.Calculate(AtsSimulationEnvironment.Instance.DeltaTime); TurbineDelay.U = Tacn.CurrentDrivingState == Transmission.DrivingState.Synching ? 0.0 : FuelControl.OutFuelCurrent; TurbineDelay.Tp = 1000.0f; TurbineDelay.Calculate(AtsSimulationEnvironment.Instance.DeltaTime); var actualRpm = EngineDelay.Y; ElectricGovernor.InActualRpm = actualRpm; ElectricGovernor.InTargetRpm = targetRpm; ElectricGovernor.Update(); Tacn.InRpm = actualRpm; Tacn.Update(AtsSimulationEnvironment.Instance.DeltaTime); EngineNoise.DirectionMixtureRatio = (float)(fuelInjectionCurrent * 2.0); EngineNoise.Position = (float)Tacn.OutRpm; DebugForm.SetText(DebugForm.FuelInjectionCurrent, fuelInjectionCurrent.ToString("F3")); DebugForm.SetText(DebugForm.EngineRpm, EngineNoise.Position.ToString("0000")); GearNoise.DirectionMixtureRatio = 1.0f; GearNoise.Position = AtsSimulationEnvironment.Instance.CurrentStates.AbsoluteVelocity; GearNoise.Volume = AtsSimulationEnvironment.Instance.CurrentStates.MainCircuitCurrent / 100.0f; ExhaustNoise.DirectionMixtureRatio = (float)fuelInjectionCurrent; ExhaustNoise.Position = (float)Tacn.OutRpm; ExhaustNoise.Volume = (float)fuelInjectionCurrent; TurbineNoise.DirectionMixtureRatio = (float)fuelInjectionCurrent; TurbineNoise.Position = (float)TurbineDelay.Y; TurbineNoise.Volume = 1.0f; switch (Tacn.CurrentGearPosition) { case Transmission.GearPositionState.Mission1: TransferGear1Noise.DirectionMixtureRatio = (float)fuelInjectionCurrent; TransferGear1Noise.Position = (float)Tacn.OutRpm; TransferGear1Noise.Volume = (float)Tacn.OutTransferGearNoiseVolume; TransferGear2Noise.Volume = 0.0f; break; case Transmission.GearPositionState.Mission2: TransferGear1Noise.Volume = 0.0f; TransferGear2Noise.DirectionMixtureRatio = (float)fuelInjectionCurrent; TransferGear2Noise.Position = (float)Tacn.OutRpm; TransferGear2Noise.Volume = (float)Tacn.OutTransferGearNoiseVolume; break; default: TransferGear1Noise.Volume = 0.0f; TransferGear2Noise.Volume = 0.0f; break; } EngineNoise.Update(); GearNoise.Update(); TransferGear1Noise.Update(); TransferGear2Noise.Update(); ExhaustNoise.Update(); TurbineNoise.Update(); AtsSimulationEnvironment.Instance.ControlHandle.TractionPosition = Tacn.OutTractionPosition; AtsSimulationEnvironment.Instance.ControlHandle.ReverserPosition = Tacn.OutReverserPosition; if (DebugForm.Visible) { DebugForm.Update(); } }
void Update() { if (Input.GetKeyDown(KeyCode.F)) { UseFuel.CurFuel -= DecreasedAmount; UseFuel.FuelBar.fillAmount -= DecreasedAmount; inPast = !inPast; } if (flipped && !zeroGravity) { gravity = -gravityValue; } if (!flipped && !zeroGravity) { gravity = gravityValue; } if (!isPaused) { transform.Rotate(0, Input.GetAxis("Mouse X") * rotateSpeed, 0); // gets tge Y axus from the mouse for the rotaion so the camera can look up or down CurX += Input.GetAxis("Mouse Y") * -rotateSpeed; // locks the camera CurX = Mathf.Clamp(CurX, -60f, 60); // rotates the camear up or down FPSCam.transform.localRotation = Quaternion.Euler(CurX, 0, 0); } /*if (!zeroGravity) * { * gravity = 30; * }*/ CharacterController controller = GetComponent <CharacterController>(); if (controller.isGrounded) { canJump = true; inair = false; moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); moveDirection = transform.TransformDirection(moveDirection); moveDirection *= moveSpeed; // moveDirection.y -= gravity * Time.deltaTime; } //needs to not be done when grounded anymore controller.Move(moveDirection * Time.deltaTime); if (onRoof && !zeroGravity && curState != PlayerStates.jetPack && flipped && canJump) { if (Input.GetKey(KeyCode.Space)) { moveDirection.y = -jumpSpeed; onground = false; curState = PlayerStates.Inair; } } if (onground && !zeroGravity && curState != PlayerStates.jetPack && !flipped && canJump) { if (Input.GetKey(KeyCode.Space)) { moveDirection.y = jumpSpeed; onground = false; curState = PlayerStates.Inair; } } if (inair) { moveDirection.y -= gravity * Time.deltaTime; canJump = false; if (controller.isGrounded) { curState = PlayerStates.idle; canJump = true; } } // moveDirection.y -= gravity * Time.deltaTime; controller.Move(moveDirection * Time.deltaTime); if (flipped) { if (curState != PlayerStates.jetPack) { moveDirection.y -= gravity * Time.deltaTime; } } if (!flipped) { if (curState != PlayerStates.jetPack) { moveDirection.y -= gravity * Time.deltaTime; } } if (Input.GetKeyDown(KeyCode.G) && inPast == true) { //Debug.Log("can"); zeroGravity = !zeroGravity; } /* if (transform.Find("PauseMenu")) * { * //Debug.Log("Found it"); * } * if (pauseMenuScreen == null) * { * pauseMenuScreen = GameObject.Find("PauseMenu"); * } */ if (isJumping == true) { jumpTimer -= Time.deltaTime; } if (isJumping == false) { jumpTimer = 1.5f; } ps[curState].Invoke(); if (UseFuel == null) { UseFuel = GameObject.Find("FuelMeter").GetComponent <FuelControl>(); } if (FPSCam == null) { FPSCam = GameObject.Find("FPCamera"); } if (Input.GetKeyDown(KeyCode.LeftShift)) { moveSpeed = sprintSpeed; } if (Input.GetKeyUp(KeyCode.LeftShift)) { moveSpeed = startSpeed; } }