private void DrawBBOnUnits(ModelClasses.Player a_player, Camera a_camera, GraphicsDevice a_gd) { BoundingBoxBuffer.m_color = Color.White; foreach (ModelClasses.Units.Unit unit in a_player.m_units) { GameView.DrawBoundingBox((BoundingBox)unit.m_model.Tag, a_gd, a_camera.GetWorldMatrix(unit.m_currentposition), a_camera); } }
/// <summary> /// Draws a player (computers are players aswell, let's not be discriminating) /// </summary> private void DrawPlayer(ModelClasses.Player a_player, GameAssets a_gameAsset) { //It's a switch because of scale levels, if it was 6 players a switch is better than if :) switch (a_player.m_playerID) { case 0: SetPlayerColor(ref m_player1Color, a_gameAsset); break; case 1: SetPlayerColor(ref m_player2Color, a_gameAsset); break; case 2: SetPlayerColor(ref m_player3Color, a_gameAsset); break; case 3: SetPlayerColor(ref m_player4Color, a_gameAsset); break; default: break; } //draw units foreach (ModelClasses.Units.Thing unit in a_player.m_units) { DrawThing(unit); } //draw buildings foreach (ModelClasses.Units.Thing building in a_player.m_buildings) { DrawThing(building); } //Draws buildingObjects foreach (ModelClasses.Units.BuildingObject bo in a_player.m_buildObjects) { if (bo.m_isBuilding) { DrawThing(bo.m_object); } } }
//Draws a selected units stats private void DrawInfo(SpriteBatch a_spriteBatch, GameAssets a_gameAssets, ModelClasses.Player a_player) { //TEMP to see the info area - I c wut u did thar /Tiger! a_spriteBatch.Draw(a_gameAssets.m_button, m_infoArea, Color.Violet); if (a_player.m_focusedTarget != null) { //Format text string f_info = string.Format("HP: {0}/{1}\n", a_player.m_focusedTarget.HP, a_player.m_focusedTarget.m_maxHP); if (a_player.m_focusedTarget.m_builtTimer < a_player.m_focusedTarget.m_requiredBuildTime) { m_buildProgress.SetProgress(a_player.m_focusedTarget.m_builtTimer / a_player.m_focusedTarget.m_requiredBuildTime); string f_buildingInfo = string.Format("{0:0.0} / {1:0.0} {2:0.0}% \nBuilding: {3}", a_player.m_focusedTarget.m_builtTimer, a_player.m_focusedTarget.m_requiredBuildTime, m_buildProgress.Percentage * 100, GetUnitName(a_player.m_focusedTarget.m_type)); a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_rectangle, Color.DarkGray); a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_progressArea, Color.Green); a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_buildingInfo, m_buildInfo, Color.White); } //Special hud info for special types, like extractor needs to write how many sols it has left switch (a_player.m_focusedTarget.m_type) { case ModelClasses.Units.ThingType.C_Extractor: Extractor f_tempExtractor = (Extractor)a_player.m_focusedTarget; if (f_tempExtractor.m_SoL != null && f_tempExtractor.m_SoL.m_resources >= 0) { f_info += "SoLs: " + f_tempExtractor.m_SoL.m_resources; } else { f_info += "SoLs: Depleted"; } break; } if (a_player.m_focusedTarget.m_buildBehavior != null) { if (a_player.m_focusedTarget.m_buildBehavior.IsBuilding()) { ThingType f_type = a_player.m_focusedTarget.m_buildBehavior.GetBuildingType(); float a_requiredBuildTime = a_player.m_thingsAssets.GetThing(f_type).m_requiredBuildTime; m_buildProgress.SetProgress(a_player.m_focusedTarget.m_buildBehavior.GetBuildTimer() / a_requiredBuildTime); string f_buildingInfo = string.Format("Building: {0}\n{1:0.0} / {2:0.0} {3:0.0}% ", HUD.GetUnitName(f_type), a_player.m_focusedTarget.m_buildBehavior.GetBuildTimer(), a_requiredBuildTime, m_buildProgress.Percentage * 100); a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_rectangle, Color.DarkGray); a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_progressArea, Color.Green); a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_buildingInfo, m_buildInfo, Color.White); } if (a_player.m_focusedTarget.m_buildBehavior is ModelClasses.BehaviorInterfaces.StandardBuild) { f_info += "Workers: " + a_player.m_focusedTarget.m_buildBehavior.GetSacrificeCount(); } } //Checks if the attack behavior is null or not! to write out that data! if (a_player.m_focusedTarget.m_attackBehavior != null) { f_info += string.Format("Damage: {0} \nRange: {1}", a_player.m_focusedTarget.m_attackBehavior.GetDamage(), a_player.m_focusedTarget.m_attackBehavior.GetAttackRange()); } if (a_player.m_selectedThings.Count > 1) { //Should have draw portraits or something here instead, just temp stuff.. I wanna see selected info!!! //Extremely temp code if (a_player.m_focusedTarget.m_isUnit) { string f_selectedInfo = string.Format("Units selected: {0}", a_player.m_selectedThings.Count); a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_selectedInfo, new Vector2(m_infoAreaPadded.X + m_infoArea.Width * 0.5f, m_area.Bottom - 45), Color.White); } else { string f_selectedInfo = string.Format("Buildings selected: {0}", a_player.m_selectedThings.Count); a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_selectedInfo, new Vector2(m_infoAreaPadded.X + m_infoArea.Width * 0.5f, m_area.Bottom - 45), Color.White); } } //Draw text a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_info, m_infoAreaPadded, Color.White); } else if (a_player.m_selectedWorldObject != null) { if (a_player.m_selectedWorldObject.m_type == WorldObjectType.SoL) { //Creates a sol variable to access the SoL variables SoL f_SoL = (SoL)a_player.m_selectedWorldObject; string f_info = string.Format("SoLs: {0}", f_SoL.m_resources); a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_info, m_infoAreaPadded, Color.White); } } }