Exemple #1
0
 /// <summary>
 /// Method that updates the game
 /// </summary>
 /// <param name="input">Input</param>
 /// <param name="gameTime">GameTime</param>
 public override void Update(Input input, GameTime gameTime)
 {
     base.Update(input, gameTime);
     // Check if the camera is not hacked
     if (!hacked)
     {
         var pos = new Vector2();
         // Check if the CCTV camera can see the player
         if (CanSee(out pos))
         {
             var guards = MonoGearGame.FindEntitiesWithTag("Guard");
             // Alert all guards in the vicinity
             foreach (var g in guards)
             {
                 var guard = g as Guard;
                 if (guard != null)
                 {
                     guard.Alert(pos);
                 }
             }
         }
     }
     else
     {
         // Disable the CCTV camera if it's hacked
         Enabled = false;
     }
 }
Exemple #2
0
        /// <summary>
        /// Method that updates the game.
        /// </summary>
        /// <param name="input">Input</param>
        /// <param name="gameTime">GameTime</param>
        public override void Update(Input input, GameTime gameTime)
        {
            base.Update(input, gameTime);

            Collider collider;
            var      pos   = Position;
            var      delta = Forward * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

            Move(delta);

            bool hitTilemap;

            // Check if the sleep dart collides with anything
            if (Collider.CollidesAny(out collider, out hitTilemap, originCollider))
            {
                Position = pos;
                // Set the speed to 0
                Speed = 0.0f;
                // Check if the sleep dart collides with a guard
                if (collider != null && collider.Entity.Tag.Equals("Guard"))
                {
                    var guard = collider.Entity as Guard;
                    guard.Sleep();
                    var sound = MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/DartHit").CreateInstance();
                    sound.Volume = 1 * SettingsPage.Volume * SettingsPage.EffectVolume;
                    sound.Play();
                    MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/HurtSound").CreateInstance();
                    sound.Volume = 1 * SettingsPage.Volume * SettingsPage.EffectVolume;
                    sound.Play();
                    MonoGearGame.DestroyEntity(this);
                }
                // Disable the sleep dart
                Enabled = false;
            }
        }
Exemple #3
0
        /// <summary>
        /// Called when level is loaded or entity is added to scene
        /// </summary>
        public override void OnLevelLoaded()
        {
            base.OnLevelLoaded();

            tankSound       = AudioManager.AddPositionalAudio(MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Tank Movement"), 0, 250, Position, true);
            destroyedSprite = MonoGearGame.GetResource <Texture2D>("Sprites/BrokenAbrams");
        }
Exemple #4
0
        /// <summary>
        /// Method that updates the game
        /// </summary>
        /// <param name="input">Input</param>
        /// <param name="gameTime">GameTime</param>
        public override void Update(Input input, GameTime gameTime)
        {
            base.Update(input, gameTime);

            // Check if the player is in range
            if (Vector2.Distance(Position, player.Position) < 20)
            {
                inRange = true;
            }
            else
            {
                inRange = false;
            }
            // Check if the interact button is pressed
            if (input.IsButtonPressed(Input.Button.Interact) && inRange)
            {
                hackingProgress += ProgressPerClick;
                var sound = MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Hacking_sound").CreateInstance();
                sound.Volume = 1 * SettingsPage.Volume * SettingsPage.EffectVolume;
                sound.Play();
            }
            // Check if the hacking progress is completed
            if (hackingProgress >= 100)
            {
                // Hack the pc
                HackPC();
                Enabled = false;
                if (Objective != null)
                {
                    // Complete the objective
                    GameUI.CompleteObjective(Objective);
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Method that checks if there is a collision with any collider
        /// </summary>
        /// <returns>True if a collision is detected</returns>
        public virtual bool CollidesAny()
        {
            // Check if we could be colliding
            var colliders = BoxOverlapAny(this);

            if (colliders.Count() != 0)
            {
                // Run through all colliders that might collide and check if we do
                foreach (var col in colliders)
                {
                    if (Collides(col))
                    {
                        return(true);
                    }
                }
            }

            // Tilemap collision
            var circle = this as CircleCollider;

            if (circle != null)
            {
                return(CircleTilemapOverlap(circle, MonoGearGame.GetCurrentLevel()));
            }
            else
            {
                return(BoxTilemapOverlap(this, MonoGearGame.GetCurrentLevel()));
            }
        }
Exemple #6
0
        /// <summary>
        /// Method that updates the game
        /// </summary>
        /// <param name="input">Input</param>
        /// <param name="gameTime">GameTime</param>
        public override void Update(Input input, GameTime gameTime)
        {
            base.Update(input, gameTime);

            // Keep moving the missile forward
            var pos   = Position;
            var delta = Forward * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

            Move(delta);

            // If not exploded, kee[ counting down
            if (boemInSec > 0)
            {
                boemInSec -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

            // If we hit anything or the timer runs out, EXPLODE
            if (Collider.CollidesAny() || boemInSec <= 0)
            {
                Position = pos;
                Speed    = 0.0f;

                MonoGearGame.SpawnLevelEntity(new Explosion()
                {
                    Position = this.Position
                });
                MonoGearGame.DestroyEntity(this);
            }
        }
Exemple #7
0
        /// <summary>
        /// Method that checks if there is a collision with any collider
        /// </summary>
        /// <param name="other">Returns the other collider</param>
        /// <param name="hitTilemap">Returns if the collision is with the tilemap</param>
        /// <returns>True if a collision is detected</returns>
        public virtual bool CollidesAny(out Collider other, out bool hitTilemap)
        {
            // Check if we could be colliding
            var colliders = BoxOverlapAny(this);

            if (colliders.Count() != 0)
            {
                // Run through all colliders that might collide and check if we do
                foreach (var col in colliders)
                {
                    if (Collides(col))
                    {
                        other      = col;
                        hitTilemap = false;
                        return(true);
                    }
                }
            }
            other = null;

            // Tilemap collision
            var circle = this as CircleCollider;

            if (circle != null)
            {
                hitTilemap = CircleTilemapOverlap(circle, MonoGearGame.GetCurrentLevel());
            }
            else
            {
                hitTilemap = BoxTilemapOverlap(this, MonoGearGame.GetCurrentLevel());
            }

            return(hitTilemap);
        }
Exemple #8
0
        /// <summary>
        /// Method called every frame
        /// </summary>
        /// <param name="input">Input</param>
        /// <param name="gameTime">GameTime</param>
        public override void Update(Input input, GameTime gameTime)
        {
            if (creditsMode)
            {
                //One time changes
                if (MonoGearGame.FindEntitiesOfType <GameUI>()[0].Enabled)
                {
                    // Disable UI, spawn credits and set other things
                    MonoGearGame.FindEntitiesOfType <GameUI>()[0].Enabled = false;
                    MonoGearGame.FindEntitiesOfType <GameUI>()[0].Visible = false;

                    MonoGearGame.SpawnLevelEntity(new Credits());

                    instanceTexture = playerSprite;
                    Health          = 1;
                }

                // Move right on the screen
                Position        += Speed * new Vector2(1, 0) * (float)gameTime.ElapsedGameTime.TotalSeconds;
                Rotation         = MathHelper.ToRadians(90);
                forwardSpeed     = Speed;
                jeepSound.Volume = 0;
                // Required for tank range detection
                player.Position = Position;

                // Camera tracking
                if (Position.X < 28000)
                {
                    Camera.main.Position = Position;
                }

                return;
            }

            // Handles driving and input
            base.Update(input, gameTime);

            // Speed based volume
            float minVolume = 0.75f;

            if (Entered)
            {
                if (instanceTexture != playerSprite)
                {
                    instanceTexture = playerSprite;
                }
                jeepSound.Volume = minVolume + (1.0f - minVolume) * Math.Abs(forwardSpeed) / Speed;
            }
            else
            {
                if (instanceTexture != jeepSprite)
                {
                    instanceTexture = jeepSprite;
                }
                jeepSound.Volume = minVolume;
            }

            jeepSound.Position = Position;
        }
Exemple #9
0
        /// <summary>
        /// Method that executes when the level is loaded.
        /// </summary>
        public override void OnLevelLoaded()
        {
            base.OnLevelLoaded();
            birdSound        = AudioManager.AddPositionalAudio(MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Bird_sounds"), 1, 210, Position, true);
            birdSound.Volume = 0.2f;

            destroyedSprite = MonoGearGame.GetResource <Texture2D>("Sprites/DeadBird");
        }
Exemple #10
0
 protected virtual void LoadContent()
 {
     instanceTexture = MonoGearGame.GetResource <Texture2D>(TextureAssetName);
     if (instanceTexture != null)
     {
         Size = new Vector2(instanceTexture.Bounds.Size.X, instanceTexture.Bounds.Size.Y);
     }
 }
Exemple #11
0
        /// <summary>
        /// Method that executes when the level is loaded.
        /// </summary>
        public override void OnLevelLoaded()
        {
            base.OnLevelLoaded();
            // Add a sound effect to the car
            carSound = AudioManager.AddPositionalAudio(MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Deja Vu"), 0.3f, 500, Position, true);

            destroyedSprite = MonoGearGame.GetResource <Texture2D>("Sprites/BrokenCar");
        }
Exemple #12
0
        /// <summary>
        /// Adds a node to the list if it's walkable.
        /// </summary>
        /// <param name="x">Tile x</param>
        /// <param name="y">Tile y</param>
        /// <param name="map">map of tiles</param>
        /// <param name="list">list to add to</param>
        static void GetNodeIfWalkable(int x, int y, Tile[] map, List <Node> list)
        {
            var level = MonoGearGame.GetCurrentLevel();

            if (x < level.Width && x >= 0 && (y) < level.Height && y >= 0 && (map[x + y * level.Width]?.Walkable) == true)
            {
                list.Add(nodes[x + y * level.Width]);
            }
        }
Exemple #13
0
        /// <summary>
        /// Method that updates the game.
        /// </summary>
        /// <param name="input">Input</param>
        /// <param name="gameTime">GameTime</param>
        public override void Update(Input input, GameTime gameTime)
        {
            if (creditsMode)
            {
                // Fire at player jeep once
                if (Vector2.Distance(player.Position, Position) < 250)
                {
                    FireCannon();
                    creditsMode = false;
                }
            }

            // Input and movement handling
            base.Update(input, gameTime);

            if (destroyed)
            {
                AudioManager.StopPositional(tankSound);
            }


            float minVolume = 0.1f;

            if (Entered)
            {
                // Speed based sound
                tankSound.Position = Position;
                tankSound.Volume   = minVolume + (0.2f - minVolume) * Math.Abs(forwardSpeed) / Speed;

                // Player controlled cannon
                if (input.IsButtonPressed(Input.Button.Shoot) && lastShootTime + GunCycleTime <= (float)gameTime.TotalGameTime.TotalSeconds)
                {
                    lastShootTime = (float)gameTime.TotalGameTime.TotalSeconds;
                    FireCannon();
                }

                // Player controlled MG
                if (input.IsButtonPressed(Input.Button.Throw))
                {
                    var bullet = new Bullet(Collider);
                    bullet.Rotation = Rotation;

                    bullet.Position = Position + Forward * 18 + Right * 10;

                    MonoGearGame.SpawnLevelEntity(bullet);

                    var sound = MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Tank_gatling").CreateInstance();
                    sound.Volume = 0.5f * SettingsPage.Volume * SettingsPage.EffectVolume;
                    sound.Play();
                }
            }
            else
            {
                tankSound.Volume = minVolume;
            }
        }
Exemple #14
0
        /// <summary>
        /// Method that loads the content.
        /// </summary>
        protected override void LoadContent()
        {
            base.LoadContent();

            // Load sprite
            if (gameOverSprite == null)
            {
                gameOverSprite = MonoGearGame.GetResource <Texture2D>("Sprites/gameover");
            }
        }
Exemple #15
0
        /// <summary>
        /// Method that draws the pc.
        /// </summary>
        /// <param name="spriteBatch">SpriteBatch</param>
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);

            if (inRange && !hacked)
            {
                spriteBatch.DrawString(MonoGearGame.GetResource <SpriteFont>("Fonts/Arial"), "PRESS C TO HACK...", Position + new Vector2(-35, 16), Color.White);
                spriteBatch.DrawString(MonoGearGame.GetResource <SpriteFont>("Fonts/Arial"), "PROGRESS: " + hackingProgress.ToString() + "%", Position + new Vector2(-35, 24), Color.White);
            }
        }
Exemple #16
0
        /// <summary>
        /// Method that executes when the level is loaded.
        /// </summary>
        public override void OnLevelLoaded()
        {
            base.OnLevelLoaded();
            // Find the player
            player = MonoGearGame.FindEntitiesWithTag("Player")[0] as Player;

            //Play the explotion sound on creation
            sound          = AudioManager.AddPositionalAudio(MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Explosion"), 1, 1200, Position, false);
            sound.Position = Position;
            sound.Volume   = 0.8f;
        }
Exemple #17
0
 /// <summary>
 /// Method used to disable the gameover screen
 /// </summary>
 public void DisableGameOver()
 {
     // Find the player
     player         = MonoGearGame.FindEntitiesWithTag("Player")[0] as Player;
     gameOver       = false;
     Visible        = false;
     player.Enabled = true;
     player.Visible = true;
     MonoGearGame.FindEntitiesOfType <GameUI>()[0].Enabled = true;
     MonoGearGame.FindEntitiesOfType <GameUI>()[0].Visible = true;
 }
Exemple #18
0
        /// <summary>
        /// Method that executes when the level is loaded.
        /// </summary>
        public override void OnLevelLoaded()
        {
            base.OnLevelLoaded();

            player = MonoGearGame.FindEntitiesWithTag("Player")[0] as Player;

            //Reset the objectives list and sort in on index
            objectives.Clear();
            objectives.AddRange(MonoGearGame.FindEntitiesOfType <Objective>());
            objectives.Sort((a, b) => a.Index.CompareTo(b.Index));
        }
Exemple #19
0
        /// <summary>
        /// Called when level is loaded
        /// </summary>
        public override void OnLevelLoaded()
        {
            base.OnLevelLoaded();

            // Find spawnpoint and place player on it
            var ents = MonoGearGame.FindEntitiesWithTag("PlayerSpawnPoint");

            if (ents.Count > 0)
            {
                Position = new Vector2(ents[0].Position.X, ents[0].Position.Y);
            }
        }
Exemple #20
0
 public void Sleep()
 {
     if (state != State.Sleeping)
     {
         Enabled               = false;
         Z                     = -1; // Display below player
         AnimationRunning      = false;
         AnimationCurrentFrame = 1;
         state                 = State.Sleeping;
         sound                 = AudioManager.AddPositionalAudio(MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/snoreWhistle"), 1, 150, Position, true);
         sound.Volume          = 0.2f;
     }
 }
Exemple #21
0
        /// <summary>
        /// Method that executes when the level is loaded.
        /// </summary>
        public override void OnLevelLoaded()
        {
            base.OnLevelLoaded();

            player = MonoGearGame.FindEntitiesWithTag("Player")[0] as Player;

            if (props == null)
            {
                props = MonoGearGame.GetResource <Texture2D>("Sprites/Soisoisoisoisoisoisoisoisoisoisoisoisoisoisoisois");
            }
            heliSound        = AudioManager.AddPositionalAudio(MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Helicopter Sound Effect"), 1, 300, Position, true);
            heliSound.Volume = 0.1f;
            destoyedSprite   = MonoGearGame.GetResource <Texture2D>("Sprites/BrokenRoflcopter");
        }
Exemple #22
0
        /// <summary>
        /// Method used to enable the gameover screen
        /// </summary>
        public void EnableGameOver()
        {
            // Find the player
            player         = MonoGearGame.FindEntitiesWithTag("Player")[0] as Player;
            gameOver       = true;
            Position       = player.Position;
            Visible        = true;
            player.Enabled = false;

            var sound = MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Wasted_sound").CreateInstance();

            sound.Volume = 0.5f * SettingsPage.Volume * SettingsPage.EffectVolume;
            sound.Play();
        }
Exemple #23
0
        /// <summary>
        /// Adds a foreground layer.
        /// </summary>
        /// <param name="layer"></param>
        public void AddForegroundLayer(LevelOverlay layer)
        {
            if (layer.texture == null)
            {
                layer.texture = MonoGearGame.GetResource <Texture2D>(layer.textureName);
            }

            foregroundLayers.Add(layer);
            foregroundLayers.Sort(
                (a, b) =>
            {
                return(a.layer.CompareTo(b.layer));
            });
        }
Exemple #24
0
        /// <summary>
        /// Method that updates the game
        /// </summary>
        /// <param name="input">Input</param>
        /// <param name="gameTime">GameTime</param>
        public override void Update(Input input, GameTime gameTime)
        {
            base.Update(input, gameTime);

            // Check if the game is over
            if (gameOver)
            {
                // Check if space is pressed
                if (input.IsKeyPressed(Keys.Space))
                {
                    // Restart the game
                    MonoGearGame.Restart();
                }
            }
        }
Exemple #25
0
        /// <summary>
        /// Fires tank main gun by spaning a missile
        /// </summary>
        public void FireCannon()
        {
            var missile = new Missile(MonoGearGame.FindEntitiesOfType <Player>()[0].Collider);

            missile.Rotation = Rotation;

            missile.Position = Position + Forward * 88;

            MonoGearGame.SpawnLevelEntity(missile);

            var sound = MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Tank_shot").CreateInstance();

            sound.Volume = 0.5f * SettingsPage.Volume * SettingsPage.EffectVolume;
            sound.Play();
        }
Exemple #26
0
        /// <summary>
        /// Method that executes when the level is loaded.
        /// </summary>
        public override void OnLevelLoaded()
        {
            base.OnLevelLoaded();

            jeepSound        = AudioManager.AddPositionalAudio(MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Car"), 0, 300, Position, true);
            jeepSound.Volume = 0.1f;

            playerSprite    = MonoGearGame.GetResource <Texture2D>("Sprites/WillysPlayer");
            destroyedSprite = MonoGearGame.GetResource <Texture2D>("Sprites/BrokenWillys");
            jeepSprite      = MonoGearGame.GetResource <Texture2D>("Sprites/Willys");

            // Enter on level load, for example heli chase scene
            if (autoenter)
            {
                Enter();
            }
        }
Exemple #27
0
        /// <summary>
        /// Alerts a guard to the specified position and changes state
        /// </summary>
        /// <param name="origin"></param>
        public async void Alert(Vector2 origin)
        {
            // Make sure the correct thing happens based on the current state
            if (!Enabled || state == State.ToAlert)
            {
                return;
            }

            if (state == State.Patrolling)
            {
                patrolPathIndex = currentPathIndex;
            }

            if (state != State.Alerted)
            {
                var sound = MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Guard_Alert_Sound").CreateInstance();
                sound.Volume = 0.4f * SettingsPage.Volume * SettingsPage.EffectVolume;
                sound.Play();
            }

            state = State.ToAlert;

            // Small delay before being alerted
            await Task.Delay(1000);

            // Find a path
            Task.Run(() =>
            {
                Pathfinding.FindPath(Position, origin, (path) =>
                {
                    currentPath      = path;
                    currentPathIndex = 0;
                    state            = path != null ? State.Alerted : State.Idle;
                    Random rand      = new Random();
                    int number       = rand.Next(0, 9);
                    if (number == 0)
                    {
                        var sound    = MonoGearGame.GetResource <SoundEffect>("Audio/AudioFX/Get_over_here").CreateInstance();
                        sound.Volume = 0.2f * SettingsPage.Volume * SettingsPage.EffectVolume;
                        sound.Play();
                    }
                });
            });
        }
Exemple #28
0
        /// <summary>
        /// Method that updates the game
        /// </summary>
        /// <param name="input">Input</param>
        /// <param name="gameTime">GameTime</param>
        public override void Update(Input input, GameTime gameTime)
        {
            base.Update(input, gameTime);

            Collider collider;
            var      pos   = Position;
            var      delta = Forward * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

            Move(delta);

            bool hitTilemap;

            // Check if the bullet collides with anything
            if (Collider.CollidesAny(out collider, out hitTilemap, originCollider))
            {
                Position = pos;
                // Set the speed to 0
                Speed = 0.0f;

                // Check if the bullet collides with a player
                if (!hitTilemap && collider.Entity.Tag == "Player")
                {
                    var player = collider.Entity as Player;
                    // Decrease the player's health by 1
                    player.Health -= 1.0f;
                }

                // Find everything that can be destroyed
                var things = MonoGearGame.FindEntitiesOfType <IDestroyable>();
                foreach (var thing in things)
                {
                    // Damage the thing if it gets hit
                    var dis = thing as WorldEntity;
                    if (!hitTilemap && collider.Entity == dis)
                    {
                        thing.Damage(maxDamage);
                    }
                }

                // Destroy if we hit something
                MonoGearGame.DestroyEntity(this);
            }
        }
Exemple #29
0
        /// <summary>
        /// Method that updates the game
        /// </summary>
        /// <param name="input">Input</param>
        /// <param name="gameTime">GameTime</param>
        public override void Update(Input input, GameTime gameTime)
        {
            base.Update(input, gameTime);

            Collider collider;
            var      pos   = Position;
            var      delta = Forward * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

            Move(delta);

            bool hitTilemap;

            // Check if the rock collides with anything
            if (Collider.CollidesAny(out collider, out hitTilemap, originCollider))
            {
                Position = pos;
                Speed    = 0.0f;

                var entities = MonoGearGame.FindEntitiesOfType <Guard>();

                // Loop through all guards
                foreach (var guard in entities)
                {
                    // Check if the guard is in range
                    if (Vector2.Distance(Position, guard.Position) < 150)
                    {
                        guard.Interest(Position);
                    }
                }

                Enabled = false;
            }

            if (Speed > 0)
            {
                Speed -= 3;
            }
            else
            {
                Speed = 0;
            }
        }
Exemple #30
0
        /// <summary>
        /// Method that executes when the level is loaded.
        /// </summary>
        public override void OnLevelLoaded()
        {
            base.OnLevelLoaded();

            AudioManager.PlayGlobal(MonoGearGame.GetResource <SoundEffect>("Audio/Music/America_Horse_With_No_Name").CreateInstance());

            // Load all sprites
            wouter        = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/Wouter");
            manuel        = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/Manuel");
            bram          = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/Bram");
            danny         = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/Danny");
            tom           = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/Tom");
            thomas        = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/Thomas");
            madeby        = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/MadeBy");
            specialThanks = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/SpecialThanks");
            music         = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/Music");
            dejaVu        = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/DejaVu");
            america       = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/America");
            kevin         = MonoGearGame.GetResource <Texture2D>("Sprites/Credits/Kevin");
        }