Esempio n. 1
0
    private void OnClickStartNewServer()
    {
        if (_playerName != null && _playerName.Length > 0)
        {
            StartNewServerEvent SNSE;
            string ipAddress = FFClient.GetLocalIP().ToString();
            SNSE.serverIpAddress = System.Net.IPAddress.Parse(ipAddress);
            SNSE.serverName      = _playerName;
            FFMessage <StartNewServerEvent> .SendToLocal(SNSE);

#if UNITY_WEBPLAYER
            // Start + Connect to local Server
            FFServer.StartServer(80, _playerName + "'s Server", true);
            FFClient.StartClient(ipAddress, 80, _playerName);
#endif

#if UNITY_STANDALONE
            // Start + Connect to local Server
            FFServer.StartServer(6532, _playerName + "'s Server", true);
            FFClient.StartClient(ipAddress, 6532, _playerName);
#endif
            ChangeLevelStateEvent CLSE;
            CLSE.newState = LevelState.In_Game;
            FFMessage <ChangeLevelStateEvent> .SendToLocal(CLSE);
        }
        else
        {
            NoticeAddPlayerName();
        }
        Debug.Log("Clicked StartNewServer"); // debug
    }
Esempio n. 2
0
    private void OnClickJoinServer()
    {
        if (_serverIPAddress != null && _playerName != null && _playerName.Length > 0)
        {
            JoinServerEvent e;
            e.serverIpAddress = _serverIPAddress;
            e.playerName      = _playerName;
            FFMessage <JoinServerEvent> .SendToLocal(e);

            FFClient.StartClient(_serverIPAddress.ToString(), 6532, _playerName);

            ChangeLevelStateEvent CLSE;
            CLSE.newState = LevelState.In_Game;
            FFMessage <ChangeLevelStateEvent> .SendToLocal(CLSE);
        }
        else
        {
            if (_serverIPAddress == null)
            {
                NoticeValidIPAddress();
            }
            if (_playerName == null)
            {
                NoticeAddPlayerName();
            }
        }

        Debug.Log("Clicked JoinServer"); // debug
    }