Inheritance: Space
Ejemplo n.º 1
0
        public Map(int nPlayers, int instanceIndex, String name, Int64 seed)
        {
            //For if we want a specific name
            Int64 size1 = CommonRNG.getRandom(seed);
            Int64 size2 = CommonRNG.getRandom(size1);

            int s1, s2;

            s1 = 3;// (int)(size1 % (nPlayers + 1));
            s2 = 3;// (int)(size2 % (nPlayers + 1));

            Console.WriteLine("S1, S2 = " + s1 + ", " + s2);

            galaxy = new Galaxy("random galaxy", nPlayers+s1+s2, size2);
            //populate galaxy with non-Units and non-affiliated Units
            List<SolarSystem3D> cands = new List<SolarSystem3D>();
            foreach (SolarSystem3D sys in galaxy.systems) {
                cands.Add(sys);
            }
            players = new List<Player>(nPlayers);
            //Initialize players - agendum when we have a Player class
            CommonRNG.resetSeed();
            for (int i = 0; i < nPlayers; i++) {
                size2 = CommonRNG.getRandom(size2);
                SolarSystem3D sTemp = cands.ElementAt((int)(size2 % cands.Count));
                cands.Remove(sTemp);
                size2 = CommonRNG.getRandom(size2);
                players.Add(new Player(sTemp.planets.ElementAt((int)(size2 % sTemp.planets.Count)), "Player " + i));
            }

            //i.e. give each player a starting planet.
            this.MapName = name;
            this.instancePlayer = players.ElementAt(instanceIndex);
        }
Ejemplo n.º 2
0
 public static List<QueuedCommand> QueuedCommandList(Command C, Galaxy g)
 {
     List<QueuedCommand> qcs = new List<QueuedCommand>();
     int dist = ((Ship)(g.GetHex(C.start).GetGameObject())).getSpeed();
     for (int i = 0; i < dist; i++) {
         qcs.Add(new QueuedCommand(C, g, i));
     }
     return qcs;
 }
Ejemplo n.º 3
0
 public QueuedCommand(Command C, Galaxy g, int offset)
 {
     agent = (Unit)g.GetHex(C.start).GetGameObject();
     try
     {
         targetHex = g.GetHex(C.target);
     }
     catch (NullReferenceException) {
         targetHex = null;
     }
     order = C.action;
     shiptype = C.shiptype;
     priority = 10*(int)order+offset;
 }
Ejemplo n.º 4
0
 public SlaveDriver(Map m)
 {
     map = m;
     galaxy = map.galaxy;
 }
Ejemplo n.º 5
0
 public void SetMap(Map m)
 {
     map = m;
     galaxy = map.galaxy;
 }
Ejemplo n.º 6
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);
        }