Exemplo n.º 1
0
    void OnGUI()
    {
        // You would normally not join a match you created yourself but this is possible here for demonstration purposes.
        if(GUILayout.Button("Create Room"))
        {
            CreateMatchRequest create = new CreateMatchRequest();
            create.name = "NewRoom";
            create.size = 4;
            create.advertise = true;
            create.password = "";

            networkMatch.CreateMatch(create, OnMatchCreate);
        }

        if (GUILayout.Button("List rooms"))
        {
            networkMatch.ListMatches(0, 20, "", OnMatchList);
        }

        if (matchList.Count > 0)
        {
            GUILayout.Label("Current rooms");
        }
        foreach (var match in matchList)
        {
            if (GUILayout.Button(match.name))
            {
                networkMatch.JoinMatch(match.networkId, "", OnMatchJoined);
            }
        }
    }
Exemplo n.º 2
0
 public void createMatch()
 {
     create = new CreateMatchRequest();
     create.name = nameText.text;
     create.size = uint.Parse(sizeText.text);
     create.advertise = publicText.Equals("Yes");
     create.password = "";
     networkMatch.CreateMatch(create, OnMatchCreate);
 }
Exemplo n.º 3
0
    public void CreateRoom()
    {
        CreateMatchRequest create = new CreateMatchRequest();
        create.name = UsernameStore.username + "'s Room";
        create.size = 4;
        create.advertise = true;
        create.password = "";

        networkMatch.CreateMatch(create, OnMatchCreate);
    }
Exemplo n.º 4
0
    //call this method to request a match to be created on the server
    public void CreateInternetMatch(string matchName)
    {
        CreateMatchRequest create = new CreateMatchRequest();
        create.name = matchName;
        create.size = 32;
        create.advertise = true;
        create.password = "";

        NetworkManager.singleton.matchMaker.CreateMatch(create, OnInternetMatchCreate);
    }
Exemplo n.º 5
0
    public void Host()
    {
        CreateMatchRequest matchRequest = new CreateMatchRequest();
        matchRequest.name = "Test";
        matchRequest.size = 4;
        matchRequest.advertise = true;
        matchRequest.password = "";

        m_match.CreateMatch(matchRequest, OnMatchCreate);
    }
Exemplo n.º 6
0
    public void CreateMatch(string gameName)
    {
        var request = new CreateMatchRequest () {
            name = gameName,
            size = 10,
            advertise = true,
            password = ""
        };

        networkMatch.CreateMatch (request, TestMatchCreateResponse);
    }
Exemplo n.º 7
0
    public void hostRoom()
    {
        joinButton.gameObject.SetActive(false);
        hostButton.gameObject.SetActive(false);
        CreateMatchRequest createRequest = new CreateMatchRequest();
        createRequest.name = "Room";
        createRequest.size = 4;
        createRequest.advertise = true;
        createRequest.password = "";

        CreateMatch(createRequest, onMatchCreate);
    }
Exemplo n.º 8
0
    void Awake()
    {
        networkMatch = gameObject.AddComponent<NetworkMatch>();

        //immediately make a room
        CreateMatchRequest create = new CreateMatchRequest();
        create.name = "NewRoom";
        create.size = 4;
        create.advertise = true;
        create.password = "";

        networkMatch.CreateMatch(create, OnMatchCreate);
    }
Exemplo n.º 9
0
	public void CreateMatch() {
		CreateMatchRequest create = new CreateMatchRequest();
		create.name = "Room " + uuid;
		create.size = 2;
		create.advertise = true;
		create.password = "";

		matchName = create.name;

		uuid++;

		networkMatch.CreateMatch(create, OnMatchCreate);
	}
Exemplo n.º 10
0
    public void CreateInternetMatch(string matchName)
    {
        startMatchMaking();
        //manager.matchMaker.CreateMatch(manager.matchName, manager.matchSize, true, "", manager.OnMatchCreate);
        CreateMatchRequest create = new CreateMatchRequest();
        create.name = matchName;
        create.size = 2;
        create.advertise = true;
        create.password = "";

        //NetworkManager.singleton.matchMaker.CreateMatch(create, OnInternetMatchCreate);
        NetworkManager.singleton.matchMaker.CreateMatch(create, NetworkManager.singleton.OnMatchCreate);
    }
Exemplo n.º 11
0
    public void PressCreate()
    {
        if (!canPress) {
            return;
        }
        canPress = false;

        CreateMatchRequest create = new CreateMatchRequest();
        create.name = "TheRoom" + Mathf.RoundToInt(100f * Random.value);
        create.size = 2;
        create.advertise = true;
        create.password = "";

        netMatch.CreateMatch(create, OnMatchCreate);
    }
Exemplo n.º 12
0
		// Click to create a match name
        public void OnClickCreateMatchmakingGame() {
			lobbyManager.StartMatchMaker ();
			CreateMatchRequest newMatch = new CreateMatchRequest ();
			newMatch.name = matchNameInput.text + " "+matchMode.value.ToString();
			newMatch.size = (uint)lobbyManager.maxPlayers;
			newMatch.advertise = true;
			newMatch.password = "";
			lobbyManager.matchMaker.CreateMatch (
				newMatch,
				lobbyManager.OnMatchCreate);

			lobbyManager.backDelegate = lobbyManager.StopHost;
			lobbyManager.isMatchmaking = true;
			lobbyManager.DisplayIsConnecting ();
			lobbyManager.currentMatchValue = matchMode.value;

			lobbyManager.SetServerInfo ("Matchmaker Host", lobbyManager.matchHost);
		}
Exemplo n.º 13
0
 void OnGUI()
 {
     if (GUI.Button (new Rect (250, 20, 200, 20), "Create Room")) {
         //CreateMatchRequest: UNETにマッチメイキングを作らせるためのJSONオブジェクト
         CreateMatchRequest create = new CreateMatchRequest ();
         //部屋名
         create.name = "NewRoom";
         //人数
         create.size = 4;
         //部屋ができたことを知らせるか?
         create.advertise = true;
         //パスワード
         create.password = "";
         networkMatch = manager.matchMaker;
         //CreateMatch: create情報を持って、部屋を作ろうとしている
         //情報を元に部屋を作り、ホストとして実行
         networkMatch.CreateMatch(create, NetworkManager.singleton.OnMatchCreate);
     }
 }
Exemplo n.º 14
0
        public Coroutine CreateMatch(string matchName, uint matchSize, bool matchAdvertise, string matchPassword, string publicClientAddress, string privateClientAddress, int eloScoreForMatch, int requestDomain, DataResponseDelegate <MatchInfo> callback)
        {
            if (Application.platform == RuntimePlatform.WebGLPlayer)
            {
                UnityEngine.Debug.LogError("Matchmaking is not supported on WebGL player.");
                return(null);
            }
            CreateMatchRequest req = new CreateMatchRequest {
                name           = matchName,
                size           = matchSize,
                advertise      = matchAdvertise,
                password       = matchPassword,
                publicAddress  = publicClientAddress,
                privateAddress = privateClientAddress,
                eloScore       = eloScoreForMatch,
                domain         = requestDomain
            };

            return(this.CreateMatch(req, callback));
        }
Exemplo n.º 15
0
    //    private void SpawnPlayer(NetworkConnection conn) // spawn a new player for the desired connection
    //    {
    //        GameObject playerObj = GameObject.Instantiate(_playerPrefab); // instantiate on server side
    //        NetworkServer.AddPlayerForConnection(conn, playerObj, 0); // spawn on the clients and set owner
    //    }
    public void Init()
    {
        Debug.Log("Create host..");

        if (!_lobby._localTest)
        {
            CreateMatchRequest create = new CreateMatchRequest();
            create.name = "Mixarine";
            create.size = 4;
            create.advertise = true;
            create.password = "";

            _lobby.matchMaker.CreateMatch(create, OnMatchCreate);
        }
        else{
            NetworkManager.singleton.StartServer();
        }

        StartCoroutine(WaitServerForStart());
    }
Exemplo n.º 16
0
        public Coroutine CreateMatch(CreateMatchRequest req, NetworkMatch.ResponseDelegate <CreateMatchResponse> callback)
        {
            Uri uri = new Uri(this.baseUri, "/json/reply/CreateMatchRequest");

            Debug.Log("MatchMakingClient Create :" + uri);
            WWWForm wWWForm = new WWWForm();

            wWWForm.AddField("projectId", Application.cloudProjectId);
            wWWForm.AddField("sourceId", Utility.GetSourceID().ToString());
            wWWForm.AddField("appId", Utility.GetAppID().ToString());
            wWWForm.AddField("accessTokenString", 0);
            wWWForm.AddField("domain", 0);
            wWWForm.AddField("name", req.name);
            wWWForm.AddField("size", req.size.ToString());
            wWWForm.AddField("advertise", req.advertise.ToString());
            wWWForm.AddField("password", req.password);
            wWWForm.headers["Accept"] = "application/json";
            WWW client = new WWW(uri.ToString(), wWWForm);

            return(base.StartCoroutine(this.ProcessMatchResponse <CreateMatchResponse>(client, callback)));
        }
Exemplo n.º 17
0
    public void OnMatchList(ListMatchResponse matchListResponse)
    {
        if (matchListResponse.success && matchListResponse.matches != null)
        {
            if (matchListResponse.matches.Count == 0) {
                CreateMatchRequest create = new CreateMatchRequest();
                create.name = "Room" + UnityEngine.Random.Range(0, 1000);
                create.size = 2;
                create.advertise = true;
                create.password = "";

                Debug.Log("creating room " + create.name);

                networkMatch.CreateMatch(create, nm.OnMatchCreate);
            } else {
                foreach (var match in matchListResponse.matches)
                {
                    Debug.Log (match.name + ";" + match.networkId);
                }

                networkMatch.JoinMatch(matchListResponse.matches[0].networkId, "", nm.OnMatchJoined);
            }
        }
    }
Exemplo n.º 18
0
        public override void OnGUI()
        {
            if (this.listingMatches == false && (Time.time - this.lastMatchListingTime) > 5)
            {
                this.UpdateMatchList();
            }

            if (this.matches != null)
            {
                if (this.matches.Count == 0)
                {
                    GUILayout.Label("No games currently hosted, you should create one!");
                }
                else
                {
                    foreach (MatchDesc match in this.matches)
                    {
                        GUILayout.Label(match.name);
                        if (GUILayout.Button("Join"))
                        {
                            WaitForJoinGameState waitForJoinGameState = new WaitForJoinGameState(this.networkManager, this.networkMatch);
                            this.networkMatch.JoinMatch(match.networkId, "", waitForJoinGameState.OnJoinMatch);
                            this.nextState = waitForJoinGameState;
                        }
                    }
                }
            }
            GUILayout.Label(this.errorMessage);

            int maxLength = 32;
            this.gameName = GUILayout.TextField(this.gameName, maxLength);
            if(GUILayout.Button("Create Game"))
            {
                CreateMatchRequest createMatchRequest = new CreateMatchRequest();
                createMatchRequest.name = this.gameName;
                createMatchRequest.size = 3;
                createMatchRequest.advertise = true;
                createMatchRequest.password = "";

                WaitForCreateGameState waitForCreateGameState = new WaitForCreateGameState(this.networkManager, this.networkMatch);
                this.networkMatch.CreateMatch(createMatchRequest, waitForCreateGameState.OnCreateMatch);
                this.nextState = waitForCreateGameState;
            }
        }
    //--------------------------------------------------
    //    Server Code
    //--------------------------------------------------
    public void startServer()
    {
        if (gameCode.Equals("")) {
            Debug.LogError("Error: gameCode has not been set");
            return;
        }
        Debug.Log("Creating match under name: " + gameCode);

        //	Create the matchmaker request
        CreateMatchRequest create = new CreateMatchRequest();
        create.name = gameCode;
        create.size = 2;
        create.advertise = true;
        create.password = "";

        networkMatch.CreateMatch(create, NetworkManager.singleton.OnMatchCreate);
    }
Exemplo n.º 20
0
    public void BeginHosting()
    {
        CreateMatchRequest create = new CreateMatchRequest();
        create.name = SystemInfo.deviceName;
        create.size = 2;
        create.advertise = true;
        create.password = "";

        networkMatch.CreateMatch(create, OnMatchCreate);
        hostLabel.text = "Creating room";
    }
Exemplo n.º 21
0
    /// <summary>
    /// 点击创建房间按钮后,根据之前填写的表单创建房间
    /// </summary>
    public void UIConfirmCreateMatch( )
    {
        if (matchMaker == null)
            StartMatchMaker();

        CreateMatchRequest creating = new CreateMatchRequest();
        creating.name = m_matchNameIF.text.Equals(string.Empty) ? "default" : m_matchNameIF.text;
        m_playerName = m_playerNameIF.text;
        creating.password = /*m_matchPswdIF.text*/"";
        creating.size = m_roomSize;
        //creating.advertise = m_publicToggle;
        creating.advertise = true;
        matchMaker.CreateMatch(creating, _OnCreateMatch);
        StartCoroutine(_Waiting("CREATING"));
    }
Exemplo n.º 22
0
    public void HostGame(string name, string password)
    {
        world = new World();
        info = new World.Info
        {
            version = version,
            lastPlayed = System.DateTime.Now,
            name = name,
            root = string.Format("{0}-{1}", name, System.DateTime.Now.Ticks),
        };

        for (int i = 0; i < 1024; ++i) world.tilemap[i] = (byte) Random.Range(0, 23);
        for (int i = 0; i < 256; ++i)
        {
            if (Random.value > 0.5f) world.walls.Add((byte)i);
        }

        world.tileset.SetPixels32(testtex.GetPixels32());
        world.RandomisePalette();
        world.PalettiseTexture(world.tileset);

        SetWorld(world);

        var create = new CreateMatchRequest();
        create.name = name;
        create.size = 8;
        create.advertise = true;
        create.password = password;

        create.name += "!" + (int)version + "?0";

        testLAN.broadcastData = create.name;
        match.CreateMatch(create, OnMatchCreate);
        testLAN.StopBroadcast();
        testLAN.StartAsServer();
    }
Exemplo n.º 23
0
 // Use this for initialization
 void Start()
 {
     viewPort = transform.FindChild ("Lobbies").gameObject.transform.FindChild ("Viewport").gameObject;
     request = new UnityEngine.Networking.Match.CreateMatchRequest ();
 }
Exemplo n.º 24
0
        void CreateNewRoom(string aName, CreateMatchRequest aOptions)
        {
            List<MatchDesc> rooms = BombersNetworkManager.singleton.matches;
            bool roomExists = false;
            string roomName = aName;

            if (aName == "")
            {
                roomName = GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_playerName + "'s Room";
            }

            if (rooms != null)
            {


                for (int i = 0; i < rooms.Count; i++)
                {
                    if (rooms[i].name == aName)
                    {
                        roomExists = true;
                    }
                }
            }
            if (roomExists)
            {
                GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("There's already a room named " + aName + "!");
                return;
            }

            int playerLevel = GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().GetStats()[0].m_statValue;

            if (m_roomLevelRangeMin < 0)
            {
                m_roomLevelRangeMin = 0;
            }
            else if (m_roomLevelRangeMin > playerLevel)
            {
                m_roomLevelRangeMin = playerLevel;
            }

            if (m_roomLevelRangeMax > 50)
            {
                m_roomLevelRangeMax = 50;
            }

            if (m_roomLevelRangeMax < m_roomLevelRangeMin)
            {
                m_roomLevelRangeMax = m_roomLevelRangeMin;
            }

            if (aOptions.size > 8)
            {
                aOptions.size = 8;
            }
            else if (aOptions.size < 2)
            {
                aOptions.size = 2;
            }

            GameObject.Find("Version Text").transform.SetParent(null);
            GameObject.Find("FullScreen").transform.SetParent(null);

            CreateMatchRequest options = new CreateMatchRequest();
            options.name = aName;
            options.size = aOptions.size;
            options.advertise = true;
            options.password = "";
            options.matchAttributes = new Dictionary<string, long>();
            options.matchAttributes.Add("minLevel", m_roomLevelRangeMin);
            options.matchAttributes.Add("maxLevel", m_roomLevelRangeMax);
            options.matchAttributes.Add("StartGameTime", 600);
            options.matchAttributes.Add("IsPlaying", 0);
            options.matchAttributes.Add("MapLayout", m_presetListSelection);
            options.matchAttributes.Add("MapSize", m_sizeListSelection);
            BrainCloudWrapper.GetBC().EntityService.UpdateSingleton("gameName", "{\"gameName\": \"" + roomName + "\"}", null, -1, null, null, null);
            GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().ReadStatistics();
            m_state = eMatchmakingState.GAME_STATE_CREATE_NEW_ROOM;
            Dictionary<string, string> matchOptions = new Dictionary<string, string>();
            matchOptions.Add("gameTime", 600.ToString());
            matchOptions.Add("isPlaying", 0.ToString());
            matchOptions.Add("mapLayout", m_presetListSelection.ToString());
            matchOptions.Add("mapSize", m_sizeListSelection.ToString());
            matchOptions.Add("gameName", roomName);
            matchOptions.Add("maxPlayers", aOptions.size.ToString());
            matchOptions.Add("lightPosition", 0.ToString());

            BombersNetworkManager.m_matchOptions = matchOptions;
            BombersNetworkManager.singleton.matchMaker.CreateMatch(options, OnMatchCreate);
        }
Exemplo n.º 25
0
        public void ConfirmCreateGame()
        {
            CloseDropDowns();

            m_roomMaxPlayers = int.Parse(m_createGameWindow.transform.FindChild("Max Players").GetComponent<InputField>().text.ToString());
            m_roomLevelRangeMax = int.Parse(m_createGameWindow.transform.FindChild("Box 2").GetComponent<InputField>().text.ToString());
            m_roomLevelRangeMin = int.Parse(m_createGameWindow.transform.FindChild("Box 1").GetComponent<InputField>().text.ToString());

            CreateMatchRequest options = new CreateMatchRequest();
            options.size = (uint)m_roomMaxPlayers;
            options.advertise = true;
            options.password = "";
            options.matchAttributes = new Dictionary<string, long>() { { "minLevel", m_roomLevelRangeMin }, { "maxLevel", m_roomLevelRangeMax } };

            CreateNewRoom(m_createGameWindow.transform.FindChild("Room Name").GetComponent<InputField>().text, options);
        }
Exemplo n.º 26
0
    public void HostGame(World.Info world,
                         string name,
                         string password)
    {
        this.world = LoadWorld(world.root);
        info = world;

        SetWorld(this.world);

        var create = new CreateMatchRequest();
        create.name = name;
        create.size = 8;
        create.advertise = true;
        create.password = password;


        hostedname = create.name;

        create.name += "!" + (int)version + "?0";

        match.CreateMatch(create, OnMatchCreate);

        testLAN.broadcastData = create.name;
        testLAN.Initialize();
        testLAN.StopBroadcast();
        testLAN.StartAsServer();
    }
Exemplo n.º 27
0
	public void OnClickCreateGame() {
		Debug.Log ("OnClickCreateGame()");
		var req = new CreateMatchRequest();
		req.name = onlineHostGameNameInput.text;
		req.size = G.NUM_PLAYERS;
		req.advertise = onlineHostGamePublicToggle.isOn;
		req.password = onlineHostGamePasswordInput.text;
		match.CreateMatch(req, this.OnMatchCreate);
		isMatchCreator = true;
		switchState (State.LOBBY);
	}
Exemplo n.º 28
0
 // Use this for initialization
 void Start()
 {
     viewPort = transform.FindChild ("Lobbies").gameObject.transform.FindChild ("Viewport").gameObject;
     request = new UnityEngine.Networking.Match.CreateMatchRequest ();
     if (SelectedMatch == null)
       gameObject.transform.FindChild ("ButtonPanel").gameObject.transform.FindChild ("Join").GetComponent<Button> ().interactable = false;
 }
Exemplo n.º 29
0
    private void OnClickCreateMatchmakingGame()
    {
        m_LobbyManager.StartMatchMaker();

        NetworkMatch match = m_LobbyManager.matchMaker;

        if (match == null)
        {
            Debug.LogError("m_LobbyManager.matchMaker == null");
            return;
        }

        var matchName = m_RoonField.text;
        var matchSize = 3u;
        var matchAdvertise = true;
        var matchPassword = string.Empty;

        var request = new CreateMatchRequest();
        request.name = matchName;
        request.size = matchSize;
        request.advertise = matchAdvertise;
        request.password = matchPassword;

        match.CreateMatch(request, m_LobbyManager.OnMatchCreate);
        //match.CreateMatch(matchName, matchSize, matchAdvertise, matchPassword, m_LobbyManager.OnMatchCreate);

        m_LobbyManager.isMatchmaking = true;

        DisplayIsConnecting();

        backDelegate = m_LobbyManager.StopHost;

        SetServerInfo("Matchmaker Host", m_LobbyManager.matchHost);
    }