예제 #1
0
        public GameManager(IEnumerable<Player> players, string map, EventManager em, GameHost gh)
        {
            Map = map;
            _em = em;
            _gh = gh;

            RegisterEvents();

            foreach (var p in players)
                p.Client.OnDisconnect += c => PlayerDisconnect(p);

            CreateNetworkCharacters(players);

            foreach (var networkCharacter in Characters)
            {
                new GameStart().Pack(networkCharacter.Client.Writer,
                    Map,
                    players);

                new SetCharacterPosition().Pack(networkCharacter.Client.Writer,
                                                new CharacterPositionDatas
                                                    {
                                                        ID = networkCharacter.ID,
                                                        X = networkCharacter.X,
                                                        Y = networkCharacter.Y,
                                                        Yaw = networkCharacter.Yaw
                                                    });
            }
        }
예제 #2
0
        public Lobby(byte maxPlayers, string mapName, EventManager em, GameHost gameHost)
        {
            MaxPlayers = maxPlayers;
            _em = em;
            MapName = mapName;
            _gameHost = gameHost;

            RegisterLobbyEvents();
        }
예제 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("MetaStruggle Game Server\n");

            ushort port = GetPort();
            string map = GetMap();
            byte max = GetMaxPlayer();

            var gh = new GameHost(port, map, max);

            while (true)
            {
                switch (Console.ReadLine())
                {
                    case "quit":
                        if(gh.State == State.Lobby)
                            gh.MasterOperation(false);
                        break;
                }
            }
        }