Пример #1
0
    private void Awake()
    {
        dataManager = DataManager.Instance;

        SetController (dataManager.isGamepad);

        standaloneModule = GameObject.Find("EventSystem").GetComponent<KeyboardInputModule>();
    }
Пример #2
0
    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;
    }