// Use this for initialization void Start() { FINISH_LINE_LAYER = LayerMask.NameToLayer("FinishLine"); _trackController = FindObjectOfType <RaceTrackController>(); _trackController.onLapFinished = OnLapFinished; _trackController.onRaceFinished = OnRaceFinished; RetainedUserPicksScript userPicksScript = RetainedUserPicksScript.Instance; _multiplayerGame = userPicksScript.multiplayerGame; if (!_multiplayerGame) { SetupSinglePlayerGame(); } else { SetupMultiplayerGame(); } }
void SetupSinglePlayerGame() { RetainedUserPicksScript userPicksScript = RetainedUserPicksScript.Instance; // Can we get the car number from the previous menu? CarController car = myCar.GetComponent <CarController>(); car.SetCarChoice(userPicksScript.carSelected, false); car.id = _myParticipantId; // Set our time left and laps remaining _timeLeft = startTimesPerLevel[userPicksScript.diffSelected]; _lapsRemaining = lapsPerLevel[userPicksScript.diffSelected]; guiObject.SetTime(_timeLeft); guiObject.SetLaps(_lapsRemaining); _trackController.targetLaps = _lapsRemaining; car.SpawnAtStart(0); for (int i = 0; i < numOpponents; ++i) { GameObject c = GameObject.Instantiate(opponentPrefab); VehicleBase v = c.GetComponent <VehicleBase>(); v.Setup(); v.SetCarChoice(0, false); v.SpawnAtStart(i + 1); } VehicleBase[] cars = FindObjectsOfType <VehicleBase>(); _vehicles = new List <VehicleBase>(cars.Length); for (int i = 0; i < cars.Length; ++i) { _vehicles.Add(cars[i]); } // Rules are created with the expectation that top will execute first, but data works better to remove from the end rules.Reverse(); AdvanceToNextRule(); }
// Use this for initialization void Start() { RetainedUserPicksScript userPicksScript = RetainedUserPicksScript.Instance; _multiplayerGame = userPicksScript.multiplayerGame; if (!_multiplayerGame) { // Can we get the car number from the previous menu? myCar.GetComponent <CarController>().SetCarChoice(userPicksScript.carSelected, false); // Set the background background.GetComponent <SpriteRenderer>().sprite = backgroundSprites[userPicksScript.diffSelected - 1]; // Set our time left and laps remaining _timeLeft = startTimesPerLevel[userPicksScript.diffSelected - 1]; _lapsRemaining = lapsPerLevel[userPicksScript.diffSelected - 1]; guiObject.SetTime(_timeLeft); guiObject.SetLaps(_lapsRemaining); } else { SetupMultiplayerGame(); } }