Example #1
0
    public void closePassword()
    {
        GameObject scriptObject = GameObject.FindGameObjectWithTag("ScriptObject");
        MenuSetup  createUI     = (MenuSetup)scriptObject.GetComponent(typeof(MenuSetup));

        createUI.PasswordMaster.SetActive(false);
    }
Example #2
0
    public void joinGame()
    {
        GameObject networkObject = GameObject.FindGameObjectWithTag("NetworkObject");
        Networking networkScript = networkObject.GetComponent <Networking>();

        // Get room info that we stored earlier.
        string pw   = networkScript.password;
        string room = networkScript.roomName;

        // Get ui elements
        GameObject scriptObject = GameObject.FindGameObjectWithTag("ScriptObject");
        MenuSetup  createUI     = (MenuSetup)scriptObject.GetComponent(typeof(MenuSetup));

        Text       status  = createUI.PWStatus;
        InputField PWInput = createUI.PWInput;

        // Make sure they entered the correct password.
        if (PWInput.text == pw)
        {
            PhotonNetwork.JoinRoom(room);
        }
        else
        {
            status.text = "Wrong Password!";
        }
    }
Example #3
0
    public void cancelQuit()
    {
        GameObject scriptObject = GameObject.FindGameObjectWithTag("ScriptObject");
        MenuSetup  script       = (MenuSetup)scriptObject.GetComponent(typeof(MenuSetup));

        script.quitPanel.SetActive(false);
    }
Example #4
0
        static void Main(string[] args)
        {
            //Calls the Menu Function.
            MenuSetup menu = new MenuSetup();

            //Runs the menu.
            menu.mainMenu();
        }
Example #5
0
        static void Main(string[] args)
        {
            var       menu        = new Menu.Menu();
            MenuSetup menuSetuper = new MenuSetup();

            menuSetuper.Setup(menu);

            Run(menu);
        }
Example #6
0
    public void OnDisconnectedFromPhoton()
    {
        // After disconnecting from server.
        SceneManager.LoadScene("MainMenu");

        GameObject tmp  = GameObject.FindGameObjectWithTag("ScriptObject");
        MenuSetup  tmp2 = (MenuSetup)tmp.GetComponent(typeof(MenuSetup));

        tmp2.Start();
    }
Example #7
0
        public JsonResult GetChildMenu(int id)
        {
            objmenu = new LinkMenu();
            objmenu.Parent_MenuId = id;
            objmenusetups         = new MenuSetup(objmenu);

            var SerialzeMenu = JsonConvert.SerializeObject(objmenusetups.GetChildMenus());

            return(Json(new { data = SerialzeMenu }, JsonRequestBehavior.AllowGet));
        }
Example #8
0
    public void OnConnectedToPhoton()
    {
        // After connected to server.
        GameObject tmp = GameObject.FindGameObjectWithTag("ScriptObject");

        if (tmp != null)
        {
            MenuSetup tmp2 = (MenuSetup)tmp.GetComponent(typeof(MenuSetup));
            tmp2.afterConnection();
        }
    }
Example #9
0
    // Checks if we are logged in and on the main menu.
    // Useful for when players return to it from games so they don't have to re login.
    // Also used to get back fields etc.
    public void OnLevelWasLoaded(int level)
    {
        Scene scene = SceneManager.GetActiveScene();

        if (scene.name == "MainMenu")
        {
            // Get back our fields!
            GameObject script  = GameObject.FindGameObjectWithTag("ScriptObject");
            MenuSetup  scriptC = (MenuSetup)script.GetComponent(typeof(MenuSetup));
            username     = scriptC.username;
            pwd          = scriptC.pwd;
            saveUsername = scriptC.saveUsername;

            menuSetup = GameObject.FindGameObjectWithTag("ScriptObject");
        }
    }
Example #10
0
        public JsonResult GetMenus()
        {
            if (Session["RoleID"].ToString() == "1")
            {
                objmenusetups = new MenuSetup();

                var SerialzeMenu = JsonConvert.SerializeObject(objmenusetups.GetMenus());
                return(Json(new { data = SerialzeMenu }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                objmenusetups = new MenuSetup();

                var SerialzeMenu = JsonConvert.SerializeObject(objmenusetups.GetMenus());
                return(Json(SerialzeMenu, JsonRequestBehavior.AllowGet));
            }
        }
Example #11
0
    public void openCreateGame()
    {
        GameObject scriptObject = GameObject.FindGameObjectWithTag("ScriptObject");
        MenuSetup  createUI     = (MenuSetup)scriptObject.GetComponent(typeof(MenuSetup));

        if (createUI.CreateGameMaster.activeInHierarchy)
        {
            createUI.CreateGameMaster.SetActive(false);
        }
        else
        {
            createUI.CreateGameMaster.SetActive(true);

            // Set everything else false.
            createUI.FindGameMaster.SetActive(false);
        }
    }
Example #12
0
    public void hostGame()
    {
        GameObject menuSetup = GameObject.FindGameObjectWithTag("ScriptObject");


        MenuSetup  menuScript = (MenuSetup)menuSetup.GetComponent(typeof(MenuSetup));
        GameObject network    = menuScript.networkObject;

        Networking networkScript = (Networking)network.GetComponent(typeof(Networking));

        CreateItems items = (CreateItems)menuSetup.GetComponent(typeof(CreateItems));

        string name       = items.nameField.text;
        byte   players    = (byte)(8);
        int    passworded = items.Passworded.value;
        string password   = items.Password.text;

        // Check values
        if (name == "" || name.Length > 32)
        {
            // No!
            Debug.Log("Name");
        }
        else if (players < 2 || players > 16)
        {
            // No!
            Debug.Log("Players");
        }
        else if (passworded < 0 || passworded > 1)
        {
            // No!
            Debug.Log("Passworded");
        }
        else if (password == "" && passworded == 1)
        {
            // No!
            Debug.Log("Password");
        }
        else
        {
            // Name, Players, Server List, Passworded, Password
            networkScript.HostGame(name, players, true, passworded, password);
        }
    }
Example #13
0
    public void openFindGame()
    {
        GameObject scriptObject = GameObject.FindGameObjectWithTag("ScriptObject");
        MenuSetup  createUI     = (MenuSetup)scriptObject.GetComponent(typeof(MenuSetup));

        if (createUI.FindGameMaster.activeInHierarchy)
        {
            createUI.FindGameMaster.SetActive(false);
        }
        else
        {
            // Setup list?
            ServerListUIController control = createUI.FindGameMaster.GetComponent <ServerListUIController>();
            control.RefreshList();

            createUI.FindGameMaster.SetActive(true);

            // Set everything else false.
            createUI.CreateGameMaster.SetActive(false);
        }
    }
Example #14
0
    // Use this for initialization
    void Start()
    {
        loggedIn = false;

        GameObject script  = GameObject.FindGameObjectWithTag("ScriptObject");
        MenuSetup  scriptC = (MenuSetup)script.GetComponent(typeof(MenuSetup));

        username     = scriptC.username;
        pwd          = scriptC.pwd;
        saveUsername = scriptC.saveUsername;

        menuSetup = GameObject.FindGameObjectWithTag("ScriptObject");

        hash = hash + menuSetup.GetComponent <MenuSetup>().networkObject.GetComponent <Networking>().version().ToString();

        DontDestroyOnLoad(this.gameObject);

        if (FindObjectsOfType(GetType()).Length > 1)
        {
            Destroy(gameObject);
        }
    }
Example #15
0
 public CustomList <MenuSetup> GellAllMenu()
 {
     return(MenuSetup.GetAllMenuList());
 }
Example #16
0
    IEnumerator startLogin()
    {
        if (username.text == "")
        {
            MenuSetup menuScript = (MenuSetup)menuSetup.GetComponent(typeof(MenuSetup));
            menuScript.failedLogin("usernameBlank");
        }
        else if (pwd.text == "")
        {
            MenuSetup menuScript = (MenuSetup)menuSetup.GetComponent(typeof(MenuSetup));
            menuScript.failedLogin("pwdBlank");
        }
        else
        {
            WWWForm form = new WWWForm();
            form.AddField("uname", username.text);
            form.AddField("pwd", pwd.text);
            form.AddField("hash", hash);

            WWW w = new WWW(login_url, form);

            yield return(w);

            if (!string.IsNullOrEmpty(w.error))
            {
                print(w.error);
                MenuSetup menuScript = (MenuSetup)menuSetup.GetComponent(typeof(MenuSetup));
                menuScript.failedLogin("fatalError");
            }
            else
            {
                if (w.text == "LoginCorrect")
                {
                    loggedIn = true;

                    PhotonNetwork.playerName = username.text; // Set their multiplayer name.

                    // Check our current scene and execute certain code depending on our current scene.
                    Scene scene = SceneManager.GetActiveScene();
                    if (scene.name == "MainMenu")
                    {
                        MenuSetup menuScript = (MenuSetup)menuSetup.GetComponent(typeof(MenuSetup));
                        menuScript.afterLogin();
                    }

                    if (saveUsername.isOn)
                    {
                        PlayerPrefs.SetInt("NameSaved", 1);
                        PlayerPrefs.SetString("Username", username.text);
                    }
                    else
                    {
                        PlayerPrefs.SetInt("NameSaved", 0);
                        PlayerPrefs.SetString("Username", "");
                    }
                }
                else if (w.text == "LoginFailed")
                {
                    MenuSetup menuScript = (MenuSetup)menuSetup.GetComponent(typeof(MenuSetup));
                    menuScript.failedLogin("wrongInfo");
                }
                else
                {
                    print(w.text);
                    MenuSetup menuScript = (MenuSetup)menuSetup.GetComponent(typeof(MenuSetup));
                    menuScript.failedLogin("fatalError");
                }
                w.Dispose();
            }
        }
    }
Example #17
0
        public void RefreshData(RoomInfo roomInfo)
        {
            this.gameObject.SetActive(true);
            PlayerNameText.text = roomInfo.Name;

            string passworded = roomInfo.CustomProperties["P"].ToString();

            if (passworded == "1")
            {
                Locked.SetActive(true);
                Unlocked.SetActive(false);
            }
            else
            {
                Locked.SetActive(false);
                Unlocked.SetActive(true);
            }

            SlotText.text = roomInfo.PlayerCount + "/" + roomInfo.MaxPlayers;

            string currentMap = roomInfo.CustomProperties["M"].ToString();

            MapText.text = currentMap;

            string currentStatus = roomInfo.CustomProperties["S"].ToString();

            switch (currentStatus)
            {
            case "0":
                StatusText.text = "Creating";
                break;

            case "1":
                StatusText.text = "Prepearing";
                break;

            case "2":
                StatusText.text = "Playing";
                break;

            case "3":
                StatusText.text = "Ending";
                break;

            default:
                StatusText.enabled = false;
                break;
            }

            Button b = this.gameObject.GetComponent <Button>();

            if (b == null)
            {
                Debug.LogError(b + " does not have a button script!");
            }
            else
            {
                b.onClick.AddListener(
                    delegate {
                    string password = roomInfo.CustomProperties["PW"].ToString();

                    if (passworded == "1")
                    {
                        // Setup the ask password stuff.
                        GameObject networkObject = GameObject.FindGameObjectWithTag("NetworkObject");

                        if (networkObject != null)
                        {
                            // Tell our networking script to remember these as we need them later.
                            Networking networkScript = networkObject.GetComponent <Networking>();
                            networkScript.password   = password;
                            networkScript.roomName   = roomInfo.Name;

                            // Enable the input for the password.
                            GameObject scriptObject = GameObject.FindGameObjectWithTag("ScriptObject");
                            MenuSetup createUI      = (MenuSetup)scriptObject.GetComponent(typeof(MenuSetup));

                            createUI.PasswordMaster.SetActive(true);
                        }
                        else
                        {
                            Debug.LogError("Network Object is missing. (Called by ServerItem: " + b + ")");
                        }
                    }
                    else
                    {
                        PhotonNetwork.JoinRoom(roomInfo.Name);
                    }
                }
                    );
            }
        }
Example #18
0
 public CustomList <MenuSetup> GetAllMenuForSetup()
 {
     return(MenuSetup.GetAllMenu());
 }
Example #19
0
 public CustomList <MenuSetup> GetMenuType()
 {
     return(MenuSetup.GetMenuType());
 }