// Update is called once per frame
 void Update()
 {
     if (Input.GetButton("Start") || Input.GetKeyDown(KeyCode.Space))
     {
         Instantiate(startSound);
         manager.Load("MainMenu");
         gameObject.SetActive(false);
     }
 }
    // Update is called once per frame
    void Update()
    {
        bg.transform.localRotation = Quaternion.Lerp(bg.transform.localRotation, targetRotation, 0.18f);

        Vector2 stickPos;

        stickPos.x = Input.GetAxis("LeftStickX");
        stickPos.y = -Input.GetAxis("LeftStickY");

        if (stickPos.x > 0.1f && stickPos.y > stickPos.x * 0.5f)
        {
            targetRotation    = rotations[0];
            oldSelection      = currentSelection;
            currentSelection  = MenuSelection.LEVELSELECT;
            selectionSwitched = true;
        }
        else if (stickPos.x > 0.1f && stickPos.y < stickPos.x * 0.5f && stickPos.y > -stickPos.x)
        {
            targetRotation    = rotations[1];
            oldSelection      = currentSelection;
            currentSelection  = MenuSelection.OPTIONS;
            selectionSwitched = true;
        }
        else if (stickPos.y < -0.1f && stickPos.x > stickPos.y && stickPos.x < -stickPos.y)
        {
            targetRotation    = rotations[2];
            oldSelection      = currentSelection;
            currentSelection  = MenuSelection.EXIT;
            selectionSwitched = true;
        }
        else if (stickPos.x < -0.1f && stickPos.y > stickPos.x && stickPos.y < -stickPos.x * 0.5f)
        {
            targetRotation    = rotations[3];
            oldSelection      = currentSelection;
            currentSelection  = MenuSelection.CREDITS;
            selectionSwitched = true;
        }
        else if (stickPos.x < -0.1f && stickPos.y > stickPos.x * 0.5f)
        {
            targetRotation    = rotations[4];
            oldSelection      = currentSelection;
            currentSelection  = MenuSelection.DATABASE;
            selectionSwitched = true;
        }

        if (currentSelection != oldSelection && selectionSwitched == true)
        {
            Instantiate(switchSound);            //this probably works?
            selectionSwitched = false;
        }


        if (Input.GetButtonDown("A") || Input.GetKeyDown(KeyCode.Space))
        {
            //Play glossy interface 01
            Instantiate(acceptSound);
            if (currentSelection != MenuSelection.NULL)
            {
                switch (currentSelection)
                {
                case MenuSelection.LEVELSELECT:
                    manager.Load("LevelSelect");
                    gameObject.SetActive(false);
                    break;

                case MenuSelection.CREDITS:
                    Application.LoadLevel("toplel");
                    break;

                case MenuSelection.EXIT:
                    Application.Quit();
                    break;

                default:
                    break;
                }
            }
        }
        if (Input.GetButtonDown("B") || Input.GetKeyDown(KeyCode.Backspace))
        {
            Instantiate(backSound);
            manager.Load("TitleScreen");
            gameObject.SetActive(false);
        }
    }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        selectionCooldown -= Time.deltaTime;

        Vector2 stickPos;

        stickPos.x = Input.GetAxis("LeftStickX");
        stickPos.y = -Input.GetAxis("LeftStickY");

        if ((stickPos.y > 0.1f || Input.GetKey(KeyCode.W)) && selectionCooldown <= 0.0f)
        {
            Instantiate(switchSound);
            FlickUp();
            selectionCooldown = 0.2f;
        }
        if ((stickPos.y < -0.1f || Input.GetKey(KeyCode.S)) && selectionCooldown <= 0.0f)
        {
            Instantiate(switchSound);
            FlickDown();
            selectionCooldown = 0.2f;
        }

        if (Input.GetButtonDown("A") || Input.GetKeyDown(KeyCode.Space))
        {
            Instantiate(acceptSound);

            if (currentSelectedLevel == LevelSelection.NULL)
            {
                switch (hoveredOverLevel)
                {
                case LevelSelection.LEVEL1:
                    currentSelectedLevel = LevelSelection.LEVEL1;
                    break;

                case LevelSelection.LEVEL2:
                    currentSelectedLevel = LevelSelection.LEVEL2;
                    break;

                case LevelSelection.LEVEL3:
                    currentSelectedLevel = LevelSelection.LEVEL3;
                    break;

                case LevelSelection.NULL:
                    break;

                default:
                    break;
                }
                if (hoveredOverDifficulty == DifficultySelection.EASY)
                {
                    LevelBackLight.transform.localPosition = levelPanelPositions[1];
                }
                else if (hoveredOverDifficulty == DifficultySelection.MEDIUM)
                {
                    LevelBackLight.transform.localPosition = levelPanelPositions[3];
                }
                else
                {
                    LevelBackLight.transform.localPosition = levelPanelPositions[5];
                }
            }
            else if (currentSelectedLevel != LevelSelection.NULL)
            {
                switch (hoveredOverDifficulty)
                {
                case DifficultySelection.EASY:
                    currentSelectedDifficulty = DifficultySelection.EASY;
                    break;

                case DifficultySelection.MEDIUM:
                    currentSelectedDifficulty = DifficultySelection.MEDIUM;
                    break;

                case DifficultySelection.HARD:
                    currentSelectedDifficulty = DifficultySelection.HARD;
                    break;

                case DifficultySelection.NULL:
                    break;

                default:
                    break;
                }
            }

            if (currentSelectedDifficulty != DifficultySelection.NULL)
            {
                //start level with chosen attributes
                GameObject     persistentObject = (GameObject)Instantiate(levelData);
                PersistentData data             = persistentObject.GetComponent <PersistentData>();
                data.level      = currentSelectedLevel;
                data.difficulty = currentSelectedDifficulty;

                if (currentSelectedLevel == LevelSelection.LEVEL1)
                {
                    Application.LoadLevel("TestScene");
                }
                else if (currentSelectedLevel == LevelSelection.LEVEL2)
                {
                    Application.LoadLevel("Level 1");
                }
                else if (currentSelectedLevel == LevelSelection.LEVEL3)
                {
                    Application.LoadLevel("Level 2");
                }
            }
        }

        if (Input.GetButtonDown("B") || Input.GetKeyDown(KeyCode.Backspace))
        {
            Instantiate(backSound);

            if (currentSelectedLevel == LevelSelection.NULL)
            {
                manager.Load("MainMenu");
                gameObject.SetActive(false);
            }
            else
            {
                currentSelectedLevel = LevelSelection.NULL;
                if (hoveredOverLevel == LevelSelection.LEVEL1)
                {
                    LevelBackLight.transform.localPosition = levelPanelPositions[0];
                }
                else if (hoveredOverLevel == LevelSelection.LEVEL2)
                {
                    LevelBackLight.transform.localPosition = levelPanelPositions[2];
                }
                else
                {
                    LevelBackLight.transform.localPosition = levelPanelPositions[4];
                }
            }
        }
    }