void Start()
    {
        controllerLayout = GameObject.Find("ControllerLayout").GetComponent <ControllerLayout>();
        ///info_A = GameObject.Find("ControlsMenu_UI/ControlsMenu_Canvas/Info_Text_A");
        ///info_B = GameObject.Find("ControlsMenu_UI/ControlsMenu_Canvas/Info_Text_B");

        ChangeControllersInfo();
    }
Esempio n. 2
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);

        selectedInstruments = new int[4];
    }
Esempio n. 3
0
    /*private void PrintFrameRate()
     * {
     *      float temp = 1.0f/Time.deltaTime;
     *      if(temp < 90 && temp != 50)
     *              Debug.Log(Time.time + ": Frame Rate below 90, its " + temp);
     * }*/

    //  INIT LEVEL
    private void InitLevel()
    {
        // Components
        controllerLayout = GameObject.Find("ControllerLayout").GetComponent <ControllerLayout>();
        player           = GameObject.Find("VRCameraRig").GetComponent <Player>();
        controllerInput  = player.gameObject.GetComponent <ControllerInput>();
        L_controller_GO  = GameObject.Find("VRCameraRig/OVRCameraRig/TrackingSpace/LeftHandAnchor");
        R_controller_GO  = GameObject.Find("VRCameraRig/OVRCameraRig/TrackingSpace/RightHandAnchor");
        L_mask           = GameObject.Find("VRCameraRig/OVRCameraRig/TrackingSpace/LeftEyeAnchor/Mask");
        R_mask           = GameObject.Find("VRCameraRig/OVRCameraRig/TrackingSpace/RightEyeAnchor/Mask");

        /*L_controller_GO = GameObject.Find("Player/TrackingSpace/LeftHandAnchor");
         * R_controller_GO = GameObject.Find("Player/TrackingSpace/RightHandAnchor");
         * L_mask = GameObject.Find("Player/TrackingSpace/LeftEyeAnchor/Mask");
         * R_mask = GameObject.Find("Player/TrackingSpace/RightEyeAnchor/Mask");*/
        L_maskRend = L_mask.GetComponent <Renderer>();
        R_maskRend = R_mask.GetComponent <Renderer>();
        GameObject temp2 = GameObject.Find("ControlsMenu_UI");

        if (temp2 != null)
        {
            controllerInfo = temp2.GetComponent <ControlsMenu>();
        }
        playerSpeaker = GameObject.Find("VRCameraRig/OVRCameraRig/TrackingSpace/CenterEyeAnchor").GetComponent <AudioSource>();
        ///playerSpeaker = GameObject.Find("Player/TrackingSpace/CenterEyeAnchor").GetComponent<AudioSource>();

        L_haptics = L_controller_GO.GetComponent <OculusHaptics>();
        R_haptics = R_controller_GO.GetComponent <OculusHaptics>();

        GameObject[] temp = GameObject.FindGameObjectsWithTag("Button");
        button = new VRButton[temp.Length];
        for (int i = 0; i < button.Length; i++)
        {
            button[i] = temp[i].GetComponent <VRButton>();            // Stores all objeccts which are buttons
        }
        message_GO = GameObject.Find("VRCameraRig/OVRCameraRig/TrackingSpace/CenterEyeAnchor/Message_UI");
        ///message_GO = GameObject.Find("Player/TrackingSpace/CenterEyeAnchor/Message_UI");
        message_Text = message_GO.GetComponentInChildren <Text>();
        message_GO.transform.LookAt(centerCamTransform);

        // Controller Layout
        if (controllerLayout.layout == ControllerLayout.layoutEnum.reversed)
        {
            SwitchControllers();             // if controllers are reveresed previously, then switch now.
        }
        // Player
        player.Init();
        for (int i = 0; i < objSpawner.Length; i++)
        {
            objSpawner[i].Init();
        }
        controllerInput.Init();

        // Scene Transition
        InitSceneTransition(SceneTransition.starting);
        ResetAllButtons();

        if (currentLevel != 0)          // all except main menu level - level 0
        {
            ball = GameObject.Find("Ball").GetComponent <Ball>();

            centerCamTransform = GameObject.Find("VRCameraRig/OVRCameraRig/TrackingSpace/CenterEyeAnchor").transform;
            ///centerCamTransform = GameObject.Find("Player/TrackingSpace/CenterEyeAnchor").transform;


            /*gameOverMenu_GO = GameObject.Find("GameOverMenu_Pivot");
             * levelFinished_text
             *      = GameObject.Find("GameOverMenu_UI/GameOverMenu_Canvas/Heading_Text").GetComponent<Text>();
             * nextLevelText_GO = GameObject.Find("GameOverMenu_UI/GameOverMenu_Canvas/NextLevel_Text");
             * gameOverText_GO  = GameObject.Find("GameOverMenu_UI/GameOverMenu_Canvas/GameOver_Text");
             * levelFinished_text.text = "Level " + currentLevel + " - Finished!";
             * nextLevelText_GO.SetActive(true);
             * gameOverMenu_GO.SetActive(false);*/

            star = GameObject.FindGameObjectsWithTag("Star");
            AllStars_SetActive(true);

            starsCollected = 0;
            ///levelFinished = false;
            isGameStarted = false;
        }
    }
Esempio n. 4
0
    void Initialize()
    {
        score = new float[4];
        mult  = new float [4];
        for (int i = 0; i < 4; i++)
        {
            score[i] = 0;
            mult[i]  = 1;
        }
        cl = ControllerLayout.instance;
        int[] instruments = cl.selectedInstruments;
        if (cl.currentLayout == 0)
        {
            for (int i = 0; i < 4; i++)
            {
                switch (instruments[i])
                {
                case 0:
                    Destroy(notes[i].gameObject);
                    break;

                case 1:
                    notes[i].GetComponent <InputBehaviour>().buttonCode = KeyCode.Q;
                    break;

                case 2:
                    notes[i].GetComponent <InputBehaviour>().buttonCode = KeyCode.Space;
                    break;

                case 3:
                    notes[i].GetComponent <InputBehaviour>().buttonCode = KeyCode.P;
                    break;

                case 4:
                    notes[i].GetComponent <InputBehaviour>().buttonCode = KeyCode.KeypadEnter;
                    break;

                default:
                    break;
                }
            }
        }

        /*else{
         *  for(int i = 0; i < 4; i++){
         *      switch (instruments[i])
         *      {
         *          case 0:
         *              //disable
         *              break;
         *          case 1:
         *              notes[i].GetComponent<InputBehaviour>().buttonCode = KeyCode.;
         *              break;
         *          case 2:
         *              notes[i].GetComponent<InputBehaviour>().buttonCode = KeyCode.;
         *              break;
         *          case 3:
         *              notes[i].GetComponent<InputBehaviour>().buttonCode = KeyCode.;
         *              break;
         *          case 4:
         *              notes[i].GetComponent<InputBehaviour>().buttonCode = KeyCode.;
         *              break;
         *          default:
         *              break;
         *      }
         *  }
         * }*/

        Destroy(cl.gameObject);
    }