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; }
//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 initialize(Vector3 position, Vector3 headingDirection, float speed, int damage, GameObject target, BaseEnemy shooter) { base.initialize(position, headingDirection, speed, damage, shooter); this.target = target; this.unitDirection = target.Position - position; this.unitDirection.Normalize(); stopChasing = false; stopChasingTime = GameConstants.StopBulletChasing; }
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); }
// 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; }
public void initialize(Vector3 position, Vector3 headingDirection, float speed, int damage, GameObject target, BaseEnemy shooter, GameMode gameMode) { base.initialize(position, headingDirection, speed, damage, shooter); this.unitDirection = headingDirection; //target.Position - position; this.unitDirection.Normalize(); this.forwardDir = shooter.ForwardDirection; this.gameMode = gameMode; if (gameMode == GameMode.MainGame) { this.particleManager = PlayGameScene.particleManager; } else if (gameMode == GameMode.ShipWreck) { this.particleManager = ShipWreckScene.particleManager; } else if (gameMode == GameMode.SurvivalMode) { this.particleManager = SurvivalGameScene.particleManager; } // Use the particle emitter helper to output our trail particles. trailEmitter = new ParticleEmitter(particleManager.projectileTrailParticles, GameConstants.trailParticlesPerSecond, position); }
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 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; }
public static BaseEnemy MouseOnWhichEnemy(Cursor cursor, Camera gameCamera, BaseEnemy[] enemies, int enemiesAmount) { if (enemies == null) return null; Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix); BoundingSphere sphere; for (int i = 0; i < enemiesAmount; i++) { //making it easier to aim sphere = enemies[i].BoundingSphere; sphere.Radius *= GameConstants.EasyAimScale; if (RayIntersectsBoundingSphere(cursorRay, sphere)) { //cursor.SetShootingMouseImage(); return enemies[i]; } } //cursor.SetNormalMouseImage(); return null; }
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; }
// 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 void initialize(Vector3 position, Vector3 headingDirection, float speed, int damage, BaseEnemy shooter) { base.initialize(position, headingDirection, speed); this.damage = damage; this.shooter = shooter; if (HydroBot.gameMode == GameMode.MainGame) { this.graphicDevice = PlayGameScene.GraphicDevice; this.gameCamera = PlayGameScene.gameCamera; this.spriteBatch = PoseidonGame.spriteBatch; } else if (HydroBot.gameMode == GameMode.ShipWreck) { this.graphicDevice = ShipWreckScene.GraphicDevice; this.gameCamera = ShipWreckScene.gameCamera; this.spriteBatch = PoseidonGame.spriteBatch; } else if (HydroBot.gameMode == GameMode.SurvivalMode) { this.graphicDevice = SurvivalGameScene.GraphicDevice; this.gameCamera = SurvivalGameScene.gameCamera; this.spriteBatch = PoseidonGame.spriteBatch; } if (shooter is Terminator) laserBeamTexture = IngamePresentation.terminatorBullet; }
// push enemy away public static void PushEnemy(Vector3 Position, int MaxRangeX, int MaxRangeZ, BaseEnemy enemy, SwimmingObject[] enemies, int enemiesAmount, SwimmingObject[] fishes, int fishAmount ) { Vector3 oldPosition = enemy.Position; Vector3 pushVector = enemy.Position - Position; pushVector.Normalize(); enemy.Position += (pushVector * GameConstants.ThorPushFactor); enemy.Position.X = MathHelper.Clamp(enemy.Position.X, -MaxRangeX, MaxRangeX); enemy.Position.Z = MathHelper.Clamp(enemy.Position.Z, -MaxRangeZ, MaxRangeZ); enemy.BoundingSphere.Center = enemy.Position; if (Collision.isBarrierVsBarrierCollision(enemy, enemy.BoundingSphere, fishes, fishAmount) || Collision.isBarrierVsBarrierCollision(enemy, enemy.BoundingSphere, enemies, enemiesAmount)) { enemy.Position = oldPosition; enemy.BoundingSphere.Center = oldPosition; } }
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 bool MouseOnEnemy(Cursor cursor, Camera gameCamera, BaseEnemy[] enemies, int enemiesAmount) { Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix); BoundingSphere sphere; for (int i = 0; i < enemiesAmount; i++) { //making it easier to aim sphere = enemies[i].BoundingSphere; //boss is already big if (!enemies[i].isBigBoss) sphere.Radius *= GameConstants.EasyAimScale; if (RayIntersectsBoundingSphere(cursorRay, sphere)) { cursor.SetShootingMouseImage(); return true; } } cursor.SetNormalMouseImage(); return false; }
public static void loadContentEnemies(ref int enemiesAmount, BaseEnemy[] enemies, ContentManager Content, int currentLevel, GameMode gameMode) { if (gameMode == GameMode.SurvivalMode) { enemiesAmount = GameConstants.SurvivalModeMaxShootingEnemy + GameConstants.SurvivalModeMaxCombatEnemy + GameConstants.SurvivalModeMaxGhostPirate + GameConstants.SurvivalModeMaxMutantShark + GameConstants.SurvivalModeMaxTerminator + GameConstants.SurvivalModeMaxSubmarine; } else if (gameMode == GameMode.MainGame) enemiesAmount = GameConstants.NumberShootingEnemies[currentLevel] + GameConstants.NumberCombatEnemies[currentLevel] + GameConstants.NumberGhostPirate[currentLevel] + GameConstants.NumberMutantShark[currentLevel] + GameConstants.NumberTerminator[currentLevel] + GameConstants.NumberSubmarine[currentLevel]; else if (gameMode == GameMode.ShipWreck) { enemiesAmount = GameConstants.ShipNumberGhostPirate[PlayGameScene.currentLevel]; } int numShootingEnemies = 0; int numCombatEnemies = 0; int numGhostPirates = 0; int numMutantShark = 0; int numTerminator = 0; int numSubmarine = 0; if (gameMode == GameMode.SurvivalMode) { numShootingEnemies = GameConstants.SurvivalModeMaxShootingEnemy; numCombatEnemies = GameConstants.SurvivalModeMaxCombatEnemy; numGhostPirates = GameConstants.SurvivalModeMaxGhostPirate; numMutantShark = GameConstants.SurvivalModeMaxMutantShark; numTerminator = GameConstants.SurvivalModeMaxTerminator; numSubmarine = GameConstants.SurvivalModeMaxSubmarine; } else if (gameMode == GameMode.MainGame) { numShootingEnemies = GameConstants.NumberShootingEnemies[currentLevel]; numCombatEnemies = GameConstants.NumberCombatEnemies[currentLevel]; numGhostPirates = GameConstants.NumberGhostPirate[currentLevel]; numMutantShark = GameConstants.NumberMutantShark[currentLevel]; numTerminator = GameConstants.NumberTerminator[currentLevel]; numSubmarine = GameConstants.NumberSubmarine[currentLevel]; } else if (gameMode == GameMode.ShipWreck) { numGhostPirates = GameConstants.ShipNumberGhostPirate[PlayGameScene.currentLevel]; } Random rnd = new Random(); for (int i = 0; i < enemiesAmount; i++) { if (i < numShootingEnemies) { enemies[i] = new ShootingEnemy(); enemies[i].Name = "Shooting Enemy"; enemies[i].LoadContent(Content, "Models/EnemyModels/diver_green_ly"); enemies[i].Load(1, 25, 24); } else if (i < numShootingEnemies + numCombatEnemies){ enemies[i] = new CombatEnemy(); enemies[i].Name = "Combat Enemy"; enemies[i].LoadContent(Content, "Models/EnemyModels/diver_knife_orange_yellow"); enemies[i].Load(1, 30, 24);// 31 60 for attack } else if (i < numShootingEnemies + numCombatEnemies + numGhostPirates) { enemies[i] = new GhostPirate(); enemies[i].Name = "Ghost Pirate"; enemies[i].LoadContent(Content, "Models/EnemyModels/skeletonrigged"); enemies[i].Load(10, 40, 24); } else if (i < numShootingEnemies + numCombatEnemies + numGhostPirates + numMutantShark) { MutantShark mutantShark = new MutantShark(); mutantShark.LoadContent(Content, "Models/EnemyModels/mutantSharkVer2"); mutantShark.Name = "mutant shark"; enemies[i] = mutantShark; } else if (i < numShootingEnemies + numCombatEnemies + numGhostPirates + numMutantShark + numTerminator) { Terminator terminator = new Terminator(gameMode); terminator.LoadContent(Content, "Models/EnemyModels/terminator"); if (currentLevel == 4 && gameMode == GameMode.MainGame) terminator.Name = "???"; else terminator.Name = "terminator"; terminator.Load(31, 60, 24); enemies[i] = terminator; } else if (i < numShootingEnemies + numCombatEnemies + numGhostPirates + numMutantShark + numTerminator + numSubmarine) { Submarine submarine = new Submarine(gameMode); submarine.LoadContent(Content, "Models/EnemyModels/submarine"); submarine.Name = "Shark Submarine"; submarine.Load(21, 30, 24); enemies[i] = submarine; } } }
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 useHypnotise(BaseEnemy enemy) { enemy.setHypnotise(); }