Ejemplo n.º 1
0
        public void GetPlanetInSystemByOrbit(int x, int y, int orbitnum, ref CPlanet planet)
        {
            CStar star = null;

            GetStarAtLocation(x, y, ref star);
            star.GetPlanetByOrbit(orbitnum, ref planet);
        }
Ejemplo n.º 2
0
        public void GetPlanetInSystemByOrbit(int x, int y, int orbitnum, ref CPlanet planet)
        {
            CStar star = null;

            GetStarAtLocation(x, y, ref star);
            star.GetPlanetByOrbit(orbitnum, ref planet);
        }
Ejemplo n.º 3
0
        public void GetPlanetInSystem(int x, int y, int planetindex, ref CPlanet planet)
        {
            CStar star = null;

            GetStarAtLocation(x, y, ref star);
            star.GetPlanet(planetindex, ref planet);
        }
Ejemplo n.º 4
0
        public void GetPlanetInSystem(int x, int y, int planetindex, ref CPlanet planet)
        {
            CStar star = null;

            GetStarAtLocation(x, y, ref star);
            star.GetPlanet(planetindex, ref planet);
        }
Ejemplo n.º 5
0
 public void GetPlanetByOrbit(int orbit, ref CPlanet planet)
 {
     for (int i = 0; i < nNumPlanets; i++)
     {
         if (planets[i].Orbit == orbit)
         {
             planet = planets[i];
             break;
         }
     }
 }
Ejemplo n.º 6
0
        public SolarSystem(int X, int Y, Universe here)
        {
            // Get the system data here in the constructor
            // to avoid passing our (huge) galaxy object into yet another sub routine.
            CStar star = null;

            bool[] orbits      = new bool[8];
            int[]  PlanetTypes = new int[8];

            for (int i = 0; i < 8; i++)
            {
                orbits[i]  = false;
                Planets[i] = null;
            }

            here.GetStarAtLocation(X, Y, ref star);

            if (star != null)
            {
                for (int i = 0; i < star.NumberOfPlanets; i++)
                {
                    CPlanet planet = null;
                    int     orbitnum;

                    star.GetPlanet(i, ref planet);
                    orbitnum = planet.Orbit;

                    orbits[orbitnum - 1]     = true;
                    Planets[orbitnum - 1]    = planet;
                    planetrefs[orbitnum - 1] = i;
                }
            }

            EllipsePoints();
            SetplanetXY();

            for (int i = 0; i < 8; i++)
            {
                if (orbits[i])
                {
                    picframe[i]   = GetPicFrame(Planets[i].PClass); //PlanetTypes(i)) 'We have a planet, get it's picture
                    planethere[i] = true;
                }
                else
                {
                    planethere[i] = false;
                }
            }
        }
Ejemplo n.º 7
0
 public void InitPlanets(int nNum)
 {
     nNumPlanets = nNum;
     if (nNumPlanets > 0)
     {
         planets = new CPlanet[nNumPlanets];
         for (int i = 0; i < nNumPlanets; i++)
         {
             planets[i]          = new CPlanet();
             planets[i].SystemID = ID;
             planets[i].uSeed    = Convert.ToInt32((Coordinates.X.ToString() +
                                                    (Coordinates.Y.ToString() + (i + 1).ToString())));
         }
     }
 }
Ejemplo n.º 8
0
        public void TopDraw()
        {
            if (theGameState.IsGameInState(GameStates.MainTitle))
            {
                MainTitle.RenderTitleScreen();
            }
            else
            {
                if (theGameState.IsGameInState(GameStates.Landed))
                {
                    OuterSpace.d3d_scene.SetupLights();
                    OuterSpace.d3d_scene.transformView_Projection();
                    OuterSpace.thisPlanet.planetpoly.startSphere.render_minerals_ship_lifeforms();
                    tvMesh.Drawmesh(0, 0, OuterSpace.thisPlanet.planetpoly.z, OuterSpace.TV.theta);
                    d3d_scene.nowForTheWeather();
                }

                // Draw the message box message box text, ship status box, ship status text, scan boxes, scan box text,
                // menu boarder, menu text and cursor in that order as the last things

                // Sprite loop 1 for the scan boxes and message boxes.
                spriteobj.Begin(SpriteFlags.AlphaBlend | SpriteFlags.SortDepthBackToFront);

                // Draw the message box
                if (theWindowMgr.FindWindow("HAL-9000") == -1)
                {
                    if (theWindowMgr.LoadWindow("CmsgWindow", clientArea.Width - 330, clientArea.Height - 138, 320, 128, Color.FromArgb(217, 255, 255, 255)) == true)
                    {
                        theWindowMgr.ShowWindow(theWindowMgr.FindWindow("HAL-9000"), true);
                    }
                }

                //Draw the status box
                if (theWindowMgr.FindWindow(playership.shipName) == -1)
                {
                    if (theWindowMgr.LoadWindow("CstatusWindow", 5, 5, 272, 144, Color.FromArgb(217, 255, 255, 255)) == true)
                    {
                        theWindowMgr.ShowWindow(theWindowMgr.FindWindow(playership.shipName), true);
                        mnu.userchoice = -1;
                    }
                }

                spriteobj.Flush();
                spriteobj.End();
                // End sprite loop 1

                // Draw the appropriate scan text
                if (theGameState.IsGameInState(GameStates.Orbiting) && !theGameState.IsGameInState(GameStates.Landed))
                {
                    //In orbit?
                    theGameState.RemoveState(GameStates.InSystem);
                    theGameState.RemoveState(GameStates.Interstellar);
                    theGameState.RemoveState(GameStates.DockedAtStation);

                    thisPlanet.makeScanBox();

                    switch (mnu.userchoice)
                    {
                        // Navigate, out of orbit.
                        case 7:
                            theGameState.RemoveState(GameStates.Orbiting);
                            theGameState.RemoveState(GameStates.Landing);
                            theGameState.AddState(GameStates.InSystem);
                            thisPlanet.displayScan = false;
                            thisPlanet.displayAnalysis = false;
                            XCor = XCor + 14;
                            OuterSpace.thisPlanet = null;
                            // Get rid of the planet object, it eats memory.
                            break;

                        case 14:
                            thisPlanet.displayScan = true;
                            thisPlanet.displayAnalysis = false;
                            mnu.userchoice = -1;
                            break;

                        case 15:
                            if ((thisPlanet.displayScan == true)) {
                                thisPlanet.displayAnalysis = true;
                            }
                            else {
                                msgbox.othermessage(11);
                            }

                            mnu.userchoice = -1;
                            break;

                    }
                }
                //End in Orbit

                if (theGameState.IsGameInState(GameStates.DockedAtStation))
                {
                    theGameState.RemoveState(GameStates.InSystem);
                    theGameState.RemoveState(GameStates.Interstellar);
                    theGameState.RemoveState(GameStates.Orbiting);

                    thisPlanet.makeScanBox();

                    switch (mnu.userchoice)
                    {
                        // Navigate, out of orbit.
                        case 7:
                            theGameState.RemoveState(GameStates.DockedAtStation);
                            theGameState.RemoveState(GameStates.Orbiting);
                            theGameState.RemoveState(GameStates.Landing);
                            theGameState.AddState(GameStates.InSystem);
                            thisPlanet.displayScan = false;
                            thisPlanet.displayAnalysis = false;
                            XCor = XCor + 14;
                            OuterSpace.thisPlanet = null;
                            // Get rid of the planet object, it eats memory.
                            break;
                        case 14:
                            thisPlanet.displayScan = true;
                            thisPlanet.displayAnalysis = false;
                            mnu.userchoice = -1;
                            break;
                        case 15:
                            if ((thisPlanet.displayScan == true)) {
                                thisPlanet.displayAnalysis = true;
                            }
                            else {
                                msgbox.othermessage(11);
                            }

                            mnu.userchoice = -1;
                            break;
                    }
                }
            }

            drawWindows();

            // Sprite loop 3, for the pointer.
            spriteobj.Begin(SpriteFlags.AlphaBlend | SpriteFlags.SortDepthBackToFront);
            // Draw the menu text

            userinput.drawmouse();
            userinput.resetlastbutton(userinput.lastbutton);

            spriteobj.Flush();
            spriteobj.End();
            // End sprite loop 3
        }
Ejemplo n.º 9
0
        //Display Frame
        private void drawSystem(int X, int Y)
        {
            thisPlanet = null;
            userinput.resetlastkey(userinput.lastkey);

            for (int i = 0; i < 8; i++)
            {
                if (Currentsystems[X, Y].planethere[i])
                {
                    planetsprite.Draw(Currentsystems[X, Y].planetXY[0, i], Currentsystems[X, Y].planetXY[1, i], Currentsystems[X, Y].picframe[i], 0, Color.White);

                    //Draw the planets around the ellipses.
                    //Test to see if we are near that planet.
                    if (XCor < Currentsystems[X, Y].planetXY[0, i] + 8 & XCor > Currentsystems[X, Y].planetXY[0, i] - 8)
                    {
                        // Near the x corrdinate of this planet?
                        if ((ClientArea.Height - YCor) < Currentsystems[X, Y].planetXY[1, i] + 8 && (ClientArea.Height - YCor) > Currentsystems[X, Y].planetXY[1, i] - 8)
                        {
                            // Near the y coordianet?
                            msgbox.OrbitYN(i + 1);
                            //We are near both the X and Y coordinates!

                            if (userinput.KeyPressed(Key.Space, true))
                            {
                                //If space is hit, orbit this planet.
                                OuterSpace.msgbox.pushmsgs("Orbiting planet........");

                                CStar star = null;
                                theVerse.GetStarAtLocation(X, Y,ref star);
                                theVerse.GetPlanetInSystemByOrbit(X, Y, i + 1, ref thisPlanet);

                                if (starport.IsStarport(star.ID, i))
                                {
                                    // orbiting starport planet
                                    theGameState.AddState(GameStates.DockedAtStation);
                                }
                                else
                                {
                                    theGameState.AddState(GameStates.Orbiting);
                                }

                                drawmouse = true;
                                thisPlanet.renderPolyPlanet = false;
                                mnu.userchoice = -1;
                            }
                        }
                    }
                }

                if (mnu.userchoice == 7)
                {
                    userinput.MouseXY(0, 0);
                }
                else
                {
                    userinput.MouseXY(16, 25);
                }
            }

            // Took this out of the loop. Doubt it needed to be drawn 8 times
            //Draw the sun.
            sun.Draw(ClientArea.Center.X - 23, ClientArea.Center.Y - 23, sun.sourceFrame[0], 0, Color.White);
            // Draw the lil' ship. Invert YCor..
            smallship.Draw((int)XCor, (int)(ClientArea.Height - YCor), smallship.sourceFrame[0],
                playership.theta, Color.White);
        }
Ejemplo n.º 10
0
 public void GetPlanet(int index, ref CPlanet planet)
 {
     planet = planets[index];
 }
Ejemplo n.º 11
0
        public bool LoadUniverse(string strPath)
        {
            int nNumStars    = 0;
            int nNumPlanets  = 0;
            int nNumNebulae  = 0;
            int nNumStations = 0;

            DataTable dtStars    = null;
            DataTable dtPlanets  = null;
            DataTable dtNebulae  = null;
            DataTable dtStations = null;

            DataRow row     = null;
            DataSet ds      = new DataSet();
            bool    bRetVal = false;

            ds.ReadXml(strPath, XmlReadMode.InferSchema);

            //  load stars
            dtStars   = ds.Tables["Star"];
            nNumStars = dtStars.Rows.Count;

            for (int nRow = 0; nRow < nNumStars; nRow++)
            {
                int x = Convert.ToInt16(dtStars.Rows[nRow]["X"]);
                int y = Convert.ToInt16(dtStars.Rows[nRow]["Y"]);

                stars[x, y] = new CStar();

                row = dtStars.Rows[nRow];

                stars[x, y].ID = Convert.ToInt16(dtStars.Rows[nRow]["ID"]);
                // stars[x, y].GroupID = Convert.ToInt16(dtStars.Rows[nRow]["GroupID"])
                stars[x, y].Name        = dtStars.Rows[nRow]["Name"].ToString();
                stars[x, y].Coordinates = new Point(x, y);
                // stars[x, y].Z = Convert.ToInt16(dtStars.Rows[nRow]["Z"])
                stars[x, y].SpectralClass = dtStars.Rows[nRow]["SpectralClass"].ToString();
                stars[x, y].Temperature   = Convert.ToInt32(dtStars.Rows[nRow]["Temperature"]);
                stars[x, y].InitPlanets(Convert.ToInt16(dtStars.Rows[nRow]["NumberOfPlanets"]));

                bRetVal = true;
            }

            //  load planets
            dtPlanets   = ds.Tables["Planet"];
            nNumPlanets = dtPlanets.Rows.Count;

            for (int nRow = 0; nRow < nNumPlanets; nRow++)
            {
                CPlanet planet = null;
                int     nSysID = Convert.ToInt16(dtPlanets.Rows[nRow]["SystemID"]);
                int     nPlanetID = Convert.ToInt16(dtPlanets.Rows[nRow]["ID"]);
                bool    bFound = false;
                int     x = 0, y = 0;

                for (y = 0; y < 251; y++)
                {
                    for (x = 0; x < 251; x++)
                    {
                        if (stars[x, y] != null)
                        {
                            if (stars[x, y].ID == nSysID)
                            {
                                bFound = true;
                                break;
                            }
                        }
                    }

                    if (bFound)
                    {
                        break;
                    }
                }

                if (bFound)
                {
                    stars[x, y].GetPlanet(nPlanetID - 1, ref planet);

                    planet.SystemID            = nSysID;
                    planet.ID                  = nPlanetID;
                    planet.Orbit               = Convert.ToInt16(dtPlanets.Rows[nRow]["Orbit"]);
                    planet.Name                = dtPlanets.Rows[nRow]["Name"].ToString();
                    planet.PClass              = dtPlanets.Rows[nRow]["Class"].ToString();
                    planet.Density             = (float)Convert.ToDouble(dtPlanets.Rows[nRow]["Density"]);
                    planet.Radius              = Convert.ToInt32(dtPlanets.Rows[nRow]["Radius"]);
                    planet.Mass                = (float)Convert.ToDouble(dtPlanets.Rows[nRow]["Mass"]);
                    planet.SurfaceGravity      = (float)Convert.ToDouble(dtPlanets.Rows[nRow]["SurfaceGravity"]);
                    planet.Weather             = Convert.ToInt16(dtPlanets.Rows[nRow]["Weather"]);
                    planet.ClimateRange        = dtPlanets.Rows[nRow]["ClimateRange"].ToString();
                    planet.AtmosphericPressure = (float)Convert.ToDouble(dtPlanets.Rows[nRow]["AtmosphericPressure"]);
                    planet.Atmosphere          = dtPlanets.Rows[nRow]["Atmosphere"].ToString();
                    planet.Lithosphere         = dtPlanets.Rows[nRow]["Lithosphere"].ToString();
                    planet.Hydrosphere         = dtPlanets.Rows[nRow]["Hydrosphere"].ToString();
                    planet.MinDensity          = Convert.ToInt16(dtPlanets.Rows[nRow]["MinDensity"]);
                    planet.BioDensity          = Convert.ToInt16(dtPlanets.Rows[nRow]["BioDensity"]);
                }
                else
                {
                    // rogue planet
                }
            }

            //  load nebulae from xml if it exists in the same path
            ds.Reset();
            strPath = Path.GetDirectoryName(strPath) + "\\nebulae.xml";

            if (File.Exists(strPath))
            {
                ds.ReadXml(strPath, XmlReadMode.InferSchema);
                dtNebulae   = ds.Tables["Nebula"];
                nNumNebulae = dtNebulae.Rows.Count;

                //  load into nebula class
                // #SUGGESTION - FINISH
                // DOES NOT EXIST YET
            }

            //  load spacestations from xml. if not exists throw error
            ds.Reset();
            strPath = Path.GetDirectoryName(strPath) + "\\spacestations.xml";

            if (File.Exists(strPath))
            {
                ds.ReadXml(strPath, XmlReadMode.InferSchema);
                dtStations   = ds.Tables["Station"];
                nNumStations = dtStations.Rows.Count;

                //  load into stations class
                //  we don't have one yet and not sure if we need one.  only if multiple stations
                //  right now I'll assume only starport
                if (nNumStations > 0)
                {
                    OuterSpace.starport.SetStarportSystem(Convert.ToInt32(dtStations.Rows[0]["SystemID"]));
                    OuterSpace.starport.SetStarportOrbit(Convert.ToInt32(dtStations.Rows[0]["OrbitNum"]));
                }
            }

            return(bRetVal);
        }
Ejemplo n.º 12
0
 public void GetPlanetByOrbit(int orbit, ref CPlanet planet)
 {
     for (int i = 0; i < nNumPlanets; i++)
     {
         if (planets[i].Orbit == orbit)
         {
             planet = planets[i];
             break;
         }
     }
 }
Ejemplo n.º 13
0
 public void GetPlanet(int index, ref CPlanet planet)
 {
     planet = planets[index];
 }
Ejemplo n.º 14
0
 public void InitPlanets(int nNum)
 {
     nNumPlanets = nNum;
     if (nNumPlanets > 0)
     {
         planets = new CPlanet[nNumPlanets];
         for (int i = 0; i < nNumPlanets; i++)
         {
             planets[i] = new CPlanet();
             planets[i].SystemID = ID;
             planets[i].uSeed = Convert.ToInt32((Coordinates.X.ToString() +
                 (Coordinates.Y.ToString() + (i + 1).ToString())));
         }
     }
 }