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 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; }
internal void DrawBoundingSphere(Matrix view, Matrix projection, GameObject boundingSphereModel) { Matrix scaleMatrix = Matrix.CreateScale(BoundingSphere.Radius); Matrix translateMatrix = Matrix.CreateTranslation(BoundingSphere.Center); Matrix worldMatrix = scaleMatrix * translateMatrix; foreach (ModelMesh mesh in boundingSphereModel.Model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.World = worldMatrix; effect.View = view; effect.Projection = projection; } mesh.Draw(); } }
public SurvivalGameScene(Game game, GraphicsDeviceManager graphic, ContentManager content, GraphicsDevice GraphicsDevice, SpriteBatch spriteBatch, Vector2 pausePosition, Rectangle pauseRect, Texture2D actionTexture, CutSceneDialog cutSceneDialog, Radar radar, Texture2D stunnedTexture) : base(game) { graphics = graphic; Content = content; GraphicDevice = GraphicsDevice; this.spriteBatch = spriteBatch; this.pausePosition = pausePosition; this.pauseRect = pauseRect; this.actionTexture = actionTexture; this.game = game; this.radar = radar; this.stunnedIconTexture = stunnedTexture; roundTime = TimeSpan.FromSeconds(2592000); random = new Random(); gameCamera = new Camera(GameMode.SurvivalMode); boundingSphere = new GameObject(); hydroBot = new HydroBot(GameConstants.MainGameMaxRangeX, GameConstants.MainGameMaxRangeZ, GameConstants.MainGameFloatHeight, GameMode.SurvivalMode); if (File.Exists("SurvivalMode")) { ObjectsToSerialize objectsToSerialize = new ObjectsToSerialize(); Serializer serializer = new Serializer(); string SavedFile = "SurvivalMode"; objectsToSerialize = serializer.DeSerializeObjects(SavedFile); hydroBot = objectsToSerialize.hydrobot; } //stop spinning the bar IngamePresentation.StopSpinning(); HydroBot.gamePlusLevel = 0; HydroBot.gameMode = GameMode.SurvivalMode; for (int index = 0; index < GameConstants.numberOfSkills; index++) { HydroBot.skills[index] = true; } skillTextures = new Texture2D[GameConstants.numberOfSkills]; bulletTypeTextures = new Texture2D[GameConstants.numBulletTypes]; // for the mouse or touch cursor = new Cursor(game, spriteBatch); //Components.Add(cursor); bubbles = new List<Bubble>(); points = new List<Point>(); //loading winning, losing textures winningTexture = IngamePresentation.winningTexture; losingTexture = IngamePresentation.losingTexture; scaredIconTexture = IngamePresentation.scaredIconTexture; isAncientKilled = false; // Instantiate the factory Button float buttonScale = 1.0f; if (game.Window.ClientBounds.Width <= 900) { buttonScale = 0.8f; // scale the factory panel icons a bit smaller in small window mode } factoryButtonPanel = new ButtonPanel(4, buttonScale); this.Load(); gameBoundary = new GameBoundary(); gameBoundary.LoadGraphicsContent(GraphicDevice); }
// Is it the time to forget about old target? protected bool clearMind(GameTime gameTime) { if (startChasingTime.TotalSeconds == 0 || PoseidonGame.playTime.TotalSeconds - startChasingTime.TotalSeconds > giveupTime.TotalSeconds) { currentHuntingTarget = null; startChasingTime = PoseidonGame.playTime; justBeingShot = false; return true; } return false; }
public void wearOutHypnotise() { isHypnotise = false; currentHuntingTarget = null; justBeingShot = false; }
public void setHypnotise() { isHypnotise = true; currentHuntingTarget = null; startHypnotiseTime = PoseidonGame.playTime; justBeingShot = 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 placeTorpedo(GameObject shooter, GameObject target, List<DamageBullet> bullets, BoundingFrustum cameraFrustum, GameMode gameMode) { Matrix orientationMatrix = Matrix.CreateRotationY(((Submarine)shooter).ForwardDirection); Vector3 movement = Vector3.Zero; movement.Z = 1; Vector3 shootingDirection = Vector3.Transform(movement, orientationMatrix); //one topedo on the left and one on the right Torpedo newBullet = new Torpedo(); newBullet.initialize(shooter.Position - PerpendicularVector(shootingDirection) * 20 + shootingDirection * 0, shootingDirection, GameConstants.BulletSpeed, (int)(GameConstants.TorpedoDamage * ((float)HydroBot.gamePlusLevel / 2 + 1)), target, (Submarine)shooter, gameMode); newBullet.loadContent(PoseidonGame.contentManager, "Models/BulletModels/torpedo"); bullets.Add(newBullet); Torpedo newBullet1 = new Torpedo(); newBullet1.initialize(shooter.Position + PerpendicularVector(shootingDirection) * 20 + shootingDirection * 0, shootingDirection, GameConstants.BulletSpeed, (int)(GameConstants.TorpedoDamage * ((float)HydroBot.gamePlusLevel / 2 + 1)), target, (Submarine)shooter, gameMode); newBullet1.loadContent(PoseidonGame.contentManager, "Models/BulletModels/torpedo"); bullets.Add(newBullet1); if (shooter.BoundingSphere.Intersects(cameraFrustum)) { PoseidonGame.audio.bossShot.Play(); } }
public static void placeEnemyBullet(GameObject obj, int damage, List<DamageBullet> bullets, int type, BoundingFrustum cameraFrustum, float offsetFactor) { HydroBot tmp1; SwimmingObject tmp2; Matrix orientationMatrix; if (obj.GetType().Name.Equals("HydroBot")) { tmp1 = (HydroBot)obj; orientationMatrix = Matrix.CreateRotationY(tmp1.ForwardDirection); } else { tmp2 = (SwimmingObject)obj; orientationMatrix = Matrix.CreateRotationY(tmp2.ForwardDirection); } DamageBullet newBullet = new DamageBullet(); Vector3 movement = Vector3.Zero; movement.Z = 1; Vector3 shootingDirection = Vector3.Transform(movement, orientationMatrix); newBullet.initialize(obj.Position + shootingDirection * offsetFactor, shootingDirection, GameConstants.BulletSpeed, damage, (BaseEnemy)obj); if (type == 1) { newBullet.loadContent(PoseidonGame.contentManager, "Models/BulletModels/bossBullet"); if (obj.BoundingSphere.Intersects(cameraFrustum)) PoseidonGame.audio.bossShot.Play(); } else if (type == 0) { newBullet.loadContent(PoseidonGame.contentManager, "Models/BulletModels/normalbullet"); if (obj.BoundingSphere.Intersects(cameraFrustum)) PoseidonGame.audio.enemyShot.Play(); } bullets.Add(newBullet); }
public static void placeChasingBullet(GameObject shooter, GameObject target, List<DamageBullet> bullets, BoundingFrustum cameraFrustum) { if (!target.GetType().Name.Equals("HydroBot")) { return; } Matrix orientationMatrix = Matrix.CreateRotationY(((Terminator)shooter).ForwardDirection); Vector3 movement = Vector3.Zero; movement.Z = 1; Vector3 shootingDirection = Vector3.Transform(movement, orientationMatrix); ChasingBullet newBullet = new ChasingBullet(); newBullet.initialize(shooter.Position, shootingDirection, GameConstants.BulletSpeed, (int)(GameConstants.ChasingBulletDamage * ((float)HydroBot.gamePlusLevel/2 + 1)), target, (Terminator)shooter); newBullet.loadContent(PoseidonGame.contentManager, "Models/BulletModels/chasingBullet"); bullets.Add(newBullet); if (shooter.BoundingSphere.Intersects(cameraFrustum)) { PoseidonGame.audio.chasingBulletSound.Play(); } }