//Knock out any enemy that you crash into public static void KnockOutEnemies(BoundingSphere boundingSphere, Vector3 Position, int MaxRangeX, int MaxRangeZ, BaseEnemy[] enemies, ref int enemiesAmount, SwimmingObject[] fishes, int fishAmount, AudioLibrary audio, GameMode gameMode) { for (int i = 0; i < enemiesAmount; i++) { if (boundingSphere.Intersects(enemies[i].BoundingSphere)) { PoseidonGame.audio.bodyHit.Play(); float healthiness = HydroBot.currentEnergy / GameConstants.PlayerStartingEnergy; if (healthiness > 1) healthiness = 1.0f; Vector3 oldPosition = enemies[i].Position; Vector3 pushVector = enemies[i].Position - Position; pushVector.Normalize(); //can't stun a submarine if (!(enemies[i] is Submarine)) { enemies[i].stunned = true; enemies[i].stunnedStartTime = PoseidonGame.playTime.TotalSeconds; if (HydroBot.sonicHipnotiseMode) { enemies[i].setHypnotise(); } } enemies[i].Position += (pushVector * GameConstants.ThorPushFactor); enemies[i].Position.X = MathHelper.Clamp(enemies[i].Position.X, -MaxRangeX, MaxRangeX); enemies[i].Position.Z = MathHelper.Clamp(enemies[i].Position.Z, -MaxRangeZ, MaxRangeZ); enemies[i].BoundingSphere.Center = enemies[i].Position; if (Collision.isBarrierVsBarrierCollision(enemies[i], enemies[i].BoundingSphere, fishes, fishAmount) || Collision.isBarrierVsBarrierCollision(enemies[i], enemies[i].BoundingSphere, enemies, enemiesAmount)) { enemies[i].Position = oldPosition; enemies[i].BoundingSphere.Center = oldPosition; } int healthloss = (int)(GameConstants.HermesDamage * healthiness * HydroBot.speed * HydroBot.speedUp * HydroBot.sandalPower); enemies[i].health -= healthloss; //audio.Shooting.Play(); //if (enemies[i].health <= 0) //{ // if (enemies[i].isBigBoss == true) PlayGameScene.isBossKilled = true; // for (int k = i + 1; k < enemiesAmount; k++) // { // enemies[k - 1] = enemies[k]; // } // enemies[--enemiesAmount] = null; // i--; //} Point point = new Point(); String point_string = "-" + healthloss.ToString() + "HP"; point.LoadContent(PoseidonGame.contentManager, point_string, enemies[i].Position, Color.DarkRed); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } } }
public void Update(GameTime gameTime, Vector3 botPosition, ref List<Point> points) { EffectHelpers.GetEffectConfiguration(ref fogColor, ref ambientColor, ref diffuseColor, ref specularColor); if (lastConstructionSwitchTime == TimeSpan.Zero) { lastConstructionSwitchTime = PoseidonGame.playTime; } if (underConstruction) { if (buildingSoundInstance.State == SoundState.Paused) buildingSoundInstance.Resume(); if (buildingSoundInstance.State != SoundState.Playing) { buildingSoundInstance.Play(); } //environment disturbance because of factory building if (!sandDirturbedAnimationPlayed) { for (int k = 0; k < GameConstants.numSandParticles; k++) particleManager.sandParticlesForFactory.AddParticle(Position, Vector3.Zero); sandDirturbedAnimationPlayed = true; } Model = modelStates[constructionIndex]; underConstruction = (constructionIndex < (modelStates.Count - 1)); if (!underConstruction && buildingSoundInstance.State == SoundState.Playing) buildingSoundInstance.Stop(); if (PoseidonGame.playTime - lastConstructionSwitchTime >= constructionSwitchSpan) { //constructionIndex++; constructionIndex += (int)((PoseidonGame.playTime - lastConstructionSwitchTime).TotalMilliseconds / constructionSwitchSpan.TotalMilliseconds); if (constructionIndex >= modelStates.Count) { constructionIndex = modelStates.Count - 1; } lastConstructionSwitchTime = PoseidonGame.playTime; } return; } double processingTime = 12; //3 days int fossilType = random.Next(100); string point_string = ""; bool boneFound = false; //Is strange rock finished processing? for (int i = 0; i < listTimeRockProcessing.Count; i++) { if (PoseidonGame.playTime.TotalSeconds - listTimeRockProcessing[i] >= processingTime) { listTimeRockProcessing.RemoveAt(i); //produce fossil/bone 75% of the times. if (fossilType >= 74) { HydroBot.numTurtlePieces++; point_string = "Research Centre found\na Meiolania Turtle fossil\nfrom the strange rock"; boneFound = true; } else if (fossilType >= 49) { HydroBot.numDolphinPieces++; point_string = "Research Centre found\na Maui's Dolphin bone\nfrom the strange rock"; boneFound = true; } else if (fossilType >= 24) { HydroBot.numSeaCowPieces++; boneFound = true; point_string = "Research Centre found\na Stellar's SeaCow bone\nfrom the strange rock"; } } if (boneFound) { boneFound = false; Point point = new Point(); point.LoadContent(PoseidonGame.contentManager, point_string, botPosition, Color.LawnGreen); points.Add(point); } } }
public override void attack() { float damage = HydroBot.turtlePower * turtleDamage; if (PoseidonGame.playTime.TotalSeconds - lastAttack.TotalSeconds > timeBetweenAttack.TotalSeconds) { currentTarget.health -= damage; lastAttack = PoseidonGame.playTime; Vector3 facingDirection = currentTarget.Position - Position; ForwardDirection = (float)Math.Atan2(facingDirection.X, facingDirection.Z); Point point = new Point(); String point_string = "-" + (int)damage + "HP"; point.LoadContent(PoseidonGame.contentManager, point_string, currentTarget.Position, Color.Red); if (HydroBot.gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (HydroBot.gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (HydroBot.gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); //if (this.BoundingSphere.Intersects(cameraFrustum)) PoseidonGame.audio.slashSound.Play(); } base.attack(); }
// 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 override void Update(GameTime gameTime) { if (MediaPlayer.State.Equals(MediaState.Stopped)) { MediaPlayer.Play(audio.backgroundMusics[random.Next(GameConstants.NumNormalBackgroundMusics)]); } //skill combo unlock if (score >= 500 && !HydroBot.skillComboActivated) { HydroBot.skillComboActivated = true; Point point = new Point(); point.LoadContent(PoseidonGame.contentManager, "CONGRATULATIONS\nSKILL COMBO UNLOCKED", hydroBot.Position, Color.Gold); points.Add(point); PoseidonGame.audio.levelUpSound.Play(); } if (score > highestScore) highestScore = score; if (!paused) { //timming = gameTime; float aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio; lastKeyboardState = currentKeyboardState; currentKeyboardState = Keyboard.GetState(); //currentMouseState = Mouse.GetState(); // Allows the game to exit //if ((currentKeyboardState.IsKeyDown(Keys.Escape)) || // (currentGamePadState.Buttons.Back == ButtonState.Pressed)) // //this.Exit(); if ((currentGameState == GameState.Running)) { MouseState currentMouseState = new MouseState(); currentMouseState = Mouse.GetState(); // Update Factory Button Panel factoryButtonPanel.Update(gameTime, currentMouseState); UpdateAnchor(); // if mouse click happened, check for the click position and add new factory if (factoryButtonPanel.hasAnyAnchor() && factoryButtonPanel.cursorOutsidePanelArea && factoryButtonPanel.clickToBuildDetected) { // adjust the position to build factory depending on current camera position Vector3 newBuildingPosition = CursorManager.IntersectPointWithPlane(cursor, gameCamera, GameConstants.MainGameFloatHeight); // identify which factory depending on anchor index BuildingType newBuildingType = factoryButtonPanel.anchorIndexToBuildingType(); // if addition is successful, play successful sound, otherwise play unsuccessful sound if (addNewBuilding(newBuildingType, newBuildingPosition)) { factoryButtonPanel.removeAnchor(); } } if ((lastKeyboardState.IsKeyDown(Keys.LeftShift) || lastKeyboardState.IsKeyDown(Keys.RightShift)) && (lastMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released) && !openResearchFacilityConfigScene && !openFactoryConfigurationScene) { foreach (Factory factory in factories) { if (!factory.UnderConstruction && CursorManager.MouseOnObject(cursor, factory.BoundingSphere, factory.Position, gameCamera)) { openFactoryConfigurationScene = true; factoryToConfigure = factory; break; } } if (researchFacility != null && !researchFacility.UnderConstruction && CursorManager.MouseOnObject(cursor, researchFacility.BoundingSphere, researchFacility.Position, gameCamera)) { openResearchFacilityConfigScene = true; ResearchFacility.dolphinLost = ResearchFacility.seaCowLost = ResearchFacility.turtleLost = false; ResearchFacility.dolphinWon = ResearchFacility.seaCowWon = ResearchFacility.turtleWon = false; } } if (openFactoryConfigurationScene || openResearchFacilityConfigScene) { Factory.buildingSoundInstance.Pause(); ResearchFacility.buildingSoundInstance.Pause(); bool exitFactConfPressed; exitFactConfPressed = (lastKeyboardState.IsKeyDown(Keys.Enter) && (currentKeyboardState.IsKeyUp(Keys.Enter))); if (exitFactConfPressed) { openFactoryConfigurationScene = false; openResearchFacilityConfigScene = false; PoseidonGame.justCloseControlPanel = true; } else { //cursor update cursor.Update(GraphicDevice, gameCamera, gameTime, frustum); CursorManager.MouseInteractWithControlPanel(ref clicked, ref doubleClicked, ref notYetReleased, ref this.lastMouseState, ref this.currentMouseState, gameTime, ref clickTimer, openFactoryConfigurationScene, factoryToConfigure, researchFacility, factories); return; } } IngamePresentation.levelObjHover = IngamePresentation.mouseOnLevelObjectiveIcon(currentMouseState); bool mouseOnInteractiveIcons = IngamePresentation.levelObjHover || (!factoryButtonPanel.cursorOutsidePanelArea) || factoryButtonPanel.hasAnyAnchor() || factoryButtonPanel.clickToBuildDetected || factoryButtonPanel.clickToRemoveAnchorActive || factoryButtonPanel.rightClickToRemoveAnchor; //hydrobot update hydroBot.UpdateAction(gameTime, cursor, gameCamera, enemies, enemiesAmount, fish, fishAmount, Content, spriteBatch, myBullet, this, terrain.heightMapInfo, healthBullet, powerpacks, resources, trashes, null,null, mouseOnInteractiveIcons); //add 1 bubble over bot and each enemy timeNextBubble -= (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (timeNextBubble <= 0) { Bubble bubble = new Bubble(); bubble.LoadContent(Content, hydroBot.Position, false, 0.025f); bubbles.Add(bubble); for (int i = 0; i < enemiesAmount; i++) { if (enemies[i].BoundingSphere.Intersects(frustum) && !(enemies[i] is MutantShark) && !(enemies[i] is Submarine) && !(enemies[i] is GhostPirate)) { Bubble aBubble = new Bubble(); aBubble.LoadContent(Content, enemies[i].Position, false, 0.025f); bubbles.Add(aBubble); } } timeNextBubble = 200.0f; } //randomly generate few bubbles from sea bed timeNextSeaBedBubble -= (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (timeNextSeaBedBubble <= 0) { Vector3 bubblePos = hydroBot.Position; bubblePos.X += random.Next(-50, 50); //bubblePos.Y = 0; bubblePos.Z += random.Next(-50, 50); for (int i = 0; i < 7; i++) { Bubble aBubble = new Bubble(); bubblePos.X += random.Next(-2, 2); bubblePos.Z += random.Next(-2, 2); aBubble.LoadContent(Content, bubblePos, true, (float)random.NextDouble() / 80); bubbles.Add(aBubble); } //audio.Bubble.Play(); timeNextSeaBedBubble = (random.Next(3) + 3) * 1000.0f; } for (int i = 0; i < bubbles.Count; i++) { if (bubbles[i].timeLast <= 0) bubbles.RemoveAt(i--); else if (bubbles[i].scale >= 0.06) bubbles.RemoveAt(i--); } foreach (Bubble aBubble in bubbles) { if (random.Next(100) >= 95) aBubble.bubble3DPos.X += 0.5f; else if (random.Next(100) >= 95) aBubble.bubble3DPos.X -= 0.5f; if (random.Next(100) >= 95) aBubble.bubble3DPos.Z += 0.5f; else if (random.Next(100) >= 95) aBubble.bubble3DPos.Z -= 0.5f; aBubble.Update(GraphicDevice, gameCamera, gameTime); } //update points for (int i = 0; i < points.Count; i++) { Point point = points[i]; if (point.toBeRemoved) points.Remove(point); } foreach (Point point in points) { point.Update(GraphicDevice, gameCamera, gameTime); } gameCamera.Update(hydroBot.ForwardDirection, hydroBot.Position, aspectRatio, gameTime, cursor); // Updating camera's frustum frustum = new BoundingFrustum(gameCamera.ViewMatrix * gameCamera.ProjectionMatrix); if (trashes != null)// && trashes.Count < numTrash) { Vector3 pos = AddingObjects.createSinkingTrash(ref trashes, Content, random, null, null, factories, researchFacility, GameConstants.TrashMinRangeX, GameConstants.MainGameMaxRangeX - 100, GameConstants.TrashMinRangeZ, GameConstants.MainGameMaxRangeZ - 60, GameConstants.MainGameFloatHeight, terrain.heightMapInfo,ref biodegradableTrash,ref plasticTrash,ref radioactiveTrash, particleManager); //Point point = new Point(); //point.LoadContent(PoseidonGame.contentManager, "New Trash Dropped", pos, Color.LawnGreen); //points.Add(point); } foreach (Trash trash in trashes) { trash.Update(gameTime); } CursorManager.CheckClick(ref this.lastMouseState, ref this.currentMouseState, gameTime, ref clickTimer, ref clicked, ref doubleClicked, ref notYetReleased); foreach (Factory factory in factories) { factory.Update(gameTime, ref powerpacks, ref resources, ref powerpackModels, ref resourceModel, ref strangeRockModels); if (doubleClicked && !factory.UnderConstruction && hydroBot.BoundingSphere.Intersects(factory.BoundingSphere) && CursorManager.MouseOnObject(cursor, factory.BoundingSphere, factory.Position, gameCamera)) { //Dump Trash switch (factory.factoryType) { case FactoryType.biodegradable: if (HydroBot.bioTrash > 0) { dumpTrashInFactory(factory, factory.Position); HydroBot.bioTrash = 0; } break; case FactoryType.plastic: if (HydroBot.plasticTrash > 0) { dumpTrashInFactory(factory, factory.Position); HydroBot.plasticTrash = 0; } break; case FactoryType.radioactive: if (HydroBot.nuclearTrash > 0) { dumpTrashInFactory(factory, factory.Position); HydroBot.nuclearTrash = 0; } break; } } } if (researchFacility != null) { researchFacility.Update(gameTime, hydroBot.Position, ref points); if (doubleClicked && !researchFacility.UnderConstruction && hydroBot.BoundingSphere.Intersects(researchFacility.BoundingSphere) && CursorManager.MouseOnObject(cursor, researchFacility.BoundingSphere, researchFacility.Position, gameCamera)) { string point_string = HydroBot.numStrangeObjCollected + " strange rocks\ndeposited"; for (int i = 0; i < HydroBot.numStrangeObjCollected; i++) researchFacility.listTimeRockProcessing.Add(PoseidonGame.playTime.TotalSeconds + (i * GameConstants.DaysPerSecond)); Point point = new Point(); point.LoadContent(PoseidonGame.contentManager, point_string, researchFacility.Position, Color.LawnGreen); points.Add(point); HydroBot.numStrangeObjCollected = 0; } } doubleClicked = false; for (int i = 0; i < myBullet.Count; i++) { myBullet[i].update(gameTime); } for (int i = 0; i < healthBullet.Count; i++) { healthBullet[i].update(gameTime); } for (int i = 0; i < enemyBullet.Count; i++) { enemyBullet[i].update(gameTime); } for (int i = 0; i < alliesBullets.Count; i++) { alliesBullets[i].update(gameTime); } Collision.updateBulletOutOfBound(hydroBot.MaxRangeX, hydroBot.MaxRangeZ, healthBullet, myBullet, enemyBullet, alliesBullets, frustum); Collision.updateDamageBulletVsBarriersCollision(myBullet, enemies, ref enemiesAmount, frustum, GameMode.SurvivalMode, gameTime, hydroBot, enemies, enemiesAmount, fish, fishAmount, gameCamera, particleManager.explosionParticles); Collision.updateHealingBulletVsBarrierCollision(healthBullet, fish, fishAmount, frustum, GameMode.SurvivalMode); Collision.updateDamageBulletVsBarriersCollision(enemyBullet, fish, ref fishAmount, frustum, GameMode.SurvivalMode, gameTime, hydroBot, enemies, enemiesAmount, fish, fishAmount, gameCamera, particleManager.explosionParticles); Collision.updateProjectileHitBot(hydroBot, enemyBullet, GameMode.SurvivalMode, enemies, enemiesAmount, particleManager.explosionParticles, gameCamera, fish, fishAmount); Collision.updateDamageBulletVsBarriersCollision(alliesBullets, enemies, ref enemiesAmount, frustum, GameMode.SurvivalMode, gameTime, hydroBot, enemies, enemiesAmount, fish, fishAmount, gameCamera, particleManager.explosionParticles); Collision.deleteSmallerThanZero(enemies, ref enemiesAmount, frustum, GameMode.SurvivalMode, cursor, particleManager.explosionLargeParticles); Collision.deleteSmallerThanZero(fish, ref fishAmount, frustum, GameMode.SurvivalMode, cursor, particleManager.explosionLargeParticles); //revive the dead enemies to maintain their number AddingObjects.ReviveDeadEnemy(enemies, enemiesAmount, fish, fishAmount, hydroBot); for (int i = 0; i < enemiesAmount; i++) { //disable stun if stun effect times out if (enemies[i].stunned) { if (PoseidonGame.playTime.TotalSeconds - enemies[i].stunnedStartTime > GameConstants.timeStunLast) enemies[i].stunned = false; } enemies[i].Update(enemies, ref enemiesAmount, fish, fishAmount, random.Next(100), hydroBot, enemyBullet, alliesBullets, frustum, gameTime, GameMode.SurvivalMode); } for (int i = 0; i < fishAmount; i++) { fish[i].Update(gameTime, frustum, enemies, enemiesAmount, fish, fishAmount, random.Next(100), hydroBot, enemyBullet); } //Checking win/lost condition for this level if (HydroBot.currentHitPoint <= 0 || isAncientKilled) { currentGameState = GameState.Lost; audio.gameOver.Play(); } foreach (Powerpack powPack in powerpacks) powPack.Update(); foreach (Resource res in resources) res.Update(); roundTimer -= gameTime.ElapsedGameTime; PoseidonGame.playTime += gameTime.ElapsedGameTime; //for the shader m_Timer += (float)gameTime.ElapsedGameTime.Milliseconds / 1000; //cursor update cursor.Update(GraphicDevice, gameCamera, gameTime, frustum); //update graphic effects graphicEffect.UpdateInput(gameTime); //update particle systems particleManager.Update(gameTime); //update the good will bar //if (HydroBot.goodWillPoint >= HydroBot.maxGoodWillPoint) //{ // IngamePresentation.SpinNow(); // HydroBot.goodWillPoint = 0; //} //IngamePresentation.UpdateGoodWillBar(); } prevGameState = currentGameState; if (currentGameState == GameState.Lost) { // Return to main menu if (lastKeyboardState.IsKeyDown(Keys.Enter) && currentKeyboardState.IsKeyUp(Keys.Enter)) { currentGameState = GameState.ToMainMenu; } } base.Update(gameTime); } }
public void dumpTrashInFactory(Factory factory, Vector3 position) { string point_string = ""; switch (factory.factoryType) { case FactoryType.biodegradable: point_string = HydroBot.bioTrash + " biodegradable\ntrash dumped"; factory.numTrashWaiting += HydroBot.bioTrash; break; case FactoryType.plastic: point_string = HydroBot.plasticTrash + " plastic\ntrash dumped"; factory.numTrashWaiting += HydroBot.plasticTrash; break; case FactoryType.radioactive: point_string = HydroBot.nuclearTrash + " radioactive\ntrash dumped"; factory.numTrashWaiting += HydroBot.nuclearTrash; break; } Point point = new Point(); point.LoadContent(PoseidonGame.contentManager, point_string, position, Color.LawnGreen); points.Add(point); }
public static void updateProjectileHitBot(HydroBot hydroBot, List<DamageBullet> enemyBullets, GameMode gameMode, BaseEnemy[] enemies, int enemiesAmount, ParticleSystem explosionParticles, Camera gameCamera, Fish[] fishes, int fishAmount) { for (int i = 0; i < enemyBullets.Count; ) { if (enemyBullets[i].BoundingSphere.Intersects(hydroBot.BoundingSphere)) { if (!HydroBot.invincibleMode) { HydroBot.currentHitPoint -= enemyBullets[i].damage; if (gameMode == GameMode.MainGame || gameMode == GameMode.ShipWreck) PlayGameScene.healthLost += enemyBullets[i].damage; PoseidonGame.audio.botYell.Play(); Point point = new Point(); String point_string = "-" + enemyBullets[i].damage.ToString() + "HP"; point.LoadContent(PoseidonGame.contentManager, point_string, hydroBot.Position, Color.Red); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } //when auto hipnotize mode is on //whoever hits the bot will be hipnotized if (HydroBot.autoHipnotizeMode) { if (enemyBullets[i].shooter != null && !enemyBullets[i].shooter.isHypnotise) CastSkill.useHypnotise(enemyBullets[i].shooter); } if (HydroBot.autoExplodeMode) { PoseidonGame.audio.Explo1.Play(); gameCamera.Shake(12.5f, .2f); CastSkill.UseThorHammer(hydroBot.Position, hydroBot.MaxRangeX, hydroBot.MaxRangeZ, enemies, ref enemiesAmount, fishes, fishAmount, HydroBot.gameMode, true); } // add particle effect when certain kind of bullet hits if (enemyBullets[i] is Torpedo || enemyBullets[i] is ChasingBullet) { if (explosionParticles != null) { for (int k = 0; k < GameConstants.numExplosionParticles; k++) explosionParticles.AddParticle(enemyBullets[i].Position, Vector3.Zero); } PoseidonGame.audio.explosionSmall.Play(); } enemyBullets.RemoveAt(i); } else { i++; } } }
public static void updateHealingBulletVsBarrierCollision(List<HealthBullet> bullets, SwimmingObject[] barriers, int size, BoundingFrustum cameraFrustum, GameMode gameMode) { BoundingSphere sphere; for (int i = 0; i < bullets.Count; i++) { for (int j = 0; j < size; j++) { sphere = barriers[j].BoundingSphere; sphere.Radius *= GameConstants.EasyHitScale; if (bullets[i].BoundingSphere.Intersects(sphere)) { //fulfill the task of healing fish if (PlayGameScene.currentLevel == 0 && PlayGameScene.levelObjectiveState == 7) { PlayGameScene.levelObjectiveState = 8; PlayGameScene.newLevelObjAvailable = true; } if (barriers[j].BoundingSphere.Intersects(cameraFrustum)) PoseidonGame.audio.animalHappy.Play(); if (barriers[j].health < barriers[j].maxHealth ) { float amountHealed = Math.Min(bullets[i].healthAmount, barriers[j].maxHealth - barriers[j].health); barriers[j].health += amountHealed; if (barriers[j].health > barriers[j].maxHealth) barriers[j].health = barriers[j].maxHealth; int expReward = (int)(((double)amountHealed / (double)GameConstants.HealingAmount) * barriers[j].basicExperienceReward); if (PoseidonGame.gamePlus) { expReward += (int)(((double)amountHealed / (double)GameConstants.HealingAmount) * HydroBot.gamePlusLevel * 5); } //int envReward = (int) (((double)bullets[i].healthAmount / (double)GameConstants.HealingAmount) * GameConstants.BasicEnvGainForHealingFish); int goodWillReward = (int)(((double)amountHealed / (double)GameConstants.HealingAmount) * GameConstants.GoodWillPointGainForHealing); HydroBot.currentExperiencePts += expReward; //HydroBot.currentEnvPoint += envReward; //update good will point HydroBot.IncreaseGoodWillPoint(goodWillReward); if (HydroBot.gameMode == GameMode.SurvivalMode) SurvivalGameScene.score += expReward / 2; Point point = new Point(); //String point_string = "+" + envReward.ToString() + "ENV\n+"+expReward.ToString()+"EXP"; String point_string = "+" + expReward.ToString() + "EXP"; point.LoadContent(PoseidonGame.contentManager, point_string, barriers[j].Position, Color.LawnGreen); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } bullets.RemoveAt(i--); break; } } } }
// End---------------------------------------------------------- /// <summary> /// PROJECTILES FUNCTION /// </summary> /* scene --> 1-playgamescene, 2-shipwreckscene */ /* switch to use GameMode instead, look at the beginning of PoseidonGame for more details */ public static void updateDamageBulletVsBarriersCollision(List<DamageBullet> bullets, SwimmingObject[] barriers, ref int size, BoundingFrustum cameraFrustum, GameMode gameMode, GameTime gameTime, HydroBot hydroBot, BaseEnemy[] enemies, int enemiesAmount, Fish[] fishes, int fishAmount, Camera gameCamera, ParticleSystem explosionParticles) { BoundingSphere sphere; for (int i = 0; i < bullets.Count; i++) { //special handling for the skill combo FlyingHammer if (bullets[i] is FlyingHammer) { if (PoseidonGame.playTime.TotalSeconds - ((FlyingHammer)bullets[i]).timeShot > 1.25) { ((FlyingHammer)bullets[i]).explodeNow = true; PoseidonGame.audio.Explo1.Play(); gameCamera.Shake(25f, .4f); CastSkill.UseThorHammer(bullets[i].Position, hydroBot.MaxRangeX, hydroBot.MaxRangeZ, enemies, ref enemiesAmount, fishes, fishAmount, HydroBot.gameMode, false); } } if (bullets[i] is FlyingHammer) { if (((FlyingHammer)bullets[i]).explodeNow) { bullets.RemoveAt(i--); continue; } } for (int j = 0; j < size; j++) { sphere = barriers[j].BoundingSphere; sphere.Radius *= GameConstants.EasyHitScale; //because Mutant Shark's easy hit sphere is too large if (barriers[j] is MutantShark) sphere.Radius *= 0.7f; if (bullets[i].BoundingSphere.Intersects(sphere)) { if (barriers[j] is Fish && barriers[j].BoundingSphere.Intersects(cameraFrustum)) { PoseidonGame.audio.animalYell.Play(); } if (barriers[j] is BaseEnemy) { //if (((BaseEnemy)barriers[j]).isHypnotise) if (bullets[i].shooter == barriers[j]) { continue; } else { if (bullets[i].shooter == null && !((BaseEnemy)barriers[j]).isHypnotise) { ((BaseEnemy)barriers[j]).justBeingShot = true; ((BaseEnemy)barriers[j]).startChasingTime = PoseidonGame.playTime; } } //special handling for the skill combo FlyingHammer if (bullets[i] is FlyingHammer) { PoseidonGame.audio.bodyHit.Play(); Vector3 oldPosition = barriers[j].Position; Vector3 pushVector = barriers[j].Position - bullets[i].Position; pushVector.Normalize(); ((BaseEnemy)barriers[j]).stunned = true; ((BaseEnemy)barriers[j]).stunnedStartTime = PoseidonGame.playTime.TotalSeconds; ((BaseEnemy)barriers[j]).Position += (pushVector * GameConstants.ThorPushFactor); barriers[j].Position.X = MathHelper.Clamp(barriers[j].Position.X, -hydroBot.MaxRangeX, hydroBot.MaxRangeX); barriers[j].Position.Z = MathHelper.Clamp(barriers[j].Position.Z, -hydroBot.MaxRangeZ, hydroBot.MaxRangeZ); barriers[j].BoundingSphere.Center = barriers[j].Position; if (Collision.isBarrierVsBarrierCollision(barriers[j], barriers[j].BoundingSphere, fishes, fishAmount) || Collision.isBarrierVsBarrierCollision(barriers[j], barriers[j].BoundingSphere, enemies, enemiesAmount)) { barriers[j].Position = oldPosition; barriers[j].BoundingSphere.Center = oldPosition; } } } // add particle effect when certain kind of bullet hits if (bullets[i] is Torpedo || bullets[i] is ChasingBullet) { if (explosionParticles != null) { for (int k = 0; k < GameConstants.numExplosionParticles; k++) explosionParticles.AddParticle(bullets[i].Position, Vector3.Zero); } PoseidonGame.audio.explosionSmall.Play(); } //whether or not to reduce health of the hit object bool reduceHealth = true; if (bullets[i] is HerculesBullet) { if (!((HerculesBullet)bullets[i]).piercingArrow) reduceHealth = true; else { bool enemyHitBefore = false; foreach (BaseEnemy hitEnemy in ((HerculesBullet)bullets[i]).hitEnemies) { if (hitEnemy == (BaseEnemy)barriers[j]) enemyHitBefore = true; } if (!enemyHitBefore) { reduceHealth = true; ((HerculesBullet)bullets[i]).hitEnemies.Add((BaseEnemy)barriers[j]); } else reduceHealth = false; } } else reduceHealth = true; if (reduceHealth) { barriers[j].health -= bullets[i].damage; if (barriers[j].BoundingSphere.Intersects(cameraFrustum)) { Point point = new Point(); String point_string = "-" + bullets[i].damage.ToString() + "HP"; point.LoadContent(PoseidonGame.contentManager, point_string, barriers[j].Position, Color.DarkRed); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } } //remove the bullet that hits something if (bullets[i] is FlyingHammer) { //if (((FlyingHammer)bullets[i]).explodeNow) bullets.RemoveAt(i--); } //special handling for the skill combo Piercing arrow //pierce through enemies else if (bullets[i] is HerculesBullet) { if (!((HerculesBullet)bullets[i]).piercingArrow) bullets.RemoveAt(i--); } else bullets.RemoveAt(i--); break; } } } }
public static void deleteSmallerThanZero(SwimmingObject[] objs, ref int size, BoundingFrustum cameraFrustum, GameMode gameMode, Cursor cursor, ParticleSystem explosionParticles) { for (int i = 0; i < size; i++) { if (objs[i].health <= 0 && objs[i].gaveExp == false) { // Delete code is below this // This snippet does not include deleting if (objs[i] is SeaCow) { HydroBot.hasSeaCow = false; HydroBot.seaCowPower = 0; HydroBot.iconActivated[IngamePresentation.seaCowIcon] = false; } if (objs[i] is SeaTurtle) { HydroBot.hasTurtle = false; HydroBot.turtlePower = 0; HydroBot.iconActivated[IngamePresentation.turtleIcon] = false; } if (objs[i] is SeaDolphin) { HydroBot.hasDolphin = false; HydroBot.dolphinPower = 0; HydroBot.iconActivated[IngamePresentation.dolphinIcon] = false; } if (objs[i].isBigBoss == true) { if (gameMode == GameMode.MainGame || gameMode == GameMode.ShipWreck) { PlayGameScene.isBossKilled = true; PlayGameScene.numBossKills += 1; } else if (gameMode == GameMode.SurvivalMode && objs[i] is Fish) SurvivalGameScene.isAncientKilled = true; } else { if (gameMode == GameMode.MainGame || gameMode == GameMode.ShipWreck) { PlayGameScene.numNormalKills += 1; } } if (objs[i] is BaseEnemy) { HydroBot.currentExperiencePts += objs[i].basicExperienceReward; objs[i].gaveExp = true; if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.score += objs[i].basicExperienceReward / 2; if (objs[i].BoundingSphere.Intersects(cameraFrustum)) { Point point = new Point(); String point_string = "+" + objs[i].basicExperienceReward.ToString() + "EXP"; point.LoadContent(PoseidonGame.contentManager, point_string, objs[i].Position, Color.LawnGreen); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } if (!objs[i].isBigBoss) { if (objs[i].BoundingSphere.Intersects(cameraFrustum)) { if (objs[i] is GhostPirate) PoseidonGame.audio.skeletonDie.Play(); else PoseidonGame.audio.hunterYell.Play(); } } else { if (objs[i] is MutantShark) PoseidonGame.audio.mutantSharkYell.Play(); else if (objs[i] is Terminator) PoseidonGame.audio.terminatorYell.Play(); else if (objs[i] is Submarine) { PoseidonGame.audio.Explosion.Play(); if (explosionParticles != null) { for (int k = 0; k < GameConstants.numExplosionParticles; k++) explosionParticles.AddParticle(objs[i].Position, Vector3.Zero); } } } } if (objs[i] is Fish) { int envLoss; envLoss = GameConstants.envLossForFishDeath; HydroBot.currentEnvPoint -= envLoss; if (objs[i].BoundingSphere.Intersects(cameraFrustum)) { Point point = new Point(); String point_string = "-" + envLoss.ToString() + "ENV"; point.LoadContent(PoseidonGame.contentManager, point_string, objs[i].Position, Color.Red); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } } if (objs[i] == cursor.targetToLock) { cursor.targetToLock = null; //objs[i] = null; } //if we are playing the survival mode //revive the dead enemy instead if (gameMode != GameMode.SurvivalMode || objs[i] is Fish || (objs[i].releasedFromSubmarine)) { objs[i] = null; for (int k = i; k < size - 1; k++) { objs[k] = objs[k + 1]; } objs[--size] = null; } } } }
public static void UseThorHammer(Vector3 Position, int MaxRangeX, int MaxRangeZ, BaseEnemy[] enemies, ref int enemiesAmount, SwimmingObject[] fishes, int fishAmount, GameMode gameMode, bool halfStrength) { HydroBot.distortingScreen = true; HydroBot.distortionStart = PoseidonGame.playTime.TotalSeconds; for (int i = 0; i < enemiesAmount; i++) { if (InThorRange(Position, enemies[i].Position)){ float healthiness = HydroBot.currentEnergy / GameConstants.PlayerStartingEnergy; if (healthiness > 1) healthiness = 1.0f; //you can't stun a submarine if (!(enemies[i] is Submarine)) { enemies[i].stunned = true; enemies[i].stunnedStartTime = PoseidonGame.playTime.TotalSeconds; } float healthloss = (GameConstants.ThorDamage * healthiness * HydroBot.strength * HydroBot.strengthUp * HydroBot.hammerPower); if (halfStrength) healthloss /= 2; enemies[i].health -= healthloss; PushEnemy(Position, MaxRangeX, MaxRangeZ, enemies[i], enemies, enemiesAmount, fishes, fishAmount); //if (enemies[i].health <= 0) //{ // if (enemies[i].isBigBoss == true) PlayGameScene.isBossKilled = true; // for (int k = i + 1; k < enemiesAmount; k++) { // enemies[k - 1] = enemies[k]; // } // enemies[--enemiesAmount] = null; // i--; //} Point point = new Point(); String point_string = "-" + ((int)healthloss).ToString() + "HP"; point.LoadContent(PoseidonGame.contentManager, point_string, enemies[i].Position, Color.DarkRed); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } } }
public static void UseSkill(bool mouseOnLivingObject, Vector3 pointIntersect, Cursor cursor, Camera gameCamera, GameMode gameMode, HydroBot hydroBot, GameScene gameScene, ContentManager Content, SpriteBatch spriteBatch, GameTime gameTime, List<DamageBullet> myBullet, BaseEnemy[] enemies, ref int enemiesAmount, Fish[] fish, ref int fishAmount, ref bool isCastingSkill) { if (isCastingSkill) { if (!hydroBot.clipPlayer.inRange(75, 95)) hydroBot.clipPlayer.switchRange(75, 95); //animation done playing, cast the skill now if (hydroBot.clipPlayer.donePlayingAnimation) { int healthToLose = 0; isCastingSkill = false; if (shootHammer) { ShootHammer(hydroBot, Content, myBullet, gameMode); HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; HydroBot.firstUse[0] = false; HydroBot.firstUse[1] = false; shootHammer = false; } if (shootPiercingArrow) { ShootPiercingArrow(hydroBot, Content, spriteBatch, myBullet, gameMode); HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; HydroBot.firstUse[0] = false; HydroBot.firstUse[3] = false; shootPiercingArrow = false; } if (shootHerculesArrow) { HydroBot.firstUse[0] = false; HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; //audio.Explosion.Play(); CastSkill.UseHerculesBow(hydroBot, Content, spriteBatch, myBullet, gameMode); shootHerculesArrow = false; } if (useThorHammer) { HydroBot.firstUse[1] = false; HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; PoseidonGame.audio.Explo1.Play(); gameCamera.Shake(25f, .4f); CastSkill.UseThorHammer(hydroBot.Position, hydroBot.MaxRangeX, hydroBot.MaxRangeZ, enemies, ref enemiesAmount, fish, fishAmount, HydroBot.gameMode, false); useThorHammer = false; } if (castInvincible) { HydroBot.firstUse[2] = false; HydroBot.invincibleMode = true; HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; castInvincible = false; PoseidonGame.audio.armorSound.Play(); } if (castAutoExplode) { HydroBot.invincibleMode = true; HydroBot.autoExplodeMode = true; HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; HydroBot.firstUse[2] = false; HydroBot.firstUse[1] = false; castAutoExplode = false; PoseidonGame.audio.armorSound.Play(); } if (castAutoHipno) { HydroBot.invincibleMode = true; HydroBot.autoHipnotizeMode = true; HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; HydroBot.firstUse[2] = false; HydroBot.firstUse[4] = false; castAutoHipno = false; PoseidonGame.audio.armorSound.Play(); } if (castSonic) { HydroBot.firstUse[3] = false; HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; HydroBot.supersonicMode = true; castSonic = false; PoseidonGame.audio.hermesSound.Play(); } if (castSonicHipno) { HydroBot.sonicHipnotiseMode = true; HydroBot.supersonicMode = true; HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; HydroBot.firstUse[4] = false; HydroBot.firstUse[3] = false; castSonicHipno = false; PoseidonGame.audio.hermesSound.Play(); } if (castHipno) { HydroBot.firstUse[4] = false; PoseidonGame.audio.hipnotizeSound.Play(); useHypnotise(enemyToHipNo); HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; castHipno = false; enemyToHipNo = null; } //lose health after using skill if (HydroBot.skillComboActivated && HydroBot.secondSkillID != -1 && HydroBot.secondSkillID != HydroBot.activeSkillID) healthToLose = (int)(2 * GameConstants.EnergyLostPerSkill);//GameConstants.skillHealthLoss; else healthToLose = (int)(GameConstants.EnergyLostPerSkill); //display HP loss //HydroBot.currentHitPoint -= healthToLose; //we now lose energy instead of health int energyLost = healthToLose; HydroBot.currentEnergy -= energyLost; Point point = new Point(); String point_string = "-" + energyLost.ToString() + "Energy"; point.LoadContent(PoseidonGame.contentManager, point_string, hydroBot.Position, Color.Red); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); if (!hydroBot.clipPlayer.inRange(50, 74)) hydroBot.clipPlayer.switchRange(50, 74); } return; } else //skill casting may have been aborted { shootHammer = shootPiercingArrow = shootHerculesArrow = useThorHammer = castInvincible = castAutoExplode = castAutoHipno = castSonic = castSonicHipno = castHipno = false; } bool skillUsed = false; int floatHeight; if (gameMode == GameMode.ShipWreck) floatHeight = GameConstants.ShipWreckFloatHeight; else floatHeight = GameConstants.MainGameFloatHeight; pointIntersect = CursorManager.IntersectPointWithPlane(cursor, gameCamera, floatHeight); hydroBot.ForwardDirection = CursorManager.CalculateAngle(pointIntersect, hydroBot.Position); // Hercules' Bow!!! if (HydroBot.activeSkillID == 0)// && mouseOnLivingObject) { //use skill combo if activated //cooldowns for both skills must be cleared if ((HydroBot.skillComboActivated && HydroBot.secondSkillID == 1) && //cooldowns check ((HydroBot.firstUse[0] == true && HydroBot.firstUse[1] == true)|| (PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[0] > GameConstants.coolDownForHerculesBow && PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[1] > GameConstants.coolDownForThorHammer))) { //ShootHammer(hydroBot, Content, myBullet, gameMode); //HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; //HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; //HydroBot.firstUse[0] = false; //HydroBot.firstUse[1] = false; shootHammer = true; skillUsed = true; } else if ((HydroBot.skillComboActivated && HydroBot.secondSkillID == 3) && ((HydroBot.firstUse[3] == true && HydroBot.firstUse[0] == true) || (PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[0] > GameConstants.coolDownForHerculesBow && PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[3] > GameConstants.coolDownForHermesSandal))) { //ShootPiercingArrow(hydroBot, Content, spriteBatch, myBullet, gameMode); //HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; //HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; //HydroBot.firstUse[0] = false; //HydroBot.firstUse[3] = false; shootPiercingArrow = true; skillUsed = true; } //or else use single skill //if the skill has cooled down //or this is the 1st time the user uses it else if ((PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[0] > GameConstants.coolDownForHerculesBow) || HydroBot.firstUse[0] == true) { //HydroBot.firstUse[0] = false; //HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; ////audio.Explosion.Play(); //CastSkill.UseHerculesBow(hydroBot, Content, spriteBatch, myBullet, gameMode); shootHerculesArrow = true; skillUsed = true; } } //Thor's Hammer!!! if (HydroBot.activeSkillID == 1) { if ((PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[1] > GameConstants.coolDownForThorHammer) || HydroBot.firstUse[1] == true) { //HydroBot.firstUse[1] = false; //HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; //PoseidonGame.audio.Explo1.Play(); //gameCamera.Shake(25f, .4f); //CastSkill.UseThorHammer(hydroBot.Position, hydroBot.MaxRangeX, hydroBot.MaxRangeZ, enemies, ref enemiesAmount, fish, fishAmount, HydroBot.gameMode, false); useThorHammer = true; skillUsed = true; } } // Achilles' Armor!!! if (HydroBot.activeSkillID == 2) { if ((HydroBot.skillComboActivated && HydroBot.secondSkillID == 4) && //cooldowns check ((HydroBot.firstUse[2] == true && HydroBot.firstUse[4] == true) || (PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[2] > GameConstants.coolDownForArchillesArmor && PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[4] > GameConstants.coolDownForHypnotise))) { //HydroBot.invincibleMode = true; //HydroBot.autoHipnotizeMode = true; //HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; //HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; //HydroBot.firstUse[2] = false; //HydroBot.firstUse[4] = false; castAutoHipno = true; skillUsed = true; } else if ((HydroBot.skillComboActivated && HydroBot.secondSkillID == 1) && //cooldowns check ((HydroBot.firstUse[2] == true && HydroBot.firstUse[1] == true) || (PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[2] > GameConstants.coolDownForArchillesArmor && PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[1] > GameConstants.coolDownForThorHammer))) { //HydroBot.invincibleMode = true; //HydroBot.autoExplodeMode = true; //HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; //HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; //HydroBot.firstUse[2] = false; //HydroBot.firstUse[1] = false; castAutoExplode = true; skillUsed = true; } else if ((PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[2] > GameConstants.coolDownForArchillesArmor) || HydroBot.firstUse[2] == true) { //HydroBot.firstUse[2] = false; //HydroBot.invincibleMode = true; //HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; castInvincible = true; skillUsed = true; } //if (skillUsed) PoseidonGame.audio.armorSound.Play(); } //Hermes' Winged Sandal!!! if (HydroBot.activeSkillID == 3) { if ((HydroBot.skillComboActivated && HydroBot.secondSkillID == 4) && ((HydroBot.firstUse[3] == true && HydroBot.firstUse[4] == true) || (PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[4] > GameConstants.coolDownForHypnotise && PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[3] > GameConstants.coolDownForHermesSandal))) { //HydroBot.sonicHipnotiseMode = true; //HydroBot.supersonicMode = true; //HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; //HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; //HydroBot.firstUse[4] = false; //HydroBot.firstUse[3] = false; castSonicHipno = true; skillUsed = true; } else if ((PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[3] > GameConstants.coolDownForHermesSandal) || HydroBot.firstUse[3] == true) { //HydroBot.firstUse[3] = false; //HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; //HydroBot.supersonicMode = true; castSonic = true; skillUsed = true; } //if (skillUsed) PoseidonGame.audio.hermesSound.Play(); } // Hypnotise skill if (HydroBot.activeSkillID == 4) { BaseEnemy enemy = CursorManager.MouseOnWhichEnemy(cursor, gameCamera, enemies, enemiesAmount); //can't hipnotize a submarine if (enemy != null && !(enemy is Submarine) && (HydroBot.firstUse[4] == true || PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[4] > GameConstants.coolDownForHypnotise)) { //HydroBot.firstUse[4] = false; //PoseidonGame.audio.hipnotizeSound.Play(); //useHypnotise(enemy); //HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; castHipno = true; skillUsed = true; enemyToHipNo = enemy; } } if (skillUsed) { isCastingSkill = true; } //stop moving whether or not the skill has been casted hydroBot.reachDestination = true; pointIntersect = Vector3.Zero; }
// Execute the actions .. scene -> 1=playgamescene, 2=shipwreckscene protected virtual void makeAction(int changeDirection, SwimmingObject[] enemies, int enemiesAmount, SwimmingObject[] fishes, int fishAmount, List<DamageBullet> bullets, HydroBot hydroBot, BoundingFrustum cameraFrustum, GameTime gameTime, GameMode gameMode) { if (configBits[0] == true) { // swimming w/o attacking if (!clipPlayer.inRange(1, 30) && !configBits[3]) clipPlayer.switchRange(1, 30); randomWalk(changeDirection, enemies, enemiesAmount, fishes, fishAmount, hydroBot, speedFactor); return; } if (currentHuntingTarget != null) { calculateHeadingDirection(); calculateFutureBoundingSphere(); } if (configBits[2] == true) { // swimming w/o attacking if (!clipPlayer.inRange(1, 30) && !configBits[3]) clipPlayer.switchRange(1, 30); goStraight(enemies, enemiesAmount, fishes, fishAmount, hydroBot); } if (configBits[3] == true) { startChasingTime = PoseidonGame.playTime; if (currentHuntingTarget is Fish) { Fish tmp = (Fish)currentHuntingTarget; if (tmp.health <= 0) { currentHuntingTarget = null; justBeingShot = false; return; } } if (currentHuntingTarget is BaseEnemy) { BaseEnemy tmp = (BaseEnemy)currentHuntingTarget; if (tmp.health <= 0) { currentHuntingTarget = null; justBeingShot = false; return; } } if (PoseidonGame.playTime.TotalSeconds - prevFire.TotalSeconds > timeBetweenFire / speedFactor) { if (!clipPlayer.inRange(31, 60)) clipPlayer.switchRange(31, 60); if (currentHuntingTarget.GetType().Name.Equals("HydroBot")) { if (!(HydroBot.invincibleMode || HydroBot.supersonicMode)) { HydroBot.currentHitPoint -= damage; Point point = new Point(); String point_string = "-" + damage.ToString() + "HP"; point.LoadContent(PoseidonGame.contentManager, point_string, hydroBot.Position, Color.Red); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); PoseidonGame.audio.botYell.Play(); PlayGameScene.healthLost += damage; } if (HydroBot.autoHipnotizeMode) { setHypnotise(); } if (HydroBot.autoExplodeMode) { PoseidonGame.audio.Explo1.Play(); if (gameMode == GameMode.MainGame) PlayGameScene.gameCamera.Shake(12.5f, .2f); else if (gameMode == GameMode.ShipWreck) ShipWreckScene.gameCamera.Shake(12.5f, .2f); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.gameCamera.Shake(12.5f, .2f); CastSkill.UseThorHammer(hydroBot.Position, hydroBot.MaxRangeX, hydroBot.MaxRangeZ, (BaseEnemy[])enemies, ref enemiesAmount, fishes, fishAmount, HydroBot.gameMode, true); } } if (currentHuntingTarget is SwimmingObject) { ((SwimmingObject)currentHuntingTarget).health -= damage; if (currentHuntingTarget.BoundingSphere.Intersects(cameraFrustum)) { if (currentHuntingTarget is Fish) PoseidonGame.audio.animalYell.Play(); Point point = new Point(); String point_string = "-" + damage.ToString() + "HP"; point.LoadContent(PoseidonGame.contentManager, point_string, currentHuntingTarget.Position, Color.Red); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); } } prevFire = PoseidonGame.playTime; if (this.BoundingSphere.Intersects(cameraFrustum)) PoseidonGame.audio.slashSound.Play(); } } }