public override IEnumerator triggerEffect(SimpleCarController car) { if (car == null) { Debug.Log("Broken Car!"); yield break; } originalMotor = car.maxMotorTorque; originalBraking = car.maxBrakingForce; Debug.Log("Motor: " + originalMotor); Debug.Log("Brake: " + originalBraking); car.maxBrakingForce *= speedScale; car.maxMotorTorque *= speedScale; base.spawner.powerupTimeLeftFillImage.GetComponent <decreaseFillAmount> ().resetFillAmount(); base.spawner.powerupText.SetActive(true); base.spawner.powerupText.GetComponent <Text> ().text = "Speed Boost"; base.spawner.nonePowerupText.SetActive(false); GameObject.FindObjectOfType <SoundController> ().playPowerupSound(); yield return(new WaitForSeconds(effectTime)); base.spawner.powerupText.SetActive(false); base.spawner.nonePowerupText.SetActive(true); car.maxMotorTorque = originalMotor; car.maxBrakingForce = originalBraking; }
public void LeaveCar(SimpleCarController otherCar) { if (nearestCar == otherCar) { nearestCar = null; } }
public override IEnumerator triggerEffect(SimpleCarController car) { if (car == null) { Debug.Log("Broken Car!"); yield break; } originalScale = car.transform.root.gameObject.transform.localScale; originalMass = car.carRB.mass; car.transform.root.gameObject.transform.localScale = newScale; car.carRB.mass *= massScaleFactor; base.spawner.powerupText.SetActive(true); base.spawner.powerupText.GetComponent <Text> ().text = "Size Up"; base.spawner.nonePowerupText.SetActive(false); GameObject.FindObjectOfType <SoundController> ().playPowerupSound(); base.spawner.powerupTimeLeftFillImage.GetComponent <decreaseFillAmount> ().resetFillAmount(); yield return(new WaitForSeconds(effectTime)); base.spawner.powerupText.SetActive(false); base.spawner.nonePowerupText.SetActive(true); car.carRB.mass = originalMass; car.transform.root.gameObject.transform.localScale = originalScale; }
private IEnumerator powerupCoroutine(Coin c, SimpleCarController car) { isUsingPowerup = true; yield return(c.triggerEffect(car)); isUsingPowerup = false; }
public override IEnumerator triggerEffect(SimpleCarController car) { if (car == null) { Debug.Log("Broken Car!"); yield break; } IncrementScore scoreHolder = GameObject.FindObjectOfType <IncrementScore>(); originalScoreScale = scoreHolder.scoreScaleFactor; scoreHolder.scoreScaleFactor = scoreScale; base.spawner.powerupTimeLeftFillImage.GetComponent <decreaseFillAmount> ().resetFillAmount(); base.spawner.powerupText.SetActive(true); base.spawner.powerupText.GetComponent <Text> ().text = "Multiplier " + scoreScale + "X"; base.spawner.nonePowerupText.SetActive(false); if (scoreScale == .5f) { GameObject.FindObjectOfType <SoundController> ().playHalfCoinMultiplierSound(); } else { GameObject.FindObjectOfType <SoundController> ().playPowerupSound(); } yield return(new WaitForSeconds(effectTime)); base.spawner.powerupText.SetActive(false); base.spawner.nonePowerupText.SetActive(true); scoreHolder.scoreScaleFactor = originalScoreScale; }
protected override void Start() { base.Start(); c = GetComponent <SimpleCarController>(); message = new Velocity(); velocityNoiseStdDev = ConfigLoader.Instance.sensors.encoders.velocityNoise; }
// Use this for initialization void Start() { controller = GetComponent<SimpleCarController>(); rigidbody = GetComponent<Rigidbody>(); ProcessTrack(); target = GetTarget(); }
protected override void Start() { base.Start(); c = GetComponent <SimpleCarController>(); message = new Imuodom(); accelNoiseStdDev = ConfigLoader.Instance.sensors.imu.accelNoise; }
// Use this for initialization void Start() { controller = GetComponent <SimpleCarController>(); rigidbody = GetComponent <Rigidbody>(); ProcessTrack(); target = GetTarget(); }
public void OnTriggerExit(Collider other) { if (other.GetComponentInChildren <SimpleCarController>() != null) { SimpleCarController otherCar = other.GetComponentInChildren <SimpleCarController>(); LeaveCar(otherCar); } }
public void Init(SimpleCarController carController) { CarController = carController; CarController.tag = "Player"; carController.EquipWeapon(LevelManager.Instance.GetEquipedWeapon()); carController.EnableEngineSound(true); CarController.PlaySirene(); }
void Start() { _rb = transform.GetComponent <Rigidbody>(); _rayPer = GetComponent <RayPerception3D>(); _controller = GetComponent <SimpleCarController>(); _startPosition = transform.position; _startRotation = transform.rotation; }
protected override void Start() { base.Start(); c = GetComponent <SimpleCarController>(); message = new Imu(); accelNoiseStdDev = ConfigLoader.Instance.sensors.imu.accelNoise; orientationNoiseStdDev = ConfigLoader.Instance.sensors.imu.orientationNoise; angularVelocityNoiseStdDev = ConfigLoader.Instance.sensors.imu.angularVelocityNoise; }
public void PlayerByCar(SimpleCarController otherCar) { if (nearestCar == null || Vector3.Distance(otherCar.transform.position, transform.position) < Vector3.Distance(nearestCar.transform.position, transform.position)) { nearestCar = otherCar; Debug.Log("Near Car"); //EnterCar(carToEnter); } }
protected override void Start() { base.Start(); c = GetComponent <SimpleCarController>(); message = new DriveStatus(); message.device_id = 1; accelNoiseStdDev = ConfigLoader.Instance.sensors.imu.accelNoise; velocityNoiseStdDev = ConfigLoader.Instance.sensors.encoders.velocityNoise; }
private void SetupPlayer() { List <SimpleCarController> cars = LevelManager.Instance.GetCarsList(); SimpleCarController car = Instantiate(cars[LoadCarIndex]); car.transform.SetParent(PlayerInputController.transform); PlayerInputController.Init(car); SetPlayerPoistion(); CameraController.Init(car.gameObject); }
public void EnterCar(SimpleCarController activeCar) { Debug.Log("Enter Car Triggered"); activeCar.isCarActive = true; this.activeCar = activeCar; gameObject.SetActive(false); transform.parent = activeCar.centerOfMass.transform; //Connect to car, allows exit at proper location. activeCar.PlayerEnter(this); Camera.main.GetComponent <SmoothCameraMove>().SwitchTarget(activeCar.carCamera.transform); Camera.main.cullingMask &= ~(1 << LayerMask.NameToLayer("Car Indicators")); }
void OnTriggerEnter(Collider col) { if (col.gameObject.layer == LayerMask.NameToLayer("Player")) { SimpleCarController car = col.gameObject.transform.root.GetComponent <SimpleCarController>(); if (this.spawner != null) { this.spawner.pickedUpCoin(this, car); } } }
public void ExitCar() { Debug.Log("CarExit Triggered"); activeCar.isCarActive = false; transform.parent = null; //Disconnect from car to allow free movement. gameObject.SetActive(true); Camera.main.GetComponent <SmoothCameraMove>().SwitchTarget(playerCamera.transform); activeCar = null; nearestCar = null; Camera.main.cullingMask |= (1 << LayerMask.NameToLayer("Car Indicators")); }
public virtual IEnumerator triggerEffect(SimpleCarController car) { GameObject.FindObjectOfType <IncrementScore>().addToScore(100); this.spawner.plusOneHundred.GetComponent <Text>().text = "+ " + (GameObject.FindObjectOfType <IncrementScore> ().scoreScaleFactor * 100); this.spawner.plusOneHundred.SetActive(true); GameObject.FindObjectOfType <SoundController> ().playCoinSound(); // this.spawner.sizePowerupText.SetActive(true); // this.spawner.nonePowerupText.SetActive (false); yield return(new WaitForSeconds(1f)); //this.spawner.sizePowerupText.SetActive(false); this.spawner.plusOneHundred.SetActive(false); yield break; }
public void pickedUpCoin(Coin coin, SimpleCarController car) { GameObject.FindObjectOfType <SoundController> ().playCoinSound(); //Not using a powerup, or we can pick up this coin while a powerup is going on if (!isUsingPowerup || coin.canPickupDuringPowerup()) { removeCoin(coin); if (coin.isPowerupCoin()) { StartCoroutine(powerupCoroutine(coin, car)); } else { StartCoroutine(coin.triggerEffect(car)); } } }
private void Start() { rigidBody = GetComponent <Rigidbody>(); carExplosion = Instantiate(carExplosion, transform.position, Quaternion.identity); carExplosion.Stop(); carExplosion.gameObject.SetActive(false); carSmoke = Instantiate(carSmoke, roodFrontPosition.position, roodFrontPosition.rotation); carSmoke.Stop(); carSmoke.gameObject.SetActive(false); LevelController.instance.onGameEnd += OnGameEnd; LevelController.instance.onGameEndNow += OnGameEndNow; LevelController.instance.onGameStart += OnGameStart; LevelController.instance.onGameStartLater += OnGameStartLater; simpleCarController = GetComponent <SimpleCarController>(); }
public void Init(CarAIData data) { Data = data; if (Data.Keys.Count > 0) { SimpleCarController prefab = LevelManager.Instance.GetCarsList()[Data.CarIndex]; CarController = Instantiate(prefab); CarController.transform.SetParent(transform); CarController.Init(CarOwner.kAI); if (Data.Keys.Count > 1) { Vector3 spawnLocation = Data.GetKey(0); Vector3 targetVector = Data.GetKey(1) - Data.GetKey(0); CarController.SetTransform(spawnLocation, Mathf.Atan2(targetVector.x, targetVector.z) * Mathf.Rad2Deg); CanMove = true; TargetKeyIndex = 1; } } }
// GRAB AND UPDATE MOTOR OUTPUT VALUES. // // Updates both nonScaled and scaled motor value arrays. public void updateMotorValues() { string outputString = "RMI Length: " + RMI.Length + "Ouput length: " + output.Length + ". Contents: "; for (int i = 0; i < output.Length; i++) { outputString += output[i] + ", "; } for (int i = 0; i < LMILength; i++) { nonScaledLMspeed = output[LMI[i]]; } for (int i = 0; i < RMILength; i++) { nonScaledRMspeed = output[RMI[i]]; } SimpleCarController.runMotors(nonScaledLMspeed, nonScaledRMspeed); }
// Start is called before the first frame update void Start() { myCarController = GetComponent <SimpleCarController>(); palabrasAccion.Add("adelante", myCarController.MoveForward); palabrasAccion.Add("atras", myCarController.MoveBackward); palabrasAccion.Add("izquierda", myCarController.SteerLeft); palabrasAccion.Add("derecha", myCarController.SteerRight); palabrasAccion.Add("giro izquierda", myCarController.SteerAllLeft); palabrasAccion.Add("giro derecha", myCarController.SteerAllRight); palabrasAccion.Add("stop", myCarController.StopCar); palabrasAccion.Add("defrente", myCarController.SteerStraightAhead); palabrasAccion.Add("turbo", myCarController.MaxSpeed); palabrasAccion.Add("inicio", myCarController.ResetCar); reconocePalabras = new KeywordRecognizer(palabrasAccion.Keys.ToArray(), confidencialidad); reconocePalabras.OnPhraseRecognized += OnKeywordsRecognized; reconocePalabras.Start(); }
private void addCarControllerScript() { SimpleCarController simpleCarController = machineGameObject.AddComponent <SimpleCarController>(); AxleInfo frontAxle = new AxleInfo(); frontAxle.wheels = new WheelCollider[] { wheels[0].GetComponent <WheelCollider>(), wheels[1].GetComponent <WheelCollider>() }; frontAxle.motor = true; frontAxle.steering = true; AxleInfo rearAxle = new AxleInfo(); rearAxle.wheels = new WheelCollider[] { wheels[2].GetComponent <WheelCollider>(), wheels[3].GetComponent <WheelCollider>() }; rearAxle.motor = true; rearAxle.steering = false; simpleCarController.axleInfos = new List <AxleInfo>() { frontAxle, rearAxle };; simpleCarController.maxMotorTorque = DEFAULT_MOTOR_TORQUE; simpleCarController.maxSteeringAngle = 50; simpleCarController.verticalAxisInputName = verticalAxisInputName; simpleCarController.horizontalAxisInputName = horizontalAxisInputName; }
// Use this for initialization void Start() { //first show payer selected car to drive showSelectedPlayerCar(); carController = GameObject.FindGameObjectWithTag("Player").GetComponent <SimpleCarController>(); }
protected override void Start() { base.Start(); car = GetComponent <SimpleCarController>(); }
void Awake() { instance = this; }
protected override void Start() { base.Start(); message = new Motors(); car = GetComponent <SimpleCarController>(); }
void Update() { timeCurrent = Time.timeSinceLevelLoad; Debug.Log("RUNNING GENERATION: " + testGeneration.generationIndex); Debug.Log("RUNNING INDIVIDUAL: " + currentIndex); rawirDataArray = SimpleCarController.returnRawIRdata(); rawldrDataArray = SimpleCarController.returnRawLDRdata(); ldrDataArray = SimpleCarController.returnLDRdata(); irDataArray = SimpleCarController.returnIRdata(); if (simulationRunning) { // IF we have passed the start screen... if (pastStartScreen) { // If this is the first run after passing the start screen... if (firstRun) { trialTime = MainMenu.INPUTtrialLength; Debug.Log("THIS IS THE TRIAL TIME: " + trialTime); // Create a generation. testGeneration.setGenerationParameters(MainMenu.INPUTavgGenomeSize, MainMenu.INPUTnumberOfGenerations, MainMenu.INPUTnumberOfIndividuals); testGeneration.createStartGeneration(); } if (!(firstGenerationRun)) { if (timeCurrent < trialTime) { evaluateTrialFitness(rawldrDataArray, rawirDataArray, testGeneration.collectionOfIndividuals[currentIndex].paramsCollection.chosenSensorArray); beginRun(ldrDataArray, irDataArray); } else if (timeCurrent >= trialTime) { SimpleCarController.stopMovement(); Debug.Log("DONE RUNNING INDIVIDUAL: " + currentIndex); testGeneration.collectionOfIndividuals[currentIndex].fitnessScore = finalFitnessCalculation(); int numberOfindividuals = testGeneration.numberOfIndividualsInGeneration; if (currentIndex < numberOfindividuals) { // testGeneration.collectionOfIndividuals[currentIndex].fitnessScore = finalFitnessCalculation(); SimpleCarController.stopMovement(); reset(); } else if (currentIndex >= numberOfindividuals) { if (testGeneration.generationIndex < testGeneration.numberOfGenerations) { Debug.Log("Starting next generation"); testGeneration.createNewGeneration(); currentIndex = 0; SceneManager.LoadScene("Experiment"); } else if (testGeneration.generationIndex >= testGeneration.numberOfGenerations) { Debug.Log("END OF SIMULATION REACHED, NUMBER OF GENERATIONS EVALUATED: " + testGeneration.numberOfGenerations); simulationRunning = false; } } } } else { totalIterations = 0; } firstGenerationRun = false; } } else { Debug.Log("Simulation has finished!"); } }