Пример #1
0
        public void newPlayer(Playertoken token)
        {
            Playerno++;
            User player = new User();

            token.setIPeer(new ServerPeer(this, player, token));
            player.setPlayer_no(Playerno_Pool.pop());


            Record(player, "Connected");


            //보냄
            Packet packet = Packet.create(PROTOCOL.Player_no);

            packet.push(player.Player_no);
            player.Peer.send(packet);


            Packet packets = Packet.create(PROTOCOL.Note_Servertime);

            packets.push(ServerTime.ElapsedMilliseconds);
            player.Peer.send(packets);

            player.x = xyPool.pop();
            player.y = xyPool.pop();
            COLOR color = (COLOR)colorpool.pop();

            player.setCOLOR(color);
            player.setDirection(DIRECTION.Up);


            for (int i = 0; i < 7; i++)
            {
                if (Userarr[i] != null)
                {
                    Packet olduserinfo = Packet.create(PROTOCOL.Player);
                    olduserinfo.push(ServerTime.ElapsedMilliseconds);
                    olduserinfo.push(Userarr[i]);
                    player.Peer.send(olduserinfo);
                }
            }

            Packet tome = Packet.create(PROTOCOL.Player);

            tome.push(ServerTime.ElapsedMilliseconds);
            tome.push(player);


            Packet newuserinfo = Packet.create(PROTOCOL.Player);

            newuserinfo.push(ServerTime.ElapsedMilliseconds);
            newuserinfo.push(player);

            Send_all(newuserinfo);

            Userarr[player.Player_no] = player;
            player.Peer.send(tome);
        }
Пример #2
0
        private GameServer Server_generate()
        {
            GameServer new_server = new GameServer(ServerCodePool.pop());

            ServerList.Add(new_server);
            return(new_server);
        }