public static List<GameObject> getAllObstacle(GameObject observer, Fish[] fishes, int fishAmount, BaseEnemy[] enemies, int enemyAmount, HydroBot bot, List<GameObject> exclude) { List<GameObject> obstacles = new List<GameObject>(); if (observer != bot) { obstacles.Add(bot); } for (int i = 0; i < enemyAmount; i++) { if (observer != enemies[i]) { obstacles.Add(enemies[i]); } } for (int i = 0; i < fishAmount; i++) { if (observer != fishes[i]) { obstacles.Add(fishes[i]); } } for (int i = 0; i < obstacles.Count; i++) { for (int j = 0; j < exclude.Count; j++) { if (obstacles[i] == exclude[j]) { obstacles.RemoveAt(i); } } } return obstacles; }
public static Vector3 calculatePlacingPosition(float radius, HydroBot bot, BaseEnemy[] enemies, int enemiesAmount, Fish[] fish, int fishAmount) { Random random = new Random(); BoundingSphere newSphere = new BoundingSphere(new Vector3(), radius); float X, Y = bot.Position.Y, Z; do { X = (float)random.NextDouble() * (2 * bot.Position.X + 50) - bot.Position.X - 25f; //X = bot.Position.X + (float)random.NextDouble() * 50f; Z = (float)random.NextDouble() * (2 * bot.Position.Z + 50) - bot.Position.Z - 25f; newSphere.Center = new Vector3(X, Y, Z); } while (IsSurfaceOccupied(newSphere, enemiesAmount, fishAmount, enemies, fish) || newSphere.Intersects(bot.BoundingSphere)); return new Vector3(X, Y, Z); }
public static Fish MouseOnWhichFish(Cursor cursor, Camera gameCamera, Fish[] fish, int fishAmount) { if (fish == null) return null; BoundingSphere sphere; Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix); for (int i = 0; i < fishAmount; i++) { sphere = fish[i].BoundingSphere; sphere.Radius *= GameConstants.EasyAimScale; if (RayIntersectsBoundingSphere(cursorRay, sphere)) { return fish[i]; } } //cursor.SetNormalMouseImage(); return null; }
public static bool MouseOnFish(Cursor cursor, Camera gameCamera, Fish[] fish, int fishAmount) { BoundingSphere sphere; Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix); for (int i = 0; i < fishAmount; i++) { sphere = fish[i].BoundingSphere; sphere.Radius *= GameConstants.EasyAimScale; if (RayIntersectsBoundingSphere(cursorRay, sphere)) { cursor.SetOnFishMouseImage(); return true; } } cursor.SetNormalMouseImage(); return false; }
public bool PlaceHunter(SwimmingObject newHunter, HydroBot hydroBot, BaseEnemy[] enemies, int enemyAmount, Fish[] fishes, int fishAmount, bool releaseOnRightSide) { Random random = new Random(); Vector3 movement = Vector3.Zero; movement.Z = 1; Matrix orientationMatrix = Matrix.CreateRotationY(ForwardDirection); Vector3 shootingDirection = Vector3.Transform(movement, orientationMatrix); Vector3 hunterPos; if (releaseOnRightSide) hunterPos = this.Position + AddingObjects.PerpendicularVector(shootingDirection) * 25; else hunterPos = this.Position - AddingObjects.PerpendicularVector(shootingDirection) * 25; if (!(AddingObjects.IsSurfaceOccupied(new BoundingSphere(hunterPos, newHunter.BoundingSphere.Radius), enemyAmount, fishAmount, enemies, fishes))) { newHunter.Position = hunterPos; newHunter.ForwardDirection = this.ForwardDirection; ((BaseEnemy)newHunter).currentHuntingTarget = hydroBot; ((BaseEnemy)newHunter).startChasingTime = PoseidonGame.playTime; ((BaseEnemy)newHunter).giveupTime = new TimeSpan(0, 0, 3); newHunter.BoundingSphere = new BoundingSphere(newHunter.Position, newHunter.BoundingSphere.Radius); return true; } else return false; }
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++; } } }
// 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 placeMinion(ContentManager Content, int type, BaseEnemy[] enemies, int enemiesAmount, Fish[] fish, ref int fishAmount, HydroBot bot) { Fish newFish; if (type == 0) { newFish = new SeaCow(); newFish.Name = "Steller's Sea Cow"; newFish.LoadContent(Content, "Models/SeaAnimalModels/stellarSeaCow"); newFish.Load(1, 24, 24); newFish.happy_talk = "I am much larger than manetee or dugong."; newFish.sad_talk = "I was too slow to escape the hunters."; } else if (type == 1) { newFish = new SeaTurtle(); newFish.Name = "Meiolania"; newFish.LoadContent(Content, "Models/SeaAnimalModels/MeiolaniaWithAnim"); newFish.Load(1, 24, 24); newFish.happy_talk = "Huge, hard shell, armored head and spiked tail ... anything else about me?"; newFish.sad_talk = "I actually ... have never swum before ^^!"; } else { newFish = new SeaDolphin(); newFish.Name = "Maui's Dolphin"; newFish.LoadContent(Content, "Models/SeaAnimalModels/mauiDolphin"); newFish.Load(1, 24, 24); newFish.happy_talk = "I am the world's rarest and smallest known species of dolphin!"; newFish.sad_talk = "If only human did not fish us."; } newFish.Position = newFish.BoundingSphere.Center = calculatePlacingPosition(newFish.BoundingSphere.Radius, bot, enemies, enemiesAmount, fish, fishAmount); fish[fishAmount] = newFish; fishAmount++; }
public static void placeFish(ref int fishAmount, Fish[] fish, ContentManager Content, Random random, int enemiesAmount, BaseEnemy[] enemies, List<ShipWreck> shipWrecks, int minX, int maxX, int minZ, int maxZ, int currentLevel, GameMode gameMode, float floatHeight) { loadContentFish(ref fishAmount, fish, Content, currentLevel, gameMode); //int min = GameConstants.MinDistance; //int max = GameConstants.MaxDistance; //Vector3 tempCenter; //place fish for (int i = 0; i < fishAmount; i++) { //in survival mode, try to place the ancient fish near you if (gameMode == GameMode.SurvivalMode) fish[i].Position = GenerateSurfaceRandomPosition(50, 80, 50, 80, floatHeight, fish[i].BoundingSphere.Radius, random, enemiesAmount, fishAmount, enemies, fish, shipWrecks); else fish[i].Position = GenerateSurfaceRandomPosition(minX, maxX, minZ, maxZ, floatHeight, fish[i].BoundingSphere.Radius, random, enemiesAmount, fishAmount, enemies, fish, shipWrecks); fish[i].Position.Y = floatHeight; //tempCenter = fish[i].BoundingSphere.Center; //tempCenter.X = fish[i].Position.X; //tempCenter.Y = floatHeight; //tempCenter.Z = fish[i].Position.Z; fish[i].BoundingSphere = new BoundingSphere(fish[i].Position, fish[i].BoundingSphere.Radius); } }
public static void placeEnemies(ref int enemiesAmount, BaseEnemy[] enemies, ContentManager Content, Random random, int fishAmount, Fish[] fish, List<ShipWreck> shipWrecks, int minX, int maxX, int minZ, int maxZ, int currentLevel, GameMode gameMode, float floatHeight) { loadContentEnemies(ref enemiesAmount, enemies, Content, currentLevel, gameMode); //int min = GameConstants.MinDistance; //int max = GameConstants.MaxDistance; //Vector3 tempCenter; //place enemies for (int i = 0; i < enemiesAmount; i++) { enemies[i].Position = GenerateSurfaceRandomPosition(minX, maxX, minZ, maxZ, floatHeight, enemies[i].BoundingSphere.Radius, random, enemiesAmount, fishAmount, enemies, fish, shipWrecks); enemies[i].Position.Y = floatHeight; //tempCenter = enemies[i].BoundingSphere.Center; //tempCenter.X = enemies[i].Position.X; //tempCenter.Y = floatHeight; //tempCenter.Z = enemies[i].Position.Z; enemies[i].BoundingSphere = new BoundingSphere(enemies[i].Position, enemies[i].BoundingSphere.Radius); //enemies[i].ChangeBoundingSphere(); } }
public static void loadContentFish(ref int fishAmount, Fish[] fish, ContentManager Content, int currentLevel, GameMode gameMode) { if (gameMode == GameMode.MainGame) fishAmount = GameConstants.NumberFish[currentLevel]; else if (gameMode == GameMode.ShipWreck) fishAmount = GameConstants.ShipNumberFish; //there is only 1 fish to protect in the survival mode else if (gameMode == GameMode.SurvivalMode) { fishAmount = 1; } else fishAmount = 0; Random random = new Random(); int type; //level 1: seagrass meadow is turtle and manetee only if (currentLevel == 1) type = random.Next(2); //Level 4 is shark only else if (currentLevel == 4) type = random.Next(6, 9); //level 5: polar sea, we have penguin else if (currentLevel == 5) type = random.Next(10); else type = random.Next(9); for (int i = 0; i < fishAmount; i++) { fish[i] = new Fish(); //type = 9; if (gameMode == GameMode.SurvivalMode) { fish[i].Name = "Ancient "; fish[i].isBigBoss = true; } else fish[i].Name = ""; if (type == 0) { fish[i].LoadContent(Content, "Models/SeaAnimalModels/turtle"); //name must be initialized before Load() fish[i].Name += "turtle"; fish[i].Load(1, 24, 24); fish[i].happy_talk = "We are reptiles from much before the Jurassic age. Oh, I cry not for sorrow, just to get the salt out."; fish[i].sad_talk = "I need to go to the beach to lay eggs. Can you ask the humans not to hunt me?"; } else if (type == 1) { fish[i].LoadContent(Content, "Models/SeaAnimalModels/maneteeVer2"); fish[i].Name += "manetee"; fish[i].Load(1, 24, 24); fish[i].happy_talk = "Do not call me sea-cow. Do I look that fat?"; fish[i].sad_talk = "I am a vegeterian. Why are they killing me?"; } else if (type == 2) { fish[i].LoadContent(Content, "Models/SeaAnimalModels/dolphinVer3"); fish[i].Name += "dolphin"; fish[i].Load(1, 24, 24); fish[i].happy_talk = "We remind you to play, play, play, for you will find great power in play."; fish[i].sad_talk = "Though we try to be friends with humans, they always hurt us with their pollution, propellers and what not!"; } else if (type == 3) { fish[i].LoadContent(Content, "Models/SeaAnimalModels/stingray"); fish[i].Name += "sting ray"; fish[i].Load(1, 24, 24); fish[i].happy_talk = "I can't see you as my eyes are on top. But I can sense a bot with my electro-receptors."; fish[i].sad_talk = "I will teach you to sting, if you promise to sting everyone who eat bbq sting-ray."; } else if (type == 4) { fish[i].LoadContent(Content, "Models/SeaAnimalModels/orcaVer2"); fish[i].Name += "orca"; fish[i].Load(1, 24, 24); fish[i].happy_talk = "Move away, you little bot, here comes the killer whale."; fish[i].sad_talk = "I lost my way. I can't hear my friends due to the noise from the oil-rig."; } else if (type == 5) { fish[i].LoadContent(Content, "Models/SeaAnimalModels/sealVer2"); fish[i].Name += "seal"; fish[i].Load(1, 24, 24); fish[i].happy_talk = "See how I swim, with a swerve and a twist, a flip of the flipper, a flick of the wrist!"; fish[i].sad_talk = "We need the arctic ice. Stop global warming."; } else if (type == 6) { fish[i].LoadContent(Content, "Models/SeaAnimalModels/normalsharkVer3"); fish[i].Name += "shark"; fish[i].Load(1, 24, 24); fish[i].happy_talk = "You stink like a rusty metal. I can smell it. I also hear a prey far away. I'll go 15mph this time."; fish[i].sad_talk = "Humans kill over 30 million sharks every year. We are the oldest fish, spare us."; } else if (type == 7) { fish[i].LoadContent(Content, "Models/SeaAnimalModels/leopardsharkVer3"); fish[i].Name += "leopard shark"; fish[i].Load(1, 24, 24); fish[i].happy_talk = "No, I am not racist and I date all kinds of shark, not you, dear bot."; fish[i].sad_talk = "We never eat humans. Why do they hurt us?"; } else if (type == 8) { fish[i].LoadContent(Content, "Models/SeaAnimalModels/hammersharkVer2"); fish[i].Name += "hammer shark"; fish[i].Load(1, 24, 24); fish[i].happy_talk = "I have 360 degree binocular vision. I can detect an electrical signal of half a billionth of a volt. What superpower you brag about?"; fish[i].sad_talk = "Why do humans like our fins so much. Does 'delicacy' mean genocide?"; } else if (type == 9) { fish[i].LoadContent(Content, "Models/SeaAnimalModels/penguin"); fish[i].Name += "Penguin"; fish[i].Load(1, 24, 24); fish[i].happy_talk = "I am an aquatic, flightless bird that lives almost exclusively in the southern hemisphere, especially in Antarctica."; fish[i].sad_talk = "Why humans can not be as friendly as us?"; } fish[i].ForwardDirection = (float)random.Next(0, 629) / 100; //fish[i].Name += "AAAAAAAAAAAAAAAAAAAAAAAAAA"; //level 1: seagrass meadow is turtle and manetee only if (currentLevel == 1) type = random.Next(2); //Level 4 is shark only else if (currentLevel == 4) type = random.Next(6, 9); //level 5: polar sea, we have penguin else if (currentLevel == 5) type = random.Next(10); else type = random.Next(9); } }
// Helper public static bool IsSurfaceOccupied(BoundingSphere prospectiveBoundingSphere, int enemiesAmount, int fishAmount, BaseEnemy[] enemies, Fish[] fish) { //int optimalDistance; for (int i = 0; i < enemiesAmount; i++) { ////give more space for big guys //if (enemies[i] is MutantShark) optimalDistance = 70; //else optimalDistance = 30; //if (((int)(MathHelper.Distance( // xValue, enemies[i].Position.X)) < optimalDistance) && // ((int)(MathHelper.Distance( // zValue, enemies[i].Position.Z)) < optimalDistance)) // return true; if (prospectiveBoundingSphere.Intersects(enemies[i].BoundingSphere)) return true; } for (int i = 0; i < fishAmount; i++) { //if (fish[i].isBigBoss) optimalDistance = 70; //else optimalDistance = 30; //if (((int)(MathHelper.Distance( // xValue, fish[i].Position.X)) < optimalDistance) && // ((int)(MathHelper.Distance( // zValue, fish[i].Position.Z)) < optimalDistance)) // return true; if (prospectiveBoundingSphere.Intersects(fish[i].BoundingSphere)) return true; } if (HydroBot.gameMode == GameMode.ShipWreck) { bool objInsideShip = false; foreach (BoundingBox bbox in ShipWreckScene.levelContainBoxes[ShipWreckScene.shipSceneType[PoseidonGame.currentShipWreckID]]) { if (bbox.Contains(prospectiveBoundingSphere) == ContainmentType.Contains) objInsideShip = true; } return !objInsideShip; } return false; }
// Helper public static Vector3 GenerateSurfaceRandomPosition(int minX, int maxX, int minZ, int maxZ, float floatHeight, float boundingSphereRadius, Random random, int enemiesAmount, int fishAmount, BaseEnemy[] enemies, Fish[] fish, List<ShipWreck> shipWrecks) { int xValue, zValue; int numTries = 0; do { xValue = random.Next(minX, maxX); zValue = random.Next(minZ, maxZ); if (random.Next(100) % 2 == 0) xValue *= -1; if (random.Next(100) % 2 == 0) zValue *= -1; numTries++; } while (IsSurfaceOccupied(new BoundingSphere(new Vector3(xValue, floatHeight, zValue), boundingSphereRadius + 10), enemiesAmount, fishAmount, enemies, fish) && numTries < GameConstants.MaxNumTries); return new Vector3(xValue, 0, zValue); }
public static void ReviveDeadEnemy(BaseEnemy[] enemies, int enemyAmount, Fish[] fishes, int fishAmount, HydroBot hydroBot) { //we can't afford trying forever int numTries = 0; Random random = new Random(); for (int i = 0; i < enemyAmount; i++) { //we do not revive enemy release by submarine cuz the sub will get revived if (enemies[i].health <= 0 && !enemies[i].releasedFromSubmarine) { int xValue, zValue; //do //{ // xValue = random.Next(0, hydroBot.MaxRangeX); // zValue = random.Next(0, hydroBot.MaxRangeZ); // numTries++; //} while (numTries < 20 && (IsSurfaceOccupied(xValue, zValue, enemyAmount, fishAmount, enemies, fishes) || // (((int)(MathHelper.Distance(xValue, hydroBot.Position.X)) < 200) && // ((int)(MathHelper.Distance(zValue, hydroBot.Position.Z)) < 200)))); for (numTries = 0; numTries < GameConstants.MaxNumTries; numTries++) { xValue = random.Next(0, hydroBot.MaxRangeX); zValue = random.Next(0, hydroBot.MaxRangeZ); if (random.Next(100) % 2 == 0) xValue *= -1; if (random.Next(100) % 2 == 0) zValue *= -1; if (!(IsSurfaceOccupied(new BoundingSphere(new Vector3(xValue, hydroBot.floatHeight, zValue), enemies[i].BoundingSphere.Radius), enemyAmount, fishAmount, enemies, fishes) || (((int)(MathHelper.Distance(xValue, hydroBot.Position.X)) < 200) && ((int)(MathHelper.Distance(zValue, hydroBot.Position.Z)) < 200)))) { enemies[i].health = enemies[i].maxHealth; enemies[i].stunned = false; enemies[i].isHypnotise = false; enemies[i].gaveExp = false; enemies[i].Position.X = xValue; enemies[i].Position.Z = zValue; enemies[i].Position.Y = hydroBot.floatHeight; enemies[i].BoundingSphere = new BoundingSphere(enemies[i].Position, enemies[i].BoundingSphere.Radius); break; } else { //if we can not find a spare space to put the revived enemy //temporarily put it somewhere far enemies[i].Position.X = -50000; enemies[i].Position.Z = -50000; enemies[i].BoundingSphere.Center = enemies[i].Position; } } } } }
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; }