public UserControl_System(SystemObj system, HazMap parenthazmapform, Canvasdata canvasdata)
        {
            InitializeComponent();
            this.system = system;
            //updateloc(canvasdata);
            this.parenthazmapform = parenthazmapform;
            this.textBox_sysnotes.Text = system.notes;
            this.canvasdata = canvasdata;
            //system.usrctrl = this;
            //this.Location = canvasdata.sub(canvasdata.canvasLocation(system.maploc), offset);
            location();

            this.Size = this.MinimumSize;
            setminsize();
            label_SysName.Text = system.name;
            if (showname)
            {
                label_SysName.Enabled = true;
            }
            else
            {
                label_SysName.Enabled = false;
            }
        }
Example #2
0
 public void makelink(SystemObj System1, SystemObj System2 = null)
 {
     if (!this.SystemsLinked.Contains(System1))
     {
         this.SystemsLinked.Add(System1);
     }
     if (System2 != null)
     {
         if (!this.SystemsLinked.Contains(System2))
         {
             this.SystemsLinked.Add(System2);
         }
     }
 }
Example #3
0
        bool WHPolarity = false; //false = negitive true = positive

        #endregion Fields

        #region Constructors

        public WormHoleObj(string WHName, bool WHPolarity, SystemObj System, Galaxy galaxy)
        {
            this.WHName = WHName;
            this.WHPolarity = WHPolarity;
            makelink(System);
            //galaxy.add_WH(this);
            System.add_WH(this);
        }
Example #4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="thissystem"></param>
 /// <returns>the sytem that 'thissystem' links to</returns>
 public SystemObj getlink(SystemObj thissystem)
 {
     SystemObj linkedsys;
     if (this.SystemsLinked[0] == thissystem)
     {
         linkedsys = SystemsLinked[1];
     }
     else if (this.SystemsLinked[1] == thissystem)
     {
         linkedsys = SystemsLinked[0];
     }
     else
     {
         throw new System.ArgumentException("System does not exsist in this link");
     }
     return linkedsys;
 }
Example #5
0
 public SystemBodyObj(string name, string orbitzone, SystemObj system)
 {
     this.name = name;
     this.orbzone = orbitzone;
     this.system = system;
 }
Example #6
0
 public void add_system(string systemloc, SystemObj system)
 {
     if (!system.sector.Systems_dictionary.Keys.Contains(systemloc))
     {
         system.sector.Systems_dictionary.Add(systemloc, system);
     }
     else
     {
         //system.sector.Systems_dictionary[systemloc] = system;
     }
 }
Example #7
0
 public selectsys_returnObj(SystemObj system, int depth, bool resetloc)
 {
     this.system = system;
     this.depth = depth;
     this.resetloc = resetloc;
 }
Example #8
0
        private void placesystems(SystemObj parentsystem, int angle, int depth, bool resetlocs)
        {
            if (depth > 0)
            {
                //Dictionary<string, SystemObj> systemslinked = new Dictionary<string, SystemObj>();
                List<SystemObj> systemslinked = new List<SystemObj>();
                int icondistance = 100;
               // Point parentMaploc = parentsystem.maploc;
                bool resetthisloc = false;

                foreach (WormHoleObj wh in parentsystem.Wormholes) //foreach wormhole from this system.
                {

                    SystemObj linkedsys = wh.getlink(parentsystem);

                    //if (!systemslinked.Keys.Contains(linkedsys.location))
                    if (!systemslinked.Contains(linkedsys))
                    {
                        //systemslinked.Add(linkedsys.location, linkedsys);
                        systemslinked.Add(linkedsys);
                    }

                    if (!mappedwormholes.Contains(wh))
                    {
                        mappedwormholes.Add(wh);
                    }
                    if (!mappedsystems.Keys.Contains(linkedsys.location))
                    {

                        syslink_usrctrl = new UserControl_System(linkedsys, this, canvasdata);
                        sys_usrCtrls.Add(syslink_usrctrl);
                        mappedsystems.Add(linkedsys.location, linkedsys);
                        pictureBox1.Controls.Add(syslink_usrctrl);
                    }
                }
                //foreach (KeyValuePair<string, SystemObj> kvp_system in systemslinked)
                foreach (SystemObj linkedsys in systemslinked) //this list should not include the parent...
                {
                    if (!systemPlaced.Contains(linkedsys))
                    {
                        //SystemObj linkedsys = kvp_system.Value;
                        Point thismaploc = new Point();

                        //Point dloc = mappedsystems[linkedsys.location].maploc;
                        //if (dloc.X < 1 || dloc.Y < 1) { resetthisloc = true; }
                        int linkcount = systemslinked.Count;
                        //if (linkcount > 1) { linkcount -= 1; }
                        if (resetthisloc || resetlocs) //reset.
                        {
                            thismaploc = parentsystem.maploc;
                            angle += (360 / linkcount);
                            thismaploc = sides_ab(icondistance, angle, false);
                            thismaploc.X += parentsystem.maploc.X;
                            thismaploc.Y += parentsystem.maploc.Y;
                            linkedsys.maploc = thismaploc;
                            //

                        }
                        //mappedsystems[linkedsys.location].maploc = thismaploc;

                        systemPlaced.Add(linkedsys);
                    }
                    //placesystems(mappedsystems[linkedsys.location], angle, depth - 1, resetlocs);
                    placesystems(linkedsys, angle, depth - 1, resetlocs);

                }
            }
        }
Example #9
0
        public static string readscan(string scanfile, Galaxy galaxy)
        {
            string systemName = null;
            string sectorName = null;
            string systemLoc = null;
            string sectorLoc = null;
            bool readingWH = false;
            int whlinecount = 0;
            int whcount = 0;

            string whname = null;
            bool whpolarity = false;
            string linkstosystemName = null;
            string linktosystemLoc = null;
            string linkstosectorName = null;
            string linktosectorLoc = null;
            //SectorObj sector = new SectorObj(sectorName, galaxy);
            SectorObj sector = null;
            SystemObj sys = null;

            //debugging
            int linecount = 0;
            int sectorscount = 0;
            int systemscount = 0;

            string returnstring = null;

            //using (StreamReader reader = new StreamReader(scanfile))
            //{
                //string line;
                //while ((line = reader.ReadLine()) != null)
            List<string> lines = new List<string>(scanfile.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries));
            foreach (string line in lines)
            {
                linecount++;
                if (!readingWH)
                {
                    if (line.Contains("Wormholes"))
                    {
                        readingWH = true;
                    }

                    else if (line.Contains("Sector ("))
                    {
                        int index = line.IndexOf("(");
                        sectorName = line.Trim();
                        sectorLoc = line.Substring(index).Trim();
                    }
                    else if (line.Contains("System ("))
                    {
                        int index = line.IndexOf("(");
                        systemName = line.Remove(index - 7).Trim();
                        systemLoc = line.Substring(index).Trim();
                    }
                    else if (line.Contains("'") && line.Contains("(")) // Same as above but in case of missing system word. See: http://hazeron.com/phpBB3/viewtopic.php?f=6&t=6568
                    {
                        int index = line.IndexOf("(");
                        systemName = line.Remove(index - 1).Trim();
                        systemLoc = line.Substring(index).Trim();
                    }
                }
                else
                {
                    whlinecount++;
                    if (sector == null)
                    {
                        sector = new SectorObj(sectorLoc, sectorName, galaxy);
                        sectorscount++;
                        sys = new SystemObj(systemLoc, systemName, galaxy.sectors_dictionary[sectorLoc]);
                        systemscount++;
                        returnstring = "Added " + systemName;
                    }
                    if (whlinecount == 1)
                    {
                        whname = line;
                    }
                    else if (line.Contains("Positive Wormhole"))
                    {
                        whpolarity = true;
                    }
                    else if (line.Contains("Negative Wormhole"))
                    {
                        whpolarity = false;
                    }
                    else if (whlinecount == 3)
                    {
                        int index = line.IndexOf("(");
                        linkstosystemName = line.Remove(index).Trim();
                        linktosystemLoc = line.Substring(index).Trim();
                    }
                    else if (whlinecount == 4)
                    {
                        int index = line.IndexOf("(");
                        linkstosectorName = line.Trim();
                        linktosectorLoc = line.Substring(index).Trim();
                    }
                    else if (whlinecount == 5)
                    {
                        WormHoleObj wh = new WormHoleObj(whname, whpolarity, galaxy.sectors_dictionary[sectorLoc].systems_dictionary[sys.location], galaxy);
                        //WormHoleObj wh = new WormHoleObj(whname, whpolarity, sys, galaxy);
                        SectorObj whlinksec = new SectorObj(linktosectorLoc, linkstosectorName, galaxy);
                        sectorscount++;
                        SystemObj whlinksys = new SystemObj(linktosystemLoc, linkstosystemName, galaxy.sectors_dictionary[linktosectorLoc]);
                        systemscount++;
                        wh.makelink(galaxy.sectors_dictionary[linktosectorLoc].systems_dictionary[whlinksys.location]);
                        whlinecount = 0;
                        whcount++;
                    }
                }
                if (line == "Primary")
                {
                    break;
                }
            }
            return returnstring;
        }