spaceconquest.GameScreen.GameScreen C# (CSharp) Method

GameScreen() public method

public GameScreen ( bool h, String ipstring, int numclients, Map m ) : System
h bool
ipstring String
numclients int
m Map
return System
        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);
        }