상속: NetworkLobbyManager
예제 #1
0
 public void HandleResponse(ISFSObject anObjectIn, GameLobbyManager ourGLM)
 {
     foreach (string playerName in anObjectIn.GetUtfStringArray("PlayerNameArray"))
     {
         ourGLM.getUserInterface().alterOnlinePlayerText(playerName);
     }
 }
예제 #2
0
        public void HandleResponse(ISFSObject anObjectIn, GameLobbyManager ourGLM)
        {
            //Remove formationsPanel
            ourGLM.destroyObject("FormationsPanel");

            //Draw Halfboard
            ourGLM.getGameManager().drawHexGrid(5);
        }
예제 #3
0
    void Start()
    {		
		connectionConfig.MaxSentMessageQueueSize = 256;

        if (instance != null)
            DestroyImmediate(instance.gameObject);
        
        instance = this;
    }
        public void performClickAction(GameLobbyManager ourGLM, Button clickedButton)
        {
            string formationName = clickedButton.name.Substring(clickedButton.name.IndexOf("]") + 2);

            Debug.Log(formationName);
            ISFSObject objectOut = new SFSObject();

            objectOut.PutUtfString("FormationName", formationName);
            ourGLM.getSFServer().Send(new ExtensionRequest("GetFormation", objectOut));
        }
예제 #5
0
    void Start()
    {
        connectionConfig.MaxSentMessageQueueSize = 256;

        if (instance != null)
        {
            DestroyImmediate(instance.gameObject);
        }

        instance = this;
    }
예제 #6
0
        public UIManager(GameLobbyManager gLM)
        {
            ourGLM = gLM;

            //Setup ButtonEventHandlers
            buttonDictionary.Add((Button)GameObject.Find("FindMatchButton").GetComponent <Button>(), new FindMatchButtonHandler());
            buttonDictionary.Add((Button)GameObject.Find("EditFormationButton").GetComponent <Button>(), new EditFormationButtonHandler());
            buttonDictionary.Add((Button)GameObject.Find("EnterChatButton").GetComponent <Button>(), new EnterChatButtonHandler());

            chatTextLabel          = new List <Text>();
            onlinePlayerDictionary = new Dictionary <string, Text>();
        }
예제 #7
0
        public void performAction(GameLobbyManager ourGLM)
        {
            objectOut = new SFSObject();
            InputField chatField = GameObject.Find("EnterChatField").GetComponent <InputField>();

            string chatText = chatField.text;

            //Build and send request to Game Server
            objectOut.PutUtfString("ChatText", chatText);
            ourGLM.getSFServer().Send(new ExtensionRequest("EnterChat", objectOut));

            //Blank out ChatTextField
            chatField.text = "";
        }
예제 #8
0
        public Game()
        {
            this.HotelManager     = new HotelManager();
            this.SessionManager   = new SessionManager();
            this.GameLobbyManager = new GameLobbyManager();

            this.UpdateConsoleTitleTimer = Stopwatch.StartNew();

            this.GameCycleTimer           = new Timer();
            this.GameCycleTimer.Elapsed  += this.Cycle;
            this.GameCycleTimer.AutoReset = true;
            this.GameCycleTimer.Interval  = 8;
            this.GameCycleTimer.Start();

            GC.KeepAlive(this.GameCycleTimer); //IK timer adds itself to the gc already, but just for sure ;P
        }
예제 #9
0
        public void HandleResponse(ISFSObject anObjectIn, GameLobbyManager ourGLM)
        {
            //Create Unit GameObject and Set it's parent
            GameObject aUnit = ourGLM.createObject("Units/" + anObjectIn.GetUtfString("UnitID"));

            aUnit.transform.SetParent(GameObject.Find("Units").transform);

            //Set its position
            aUnit.transform.localPosition = ourGLM.getGameManager().getLocation(anObjectIn.GetInt("xLoc"), anObjectIn.GetInt("yLoc"));

            //Determine if it needs to be rotated
            if (anObjectIn.GetInt("yLoc") > 6)
            {
                aUnit.transform.Rotate(0, 180, 0);
            }
        }
예제 #10
0
    private void OnServerDiscovered(string address)
    {
        if (DEBUG)
        {
            Debug.Log("OnServerDiscovered");
        }
        _innerProcess.MoveNext(Command.ConnectGame);
        ensureCorrectScene();

        // stop listening for broadcasts
        if (_discoveryClient != null && _discoveryClient.running && !Flags.GAME_SERVER_IS_LOCALHOST)
        {
            _discoveryClient.serverDiscoveryEvent -= OnServerDiscovered;
            _discoveryClient.StopBroadcast();
            Destroy(_discoveryClient);
        }

        var ipv4 = address.Substring(address.LastIndexOf(":") + 1, address.Length - (address.LastIndexOf(":") + 1));

        Debug.Log(string.Format("ipv6: {0}, ipv4: {1}", address, ipv4));


        if (_networkLobbyManager == null)
        {
            _networkLobbyManager = CreateNetLobby();
        }

        if (Flags.GAME_SERVER_IS_LOCALHOST)
        {
            _networkLobbyManager.networkAddress = Network.player.ipAddress;
        }
        else
        {
            _networkLobbyManager.networkAddress = ipv4;
        }

        Debug.Log(string.Format("found server at {0}", _networkLobbyManager.networkAddress));

        ConfigNetLobby();


        // we have to delay, because apparently the teardown of discovery
        // impacts the next part. 2 seconds seems long enough...
        Invoke("DelayedConnect", 2);
    }
        public void HandleResponse(ISFSObject anObjectIn, GameLobbyManager ourGLM)
        {
            //Define variables
            GameObject formationsPanel = ourGLM.createObject("UI/FormationsPanel");

            formationsPanel.name = "FormationsPanel";
            formationsPanel.transform.SetParent(GameObject.Find("Canvas").transform);
            formationsPanel.transform.localPosition = new Vector3();

            if (anObjectIn.GetInt("NumberOfFormations") > 0)
            {
                string[] formationButtonNames = anObjectIn.GetUtfStringArray("FormationNames");
                for (int i = 0; i < formationButtonNames.Length; i++)
                {
                    Transform aFormationButton = formationsPanel.transform.FindChild("New 1v1 Formation");
                    aFormationButton.GetComponentInChildren <Text>().text = formationButtonNames[i];
                    aFormationButton.name = formationButtonNames[i];

                    //Add Button Event Listener and Button to the ButtonDictionary
                    ourGLM.getUserInterface().getButtonDictionary().Add(aFormationButton.GetComponent <Button>(), new GetFormationButtonHandler());
                    aFormationButton.GetComponent <Button>().onClick.AddListener(() => { ourGLM.buttonClicked(aFormationButton.GetComponent <Button>()); });
                }
            }
        }
예제 #12
0
        public void HandleResponse(ISFSObject anObjectIn, GameLobbyManager ourGLM)
        {
            //Define variables
            GameObject  chatBox      = GameObject.Find("ChatContent");
            List <Text> chatTextList = ourGLM.getUserInterface().getChatTextLabel();

            chatTextList.Add(ourGLM.createObject("UI/ChatText").GetComponent <Text>());
            chatBox.GetComponent <RectTransform>().sizeDelta = new Vector2(0, chatTextList.Count * 20);

            //Determine the Y-Position for the Chat Content rect to look at
            int posY;

            if (chatBox.GetComponent <RectTransform>().rect.height > 250)
            {
                posY = (int)chatBox.GetComponent <RectTransform>().rect.height - 250;
            }
            else
            {
                posY = 0;
            }

            //Update ChatContent position
            chatBox.GetComponent <RectTransform>().localPosition = new Vector2(0, posY);

            //Create new Chat Messag to display
            chatTextList.Last().name = "ChatTextLabel " + chatTextList.Count;
            chatTextList.Last().text = anObjectIn.GetUtfString("ChatText");
            chatTextList.Last().rectTransform.SetParent(chatBox.GetComponent <RectTransform>());

            //Update position of all chat messages
            for (int i = 0; i < chatTextList.Count; i++)
            {
                chatTextList[i].rectTransform.offsetMin = new Vector2(9, -25 + (chatTextList.Count - i) * 20);
                chatTextList[i].rectTransform.offsetMax = new Vector2(0, -5 + (chatTextList.Count - i) * 20);
            }
        }
예제 #13
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(gameObject);

        //Player has joined. Tell the lobbyManager so that it can spawn a lobby entity for the player.
        lobbyManager = GameObject.Find("GameLobby").GetComponent <GameLobbyManager>();
        lobbyManager.PlayerConnected(this, isLocalPlayer, isServer); //Behaviour changes for local players own lobby entity.

        PlayerID = playerID++;

        if (isHost) //To identify host in Hierachy, this conditional is only fired for clients, isHost is false for the host itself until later.
        {
            name = "HostPlayer";
        }
        if (!isLocalPlayer)
        {
            return;
        }
        if (isServer) // player object becomes TurnController for everyone;
        {
            Cmd_SetHost();
            Cmd_SpawnTurnController();
        }
    }
예제 #14
0
 public GameManager(GameLobbyManager gLM)
 {
     ourGLM = gLM;
 }
예제 #15
0
 public void performClickAction(GameLobbyManager ourGLM, Button clickedButton)
 {
     ourGLM.getSFServer().Send(new ExtensionRequest("JoinQueue", new SFSObject()));
 }
예제 #16
0
 public void performClickAction(GameLobbyManager ourGLM, Button clickedButton)
 {
     ourGLM.getPlayerActionDictionary()["EnterChat"].performAction(ourGLM);
 }
예제 #17
0
 public void HandleResponse(ISFSObject anObjectIn, GameLobbyManager ourGLM)
 {
     //Create Unit GameObject and Set it's parent
     ourGLM.getGameManager().drawHexGrid(12);
 }
 public void HandleResponse(ISFSObject anObjectIn, GameLobbyManager ourGLM)
 {
     ourGLM.getUserInterface().alterOnlinePlayerText(anObjectIn.GetUtfString("PlayerName"));
 }
    void Start()
    {
        DontDestroyOnLoad(gameObject);
        var ugly = UnityThreadHelper.Dispatcher;

        // If clients will be looking at localhost anyway, don't
        // pollute the network with broadcasts
        if (!Flags.GAME_SERVER_IS_LOCALHOST)
        {
            transform.gameObject.AddComponent <DiscoveryServer> ();
        }

        _networkLobbyManager = transform.gameObject.AddComponent <GameLobbyManager> ();

        _meshDiscoveryServer = new MeshDiscoveryServer();
        _meshTransferManager = new MeshTransferManager();

        _networkLobbyManager.logLevel     = UnityEngine.Networking.LogFilter.FilterLevel.Info;
        _networkLobbyManager.showLobbyGUI = false;
        _networkLobbyManager.minPlayers   = MIN_REQ_PLAYERS;

        // seemingly weird neccesary hack. todo: add this to our compat implementation
        _networkLobbyManager.maxPlayers     = MAX_DEVICES;
        _networkLobbyManager.maxConnections = MAX_DEVICES;
        _networkLobbyManager.lobbySlots     = new NetworkLobbyPlayer[_networkLobbyManager.maxPlayers];

        List <string> lobbyScenes = new List <string> ();

        lobbyScenes.Add("Idle");
        lobbyScenes.Add("Leaderboard");
        _networkLobbyManager.lobbyScenes = lobbyScenes;

        _networkLobbyManager.playScene = "Game";

        _networkLobbyManager.lobbyPlayerPrefab = LobbyPlayerPrefab;
        _networkLobbyManager.gamePlayerPrefab  = GamePlayerPrefab;

        _networkLobbyManager.networkPort = NetworkConstants.GAME_PORT;

        _networkLobbyManager.serverBindToIP    = true;
        _networkLobbyManager.serverBindAddress = Network.player.ipAddress;

        Debug.Log(string.Format("bound to {0}", _networkLobbyManager.serverBindAddress));


        _networkLobbyManager.customConfig = true;
        var config = _networkLobbyManager.connectionConfig;

        config.NetworkDropThreshold = 80;
        config.ConnectTimeout       = 10000;
        config.DisconnectTimeout    = 10000;
        config.PingTimeout          = 2000;
        _networkLobbyManager.channels.Add(UnityEngine.Networking.QosType.ReliableFragmented);
        _networkLobbyManager.channels.Add(UnityEngine.Networking.QosType.ReliableFragmented);

        _networkLobbyManager.StartServer();

        // register listeners for when players connect / disconnect
        _networkLobbyManager.OnLobbyServerConnectedEvent    += OnGamePlayerConnected;
        _networkLobbyManager.OnLobbyServerDisconnectedEvent += OnGamePlayerDisconnected;
        _networkLobbyManager.OnLobbyClientReadyToBeginEvent += OnGamePlayerReady;
        _networkLobbyManager.OnLobbyClientGameLoadedEvent   += OnPlayerGameLoaded;

        _meshDiscoveryServer.MeshServerDiscoveredEvent += OnMeshServerFound;

        _meshTransferManager.OnMeshDataReceivedEvent += OnMeshDataReceived;

        OnServerRequestLoadNewMesh();

        if (StartMuted)
        {
            AudioListener.volume = 0.0f;
        }
    }