using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization; using System.IO; using System.Windows.Forms; namespace Mars_Mission { public class classBase { public static classBase[] cBases = new classBase[0]; static int intUniqueIDCounter = 0; public int intMyUniqueID; public classCollisionDetectionObject cCDO = new classCollisionDetectionObject(); public int intMyIndex; public classObjectContainer cObjContainer = new classObjectContainer(); public TreeNode tNode = new TreeNode(); public TreeNode tNode_Astronauts = new TreeNode(); public TreeNode tNode_Resources = new TreeNode(); public TreeNode tNode_Ships = new TreeNode(); classBase cMyReference; public classStructure[] cStructures = new classStructure[(int)enuStructureModels._numStructureModels]; private classBase() { cMyReference = this; intMyUniqueID = intUniqueIDCounter++; Name = "Base #" + intMyUniqueID.ToString(); Array.Resize<classBase>(ref cBases, cBases.Length + 1); cBases[cBases.Length - 1] = this; cCDO.cIAmBase = this; cCDO.eTypeObject = classCollisionDetectionObject.enuTypeObject.Base; tNode.Text = Name; tNode.ForeColor = formMarsMission.clrNodeDull; tNode.Nodes.Add(tNode_Ships); tNode_Ships.Text = "Ships"; tNode_Ships.ForeColor = formMarsMission.clrNodeDull; tNode.Nodes.Add(tNode_Resources); tNode_Resources.Text = "Resources"; tNode_Resources.ForeColor = formMarsMission.clrNodeDull; tNode.Nodes.Add(tNode_Astronauts); tNode_Astronauts.Text = "Astronauts"; tNode_Astronauts.ForeColor = formMarsMission.clrNodeDull; } public void Build(enuStructureModels eStructureModel) { cStructures[(int)eStructureModel] = new classStructure(eStructureModel); cStructures[(int)eStructureModel].cBase = this; } public static classBase createBase() { classBase cNewBase = new classBase(); return cNewBase; } string _Name; public string Name { get { return _Name; } set { _Name = value; tNode.Text = _Name; } } public void RemoveFromSolarObject() { if (cCDO.cSolarObject == null) MessageBox.Show("error : Remove Ship From cSolarObject -> Ship's cSolarObject == null"); cCDO.cSolarObject.cObjContainer.removeBase(ref cMyReference); for (int intShipNodeCounter = 0; intShipNodeCounter < cCDO.cSolarObject.tNode_Ships.Nodes.Count; intShipNodeCounter++) { if (cCDO.cSolarObject.tNode_Ships.Nodes[intShipNodeCounter] == tNode) { cCDO.cSolarObject.tNode_Ships.Nodes.Remove(tNode); break; } } cCDO.cSolarObject = null; } public static void clear() { cBases = new classBase[0]; } public void AddToSolarObject(ref classSolarObject cNewSolarObject) { cCDO.cSolarObject = cNewSolarObject; cCDO.cSolarObject.cObjContainer.addBase(ref cMyReference); cCDO.cSolarObject.tNode_Bases.Nodes.Add(tNode); } public static classBase getBaseByName(string strName) { //strName = strName.Trim().Replace(" ", "_").Replace("/", "_").Replace("'", "_"); for (int intBaseCounter = 0; intBaseCounter < cBases.Length && cBases[intBaseCounter] != null; intBaseCounter++) if (cBases[intBaseCounter].Name == strName) { return cBases[intBaseCounter]; } return null; } } public class classStructure { public enuStructureModels eModel; public classBase cBase; public double dblSize; public classStructure(enuStructureModels eStructureModel) { eModel = eStructureModel; switch (eModel) { case enuStructureModels.Base: dblSize = .4; break; default: dblSize = .4; break; } } public Bitmap myImage(double dblDrawAngle) { return classLandscape.cStructureImages[(int)eModel].getImage(dblDrawAngle); } } public class classBaseData { public static GroupBox grbBaseData = new GroupBox(); static Label lblLongitude_Name = new Label(), lblPosition_Name; static Label lblLongitude_Value = new Label(), lblPosition_Value; static Label lblAltitude_Name = new Label(); static Label lblAltitude_Value = new Label(); static Label lblLocation_Name = new Label(); static Label lblLocation_Value = new Label(); static classBase cBase; static public classBase Base { get { return cBase; } set { cBase = value; if (grbBaseData.Text != cBase.Name) grbBaseData.Text = cBase.Name + "(" + cBase.cCDO.cSolarObject.eSolarObject.ToString() + ")"; } } static public void setLabelNames() { if (cBase != null) { switch (cBase.cCDO.eLoc) { case enuLocation.Surface: case enuLocation.Cave: case enuLocation.Base: lblLongitude_Name.Text = "Longitude"; lblAltitude_Name.Visible = lblAltitude_Value.Visible = true; grbBaseData.Text = cBase.Name + " (" + cBase.cCDO.cSolarObject.eSolarObject.ToString() + ")"; break; } } } static public void DisplayBaseInfo() { if (cBase != null) { switch (cBase.cCDO.eLoc) { case enuLocation.Surface: case enuLocation.Cave: if (cBase.cCDO.eLoc == enuLocation.Surface) { /// prime-meridian at crease double dblRealWidth = cBase.cCDO.cLandscapeCell.cLandscape.dblRealWidth; double dblX = cBase.cCDO.dptPos.X; while (dblX >= dblRealWidth) dblX -= dblRealWidth; while (dblX < 0) dblX += dblRealWidth; //grbBaseData.Text = dblX.ToString(); double dblRWBy2 = dblRealWidth / 2; if (dblX > dblRWBy2) { /// 180 e/w at RW/2 -> west longitudinal values decreasing towards limit of X double dblDifference = dblRWBy2 - cBase.cCDO.dptPos.X; double dblDegreesAwayFromPrimeMeridian = 180.0 - Math.Abs(dblDifference / dblRWBy2) * 180.0; lblLongitude_Value.Text = classStringHandler.F2( dblDegreesAwayFromPrimeMeridian) + " West"; } else { /// east longitudinal values increasing towards limit of RW/2 double dblDegreesAwayFromPrimeMeridian = Math.Abs(dblX / dblRWBy2) * 180.0; lblLongitude_Value.Text =classStringHandler.F2( dblDegreesAwayFromPrimeMeridian) + " East"; } } if (cBase.cCDO.eLoc == enuLocation.Surface) lblAltitude_Value.Text = classStringHandler.F2(cBase.cCDO.cLandscapeCell.cLandscape.intAveAlt - cBase.cCDO.dptPos.Y); if (cBase.cCDO.eLoc == enuLocation.Cave && cBase.cCDO.cCaveCellWall.cMyCaveCell != null) { lblLocation_Value.Text += "(" + cBase.cCDO.cCaveCellWall.cMyCaveCell.intMyIndex.ToString() + "/" + cBase.cCDO.cCaveCellWall.cMyCaveCell.cCave.cCells.Length.ToString() + ")"; } else lblLocation_Value.Text = cBase.cCDO.eLoc.ToString(); break; } } } public static void initGrbBaseData() { grbBaseData.ForeColor = Color.Yellow; lblPosition_Name = lblLongitude_Name; lblPosition_Value = lblLongitude_Value; grbBaseData.Controls.Add(lblAltitude_Name); grbBaseData.Controls.Add(lblAltitude_Value); grbBaseData.Controls.Add(lblLocation_Name); grbBaseData.Controls.Add(lblLocation_Value); grbBaseData.Controls.Add(lblLongitude_Name); grbBaseData.Controls.Add(lblLongitude_Value); lblLongitude_Name.AutoSize = lblLongitude_Value.AutoSize = lblAltitude_Name.AutoSize = lblAltitude_Value.AutoSize = lblLocation_Name.AutoSize = lblLocation_Value.AutoSize = true; lblLongitude_Name.Visible = lblLongitude_Value.Visible = lblAltitude_Name.Visible = lblAltitude_Value.Visible = lblLocation_Name.Visible = lblLocation_Value.Visible = true; lblAltitude_Value.ForeColor = lblLocation_Value.ForeColor = lblLongitude_Value.ForeColor = Color.White; int intValueLabelsLeft = 219; int intVerticalGapBetweenLabels = 19; lblLongitude_Value.Left = lblAltitude_Value.Left = lblLocation_Value.Left = intValueLabelsLeft; lblLongitude_Value.Top = lblLongitude_Name.Top = 9; lblAltitude_Name.Top = lblAltitude_Value.Top = lblLongitude_Name.Top + intVerticalGapBetweenLabels; lblLocation_Name.Top = lblLocation_Value.Top = lblAltitude_Value.Top + intVerticalGapBetweenLabels; lblLongitude_Name.Text = "Longitude"; lblLongitude_Name.Left = intValueLabelsLeft - 5 - lblLongitude_Name.Width; lblAltitude_Name.Text = "Altitude"; lblAltitude_Name.Left = intValueLabelsLeft - 5 - lblAltitude_Name.Width; lblLocation_Name.Text = "Location"; lblLocation_Name.Left = intValueLabelsLeft - 5 - lblLocation_Name.Width; grbBaseData.Height = lblLocation_Name.Top + lblLocation_Name.Height + 5; grbBaseData.Width = intValueLabelsLeft + 200; } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)