Exemplo n.º 1
0
 public Hex3D(int xx, int yy, SolarSystem3D ss, Color c)
 {
     defaultcolor = c;
     color = c;
     x = xx;
     y = yy;
     hexgrid = ss;
     boundsphere = new BoundingSphere(getCenter(), radius);
 }
Exemplo n.º 2
0
        public void Update(SolarSystem3D u)
        {
            if (mousesystem == u) {return;}
            mousesystem = u;
            Boolean vis = false;
            foreach (Unit u1 in plyr.army) {
                SolarSystem3D u1ss = u1.hex.hexgrid;
                if (u1ss == mousesystem) { Console.WriteLine("I can see!"); vis = true; break; }

                if (mousesystem.neighbors.Contains(u1ss) && u1 is Ship && ((Ship)u1).shiptype is Telescope) { vis = true; break; }
            }
            if (vis)
            {
                int totalShips = 0;
                int totalPlanets = 0;
                int totalRoids = 0;
                int enemyShips = 0;
                int enemyPlanets = 0;
                int enemyRoids = 0;
                int myShips = 0;
                int myPlanets = 0;
                int myRoids = 0;
                foreach (Hex3D h1 in mousesystem.getHexes())
                {
                    GameObject go = h1.GetGameObject();
                    if (go != null && go is Unit)
                    {
                        Unit u1 = ((Unit)go);
                        Player p1 = u1.getAffiliation();
                        if (u1 is Asteroid)
                        {
                            totalRoids++;
                            if (p1 == null) { }
                            else if (p1 == plyr) { myRoids++; }
                            else { enemyRoids++; }
                        }
                        if (u1 is Planet)
                        {
                            totalPlanets++;
                            if (p1 == null) { }
                            else if (p1 == plyr) { myPlanets++; }
                            else { enemyPlanets++; }
                        }
                        if (u1 is Ship)
                        {
                            totalShips++;
                            if (p1 == null) { }
                            else if (p1 == plyr) { myShips++; }
                            else { enemyShips++; }
                        }
                    }
                }
                String[] spacing = new String[3];
                if (myPlanets < 10) { spacing[0] = " "; }
                else { spacing[0] = ""; }
                if (enemyPlanets < 10) { spacing[1] = " "; }
                else { spacing[1] = ""; }
                if (totalPlanets < 10) { spacing[2] = " "; }
                else { spacing[2] = ""; }
                planets.text = "Planets:       " + spacing[0] + myPlanets + "  " + spacing[1] + enemyPlanets + "    " + spacing[2] + totalPlanets;
                if (myRoids < 10) { spacing[0] = " "; }
                else { spacing[0] = ""; }
                if (enemyRoids < 10) { spacing[1] = " "; }
                else { spacing[1] = ""; }
                if (totalRoids < 10) { spacing[2] = " "; }
                else { spacing[2] = ""; }
                asteroids.text = "Asteroids:     " + spacing[0] + myRoids + "  " + spacing[1] + enemyRoids + "    " + spacing[2] + totalRoids;
                if (myShips < 10) { spacing[0] = " "; }
                else { spacing[0] = ""; }
                if (enemyShips < 10) { spacing[1] = " "; }
                else { spacing[1] = ""; }
                if (totalShips < 10) { spacing[2] = " "; }
                else { spacing[2] = ""; }
                ships.text = "Vessels:       " + spacing[0] + myShips + "  " + spacing[1] + enemyShips + "    " + spacing[2] + totalShips;

            }
            else
            {

                //               "Object:    Friend Foe Total"
                planets.text = "Planets:       ??  ??    ??";
                asteroids.text = "Asteroids:     ??  ??    ??";
                ships.text = "Vessels::      ??  ??    ??";
            }
        }
Exemplo n.º 3
0
        public void UpdateGalaxy()
        {
            statusmenu.Hide();
            SolarSystem3D mousesystem = galaxy.GetMouseOverSystem();
            if (oldmousesystem != null) oldmousesystem.sun.color = oldmousesystem.sun.defaultcolor;
            if (mousesystem != null) { mousesystem.sun.color = Color.Green; telescopemenu.Show(); telescopemenu.Update(mousesystem); }
            else { telescopemenu.Hide(); }

            if ((mousestate.LeftButton == ButtonState.Pressed) && (oldmousestate.LeftButton == ButtonState.Released) && !shipmenu.Contains(mousestate.X, mousestate.Y) && mousesystem != null)
            {
                if (clickedaction == Command.Action.Jump)
                {
                    //commands.Add(new Command(selectedhex, mousesystem.getHex(-2, -2), Command.Action.Jump));
                    space = mousesystem;
                    Boolean occupied = false;
                    foreach (Hex3D h1 in mousesystem.getHexes()) {
                        GameObject o = h1.GetGameObject();
                        if (o != null && o is Unit && ((Unit)o).getAffiliation() == player) {
                            occupied = true;
                            break;
                        }
                    }
                    if (!occupied) {
                        foreach (Hex3D h1 in mousesystem.getHexes()) {
                        h1.visible = false;
                        h1.color = Color.Black;
                        }
                    }

                    //selectedhex = nullhex;
                    clickedaction = Command.Action.Jump;

                }
                else {
                    HashSet<SolarSystem3D> targetable = new HashSet<SolarSystem3D>();
                    foreach (Unit u in player.army) {
                        targetable.Add(u.hex.hexgrid);
                    }
                    if (targetable.Contains(mousesystem)) {
                        space = mousesystem;
                    }

                }
            }

            oldmousesystem = mousesystem;
        }