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 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.º 3
0
        private void drawStars()
        {
            int   xPos;
            int   yPos;
            Point starScreen = new Point();

            for (xPos = 0; xPos <= 250; xPos++)
            {
                for (yPos = 0; yPos <= 250; yPos++)
                {
                    if (OuterSpace.theVerse.HasStar(xPos, yPos))
                    {
                        CStar star = null;
                        OuterSpace.theVerse.GetStarAtLocation(xPos, yPos, ref star);
                        starScreen.X = (int)MathFunctions.scaleValue(xPos, 250, 0, mapArea[1].X, mapArea[0].X);
                        starScreen.Y = (int)MathFunctions.scaleValue(250 - yPos, 250, 0, mapArea[1].Y, mapArea[0].Y);
                        // Invert the yPos cause the screen corrdinates are top 0, bottom max.
                        OuterSpace.backstars.Draw(starScreen.X, starScreen.Y, OuterSpace.backstars.sourceFrame[OuterSpace.theVerse.GetTempType(star.SpectralClass)], 0,
                                                  Color.FromArgb(100 + (int)(rnd.NextDouble() * 150) + 1, 255, 255, 255));
                    }
                }
            }

            starScreen.X = (int)MathFunctions.scaleValue(OuterSpace.XCor, 250, 0, mapArea[1].X, mapArea[0].X);
            starScreen.Y = (int)MathFunctions.scaleValue(250 - OuterSpace.YCor, 250, 0, mapArea[1].Y, mapArea[0].Y);

            OuterSpace.smallship.Draw(starScreen.X - 8, starScreen.Y - 5, OuterSpace.smallship.sourceFrame[0],
                                      OuterSpace.playership.theta, Color.FromArgb(90, 255, 255, 255));
        }
Ejemplo n.º 4
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.º 5
0
 public void GetStarByID(int id, ref CStar star)
 {
     for (int y = 0; y < 251; y++)
     {
         for (int x = 0; x < 251; x++)
         {
             if (stars[x, y] != null)
             {
                 if (stars[x, y].ID == id)
                 {
                     star = stars[x, y];
                     return;
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 public void GetStarByName(string name, ref CStar star)
 {
     for (int y = 0; y < 251; y++)
     {
         for (int x = 0; x < 251; x++)
         {
             if (stars[x, y] != null)
             {
                 if (stars[x, y].Name == name)
                 {
                     star = stars[x, y];
                     return;
                 }
             }
         }
     }
 }
Ejemplo n.º 7
0
 public void GetStarByID(int id, ref CStar star)
 {
     for (int y = 0; y < 251; y++)
     {
         for (int x = 0; x < 251; x++)
         {
             if (stars[x, y] != null)
             {
                 if (stars[x, y].ID == id)
                 {
                     star = stars[x, y];
                     return;
                 }
             }
         }
     }
 }
Ejemplo n.º 8
0
 public void GetStarAtLocation(int x, int y, ref CStar star)
 {
     star = stars[x, y];
 }
Ejemplo n.º 9
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.º 10
0
 public void GetStarByName(string name, ref CStar star)
 {
     for (int y = 0; y < 251; y++)
     {
         for (int x = 0; x < 251; x++)
         {
             if (stars[x, y] != null)
             {
                 if (stars[x, y].Name == name)
                 {
                     star = stars[x, y];
                     return;
                 }
             }
         }
     }
 }
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 GetStarAtLocation(int x, int y, ref CStar star)
 {
     star = stars[x, y];
 }