예제 #1
0
 void LobbyActive()
 {
     StartButton.SetActive(false);
     OptionButton.SetActive(false);
     ExitButton.SetActive(false);
     hostOn.SetActive(false);
     joinOn.SetActive(false);
     TiltButton.SetActive(false);
     MuteButton.SetActive(false);
     OnOffButton.SetActive(false);
     lobbyActive = true;
 }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        playerName = PlayerPrefs.GetString("PlayerName");
        if (playerName == "")
        {
            playerName = "PlayerName";
        }
        mute = PlayerPrefs.GetInt("Mute") == 1 ? true : false;
        tilt = PlayerPrefs.GetInt("Tilt") == 1 ? true : false;
        if (tilt)
        {
            TiltButton.GetComponent <SpriteRenderer> ().sprite = tiltOn;
        }
        else
        {
            TiltButton.GetComponent <SpriteRenderer> ().sprite = tiltOff;
        }
        if (mute)
        {
            OnOffButton.GetComponent <SpriteRenderer> ().sprite = on;
            AudioListener.pause = true;
        }
        else
        {
            OnOffButton.GetComponent <SpriteRenderer> ().sprite = off;
            AudioListener.pause = false;
        }

        if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer)
        {
            TiltButton.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0.3f);
            tiltButtonEnabled = false;
        }

        hostOn.SetActive(false);
        joinOn.SetActive(false);
        NameButton.SetActive(false);
        TiltButton.SetActive(false);
        BackButton.SetActive(false);
        MuteButton.SetActive(false);
        OnOffButton.SetActive(false);

        textScale = (nameInputFieldStyle.fontSize * (Screen.width * 0.001f));
        nameInputFieldStyle.fontSize = (int)textScale;

        serverNameLabel = nameInputFieldStyle;

        InvokeRepeating("GetHostList", 0.0f, 2.0f);
    }
예제 #3
0
 public void MenuReset()
 {
     hostOn.SetActive(false);
     joinOn.SetActive(false);
     NameButton.SetActive(false);
     TiltButton.SetActive(false);
     SetBackButtonEnable(false);
     optionsClicked    = false;
     startClicked      = false;
     nameClicked       = false;
     hostClicked       = false;
     serverListIsShown = false;
     MuteButton.SetActive(false);
     OnOffButton.SetActive(false);
     gameObject.GetComponent <SplashScreen> ().Hide();
     gameObject.GetComponent <SplashScreen> ().SetText("No Text");
     if (lobbyActive)
     {
         lobbyActive = false;
     }
     StartButton.SetActive(true);
     OptionButton.SetActive(true);
     ExitButton.SetActive(true);
 }
예제 #4
0
    void Click(Vector2 position)
    {
        Ray        ray = Camera.main.ScreenPointToRay(position);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (lobbyActive == false)
            {
                if (hit.collider.gameObject.name == "StartButton")
                {
                    if (!startClicked)
                    {
                        MenuReset();
                        hostOn.SetActive(true);
                        joinOn.SetActive(true);
                        refreshServerList = true;
                        startClicked      = true;
                    }
                    else
                    {
                        MenuReset();
                    }
                }
                else if (hit.collider.gameObject.name == "ExitButton")
                {
                    Application.Quit();
                }
                else if (hit.collider.gameObject.name == "HostButton")
                {
                    SavePreferences();
                    //startserver();
                    MenuHide();
                    hostClicked = true;
                }
                else if (hit.collider.gameObject.name == "JoinButton")
                {
                    SavePreferences();
                    PresentServerList();
                }
                else if (hit.collider.gameObject.name == "OptionButton")
                {
                    if (!optionsClicked)
                    {
                        TiltButton.SetActive(true);
                        hostOn.SetActive(false);
                        joinOn.SetActive(false);
                        NameButton.SetActive(true);
                        MuteButton.SetActive(true);
                        OnOffButton.SetActive(true);
                        optionsClicked = true;
                    }
                    else
                    {
                        MenuReset();
                    }
                }
                else if (hit.collider.gameObject.name == "TiltButton" && tiltButtonEnabled)
                {
                    if (tilt)
                    {
                        TiltButton.GetComponent <SpriteRenderer> ().sprite = tiltOff;
                    }
                    else
                    {
                        TiltButton.GetComponent <SpriteRenderer> ().sprite = tiltOn;
                    }
                    tilt = !tilt;
                    SavePreferences();
                }
                else if (hit.collider.gameObject.name == "NameButton")
                {
                    nameClicked = true;
                }
                else if (hit.collider.gameObject.name == "MuteButton")
                {
                    if (!mute)
                    {
                        OnOffButton.GetComponent <SpriteRenderer> ().sprite = on;
                        AudioListener.pause = true;
                    }
                    else
                    {
                        OnOffButton.GetComponent <SpriteRenderer> ().sprite = off;
                        AudioListener.pause = false;
                    }
                    mute = !mute;
                    SavePreferences();
                }
                else if (hit.collider.gameObject.name == "On/OffButton")
                {
                    if (!mute)
                    {
                        OnOffButton.GetComponent <SpriteRenderer> ().sprite = on;
                        AudioListener.pause = true;
                    }
                    else
                    {
                        OnOffButton.GetComponent <SpriteRenderer> ().sprite = off;
                        AudioListener.pause = false;
                    }
                    mute = !mute;
                    SavePreferences();
                }
            }
        }
        if (backButtonEnabled)
        {
            if (BackButtonClicked(position) && !lobbyActive)
            {
                MenuReset();
            }
        }
    }