/// <summary> /// Should we spawn a special zombie? /// </summary> public static void CheckSpawnSpecial() { //If the player started the game if (GamePad.GetState(PlayerIndex.Two).Buttons.Y == ButtonState.Pressed) { //Call the spawn special zombie method, passing the variable for Juggernaught WorldDirector.ZombieSpawner("j"); } //If the player started the game if (GamePad.GetState(PlayerIndex.Two).Buttons.X == ButtonState.Pressed) { //Call the spawn special zombie method, passing the variable for Juggernaught WorldDirector.ZombieSpawner("s"); } //If the player started the game if (GamePad.GetState(PlayerIndex.Two).Buttons.A == ButtonState.Pressed) { //Call the spawn special zombie method, passing the variable for Juggernaught WorldDirector.ZombieSpawner("e"); } //If the player started the game if (GamePad.GetState(PlayerIndex.Two).Buttons.B == ButtonState.Pressed) { //Call the spawn special zombie method, passing the variable for Juggernaught WorldDirector.ZombieSpawner("cm"); } }
/// <summary> /// Override Logic method /// </summary> public override void Logic() { //Set the target to the first entry in the survivor list Target = World.AliveSurvivorList.ElementAt(0); //Go through every survivor foreach (Survivor surv in World.AliveSurvivorList) { //If the target has more kills than the next survivor if (Target.Kills >= surv.Kills && surv.IsAlive) { //Set that survivor as the target Target = surv; } } //One in three chance of this happening if (ExtensionMethods.RandomNumber(1, 3) == 2) { //If the Director has enough resources if (World.Director.Resources > SpeedEffect.Instance.Cost) { //Go through all the zombies foreach (Zombie zom in World.ZombieList) { if (CollisionEngine.IsNear(Target, zom)) { //Use either the slow or speed up if (ExtensionMethods.RandomNumber(1, 2) == 2) { //Slow the players SpeedEffect.Instance.Activate(); } else { //Make the zombies go faster SlowEffect.Instance.Activate(); } } } } } //One in three chance of spawning a juggernaught if (ExtensionMethods.RandomNumber(1, 3) == 2) { //Try and spawn a juggernaught WorldDirector.ZombieSpawner("j"); } //One in two chance of spawning an exploder if (ExtensionMethods.RandomNumber(1, 5) == 3) { //Try and spawn a juggernaught WorldDirector.ZombieSpawner("e"); } //One in three chance of spawning a speeder //One in three chance of spawning a juggernaught if (ExtensionMethods.RandomNumber(1, 1000) == 2) { //Try and spawn a juggernaught WorldDirector.ZombieSpawner("s"); } }
/// <summary> /// Override Logic method /// </summary> public override void Logic() { if (Target.IsAlive == false) { Target = World.AliveSurvivorList.ElementAt(ExtensionMethods.RandomNumber(0, World.AliveSurvivorList.Count)); } //If the Director has enough resources if (World.Director.Resources > SpeedEffect.Instance.Cost) { //Use either the slow or speed up if (ExtensionMethods.RandomNumber(1, 10) == 5) { //Slow the players SpeedEffect.Instance.Activate(); } else if (ExtensionMethods.RandomNumber(1, 10) == 2) { //Make the zombies go faster SlowEffect.Instance.Activate(); } } //Spawn a new common zomibie, one in five chance if (ExtensionMethods.RandomNumber(1, 20) == 2) { //Try and spawn a common zombie WorldDirector.ZombieSpawner("cm"); } //If the director can spawn a weapon, do it if (World.Director.CanSpawnWeapon) { SpawnWeaponEffect.Instance.Activate(); } }
//Frames elapsed public static void Update(GameEngine instance) { //Is updating equals true IsUpdating = true; //Update the world director WorldDirector.Update(); //Check for collisions CollisionEngine.collisionHandler(ZombieList, BulletList, SurvivorList, WeaponList); //Call update for every entity in the game foreach (GameEntity entity in GameEntities) { //Update every entity in the game entity.Update(); } //Once every entity has been updated, set the updating flag to false IsUpdating = false; //Add all the newly added entities into the list of added entities foreach (GameEntity entity in AddedEntities) { AddEntityToLists(entity); } //Clear the added entities list AddedEntities.Clear(); //Remove any dead entities //Lambada alogirthims adapted from Michael Hoffmans //http://gamedevelopment.tutsplus.com/tutorials/make-a-neon-vector-shooter-in-xna-more-gameplay--gamedev-10103 GameEntities = GameEntities.Where(x => x.IsAlive).ToList(); ZombieList = ZombieList.Where(x => x.IsAlive).ToList(); BulletList = BulletList.Where(x => x.IsAlive).ToList(); WeaponList = WeaponList.Where(x => x.IsAlive).ToList(); AliveSurvivorList = SurvivorList.Where(x => x.IsAlive).ToList(); //Gameover is true bool gameover = true; //If any survivors are still alive foreach (Survivor surv in SurvivorList) { if (surv.IsAlive == true) { //Then it's not game over gameover = false; } } //If the games over, set the gamestate to gameover if (gameover) { instance.currentState = GameEngine.GameState.GameOver; } }
//Make every zombie in the game world faster public override void Activate() { //If the director can spawn a weapon if (World.Director.CanSpawnWeapon) { //Spawn the weapon WorldDirector.SpawnWeapon(); //Reward the director World.Director.Resources += Reward; //Reset the directors ability to spawn a weapon World.Director.CanSpawnWeapon = false; } }
/// <summary> /// Override Logic method /// </summary> public override void Logic() { //Go through every survivor foreach (Survivor surv in World.AliveSurvivorList) { //If the survivor has more kills than the target if (Target.Kills < surv.Kills && surv.IsAlive) { //Set that survivor to be the target Target = surv; } } //If the Director has enough resources if (World.Director.Resources >= 10000) { while (World.Director.Resources > 500) { //Use either the slow or speed up if (ExtensionMethods.RandomNumber(1, 10) == 5) { //Slow the players SpeedEffect.Instance.Activate(); } if (ExtensionMethods.RandomNumber(1, 10) == 2) { //Make the zombies go faster SlowEffect.Instance.Activate(); } //Spawn a new common zomibie, one in ten chance if (ExtensionMethods.RandomNumber(1, 10) == 2) { //Try and spawn a common zombie WorldDirector.ZombieSpawner("cm"); } //Spawn a juggernaught, one in ten if (ExtensionMethods.RandomNumber(1, 10) == 7) { //Try and spawn a common zombie WorldDirector.ZombieSpawner("j"); } //Spawn an exploder, one in ten if (ExtensionMethods.RandomNumber(1, 10) == 4) { //Try and spawn a common zombie WorldDirector.ZombieSpawner("e"); } //Spawn a speeder, one in ten if (ExtensionMethods.RandomNumber(1, 10) == 3) { //Try and spawn a common zombie WorldDirector.ZombieSpawner("s"); } } } //If the director can spawn a weapon, do it if (World.Director.CanSpawnWeapon) { SpawnWeaponEffect.Instance.Activate(); } }