public static void DrawObjectPointedAtStatus(GraphicsDevice graphicsDevice, Cursor cursor, Camera gameCamera, Game game, SpriteBatch spriteBatch, Fish[] fish, int fishAmount, BaseEnemy[] enemies, int enemiesAmount, List<Trash> trashes, List<ShipWreck> shipWrecks, List<Factory> factories, ResearchFacility researchFacility, List<TreasureChest> treasureChests, List<Powerpack> powerPacks, List<Resource> resources) { bool somethingPointedAt = false; string name = ""; Vector3 position = Vector3.Zero; //Display Fish Health Fish fishPointedAt = CursorManager.MouseOnWhichFish(cursor, gameCamera, fish, fishAmount); if (fishPointedAt != null) { swimmingObjName = fishPointedAt.Name; swimmingObjHealth = (int)fishPointedAt.health; swimmingObjMaxHealth = (int)fishPointedAt.maxHealth; IngamePresentation.DrawHealthBar(game, spriteBatch, statsFont, swimmingObjHealth, swimmingObjMaxHealth, 5, swimmingObjName, 1.0f); //string fishTalk; fishTalk = "'"; if (fishPointedAt.health < 20) { fishTalk += "SAVE ME!!!"; } else if (fishPointedAt.health < 60) { fishTalk += IngamePresentation.wrapLine(fishPointedAt.sad_talk, commentMaxLength, fishTalkFont, textScaleFactor); } else { fishTalk += IngamePresentation.wrapLine(fishPointedAt.happy_talk, commentMaxLength, fishTalkFont, textScaleFactor); } fishTalk += "'"; spriteBatch.DrawString(fishTalkFont, fishTalk, new Vector2(game.Window.ClientBounds.Width / 2, 4 + (fishTalkFont.MeasureString(swimmingObjName).Y + fishTalkFont.MeasureString(fishTalk).Y / 2 + lineSpacing) * textScaleFactor), Color.Yellow, 0, new Vector2(fishTalkFont.MeasureString(fishTalk).X / 2, fishTalkFont.MeasureString(fishTalk).Y / 2), textScaleFactor, SpriteEffects.None, 0); somethingPointedAt = true; fishWasPointedAt = true; enemyWasPointedAt = nonLivingObjWasPointedAt = false; } else { //fishWasPointedAt = false; //Display Enemy Health BaseEnemy enemyPointedAt = CursorManager.MouseOnWhichEnemy(cursor, gameCamera, enemies, enemiesAmount); if (enemyPointedAt != null) { swimmingObjName = enemyPointedAt.Name; swimmingObjHealth = (int)enemyPointedAt.health; swimmingObjMaxHealth = (int)enemyPointedAt.maxHealth; IngamePresentation.DrawHealthBar(game, spriteBatch, statsFont, swimmingObjHealth, swimmingObjMaxHealth, 5, swimmingObjName, 1.0f); somethingPointedAt = true; enemyWasPointedAt = true; fishWasPointedAt = nonLivingObjWasPointedAt = false; } else { //enemyWasPointedAt = false; line = comment = tip = tip2 = ""; Powerpack powerPackPointedAt = null, botOnPowerPack = null; CursorManager.MouseOnWhichPowerPack(cursor, gameCamera, powerPacks, ref powerPackPointedAt, ref botOnPowerPack, null); if (powerPackPointedAt != null) { line = ""; comment = ""; if (powerPackPointedAt.powerType == PowerPackType.Speed) { line = "SPEED BOOST POWERPACK"; name = "Speed Boost Powerpack"; comment = "Temporarily doubles Hydrobot's movement speed."; } else if (powerPackPointedAt.powerType == PowerPackType.Strength) { line = "STRENGTH BOOST POWERPACK"; name = "Strength Boost Powerpack"; comment = "Temporarily doubles Hydrobot's power."; } else if (powerPackPointedAt.powerType == PowerPackType.FireRate) { line = "SHOOT RATE BOOST POWERPACK"; name = "Shoot Rate Boost Powerpack"; comment = "Temporarily doubles Hydrobot's shooting speed."; } else if (powerPackPointedAt.powerType == PowerPackType.Health) { line = "HEALTH BOOST POWERPACK"; name = "Health Boost Powerpack"; comment = "Replenishes Hydrobot's health."; } else if (powerPackPointedAt.powerType == PowerPackType.StrangeRock) { line = "STRANGE ROCK"; name = "Strange Rock"; comment = "A rock that exhibits abnormal characteristics. Can be dropped at Research Center for analysing."; } else if (powerPackPointedAt.powerType == PowerPackType.GoldenKey) { line = "GOLDEN KEY"; name = "Golden Key"; comment = "Can open any treasure chest."; } position = powerPackPointedAt.Position; tip = "Press Z to collect"; } else { Resource resourcePointedAt = null, botOnResource = null; CursorManager.MouseOnWhichResource(cursor, gameCamera, resources, ref resourcePointedAt, ref botOnResource, null); if (resourcePointedAt != null) { line = "RECYCLED RESOURCE BOX"; name = "Recycled Resource Box"; comment = "A box contains recycled resource produced by the processing plant. Recycled resources can be used to construct new facilities."; tip = "Press Z to collect"; position = resourcePointedAt.Position; } else { TreasureChest chestPointedAt = CursorManager.MouseOnWhichChest(cursor, gameCamera, treasureChests); if (chestPointedAt != null) { line = "TREASURE CHEST"; name = "Treasure Chest"; comment = "Contains valuables sunk with the ship hundreds years ago."; tip = "Double click to open"; position = chestPointedAt.Position; } Trash trashPointedAt = null, botOnTrash = null; CursorManager.MouseOnWhichTrash(cursor, gameCamera, trashes, ref trashPointedAt, ref botOnTrash, null); if (trashPointedAt != null) { line = ""; comment = ""; if (trashPointedAt.trashType == TrashType.biodegradable) { line += "BIODEGRADABLE WASTE"; name = "Biodegradable Waste"; comment = "Great source of renewable energy."; tip = "Press Z to collect"; } else if (trashPointedAt.trashType == TrashType.plastic) { line += "PLASTIC WASTE"; name = "Plastic Waste"; comment = "May take more than 500 years to decompose."; tip = "Press X to collect"; } else { line += "RADIOACTIVE WASTE"; name = "Radioactive Waste"; comment = "An invisible speck can cause cancer."; tip = "Press C to collect"; } position = trashPointedAt.Position; } else { ShipWreck shipPointedAt = CursorManager.MouseOnWhichShipWreck(cursor, gameCamera, shipWrecks); if (shipPointedAt != null) { line = ""; comment = ""; line = "OLD SHIPWRECK"; name = "Old Shipwreck"; comment = "Sunk hundreds years ago."; tip = "Double click to enter"; position = shipPointedAt.Position; } else { Factory factoryPointedAt = CursorManager.MouseOnWhichFactory(cursor, gameCamera, factories); if (factoryPointedAt != null) { line = ""; comment = ""; if (factoryPointedAt.factoryType == FactoryType.biodegradable) { line += "BIODEGRADABLE WASTE PROCESSING PLANT"; name = "Biodegradable Waste Processing Plant"; comment = "Organic wastes can be dropped here for processing."; } else if (factoryPointedAt.factoryType == FactoryType.plastic) { line += "PLASTIC WASTE PROCESSING PLANT"; name = "Plastic Waste Processing Plant"; comment = "Plastic wastes can be dropped here for processing."; } else { line += "RADIOACTIVE WASTE PROCESSING PLANT"; name = "Radioactive Waste Processing Plant"; comment = "Radioactive wastes can be dropped here for processing."; } position = factoryPointedAt.Position; tip = "Double click to drop collected wastes"; tip2 = "Shift + Click to open control panel"; } else { if (CursorManager.MouseOnResearchFacility(cursor, gameCamera, researchFacility)) { line = "RESEARCH FACILITY"; name = "Research Facility"; position = researchFacility.Position; comment = "Researches on upgrading plants and Hydrobot, analysing abnormal objects and resurrecting extinct animals from DNA."; tip = "Double click to drop collected objects"; tip2 = "Shift + Click to open control panel"; } } } } } } //draw name right over obj pointed at if (GameSettings.ShowLiveTip && name != "") { Vector3 screenPos = graphicsDevice.Viewport.Project(position - new Vector3(0, 0, 20), gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity); Vector2 twoDPos; twoDPos.X = screenPos.X; twoDPos.Y = screenPos.Y; spriteBatch.DrawString(IngamePresentation.fishTalkFont, name, twoDPos, Color.Gold, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(name).X / 2, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); if (tip != "") spriteBatch.DrawString(IngamePresentation.fishTalkFont, tip, twoDPos + new Vector2(0, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2 + 5 + IngamePresentation.fishTalkFont.MeasureString(tip).Y / 2) * IngamePresentation.textScaleFactor, Color.White, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(tip).X / 2, IngamePresentation.fishTalkFont.MeasureString(tip).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); if (tip2 != "") spriteBatch.DrawString(IngamePresentation.fishTalkFont, tip2, twoDPos + new Vector2(0, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2 + 5 + IngamePresentation.fishTalkFont.MeasureString(tip).Y + 5 + IngamePresentation.fishTalkFont.MeasureString(tip2).Y / 2) * IngamePresentation.textScaleFactor, Color.White, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(tip2).X / 2, IngamePresentation.fishTalkFont.MeasureString(tip2).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); } if (line != "" && comment != "") { nonLivingObjWasPointedAt = true; somethingPointedAt = true; enemyWasPointedAt = fishWasPointedAt = false; } //else nonLivingObjWasPointedAt = false; if (somethingPointedAt) { spriteBatch.DrawString(statsFont, line, new Vector2(game.Window.ClientBounds.Width / 2, 4 + statsFont.MeasureString(line).Y / 2 * textScaleFactor), Color.Yellow, 0, new Vector2(statsFont.MeasureString(line).X / 2, statsFont.MeasureString(line).Y / 2), textScaleFactor, SpriteEffects.None, 0); comment = wrapLine(comment, commentMaxLength, statsFont, textScaleFactor); tip = wrapLine(tip, commentMaxLength, statsFont, textScaleFactor); Vector2 commentPos = new Vector2(game.Window.ClientBounds.Width / 2, 4 + (statsFont.MeasureString(line).Y + lineSpacing + statsFont.MeasureString(comment).Y / 2) * textScaleFactor); spriteBatch.DrawString(statsFont, comment, commentPos, Color.Red, 0, new Vector2(statsFont.MeasureString(comment).X / 2, statsFont.MeasureString(comment).Y / 2), textScaleFactor, SpriteEffects.None, 0); //Vector2 tipPos = commentPos + new Vector2(0, statsFont.MeasureString(comment).Y / 2 + lineSpacing + statsFont.MeasureString(tip).Y / 2) * textScaleFactor; //spriteBatch.DrawString(statsFont, tip, tipPos, Color.LightCyan, 0, new Vector2(statsFont.MeasureString(tip).X / 2, statsFont.MeasureString(tip).Y / 2), textScaleFactor, SpriteEffects.None, 0); //if (tip2 != "") //{ // Vector2 tip2Pos = tipPos + new Vector2(0, statsFont.MeasureString(tip).Y / 2 + lineSpacing + statsFont.MeasureString(tip2).Y / 2) * textScaleFactor; // spriteBatch.DrawString(statsFont, tip2, tip2Pos, Color.LightCyan, 0, new Vector2(statsFont.MeasureString(tip2).X / 2, statsFont.MeasureString(tip2).Y / 2), textScaleFactor, SpriteEffects.None, 0); //} prevLine = line; prevComment = comment; prevTip = tip; prevTip2 = tip2; } } } //if nothing is pointed at now, draw the old obj-pointed messages which fade through time if (!somethingPointedAt) { opaqueValue -= (float)(fadeStep * 20 * (PoseidonGame.playTime.TotalMilliseconds - lastFadeChange) / 1000); lastFadeChange = PoseidonGame.playTime.TotalMilliseconds; if (opaqueValue <= 0) opaqueValue = 0; if (nonLivingObjWasPointedAt) { spriteBatch.DrawString(statsFont, prevLine, new Vector2(game.Window.ClientBounds.Width / 2, 4 + statsFont.MeasureString(prevLine).Y / 2 * textScaleFactor), Color.Yellow * opaqueValue, 0, new Vector2(statsFont.MeasureString(prevLine).X / 2, statsFont.MeasureString(prevLine).Y / 2), textScaleFactor, SpriteEffects.None, 0); //comment = wrapLine(comment, commentMaxLength, statsFont, textScaleFactor); //tip = wrapLine(tip, commentMaxLength, statsFont, textScaleFactor); Vector2 commentPos = new Vector2(game.Window.ClientBounds.Width / 2, 4 + (statsFont.MeasureString(prevLine).Y + lineSpacing + statsFont.MeasureString(prevComment).Y / 2) * textScaleFactor); spriteBatch.DrawString(statsFont, prevComment, commentPos, Color.Red * opaqueValue, 0, new Vector2(statsFont.MeasureString(prevComment).X / 2, statsFont.MeasureString(prevComment).Y / 2), textScaleFactor, SpriteEffects.None, 0); //Vector2 tipPos = commentPos + new Vector2(0, statsFont.MeasureString(prevComment).Y / 2 + lineSpacing + statsFont.MeasureString(prevTip).Y / 2) * textScaleFactor; //spriteBatch.DrawString(statsFont, prevTip, tipPos, Color.LightCyan * opaqueValue, 0, new Vector2(statsFont.MeasureString(prevTip).X / 2, statsFont.MeasureString(prevTip).Y / 2), textScaleFactor, SpriteEffects.None, 0); //if (prevTip2 != "") //{ // Vector2 tip2Pos = tipPos + new Vector2(0, statsFont.MeasureString(prevTip).Y / 2 + lineSpacing + statsFont.MeasureString(prevTip2).Y / 2) * textScaleFactor; // spriteBatch.DrawString(statsFont, prevTip2, tip2Pos, Color.LightCyan * opaqueValue, 0, new Vector2(statsFont.MeasureString(prevTip2).X / 2, statsFont.MeasureString(prevTip2).Y / 2), textScaleFactor, SpriteEffects.None, 0); //} } if (fishWasPointedAt) { //IngamePresentation.DrawHealthBar(game, spriteBatch, statsFont, swimmingObjHealth, swimmingObjMaxHealth, 5, swimmingObjName, opaqueValue); swimmingObjName = swimmingObjName.ToUpper(); spriteBatch.DrawString(statsFont, swimmingObjName, new Vector2(game.Window.ClientBounds.Width / 2 - statsFont.MeasureString(swimmingObjName).X / 2 * textScaleFactor, 5 - 1), Color.MediumVioletRed * opaqueValue, 0, Vector2.Zero, textScaleFactor, SpriteEffects.None, 0); spriteBatch.DrawString(fishTalkFont, fishTalk, new Vector2(game.Window.ClientBounds.Width / 2, 4 + (fishTalkFont.MeasureString(swimmingObjName).Y + fishTalkFont.MeasureString(fishTalk).Y / 2 + lineSpacing) * textScaleFactor), Color.Yellow * opaqueValue, 0, new Vector2(fishTalkFont.MeasureString(fishTalk).X / 2, fishTalkFont.MeasureString(fishTalk).Y / 2), textScaleFactor, SpriteEffects.None, 0); } //if (enemyWasPointedAt) //{ // IngamePresentation.DrawHealthBar(game, spriteBatch, statsFont, swimmingObjHealth, swimmingObjMaxHealth, 5, swimmingObjName, opaqueValue); //} } else { opaqueValue = startingOpaqueValue; } }
public static void DrawObjectUnderStatus(SpriteBatch spriteBatch, Camera gameCamera, HydroBot hydroBot, GraphicsDevice graphicsDevice, List<Powerpack> powerPacks, List<Resource> resources, List<Trash> trashes, List<TreasureChest> chests, List<ShipWreck> shipWrecks, List<Factory> factories, ResearchFacility researchFacility) { if (!GameSettings.ShowLiveTip) return; //for highlighting obj under bot Powerpack powerPackPointedAt1 = null, botOnPowerPack1 = null; CursorManager.MouseOnWhichPowerPack(null, gameCamera, powerPacks, ref powerPackPointedAt1, ref botOnPowerPack1, hydroBot); string name = "", interaction = "", interaction2 = ""; Vector2 twoDPos = Vector2.Zero; if (botOnPowerPack1 != null) { Vector3 screenPos = graphicsDevice.Viewport.Project(botOnPowerPack1.Position, gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity); twoDPos.X = screenPos.X; twoDPos.Y = screenPos.Y; if (botOnPowerPack1.powerType != PowerPackType.GoldenKey) name = "Power Pack"; else name = "Golden Key"; interaction = "Press Z to collect"; spriteBatch.DrawString(IngamePresentation.fishTalkFont, name, twoDPos, Color.Gold, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(name).X / 2, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); spriteBatch.DrawString(IngamePresentation.fishTalkFont, interaction, twoDPos + new Vector2(0, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2 + 5 + IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2) * IngamePresentation.textScaleFactor, Color.White, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(interaction).X / 2, IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); } else { Resource resourcePackPointedAt1 = null, botOnResource1 = null; CursorManager.MouseOnWhichResource(null, gameCamera, resources, ref resourcePackPointedAt1, ref botOnResource1, hydroBot); if (botOnResource1 != null) { Vector3 screenPos = graphicsDevice.Viewport.Project(botOnResource1.Position, gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity); twoDPos.X = screenPos.X; twoDPos.Y = screenPos.Y; name = "Recycled Resource Box"; interaction = "Press Z to collect"; spriteBatch.DrawString(IngamePresentation.fishTalkFont, name, twoDPos, Color.Gold, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(name).X / 2, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); spriteBatch.DrawString(IngamePresentation.fishTalkFont, interaction, twoDPos + new Vector2(0, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2 + 5 + IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2) * IngamePresentation.textScaleFactor, Color.White, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(interaction).X / 2, IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); } else { TreasureChest botOverChest = CursorManager.BotOverWhichChest(hydroBot, chests); if (botOverChest != null) { Vector3 screenPos = graphicsDevice.Viewport.Project(botOverChest.Position, gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity); twoDPos.X = screenPos.X; twoDPos.Y = screenPos.Y; name = "Treasure Chest"; interaction = "Double click to open"; spriteBatch.DrawString(IngamePresentation.fishTalkFont, name, twoDPos, Color.Gold, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(name).X / 2, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); spriteBatch.DrawString(IngamePresentation.fishTalkFont, interaction, twoDPos + new Vector2(0, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2 + 5 + IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2) * IngamePresentation.textScaleFactor, Color.White, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(interaction).X / 2, IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); } Trash trashPointedAt1 = null, botOnTrash1 = null; CursorManager.MouseOnWhichTrash(null, gameCamera, trashes, ref trashPointedAt1, ref botOnTrash1, hydroBot); if (botOnTrash1 != null) { Vector3 screenPos = graphicsDevice.Viewport.Project(botOnTrash1.Position, gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity); twoDPos.X = screenPos.X; twoDPos.Y = screenPos.Y; if (botOnTrash1.trashType == TrashType.biodegradable) { name = "Biodegradable Waste"; interaction = "Press Z to collect"; } else if (botOnTrash1.trashType == TrashType.plastic) { name = "Plastic Waste"; interaction = "Press X to collect"; } else if (botOnTrash1.trashType == TrashType.radioactive) { name = "Radioactive Waste"; interaction = "Press C to collect"; } spriteBatch.DrawString(IngamePresentation.fishTalkFont, name, twoDPos, Color.Gold, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(name).X / 2, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); spriteBatch.DrawString(IngamePresentation.fishTalkFont, interaction, twoDPos + new Vector2(0, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2 + 5 + IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2) * IngamePresentation.textScaleFactor, Color.White, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(interaction).X / 2, IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); } else { ShipWreck botOverShipWreck = CursorManager.BotOverWhichShipWreck(hydroBot, shipWrecks); if (botOverShipWreck != null) { Vector3 screenPos = graphicsDevice.Viewport.Project(botOverShipWreck.Position, gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity); twoDPos.X = screenPos.X; twoDPos.Y = screenPos.Y; name = "Old Shipwreck"; interaction = "Double click to enter"; spriteBatch.DrawString(IngamePresentation.fishTalkFont, name, twoDPos, Color.Gold, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(name).X / 2, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); spriteBatch.DrawString(IngamePresentation.fishTalkFont, interaction, twoDPos + new Vector2(0, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2 + 5 + IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2) * IngamePresentation.textScaleFactor, Color.White, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(interaction).X / 2, IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); } else { Factory botOverFactory = CursorManager.BotOverWhichFactory(hydroBot, factories); if (botOverFactory != null) { if (botOverFactory.factoryType == FactoryType.biodegradable) { name = "Biodegradable Waste Processing Plant"; } else if (botOverFactory.factoryType == FactoryType.plastic) { name = "Plastic Waste Processing Plant"; } else { name = "Radioactive Waste Processing Plant"; } interaction = "Double click to drop collected wastes"; interaction2 = "Shift + Click to open control panel"; Vector3 screenPos = graphicsDevice.Viewport.Project(botOverFactory.Position - new Vector3(0, 0, 20), gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity); twoDPos.X = screenPos.X; twoDPos.Y = screenPos.Y; } if (CursorManager.BotOverResearchFacility(hydroBot, researchFacility)) { name = "Research Facility"; interaction = "Double click to drop collected objects"; interaction2 = "Shift + Click to open control panel"; Vector3 screenPos = graphicsDevice.Viewport.Project(researchFacility.Position - new Vector3(0, 0, 20), gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity); twoDPos.X = screenPos.X; twoDPos.Y = screenPos.Y; } spriteBatch.DrawString(IngamePresentation.fishTalkFont, name, twoDPos, Color.Gold, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(name).X / 2, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); spriteBatch.DrawString(IngamePresentation.fishTalkFont, interaction, twoDPos + new Vector2(0, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2 + 5 + IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2) * IngamePresentation.textScaleFactor, Color.White, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(interaction).X / 2, IngamePresentation.fishTalkFont.MeasureString(interaction).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); spriteBatch.DrawString(IngamePresentation.fishTalkFont, interaction2, twoDPos + new Vector2(0, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2 + 5 + IngamePresentation.fishTalkFont.MeasureString(interaction).Y + 5 + IngamePresentation.fishTalkFont.MeasureString(interaction2).Y/2) * IngamePresentation.textScaleFactor, Color.White, 0, new Vector2(IngamePresentation.fishTalkFont.MeasureString(interaction2).X / 2, IngamePresentation.fishTalkFont.MeasureString(interaction2).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0); } } } } }
public void PrepareEdgeDetect(HydroBot hydroBot, Cursor cursor, Camera gameCamera, Fish[] fish, int fishAmount, BaseEnemy[] enemies, int enemiesAmount, List<Trash> trashes, List<ShipWreck> shipWrecks, List<Factory> factories, ResearchFacility researchFacility, List<TreasureChest> treasureChests, List<Powerpack> powerPacks, List<Resource> resources, GraphicsDevice graphicsDevice, RenderTarget2D normalDepthRenderTargetLow, RenderTarget2D normalDepthRenderTargetHigh) { graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow); graphicsDevice.Clear(Color.Black); graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh); graphicsDevice.Clear(Color.Black); if (!GameSettings.SpecialEffectsEnabled) return; graphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; Fish fishPointedAt = CursorManager.MouseOnWhichFish(cursor, gameCamera, fish, fishAmount); if (fishPointedAt != null) { graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh); fishPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth"); edgeDetectionParameters["EdgeColor"].SetValue(new Vector4(0, 1, 0, 1)); } else { BaseEnemy enemyPointedAt = CursorManager.MouseOnWhichEnemy(cursor, gameCamera, enemies, enemiesAmount); if (enemyPointedAt != null) { graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh); enemyPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth"); edgeDetectionParameters["EdgeColor"].SetValue(new Vector4(1, 0, 0, 1)); } else { Powerpack powerPackPointedAt = null, botOnPowerPack = null; CursorManager.MouseOnWhichPowerPack(cursor, gameCamera, powerPacks, ref powerPackPointedAt, ref botOnPowerPack, null); if (powerPackPointedAt != null) { graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh); powerPackPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth"); edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4()); } else { Resource resourcePackPointedAt = null, botOnResource = null; CursorManager.MouseOnWhichResource(cursor, gameCamera, resources, ref resourcePackPointedAt, ref botOnResource, null); if (resourcePackPointedAt != null) { graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh); resourcePackPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth"); edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4()); } else { TreasureChest chestPointedAt = CursorManager.MouseOnWhichChest(cursor, gameCamera, treasureChests); if (chestPointedAt != null) { graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow); chestPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth"); edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4()); } Trash trashPointedAt = null, botOnTrash = null; CursorManager.MouseOnWhichTrash(cursor, gameCamera, trashes, ref trashPointedAt, ref botOnTrash, null); if (trashPointedAt != null) { if (trashPointedAt.sinking) graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh); else graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow); trashPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth"); edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4()); } else { ShipWreck shipPointedAt = CursorManager.MouseOnWhichShipWreck(cursor, gameCamera, shipWrecks); if (shipPointedAt != null) { graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow); shipPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth"); edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4()); } else { Factory factoryPointedAt = CursorManager.MouseOnWhichFactory(cursor, gameCamera, factories); if (factoryPointedAt != null) { graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow); factoryPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth"); edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4()); } else { if (CursorManager.MouseOnResearchFacility(cursor, gameCamera, researchFacility)) { graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow); researchFacility.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth"); edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4()); } } } } } } } } graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; }