public static bool BotOverResearchFacility(HydroBot hydroBot, ResearchFacility researchFacility) { if (researchFacility == null) return false; if (hydroBot.BoundingSphere.Intersects(researchFacility.BoundingSphere)) { return true; } return false; }
public static bool MouseOnResearchFacility(Cursor cursor, Camera gameCamera, ResearchFacility researchFacility) { if (researchFacility == null) return false; BoundingSphere researchFacilityRealSphere; Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix); researchFacilityRealSphere = researchFacility.BoundingSphere; researchFacilityRealSphere.Center.Y = researchFacility.Position.Y; researchFacilityRealSphere.Radius *= 1; if (RayIntersectsBoundingSphere(cursorRay, researchFacilityRealSphere)) { return true; } else return false; }
// Add new factory in the game arena if conditions for adding them satisty // Research Facility: Only one // Uses class variables factories, researchFacility, HydroBot private bool addNewBuilding(BuildingType buildingType, Vector3 position) { bool status = false; float orientation; // 0, PI/2, PI, 3*PI/2 Factory oneFactory; bool notEnoughResource = false; switch (buildingType) { case BuildingType.researchlab: if (HydroBot.numResources < GameConstants.numResourcesForResearchCenter) notEnoughResource = true; break; case BuildingType.biodegradable: if (HydroBot.numResources < GameConstants.numResourcesForBioFactory) notEnoughResource = true; break; case BuildingType.plastic: if (HydroBot.numResources < GameConstants.numResourcesForPlasticFactory) notEnoughResource = true; break; case BuildingType.radioactive: if (HydroBot.numResources < GameConstants.numResourcesForRadioFactory) notEnoughResource = true; break; } // Check if hydrobot has sufficient resources for building a factory if (notEnoughResource) { // Play some sound hinting no sufficient resource audio.MenuScroll.Play(); Point point = new Point(); String point_string = "Not enough\nresources"; point.LoadContent(PoseidonGame.contentManager, point_string, position, Color.Red); PlayGameScene.points.Add(point); return false; } if (HydroBot.currentEnergy < GameConstants.EnergyLostPerBuild) { audio.MenuScroll.Play(); Point point = new Point(); String point_string = "Not enough\nenergy"; point.LoadContent(PoseidonGame.contentManager, point_string, position, Color.Red); PlayGameScene.points.Add(point); return false; } int radius = 60; // need to revise this based on the model for each building BoundingSphere buildingBoundingSphere; if (factoryAnchor != null) { buildingBoundingSphere = factoryAnchor.BoundingSphere; radius = (int)buildingBoundingSphere.Radius; } else if (researchAnchor != null) { buildingBoundingSphere = researchAnchor.BoundingSphere; radius = (int)buildingBoundingSphere.Radius; } // Check if position selected for building is within game arena.. The game area is within -MaxRange to +MaxRange for both X and Z axis // Give a lax of 40 units so that if a click happened at the edge of the arena, building is not allowed. This is to prevent the case // that power packs might appear above the end of the factory whose edge is just beyond the game arena. if (Math.Abs(position.X) > (float)(GameConstants.MainGameMaxRangeX - 40) || Math.Abs(position.Z) > (float)(GameConstants.MainGameMaxRangeZ - 40)) { // Play some sound hinting position selected is outside game arena audio.MenuScroll.Play(); Point point = new Point(); String point_string = "Can not\nbuild here"; point.LoadContent(PoseidonGame.contentManager, point_string, position, Color.Red); points.Add(point); return false; } //Verify that current location is available for adding the building int heightValue = GameConstants.MainGameFloatHeight;//(int)terrain.heightMapInfo.GetHeight(new Vector3(position.X, 0, position.Z)); if (AddingObjects.IsSeaBedPlaceOccupied((int)position.X, heightValue, (int)position.Z, radius, null, null, trashes, factories, researchFacility)) { // Play some sound hinting seabed place is occupied audio.MenuScroll.Play(); Point point = new Point(); String point_string = "Can not\nbuild here"; point.LoadContent(PoseidonGame.contentManager, point_string, position, Color.Red); points.Add(point); return false; } switch (buildingType) { case BuildingType.researchlab: if (researchFacility != null) { // do not allow addition of more than one research facility Point point = new Point(); String point_string = "Can only build\n1 research center"; point.LoadContent(PoseidonGame.contentManager, point_string, position, Color.Red); points.Add(point); audio.MenuScroll.Play(); status = false; } else { //create research facility.. Only one is allowed, hence using a separate variable for this purpose. researchFacility = new ResearchFacility(particleManager); position.Y = terrain.heightMapInfo.GetHeight(new Vector3(position.X, 0, position.Z)); //orientation = (float)(Math.PI/2) * random.Next(4); orientation = researchAnchor.orientation; researchFacility.Model = researchBuildingModel; researchFacility.ModelStates = researchBuildingModelStates; researchFacility.LoadContent(game, position, orientation); HydroBot.numResources -= GameConstants.numResourcesForResearchCenter; status = true; } break; case BuildingType.biodegradable: oneFactory = new Factory(FactoryType.biodegradable, particleManager, GraphicsDevice); position.Y = terrain.heightMapInfo.GetHeight(new Vector3(position.X, 0, position.Z)); orientation = factoryAnchor.orientation; oneFactory.Model = biodegradableFactoryModel; oneFactory.ModelStates = biodegradableFactoryModelStates; oneFactory.LevelTextures = biodegradableFactoryLevelTextures; oneFactory.LoadContent(game, position, orientation, ref IngamePresentation.factoryFont, ref IngamePresentation.factoryBackground, biofactoryAnimationTextures); HydroBot.numResources -= GameConstants.numResourcesForBioFactory; factories.Add(oneFactory); status = true; break; case BuildingType.plastic: oneFactory = new Factory(FactoryType.plastic, particleManager, GraphicDevice); position.Y = terrain.heightMapInfo.GetHeight(new Vector3(position.X, 0, position.Z)); orientation = factoryAnchor.orientation; oneFactory.Model = plasticFactoryModel; // set the model so that bounding sphere calculation happens based on fully blown model oneFactory.ModelStates = plasticFactoryModelStates; // set different model states so that under construction states are handled oneFactory.LevelTextures = plasticFactoryLevelTextures; oneFactory.LoadContent(game, position, orientation, ref IngamePresentation.factoryFont, ref IngamePresentation.factoryBackground, nuclearFactoryAnimationTextures); // for time being reuse nuclear factory animation texture HydroBot.numResources -= GameConstants.numResourcesForPlasticFactory; factories.Add(oneFactory); status = true; break; case BuildingType.radioactive: oneFactory = new Factory(FactoryType.radioactive, particleManager, GraphicDevice); position.Y = terrain.heightMapInfo.GetHeight(new Vector3(position.X, 0, position.Z)); orientation = factoryAnchor.orientation; oneFactory.Model = radioactiveFactoryModel; oneFactory.ModelStates = radioactiveFactoryModelStates; oneFactory.LoadContent(game, position, orientation, ref IngamePresentation.factoryFont, ref IngamePresentation.factoryBackground, nuclearFactoryAnimationTextures); HydroBot.numResources -= GameConstants.numResourcesForRadioFactory; factories.Add(oneFactory); status = true; break; } if (status) { // Play sound for successful addition of a building audio.OpenChest.Play(); HydroBot.currentEnergy -= GameConstants.EnergyLostPerBuild; //env loss for building factory if (GameConstants.envLossPerFactoryBuilt > 0) { HydroBot.currentEnvPoint -= GameConstants.envLossPerFactoryBuilt; Point lossPoint = new Point(); lossPoint.LoadContent(Content, "-" + GameConstants.envLossPerFactoryBuilt + "ENV", position, Color.Red); points.Add(lossPoint); } } return status; }
public static void MouseInteractWithControlPanel(ref bool clicked, ref bool doubleClicked, ref bool notYetRealeased, ref MouseState lastMouseState, ref MouseState currentMouseState, GameTime gameTime, ref double clickTimer, bool openFactoryConfigurationScene, Factory factoryToConfigure, ResearchFacility researchFacility, List<Factory> factories) { clicked = false; notYetRealeased = false; CheckClick(ref lastMouseState, ref currentMouseState, gameTime, ref clickTimer, ref clicked, ref doubleClicked, ref notYetRealeased); if (openFactoryConfigurationScene) { factoryToConfigure.produceButtonHover = factoryToConfigure.produceRect.Contains(lastMouseState.X, lastMouseState.Y); if (notYetRealeased && factoryToConfigure.produceButtonHover) { factoryToConfigure.produceButtonPress = true; } else factoryToConfigure.produceButtonPress = false; } else { researchFacility.upgradeBotButtonHover = (HydroBot.unassignedPts > 0 && researchFacility.increaseAttributeRect.Contains(lastMouseState.X, lastMouseState.Y)); if (notYetRealeased && researchFacility.upgradeBotButtonHover) { researchFacility.upgradeBotButtonPressed = true; } else researchFacility.upgradeBotButtonPressed = false; researchFacility.upgradeBioFacButtonHover = (researchFacility.bioUpgrade && researchFacility.bioUpgradeRect.Contains(lastMouseState.X, lastMouseState.Y)); if (notYetRealeased && researchFacility.upgradeBioFacButtonHover) { researchFacility.upgradeBioFacButtonPressed = true; } else researchFacility.upgradeBioFacButtonPressed = false; researchFacility.upgradePlasFacButtonHover = (researchFacility.plasticUpgrade && researchFacility.plasticUpgradeRect.Contains(lastMouseState.X, lastMouseState.Y)); if (notYetRealeased && researchFacility.upgradePlasFacButtonHover) { researchFacility.upgradePlasFacButtonPressed = true; } else researchFacility.upgradePlasFacButtonPressed = false; researchFacility.seacowButtonHover = (ResearchFacility.playSeaCowJigsaw && researchFacility.playSeaCowJigsawRect.Contains(lastMouseState.X, lastMouseState.Y)); if (notYetRealeased && researchFacility.seacowButtonHover) { researchFacility.seacowBotButtonPressed = true; } else researchFacility.seacowBotButtonPressed = false; researchFacility.dolphinButtonHover = (ResearchFacility.playSeaCowJigsaw && researchFacility.playDolphinJigsawRect.Contains(lastMouseState.X, lastMouseState.Y)); if (notYetRealeased && researchFacility.dolphinButtonHover) { researchFacility.dolphinButtonPressed = true; } else researchFacility.dolphinButtonPressed = false; researchFacility.turtleButtonHover = (ResearchFacility.playSeaCowJigsaw && researchFacility.playTurtleJigsawRect.Contains(lastMouseState.X, lastMouseState.Y)); if (notYetRealeased && researchFacility.turtleButtonHover) { researchFacility.turtleButtonPressed = true; } else researchFacility.turtleButtonPressed = false; } if (clicked) { if (openFactoryConfigurationScene) { if (factoryToConfigure.produceButtonHover) { factoryToConfigure.SwitchProductionItem(); PoseidonGame.audio.MenuScroll.Play(); } } else { if (researchFacility.bioUpgrade && researchFacility.bioUpgradeRect.Contains(lastMouseState.X, lastMouseState.Y)) { researchFacility.UpgradeBioFactory(factories); PoseidonGame.audio.MenuScroll.Play(); } if (researchFacility.plasticUpgrade && researchFacility.plasticUpgradeRect.Contains(lastMouseState.X, lastMouseState.Y)) { researchFacility.UpgradePlasticFactory(factories); PoseidonGame.audio.MenuScroll.Play(); } if (ResearchFacility.playSeaCowJigsaw && researchFacility.playSeaCowJigsawRect.Contains(lastMouseState.X, lastMouseState.Y)) { PoseidonGame.playJigsaw = true; PoseidonGame.jigsawType = 0; //seacow PoseidonGame.audio.MenuScroll.Play(); } if (ResearchFacility.playTurtleJigsaw && researchFacility.playTurtleJigsawRect.Contains(lastMouseState.X, lastMouseState.Y)) { PoseidonGame.playJigsaw = true; PoseidonGame.jigsawType = 1; //turtle PoseidonGame.audio.MenuScroll.Play(); } if (ResearchFacility.playDolphinJigsaw && researchFacility.playDolphinJigsawRect.Contains(lastMouseState.X, lastMouseState.Y)) { PoseidonGame.playJigsaw = true; PoseidonGame.jigsawType = 2; //dolphin PoseidonGame.audio.MenuScroll.Play(); } if (HydroBot.unassignedPts > 0 && researchFacility.increaseAttributeRect.Contains(lastMouseState.X, lastMouseState.Y)) { PoseidonGame.AttributeButtonPressed = true; PoseidonGame.audio.MenuScroll.Play(); } } clicked = false; } }
private void UpdateAnchor() { // check if anchor need to be instantiated or updated if (factoryButtonPanel.AnchoredIndex != factoryButtonPanel.PreviousAnchoredIndex) { factoryAnchor = null; researchAnchor = null; Vector3 anchorPosition = CursorManager.IntersectPointWithPlane(cursor, gameCamera, GameConstants.MainGameFloatHeight); float orientation; if (factoryButtonPanel.anchorIndexToBuildingType() == BuildingType.researchlab) { researchAnchor = new ResearchFacility(particleManager); anchorPosition.Y = terrain.heightMapInfo.GetHeight(new Vector3(anchorPosition.X, 0, anchorPosition.Z)); orientation = (float)(Math.PI / 2) * random.Next(4); researchAnchor.Model = researchBuildingModel; researchAnchor.LoadContent(game, anchorPosition, orientation); } else { FactoryType typeOfFactory = factoryButtonPanel.anchorIndexToFactoryType(factoryButtonPanel.AnchoredIndex); factoryAnchor = new Factory(typeOfFactory, particleManager, GraphicDevice); anchorPosition.Y = terrain.heightMapInfo.GetHeight(new Vector3(anchorPosition.X, 0, anchorPosition.Z)); orientation = (float)(Math.PI / 2) * random.Next(4); switch (typeOfFactory) { case FactoryType.biodegradable: factoryAnchor.Model = biodegradableFactoryModel; // need to make it different for each type break; case FactoryType.plastic: factoryAnchor.Model = plasticFactoryModel; break; case FactoryType.radioactive: factoryAnchor.Model = radioactiveFactoryModel; break; } factoryAnchor.LoadContent(game, anchorPosition, orientation, ref IngamePresentation.factoryFont, ref IngamePresentation.dummyTexture, null); } } else { if (factoryAnchor != null) { factoryAnchor.Position = CursorManager.IntersectPointWithPlane(cursor, gameCamera, GameConstants.MainGameFloatHeight); factoryAnchor.Position.Y = terrain.heightMapInfo.GetHeight(new Vector3(factoryAnchor.Position.X, 0, factoryAnchor.Position.Z)); } else if (researchAnchor != null) { researchAnchor.Position = CursorManager.IntersectPointWithPlane(cursor, gameCamera, GameConstants.MainGameFloatHeight); researchAnchor.Position.Y = terrain.heightMapInfo.GetHeight(new Vector3(researchAnchor.Position.X, 0, researchAnchor.Position.Z)); } } }
private void InitializeGameField(ContentManager Content) { currentGameState = GameState.Running; HydroBot.numResources += GameConstants.numResourcesAtStart; enemyBullet = new List<DamageBullet>(); healthBullet = new List<HealthBullet>(); myBullet = new List<DamageBullet>(); alliesBullets = new List<DamageBullet>(); float orientation = random.Next(100); enemiesAmount = 0; fishAmount = 0; enemies = new BaseEnemy[GameConstants.SurvivalModeMaxShootingEnemy + GameConstants.SurvivalModeMaxCombatEnemy + GameConstants.SurvivalModeMaxGhostPirate + GameConstants.SurvivalModeMaxMutantShark + GameConstants.SurvivalModeMaxTerminator + GameConstants.SurvivalModeMaxSubmarine * (1 + GameConstants.NumEnemiesInSubmarine)]; fish = new Fish[4]; AddingObjects.placeFish(ref fishAmount, fish, Content, random, enemiesAmount, enemies, null, GameConstants.MainGameMinRangeX, GameConstants.MainGameMaxRangeX, GameConstants.MainGameMinRangeZ, GameConstants.MainGameMaxRangeZ, -1, GameMode.SurvivalMode, GameConstants.MainGameFloatHeight); AddingObjects.placeEnemies(ref enemiesAmount, enemies, Content, random, fishAmount, fish, null, GameConstants.MainGameMinRangeX, GameConstants.MainGameMaxRangeX, GameConstants.MainGameMinRangeZ, GameConstants.MainGameMaxRangeZ, -1, GameMode.SurvivalMode, GameConstants.MainGameFloatHeight); //Initialize trash //int random_model; //int numberTrash = GameConstants.NumberBioTrash[currentLevel] + GameConstants.NumberNuclearTrash[currentLevel] + GameConstants.NumberPlasticTrash[currentLevel]; trashes = new List<Trash>(GameConstants.SurvivalModeNumBioTrash + GameConstants.SurvivalModeNumPlasTrash + GameConstants.SurvivalModeNumRadioTrash); int bioIndex, plasticIndex, nuclearIndex; for (bioIndex = 0; bioIndex < GameConstants.SurvivalModeNumBioTrash; bioIndex++) { orientation = random.Next(100); trashes.Add(new Trash(TrashType.biodegradable, particleManager)); trashes[bioIndex].Load(Content,ref biodegradableTrash, orientation); //bio model } for (plasticIndex = bioIndex; plasticIndex < bioIndex + GameConstants.SurvivalModeNumPlasTrash; plasticIndex++) { orientation = random.Next(100); trashes.Add(new Trash(TrashType.plastic, particleManager)); trashes[plasticIndex].Load(Content,ref plasticTrash, orientation); //plastic model } for (nuclearIndex = plasticIndex; nuclearIndex < plasticIndex + GameConstants.SurvivalModeNumRadioTrash; nuclearIndex++) { orientation = random.Next(100); trashes.Add(new Trash(TrashType.radioactive, particleManager)); trashes[nuclearIndex].Load(Content,ref radioactiveTrash, orientation); //nuclear model } AddingObjects.placeTrash(ref trashes, Content, random, null, null, GameConstants.TrashMinRangeX, GameConstants.MainGameMaxRangeX - 80, GameConstants.TrashMinRangeZ, GameConstants.MainGameMaxRangeZ - 60, GameMode.MainGame, GameConstants.MainGameFloatHeight, terrain.heightMapInfo); //Initialize a list of factories factories = new List<Factory>(); //create research facility researchFacility = null; if (HydroBot.hasDolphin) { AddingObjects.placeMinion(Content, 2, enemies, enemiesAmount, fish, ref fishAmount, hydroBot); } if (HydroBot.hasSeaCow) { AddingObjects.placeMinion(Content, 0, enemies, enemiesAmount, fish, ref fishAmount, hydroBot); } if (HydroBot.hasTurtle) { AddingObjects.placeMinion(Content, 1, enemies, enemiesAmount, fish, ref fishAmount, hydroBot); } }
public static Vector3 createSinkingTrash( ref List<Trash> trashes, ContentManager Content, Random random, List<ShipWreck> shipWrecks, List<StaticObject> staticObjects, List<Factory> factories, ResearchFacility researchFacility, int minX, int maxX, int minZ, int maxZ, float floatHeight, HeightMapInfo heightMapInfo,ref Model bioTrash,ref Model plasticTrash,ref Model nukeTrash, ParticleManagement particleManager) { if (PoseidonGame.playTime.TotalSeconds - lastTrashDrop <= 10) return Vector3.Zero; else lastTrashDrop = PoseidonGame.playTime.TotalSeconds; Vector3 tempCenter; int numTries = 0, xVal, zVal, heightValue; float orientation = random.Next(100); int trash_type = random.Next(50); Trash sinkingTrash; if (trash_type < 30) { sinkingTrash = new Trash(TrashType.biodegradable, particleManager); sinkingTrash.Load(Content,ref bioTrash, orientation); sinkingTrash.sinkingRate = 0.25f; sinkingTrash.sinkingRotationRate = 0.015f; } else if (trash_type < 48) { sinkingTrash = new Trash(TrashType.plastic, particleManager); sinkingTrash.Load(Content,ref plasticTrash, orientation); //nuclear model sinkingTrash.sinkingRate = 0.35f; sinkingTrash.sinkingRotationRate = -0.015f; } else { sinkingTrash = new Trash(TrashType.radioactive, particleManager); sinkingTrash.Load(Content,ref nukeTrash, orientation); //nuclear model sinkingTrash.sinkingRate = 0.6f; sinkingTrash.sinkingRotationRate = 0.025f; } sinkingTrash.sinking = true; sinkingTrash.sinkableTrash = true; do { //positionSign = random.Next(4); xVal = random.Next(0, 2 * maxX) - maxX; zVal = random.Next(0, 2 * maxZ) - maxZ; //switch (positionSign) //{ // case 0: // xVal *= -1; // break; // case 1: // zVal *= -1; // break; // case 2: // xVal *= -1; // zVal *= -1; // break; //} heightValue = (int)heightMapInfo.GetHeight(new Vector3(xVal, 0, zVal)); numTries++; } while (IsSeaBedPlaceOccupied(xVal, GameConstants.MainGameFloatHeight, zVal, 30, shipWrecks, staticObjects, trashes, factories, researchFacility) && numTries < GameConstants.MaxNumTries); sinkingTrash.Position.X = xVal; sinkingTrash.Position.Z = zVal; sinkingTrash.Position.Y = floatHeight+100; sinkingTrash.seaFloorHeight = heightMapInfo.GetHeight(new Vector3(sinkingTrash.Position.X, 0, sinkingTrash.Position.Z));//GameConstants.TrashFloatHeight; tempCenter = sinkingTrash.BoundingSphere.Center; tempCenter.X = sinkingTrash.Position.X; tempCenter.Y = floatHeight; tempCenter.Z = sinkingTrash.Position.Z; sinkingTrash.BoundingSphere = new BoundingSphere(tempCenter,sinkingTrash.BoundingSphere.Radius); trashes.Add(sinkingTrash); //degrade environment HydroBot.currentEnvPoint -= (int)((float)GameConstants.envLossPerTrashAdd / 2); return sinkingTrash.Position; }
//bounding box version public static bool IsSeaBedPlaceOccupied(BoundingBox objBoundingBox, List<ShipWreck> shipWrecks, List<StaticObject> staticObjects, List<Trash> trashes, List<Factory> factories, ResearchFacility researchFacility) { if (shipWrecks != null) { //not so close to the ship wreck foreach (GameObject currentObj in shipWrecks) { if (objBoundingBox.Intersects(currentObj.boundingBox)) { return true; } } } if (staticObjects != null) { //BoundingSphere sphereForTesting; foreach (StaticObject currentObj in staticObjects) { //sphereForTesting = currentObj.BoundingSphere; //special handling for kelp plant //if (HydroBot.gameMode == GameMode.MainGame && PlayGameScene.currentLevel == 7) // sphereForTesting.Radius = 3; if (objBoundingBox.Intersects(currentObj.boundingBox)) { return true; } } } if (trashes != null) { foreach (Trash trash in trashes) { if (objBoundingBox.Intersects(trash.BoundingSphere)) { return true; } } } if (factories != null) { foreach (Factory factory in factories) { if (objBoundingBox.Intersects(factory.boundingBox)) { return true; } } } if (researchFacility != null) { if (objBoundingBox.Intersects(researchFacility.boundingBox)) { return true; } } return false; }
// Helper //public static bool IsSeaBedPlaceOccupied(int xValue, int zValue, List<ShipWreck> shipWrecks, List<StaticObject> staticObjects, List<Trash> trashes, List<Factory> factories, ResearchFacility researchFacility) //{ // if (shipWrecks != null) // { // //not so close to the ship wreck // foreach (GameObject currentObj in shipWrecks) // { // if (((int)(MathHelper.Distance( // xValue, currentObj.Position.X)) < 200) && // ((int)(MathHelper.Distance( // zValue, currentObj.Position.Z)) < 200)) // { // return true; // } // } // } // if (staticObjects != null) // { // foreach (GameObject currentObj in staticObjects) // { // if (((int)(MathHelper.Distance( // xValue, currentObj.Position.X)) < 15) && // ((int)(MathHelper.Distance( // zValue, currentObj.Position.Z)) < 15)) // { // return true; // } // } // } // if (trashes != null) // { // foreach (Trash trash in trashes) // { // if (((int)(MathHelper.Distance( // xValue, trash.Position.X)) < 20) && // ((int)(MathHelper.Distance( // zValue, trash.Position.Z)) < 20)) // { // return true; // } // } // } // if (factories != null) // { // foreach (Factory factory in factories) // { // if (((int)(MathHelper.Distance( // xValue, factory.Position.X)) < 100) && // ((int)(MathHelper.Distance( // zValue, factory.Position.Z)) < 100)) // { // return true; // } // } // } // if (researchFacility != null) // { // if (((int)(MathHelper.Distance( // xValue, researchFacility.Position.X)) < 100) && // ((int)(MathHelper.Distance( // zValue, researchFacility.Position.Z)) < 100)) // { // return true; // } // } // return false; //} // Finds if seabed place is free within the radius from point xValue, yValue, zValue public static bool IsSeaBedPlaceOccupied(int xValue, int yValue, int zValue, int radius, List<ShipWreck> shipWrecks, List<StaticObject> staticObjects, List<Trash> trashes, List<Factory> factories, ResearchFacility researchFacility) { //BoundingSphere objectBoundingSphere = new BoundingSphere(new Vector3(xValue, 0, zValue), radius); BoundingSphere objectBoundingSphere = new BoundingSphere(new Vector3(xValue, yValue, zValue), radius); if (shipWrecks != null) { //not so close to the ship wreck foreach (GameObject currentObj in shipWrecks) { if (objectBoundingSphere.Intersects(currentObj.BoundingSphere)) { return true; } } } if (staticObjects != null) { BoundingSphere sphereForTesting; foreach (StaticObject currentObj in staticObjects) { sphereForTesting = currentObj.BoundingSphere; //special handling for kelp plant and animal bones if (HydroBot.gameMode == GameMode.MainGame) { if (PlayGameScene.currentLevel == 7) sphereForTesting.Radius = 3; else if (PlayGameScene.currentLevel == 6) sphereForTesting.Radius *= 0.5f; } if (objectBoundingSphere.Intersects(sphereForTesting)) { return true; } } } if (trashes != null) { foreach (Trash trash in trashes) { if (objectBoundingSphere.Intersects(trash.BoundingSphere)) { return true; } } } if (factories != null) { foreach (Factory factory in factories) { if (objectBoundingSphere.Intersects(factory.BoundingSphere)) { return true; } } } if (researchFacility != null) { if (objectBoundingSphere.Intersects(researchFacility.BoundingSphere)) { return true; } } return false; }