Esempio n. 1
0
    private void Start()
    {
        volumeFadeIn = true;
        AudioListener.volume = 0.0f;

        // Initialize values
        pauseAnimation = false;
        pause = false;
        started = false;
        settings = false;
        isDrifting = false;
        canContinue = false;
        canDrift = true;
        canShowExtra = true;
        avoiding = false;
        pressedExit = false;
        tutorial = false;
        canAdvanceTutorial = true;
        driftTutorial = false;
        driftTutorialObjective = false;
        driftTutorialDriftDone = false;
        checkingGamepad = false;
        disabledUI = false;
        totalScore = 0;
        driftScore = 0;
        maxDriftScore = 0;
        multiplier = 0;
        challengeTextState = 0;
        tutorialState = 0;
        driftTutorialState = 0;
        playerName = "";
        previousTimeScale = Time.timeScale;
        rigidbodyVelocity = Vector3.zero;
        multiplierTemp = multiplierTempInit;
        collisionTemp = collisionTempInit;
        avoidTemp = avoidTempInit;
        initPosition = new Vector3[labelsUI.Length];
        dataManager = DataManager.Instance;
        carInput = CarInput.Instance;

        // Initialize time challenge values
        leftTime = leftTimeInit;
        timePickupsCount = timePickupRoot.transform.childCount;
        currentTimePickup = 0;

        timePickups = new GameObject[timePickupsCount];

        for(int i = 0; i < timePickups.Length; i++)
        {
            timePickups[i] = timePickupRoot.transform.GetChild (i).gameObject;
        }

        for(int i = 0; i < timePickups.Length; i++)
        {
            timePickups[i].GetComponent<DriftPickup>().DisablePickupForMinimap();
        }

        timeChallengeUI.SetActive (false);

        for(int i = 0; i < freeTutorialLabels.Length; i++)
        {
            freeTutorialCameras[i].enabled = false;
            freeTutorialLabels[i].SetActive (false);
        }

        for(int i = 0; i < challengeTutorialCameras.Length; i++)
        {
            challengeTutorialCameras[i].enabled = false;
            challengeTutorialLabels[i].SetActive (false);
        }

        // Get player references
        carController = GameObject.FindWithTag ("Player").GetComponent<CarController>();
        carEngine = carController.GetComponent<CarEngine>();
        carSetup = carController.GetComponent<CarSetup>();
        carAudio = carController.GetComponent<CarAudio>();
        carRigidbody = carController.GetComponent<Rigidbody>();
        introAnimation = GetComponent<CameraIntroAnimation>();
        settingsManager = GetComponent<SettingsManager>();
        extraTweenText = extraTween.GetComponent<Text>();
        challengeLabelTween = challengeLabel.GetComponent<TweenFontSize>();
        bloomUI = GameObject.Find ("UICamera").GetComponent<Bloom>();

        if(dataManager.isGamepad)
        {
            #if !UNITY_EDITOR
            UnityEngine.Cursor.visible = false;
            UnityEngine.Cursor.lockState = CursorLockMode.Locked;
            #endif
        }
        else
        {
            #if !UNITY_EDITOR
            UnityEngine.Cursor.visible = false;
            UnityEngine.Cursor.lockState = CursorLockMode.None;
            #endif
        }

        // Load data
        maxDriftScore = dataManager.bestDrift;

        for(int i = 0; i < labelsUI.Length; i++)
        {
            labelsUI[i].color = initColor;
            auxColor = labelsUI[i].color;
            auxColor.a = initAlpha;
            labelsUI[i].color = auxColor;
            initPosition[i] = labelsUI[i].transform.position;
        }

        pauseUI.SetActive (false);
        settingsUI.SetActive (false);
        gameplayUI.SetActive (false);
        startUI.SetActive(false);
        bloomUI.enabled = false;

        carController.enabled = false;
        carEngine.enabled = false;
        carSetup.enabled = false;
        carRigidbody.isKinematic = true;
        //carRigidbody.constraints = RigidbodyConstraints.FreezeAll;

        // Disable car audio
        carAudio.EnableSources(0.5f);

        EventSystem.current.SetSelectedGameObject(null);
    }
    private void Start()
    {
        volumeFadeIn = true;
        AudioListener.volume = 0.0f;

        // Initialize values
        pauseAnimation = false;
        pause = false;
        started = false;
        client = false;
        settings = false;
        isDrifting = false;
        canContinue = false;
        canDrift = true;
        canShowExtra = true;
        avoiding = false;
        timeLabelState = 0;
        totalScore = 0;
        driftScore = 0;
        maxDriftScore = 0;
        multiplier = 0;
        rigidbodyVelocity = Vector3.zero;
        multiplierTemp = multiplierTempInit;
        collisionTemp = collisionTempInit;
        avoidTemp = avoidTempInit;
        initPosition = new Vector3[labelsUI.Length];
        dataManager = DataManager.Instance;
        carInput = CarInput.Instance;

        if(!standaloneModule)
        {
            standaloneModule = GameObject.Find ("EventSystem").GetComponent<KeyboardInputModule>();
        }

        if(dataManager.isGamepad)
        {
            standaloneModule.horizontalAxis = "Horizontal360";
            standaloneModule.verticalAxis = "Vertical360";
            standaloneModule.submitButton = "Submit360";
            standaloneModule.cancelButton = "Cancel360";

            #if !UNITY_EDITOR
            UnityEngine.Cursor.visible = false;
            UnityEngine.Cursor.lockState = CursorLockMode.Locked;
            #endif
        }
        else
        {
            standaloneModule.horizontalAxis = "Horizontal";
            standaloneModule.verticalAxis = "Vertical";
            standaloneModule.submitButton = "Submit";
            standaloneModule.cancelButton = "Cancel";

            #if !UNITY_EDITOR
            UnityEngine.Cursor.visible = false;
            UnityEngine.Cursor.lockState = CursorLockMode.None;
            #endif
        }

        if(dataManager.isGamepad)
        {
            #if !UNITY_EDITOR
            UnityEngine.Cursor.visible = false;
            UnityEngine.Cursor.lockState = CursorLockMode.Locked;
            #endif
        }
        else
        {
            #if !UNITY_EDITOR
            UnityEngine.Cursor.visible = false;
            UnityEngine.Cursor.lockState = CursorLockMode.None;
            #endif
        }

        // Load data
        maxDriftScore = dataManager.bestDrift;

        for(int i = 0; i < labelsUI.Length; i++)
        {
            labelsUI[i].color = initColor;
            auxColor = labelsUI[i].color;
            auxColor.a = initAlpha;
            labelsUI[i].color = auxColor;
            initPosition[i] = labelsUI[i].transform.position;
        }

        network = GetComponent<CustomNetworkManager>();
        introAnimation = GetComponent<CameraIntroAnimation>();
        settingsManager = GetComponent<SettingsManager>();
        extraTweenText = extraTween.GetComponent<Text>();
        challengeLabelTween = challengeLabel.GetComponent<TweenFontSize>();
        bloomUI = GameObject.Find ("UICamera").GetComponent<Bloom>();

        pauseUI.SetActive (false);
        settingsUI.SetActive (false);
        gameplayUI.SetActive (false);
        startUI.SetActive(false);
        bloomUI.enabled = false;

        EventSystem.current.SetSelectedGameObject(null);

        // Enable match maker by default
        network.StartMatchMaker();
        network.matchMaker.SetProgramAppID((UnityEngine.Networking.Types.AppID)338802);
        network.SetMatchHost("mm.unet.unity3d.com", 443, true);
        network.matchSize = 5;
        network.matchName = adressField.text;
    }