Exemplo n.º 1
0
 public Client(String ipstring, SlaveDriver sd, GameScreen GS)
 {
     gs = GS;
     try { ip = IPAddress.Parse(ipstring); }
     catch (Exception e) { MenuManager.ClickGlobalLobby(this, EventArgs.Empty); return; }
     end = new IPEndPoint(ip, 6112);
     end2 = new IPEndPoint(ip, 6113);
     socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     aSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     //socket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
     slavedriver = sd;
     //socket.EnableBroadcast = false;
     ReceiveMap();
     //Start attendance thread;
     TakeAttendance();
 }
Exemplo n.º 2
0
 public Host(Map m, SlaveDriver sd, int n, GameScreen GS)
 {
     AttendanceThread.socklist = new List<Socket>();
     HostThread.streamlist = new List<NetworkStream>();
     gs = GS;
     ip = IPAddress.Any; //IPAddress.Parse("70.55.141.164");
     end = new IPEndPoint(ip, 6112);
     end2 = new IPEndPoint(ip, 6113);
     listensocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     aSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     listensocket.Bind(end);
     aSocket.Bind(end2);
     //listensocket.EnableBroadcast = false;
     slavedriver = sd;
     slavedriver.SetMap(m);
     numclients = n;
     map = m;
     SendMap();
     TakeAttendance();
 }
Exemplo n.º 3
0
        public GameScreen(bool h, String ipstring, int numclients, Map m)
        {
            host = h;
            selectedhex = nullhex;
            if (m == null)
            {
                if (h) { map = new Map(2, 0, "test galaxy", (long)CommonRNG.rand.NextDouble()); }
                //else { map = new Map(2, numclients, "test galaxy", (long)1); }
            }
            else { map = m; }

            driver = new SlaveDriver(this); //dont use until middleman created

            if (host)
            {
                middleman = new Host(map, driver, numclients, this);
                //((Host)middleman).SendMap();
            }
            else middleman = new Client(ipstring, driver, this);

            //test for failure here

            map = driver.GetMap();

            if (map == null) { MenuManager.screen = new TitleScreen(MenuManager.batch, MenuManager.font); return; }
            Player temp = map.GetInstancePlayer();
            int num = map.players.IndexOf(temp);
            map.players[num] = map.players[0];
            map.players[0] = temp;

            if (!host) map.SetPlayer(numclients);

            galaxy = map.galaxy;
            player = map.GetInstancePlayer();
            space = map.GetHomeSystem();

            int x = Game1.device.Viewport.Width;
            int y = Game1.device.Viewport.Height;
            galaxybutton = new IconButton(new Rectangle(40, y-40, 120, 40), "GalaxyButton.png", "SystemButton.png", GalaxyClick);
            components.Add(galaxybutton);

            shipmenu = new CommandMenu(new Rectangle(x-200, y-200, 200, 200),this);
            shipmenu.AddShipStuff();
            components.Add(shipmenu);

            planetmenu = new CommandMenu(new Rectangle(x-200, y-200, 200, 200),this);

            components.Add(planetmenu);
            planetmenu.AddShipCommand(0, 0, "StarCruiserButton.png", StarCruiser.creator);
            planetmenu.AddShipCommand(2, 0, "FighterButton.png", FighterShip.creator);
            planetmenu.AddShipCommand(0, 1, "MinerButton.png", MiningShip.creator);
            planetmenu.AddShipCommand(1, 0, "ColonistButton.png", ColonyShip.creator);
            planetmenu.AddShipCommand(1, 1, "TransportButton.png", Transport.creator);
            planetmenu.AddShipCommand(1, 2, "TelescopeButton.png", Telescope.creator);
            planetmenu.AddNewCommand(0, 2, "ShieldButton.png", UpgradeClick);

            waitingmessage = new TextLine(new Rectangle(0, 20, 400, 20), "Waiting for other players.");

            //planetmenu.showbackround = false;
            //shipmenu.showbackround = false;

            statusmenu = new StatusMenu(new Rectangle(0, y - 150, 300, 150));
            statusmenu.visible = false;
            telescopemenu = new TelescopeMenu(new Rectangle(0, y - 150, 300, 150), player);
            telescopemenu.visible = false;

            topmenu = new TopMenu(new Rectangle(0, 0, x, 40), this);
            components.Add(topmenu);
        }
Exemplo n.º 4
0
 public ClientThread(Socket s, EndPoint e, SlaveDriver sd, Result r)
 {
     socket = s;
     end = e;
     //socket.Bind(end);
     formatter = new BinaryFormatter();
     slave = sd;
     action = r;
     mapexchange = true;
 }