Example #1
0
        public override void Connected(BoltConnection connection)
        {
            if (BoltNetwork.IsClient)
            {
                BoltConsole.Write("Connected Client: " + connection, Color.blue);
                infoPanel.gameObject.SetActive(false);
                string prevMatch = PreviousMatchName();
                BoltConsole.Write("Previous match if any: " + prevMatch);

                if (prevMatch != matchName)
                {
                    BoltConsole.Write("New Game");
                    ChangeTo(lobbyPanel);
                }
                else
                {
                    BoltConsole.Write("Joining previous match");
                    var returnPlayerEvnt = ReturnPlayerEvent.Create(Bolt.GlobalTargets.OnlyServer);
                    returnPlayerEvnt.Send();
                }
            }
            else if (BoltNetwork.IsServer)
            {
                BoltConsole.Write("Connected Server: " + connection, Color.blue);
                BoltEntity entity = BoltNetwork.Instantiate(BoltPrefabs.CharacterSelectionEntity);
                entity.AssignControl(connection);
                int numPlayers     = gameStateEntity.GetComponent <NetworkGameState>().onPlayerJoined();
                var playerTurnEvnt = PlayerJoinedEvent.Create(Bolt.GlobalTargets.Everyone);
                playerTurnEvnt.numOfPlayers = numPlayers;
                playerTurnEvnt.Send();
            }
        }
Example #2
0
 /*Only the server recieves this event.*/
 public override void OnEvent(ReturnPlayerEvent evnt)
 {
     NetworkGameState.instance.actuallyAReturningPlayer();
 }