void Start() { if (checkpoints.Count == 0) { return; } CheckPointEvent = new CheckPointEvent(); Object[] allRacerArray = FindObjectsOfType <Object> ().Where(x => x is IRacer).ToArray(); Object[] allAgentArray = FindObjectsOfType <Object>().Where(x => x is kartAgent).ToArray(); for (int i = 0; i < allRacerArray.Length; i++) { IRacer racer = allRacerArray[i] as IRacer; m_RacerNextCheckpoints.Add(racer, checkpoints[0]); racer.DisableControl(); } for (int i = 0; i < allAgentArray.Length; i++) { var agent = allAgentArray[i] as kartAgent; if (agent != null) { CheckPointEvent.AddListener(agent.achivedCheckPoint); } } }
void Start() { if (checkpoints.Count == 0) { return; } allRacerArray = FindObjectsOfType <Object> ().Where(x => x is IRacer).ToArray(); //If playerTwo is turned off, then need to remove player two from the above array. GameObject controllerObject = GameObject.FindWithTag("MetaGameController"); controller = (UI.MetaGameController)controllerObject.GetComponent(typeof(UI.MetaGameController)); if (controller.GetTwoPlayer() == false) { RemovePlayerTwo(); } for (int i = 0; i < allRacerArray.Length; i++) { IRacer racer = allRacerArray[i] as IRacer; m_RacerNextCheckpoints.Add(racer, checkpoints[0]); racer.DisableControl(); } }
void RacerHitCorrectCheckpoint(IRacer racer, Checkpoint checkpoint) { if (checkpoint.isStartFinishLine) { int racerCurrentLap = racer.GetCurrentLap(); if (racerCurrentLap > 0) { float lapTime = racer.GetLapTime(); if (m_SessionBestLap.time > lapTime) { m_SessionBestLap.SetRecord(trackName, 1, racer, lapTime); } if (m_HistoricalBestLap.time > lapTime) { m_HistoricalBestLap.SetRecord(trackName, 1, racer, lapTime); newRecordCanvas.TempDisplay(); } if (racerCurrentLap == raceLapTotal) { float raceTime = racer.GetRaceTime(); if (m_SessionBestRace.time > raceTime) { m_SessionBestRace.SetRecord(trackName, raceLapTotal, racer, raceTime); } if (m_HistoricalBestRace.time > raceTime) { m_HistoricalBestRace.SetRecord(trackName, raceLapTotal, racer, raceTime); } racer.DisableControl(); racer.PauseTimer(); SaveManager.saveManager.Load(); // Not necessary since it was loaded on the main menu, done here as a double check SaveManager.saveManager.earnedCoins += earnedCoins; SaveManager.saveManager.Save(); gameOverCanvas.gameObject.SetActive(true); } for (int i = 0; i < coins.Length; i++) // desactivating & activating rather than deleting and respawning coins { coins[i].gameObject.SetActive(true); } } if (CanEndRace()) { StopRace(); } racer.HitStartFinishLine(); } }
void RacerHitCorrectCheckpoint(IRacer racer, Checkpoint checkpoint) { if (checkpoint.isStartFinishLine) { int racerCurrentLap = racer.GetCurrentLap(); if (racerCurrentLap > 0) { float lapTime = racer.GetLapTime(); if (m_SessionBestLap.time > lapTime) { m_SessionBestLap.SetRecord(trackName, 1, racer, lapTime); } if (m_HistoricalBestLap.time > lapTime) { m_HistoricalBestLap.SetRecord(trackName, 1, racer, lapTime); } if (racerCurrentLap == raceLapTotal) { float raceTime = racer.GetRaceTime(); if (m_SessionBestRace.time > raceTime) { m_SessionBestRace.SetRecord(trackName, raceLapTotal, racer, raceTime); } if (m_HistoricalBestRace.time > raceTime) { m_HistoricalBestLap.SetRecord(trackName, raceLapTotal, racer, raceTime); } racer.DisableControl(); racer.PauseTimer(); } } if (CanEndRace()) { StopRace(); GameObject kart = GameObject.Find("Kart"); kart.GetComponent <KartPoints>().SaveCoins(); } else { for (int i = 0; i < 6; i++) { CoinManager.transform.GetChild(i).gameObject.SetActive(true); } } racer.HitStartFinishLine(); } }
void RacerHitCorrectCheckpoint(IRacer racer, Checkpoint checkpoint) { if (checkpoint.isStartFinishLine) { int racerCurrentLap = racer.GetCurrentLap(); if (racerCurrentLap > 0) { float lapTime = racer.GetLapTime(); if (m_SessionBestLap.time > lapTime) { m_SessionBestLap.SetRecord(trackName, 1, racer, lapTime); } if (m_HistoricalBestLap.time > lapTime) { m_HistoricalBestLap.SetRecord(trackName, 1, racer, lapTime); } if (racerCurrentLap == raceLapTotal) { float raceTime = racer.GetRaceTime(); if (m_SessionBestRace.time > raceTime) { m_SessionBestRace.SetRecord(trackName, raceLapTotal, racer, raceTime); } if (m_HistoricalBestRace.time > raceTime) { m_HistoricalBestLap.SetRecord(trackName, raceLapTotal, racer, raceTime); } if (firstCarToFinish) { victoryEvent.Invoke(); firstCarToFinish = false; } NumFinished++; racer.DisableControl(); racer.PauseTimer(); } } if (CanEndRace()) { StopRace(); } racer.HitStartFinishLine(); } }
void RacerHitCorrectCheckpoint(IRacer racer, Checkpoint checkpoint) { if (checkpoint.isStartFinishLine) { int racerCurrentLap = racer.GetCurrentLap(); if (racerCurrentLap > 0) { float lapTime = racer.GetLapTime(); if (m_SessionBestLap.time > lapTime) { m_SessionBestLap.SetRecord(trackName, 1, racer, lapTime); } if (m_HistoricalBestLap.time > lapTime) { m_HistoricalBestLap.SetRecord(trackName, 1, racer, lapTime); } if (racerCurrentLap == raceLapTotal) { float raceTime = racer.GetRaceTime(); if (m_SessionBestRace.time > raceTime) { m_SessionBestRace.SetRecord(trackName, raceLapTotal, racer, raceTime); } if (m_HistoricalBestRace.time > raceTime) { m_HistoricalBestLap.SetRecord(trackName, raceLapTotal, racer, raceTime); } racer.DisableControl(); racer.PauseTimer(); } else { collectableManager.RemoveCollectables(); collectableManager.PlaceCollectables(); } } if (CanEndRace()) { StopRace(); } racer.HitStartFinishLine(); hitFirstCheckpoint = false; } }
void RacerHitCorrectCheckpoint(IRacer racer, Checkpoint checkpoint) { if (checkpoint.isStartFinishLine) { int racerCurrentLap = racer.GetCurrentLap(); if (racerCurrentLap > 0) { float lapTime = racer.GetLapTime(); if (m_SessionBestLap.time > lapTime) { m_SessionBestLap.SetRecord(trackName, 1, racer, lapTime); } if (m_HistoricalBestLap.time > lapTime) { m_HistoricalBestLap.SetRecord(trackName, 1, racer, lapTime); } RecordCanvas.SetActive(true); if (racerCurrentLap == raceLapTotal) { float raceTime = racer.GetRaceTime(); if (m_SessionBestRace.time > raceTime) { m_SessionBestRace.SetRecord(trackName, raceLapTotal, racer, raceTime); } if (m_HistoricalBestRace.time > raceTime) { m_HistoricalBestLap.SetRecord(trackName, raceLapTotal, racer, raceTime); } racer.DisableControl(); racer.PauseTimer(); } } if (CanEndRace()) { StopRace(); } if (racerCurrentLap >= 3) { GameOverPanel.SetActive(true); } //Muestro el panel de Game Over al terminar la carrera racer.HitStartFinishLine(); } }
void Start() { if (checkpoints.Count == 0) { return; } Object[] allRacerArray = FindObjectsOfType <Object> ().Where(x => x is IRacer).ToArray(); for (int i = 0; i < allRacerArray.Length; i++) { IRacer racer = allRacerArray[i] as IRacer; m_RacerNextCheckpoints.Add(racer, checkpoints[0]); racer.DisableControl(); } }
void RacerHitCorrectCheckpoint(IRacer racer, Checkpoint checkpoint) { if (checkpoint.isStartFinishLine) { int racerCurrentLap = racer.GetCurrentLap(); if (racerCurrentLap > 0) { float lapTime = racer.GetLapTime(); if (m_SessionBestLap.time > lapTime) { m_SessionBestLap.SetRecord(trackName, 1, racer, lapTime); } if (m_HistoricalBestLap.time > lapTime) { m_HistoricalBestLap.SetRecord(trackName, 1, racer, lapTime); newRecordCanvas.gameObject.SetActive(true); } if (racerCurrentLap == raceLapTotal) { float raceTime = racer.GetRaceTime(); if (m_SessionBestRace.time > raceTime) { m_SessionBestRace.SetRecord(trackName, raceLapTotal, racer, raceTime); } if (m_HistoricalBestRace.time > raceTime) { m_HistoricalBestRace.SetRecord(trackName, raceLapTotal, racer, raceTime); } racer.DisableControl(); racer.PauseTimer(); } } if (CanEndRace()) { StopRace(); } racer.HitStartFinishLine(); } }
void Start() { if (checkpoints.Count == 0) { return; } Object[] allRacerArray = FindObjectsOfType <Object> ().Where(x => x is IRacer).ToArray(); for (int i = 0; i < allRacerArray.Length; i++) { IRacer racer = allRacerArray[i] as IRacer; m_RacerNextCheckpoints.Add(racer, checkpoints[0]); racer.DisableControl(); } PlayerPrefs.SetInt("Coins", 0); //Reinicio el contador de monedas GameOverPanel.SetActive(false); //Oculto el panel de Game Over al inciar la carrera }
public void StartTrackManager() { if (checkpoints.Count == 0) { return; } Object[] allRacerArray = FindObjectsOfType <Object> ().Where(x => x is IRacer).ToArray(); for (int i = 0; i < allRacerArray.Length; i++) { IRacer racer = allRacerArray[i] as IRacer; m_RacerNextCheckpoints.Add(racer, checkpoints[0]); racer.DisableControl(); } if (collectableManager == null) { collectableManager = GameObject.Find("CollectableManager").GetComponent <CollectableManager>(); } }
void Start() { if (checkpoints.Count == 0) { return; } Object[] allRacerArray = FindObjectsOfType <Object> ().Where(x => x is IRacer).ToArray(); for (int i = 0; i < allRacerArray.Length; i++) { IRacer racer = allRacerArray[i] as IRacer; m_RacerNextCheckpoints.Add(racer, checkpoints[0]); racer.DisableControl(); } m_Input = input as IInput; m_KartMovement = kartMovement as IKartInfo; if (tema == 1) { // mru for (int i = 0; i < questions_mru.Length; i++) { randPreguntas.Add(i); } //randPreguntas.Shuffle(); } if (tema == 2) { // mruv for (int i = 0; i < questions_mruv.Length; i++) { randPreguntas.Add(i); } //randPreguntas.Shuffle(); } }
void RacerHitCorrectCheckpoint(IRacer racer, Checkpoint checkpoint) { if (checkpoint.isStartFinishLine) { int racerCurrentLap = racer.GetCurrentLap(); currentLapAnswer = racerCurrentLap; if (racerCurrentLap > 0) { float lapTime = racer.GetLapTime(); if (m_SessionBestLap.time > lapTime) { m_SessionBestLap.SetRecord(trackName, 1, racer, lapTime); } if (m_HistoricalBestLap.time > lapTime) { m_HistoricalBestLap.SetRecord(trackName, 1, racer, lapTime); } if (racerCurrentLap == raceLapTotal) { float raceTime = racer.GetRaceTime(); if (m_SessionBestRace.time > raceTime) { m_SessionBestRace.SetRecord(trackName, raceLapTotal, racer, raceTime); } if (m_HistoricalBestRace.time > raceTime) { m_HistoricalBestLap.SetRecord(trackName, raceLapTotal, racer, raceTime); } racer.DisableControl(); racer.PauseTimer(); } if (racerCurrentLap < raceLapTotal) { switch (tema) { //case 1: // loadOptionsQuestions(racerCurrentLap, questions_mru, answersOptions_mru); // break; case 2: loadOptionsQuestions(racerCurrentLap, questions_mruv, answersOptions_mruv); break; default: Debug.Log("Tema incorrecto!"); break; } } } if (CanEndRace()) { StopRace(); panelEndGame.gameObject.SetActive(true); } racer.HitStartFinishLine(); } Debug.Log("Entro ckeckpoint !"); if (checkpoint.isFinishLine) { StopRace(); panelEndGame.gameObject.SetActive(true); racer.HitStartFinishLine(); } if (!checkpoint.isStartFinishLine && !checkpoint.isFinishLine && tema == 1) { int racerCurrentLap = Random.Range(1, questions_mru.Length); Debug.Log(racerCurrentLap); currentLapAnswer = racerCurrentLap; loadOptionsQuestions(racerCurrentLap, questions_mru, answersOptions_mru); } }