public static void MouseOnWhichResource(Cursor cursor, Camera gameCamera, List<Resource> resources, ref Resource cursorOnResource, ref Resource botOnResource, HydroBot hydroBot) { bool foundBotOnResource = false, foundCursorOnResource = false; if (hydroBot == null) foundBotOnResource = true; if (cursor == null) foundCursorOnResource = true; BoundingSphere botPowerPackBoundingSphere = new BoundingSphere(); if (!foundBotOnResource) botPowerPackBoundingSphere = new BoundingSphere(hydroBot.BoundingSphere.Center, 5); if (resources == null) return; Ray cursorRay = new Ray(); if (cursor != null) cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix); foreach (Resource resource in resources) { if (!foundBotOnResource) { if (resource.BoundingSphere.Intersects(botPowerPackBoundingSphere)) { foundBotOnResource = true; botOnResource = resource; } } if (!foundCursorOnResource) { if (RayIntersectsBoundingSphere(cursorRay, resource.BoundingSphere)) { foundCursorOnResource = true; cursorOnResource = resource; } } if (foundBotOnResource && foundCursorOnResource) return; } }
void ProduceResource(ref List<Resource> resources, List<Powerpack> powerpacks, ref Model resourceModel) { Vector3 resourcePosition; Resource resource = new Resource(); resourcePosition = findResourcePowerpackPosition(Position, resources, powerpacks); resource.Model = resourceModel; resource.LoadContent(resourcePosition); resources.Add(resource); }