コード例 #1
0
        public static gameConnection Create(IPAddress ip, long hostId, IGameHostCreation theGameHost)
        {
            var Connection = theGameHost.CreateConnection();

            Connection.HostId      = hostId;
            Connection.HostAddress = new IPEndPoint(ip, myPort);
            return(Connection);
        }
コード例 #2
0
ファイル: GameHost.cs プロジェクト: jakeross62/CO3ProjectUNO
        public static GameHost HostGame(IGameHostCreation Creator)
        {
            if (IsHosting)
            {
                throw new InvalidOperationException("Shut down other host first!");
            }
            var host = Creator.Create();

            theInstance = host;
            host.State  = GameState.Starting;
            host.State  = GameState.WaitingForPlayers;
            return(host);
        }
コード例 #3
0
        public static GameLobby CreateGame(string thePlayerName, IGameHostCreation theGameHost)
        {
            if (GameHost.IsHosting)
            {
                throw new InvalidOperationException("Cannot create another game while already hosting one!");
            }
            var host  = GameHost.HostGame(theGameHost);
            var lobby = TryToJoin(IPAddress.None, host.ID, thePlayerName, theGameHost);

            if (!GameHost.IsHosting)
            {
                return(null);
            }

            if (lobby == null)
            {
                GameHost.ShutDown();
            }
            return(lobby);
        }
コード例 #4
0
        public static GameLobby TryToJoin(IPAddress IP, long hostID, string playerName, IGameHostCreation theGameHost)
        {
            var lobby      = new GameLobby();
            var Connection = gameConnection.Create(IP, hostID, theGameHost);

            lobby.Connection = Connection;
            lobby.InitializeComponent();
            Connection.Initialize(playerName);
            return(lobby);
        }