예제 #1
0
파일: Map.cs 프로젝트: cclay/spaceconquest
        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);
        }
예제 #2
0
        public TelescopeMenu(Rectangle r, Player p)
        {
            plyr = p;
            area = r;
            texture = new Texture2D(MenuManager.batch.GraphicsDevice, 1, 1, true, SurfaceFormat.Color);
            texture.SetData(new[] { Color.White });
            planets = new TextLine(new Rectangle(area.Left + 5, area.Top + 30, 200, 20), "dummy1");
            asteroids = new TextLine(new Rectangle(area.Left + 5, area.Top + 50, 200, 20), "dummy2");
            ships = new TextLine(new Rectangle(area.Left + 5, area.Top + 70, 200, 20), "dummy3");
            header = new TextLine(new Rectangle(area.Left + 5, area.Top + 10, 200, 20), "Object:    Friend Foe Total");

            menucomponents.Add(header);
            menucomponents.Add(planets);
            //add healthBar before health Line
            menucomponents.Add(asteroids);
            menucomponents.Add(ships);
        }
예제 #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);
        }
예제 #4
0
파일: Map.cs 프로젝트: cclay/spaceconquest
 //public Map(Galaxy startingGalaxy, int nPlayers, String name, List<Planet> startingPlanets) //For designed maps.
 //assert length of startingplanets is nPlayers, and that each comes from within startingGalaxy
 public Player SetPlayer(int i)
 {
     instancePlayer = players.ElementAt(i);
     return instancePlayer;
 }
예제 #5
0
파일: Unit.cs 프로젝트: cclay/spaceconquest
 public void setAffiliation(Player p)
 {
     this.affiliation = p;
     if(p!= null) p.army.Add(this);
 }
예제 #6
0
파일: Unit.cs 프로젝트: cclay/spaceconquest
 public Unit()
 {
     affiliation = null;
 }
예제 #7
0
파일: Unit.cs 프로젝트: cclay/spaceconquest
 public Unit(Player p)
 {
     affiliation = p;
 }