Exemplo n.º 1
0
    IEnumerator StartGameSectionCoroutine()
    {
        Debug.LogWarning("Coroutine Start: Start Game Section");

        lineSpline = theStationManager.currentStation.lineToNextStation;
        CreateEvenPoints();
        theStationManager.SetupNextStation();
        SpawnPlayerTrainSet(theStationManager.currentStation, numberOfCar);
        distanceToNextStation = GetDistanceOnSpline(
            carFrontNose.transform.position + Vector3.up * currentTrainSet.noseToSplineYAxis,
            theStationManager.nextStation.stopPointOnSpline.position,
            theStationManager.currentStation.stopPointOnSpline,
            theStationManager.nextStation.stopPointOnSpline);
        thePowerControl.ResetRigidbodyPosition();
        virtualCam.Follow = firstBoogie.transform;
        virtualCam.LookAt = firstBoogie.transform;

        theUIManager.startingInfoCurrentStation.text      = theStationManager.currentStation.stationScriptableObject.stationName.ToUpper();
        theUIManager.startingInfoNextStation.text         = theStationManager.nextStation.stationScriptableObject.stationName.ToUpper();
        theUIManager.startingInfoNextStationDistance.text = (int)distanceToNextStation + "m";
        theUIManager.startingSectionInfoPanel.gameObject.SetActive(true);

        distanceToSpeedEvents          = new float[theStationManager.currentStation.upcomingSpeedEvents.Length];
        distanceRemainingToSpeedEvents = new float[theStationManager.currentStation.upcomingSpeedEvents.Length];
        if (distanceToSpeedEvents.Length != 0)
        {
            for (int i = 0; i < distanceToSpeedEvents.Length; i++)
            {
                distanceToSpeedEvents[i] = GetDistanceOnSpline(
                    carFrontNose.transform.position + Vector3.up * currentTrainSet.noseToSplineYAxis,
                    theStationManager.currentStation.upcomingSpeedEvents[i].transform.position,
                    theStationManager.currentStation.stopPointOnSpline,
                    theStationManager.currentStation.upcomingSpeedEvents[i].transform
                    );
            }
        }

        yield return(new WaitForSeconds(5f));

        theScoreManager.currentSectionScore = 0;
        theUIManager.startingSectionInfoPanel.gameObject.SetActive(false);
        theUIManager.DisplayGameplayUI(true);
        theUIManager.CurrentScoreUpdate(theScoreManager.currentScenarioScore);
        theUIManager.playerGearSlider.value = -7;

        theUIManager.DisplaySignalPanel(false);

        yield return(new WaitForSeconds(7f));

        theUIManager.DisplaySignalPanel(true);
        StartCoroutine(thePowerControl.SpeedLimitCheck());
        thePowerControl.TogglePowerLock(false);

        yield return(new WaitForSeconds(3f));

        theUIManager.signalPanel.gameObject.SetActive(false);
    }