public static void Draw(SpriteBatch sB) { sB.Begin(); //Draw layout if (uiTopBkg != null) { sB.Draw(uiTopBkg, uiTop, Color.White); } if (uiRightBkg != null) { sB.Draw(uiRightBkg, uiRight, Color.White); } if (uiRightBottomBkg != null) { sB.Draw(uiRightBottomBkg, uiRightBottom, Color.White); } if (uiRightTopBkg != null) { sB.Draw(uiRightTopBkg, uiRightTop, Color.White); } if (uiRightMiddleBkg != null) { sB.Draw(uiRightMiddleBkg, uiRightMiddle, Color.White); } if (uiHorizontalBkg != null) { sB.Draw(uiHorizontalBkg, uiHoriz1, Color.White); sB.Draw(uiHorizontalBkg, uiHoriz2, Color.White); } //Draw selection-specific commands if (SelectedObjectType == SelectedType.MultipleUnits || SelectedObjectType == SelectedType.Unit) { if (uiButtonDestroy != null) { sB.Draw(uiButtonDestroy, uiCmd1, Color.White); } if (uiButtonStop != null) { sB.Draw(uiButtonStop, uiCmd2, Color.White); } if (uiButtonMove != null) { sB.Draw(uiButtonMove, uiCmd3, Color.White); } if (uiButtonAttack != null) { sB.Draw(uiButtonAttack, uiCmd4, Color.White); } if (SelectedObject.name == "MCV") { if (uiButtonDeploy != null) { sB.Draw(uiButtonDeploy, uiCmd4, Color.White); } } if (SelectedObject.name == "Harvester") { if (uiButtonHarvest != null) { sB.Draw(uiButtonHarvest, uiCmd4, Color.White); } } if (SelectedObjectType == SelectedType.Unit) { Texture2D pict = Textures.GetPictureReference(((Unit)SelectedObject).pictureName); if (pict != null) { sB.Draw(pict, uiPicture, Color.White); } } } else if (SelectedObjectType == SelectedType.Building || SelectedObjectType == SelectedType.MultipleUnits) { if (uiButtonDestroy != null) { sB.Draw(uiButtonDestroy, uiCmd1, Color.White); } if (uiButtonRepair != null) { sB.Draw(uiButtonRepair, uiCmd2, Color.White); } Texture2D pict = Textures.GetPictureReference(((Building)SelectedObject).pictureName); if (pict != null) { sB.Draw(pict, uiPicture, Color.White); } //Available constructions if (SelectedObjectType == SelectedType.Building) { Building b = (Building)SelectedObject; if (b.IsBeingBuilt == false) { int c = 0; //c can NOT exceed 8... if there are too many buildings in Dune.xml => exception is being thrown :D //add xml validation someday... for (int i = 0; i < b.canProduceBuildings.Count; i++) { sB.Draw(Textures.GetPictureReference(GlobalData.gameSettings.GetBuildingByName(b.canProduceBuildings[i]).pictureName), objectsToBuild[c], Color.White); c++; } for (int i = 0; i < b.canProduceUnits.Count; i++) { sB.Draw(Textures.GetPictureReference(GlobalData.gameSettings.GetUnitByName(b.canProduceUnits[i]).pictureName), objectsToBuild[c], Color.White); c++; } } } } if (SelectedObjectType == SelectedType.Building || SelectedObjectType == SelectedType.Unit) { float ratio = SelectedObject.currentHealth / SelectedObject.maxHealth; Color clr = new Color((byte)(255 * (1 - ratio)), (byte)(255 * ratio), 0); Rectangle rc = new Rectangle(uiHealth.X, uiHealth.Y, (int)(uiHealth.Width * ratio), uiHealth.Height); sB.Draw(Textures.GetPictureReference("MiniMap_Object"), uiHealth, Color.White); sB.Draw(Textures.GetPictureReference("MiniMap_Object"), rc, clr); } sB.End(); bf.DrawString(exitButton.X, exitButton.Y, Color.Black, Properties.Resources.UI_Exit); string spice = Properties.Resources.UI_Credits + Supplies.spice.ToString(); string energy = Properties.Resources.UI_Energy + Supplies.energy.ToString() + Properties.Resources.UI_EnergyCreditsSeparator; int spiceStart = uiTop.Right - bf.MeasureString(spice) - exitButton.X; int energyStart = spiceStart - bf.MeasureString(energy); bf.DrawString(spiceStart, exitButton.Y, Color.Black, spice); bf.DrawString(energyStart, exitButton.Y, Color.Black, energy); }