public static void SpawnWeapon()
        {
            //One in three random numbers, one representing each weapon
            int rand = ExtensionMethods.RandomNumber(0, 3);

            switch (rand)
            {
            case 0:
            {
                //Spawn a new handgun at a random location
                World.Add(new Handgun(null, true));
                break;
            }

            case 1:
            {
                //Spawn a new handgun at a random location
                World.Add(new AssaultRifle(null, true));
                break;
            }

            case 2:
            {
                //Spawn a new handgun at a random location
                World.Add(new Shotgun(null, true));
                break;
            }
            }
        }
 /// <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");
     }
 }
        static Vector2 ZombieLocation()
        {
            //Spawn in left, right sides of the screen or up and down
            switch (ExtensionMethods.RandomNumber(0, 3))
            {
            case 0:
            {
                //Add a new common zombie at the top of the screen
                return(new Vector2(ExtensionMethods.RandomNumber(0, 1920), 1080));
            }

            case 1:
            {
                //Add a new common zombie at the bottom of the screen
                return(new Vector2(ExtensionMethods.RandomNumber(0, 1920), 0));
            }

            case 2:
            {
                //Add a new common zombie at the left of the screen
                return(new Vector2(0, ExtensionMethods.RandomNumber(0, 1080)));
            }

            case 3:
            {
                //Add a new common zombie at the right of the screen
                return(new Vector2(1920, ExtensionMethods.RandomNumber(0, 1080)));
            }
            }
            return(new Vector2(0, 0));
        }
 public AssaultRifle(Survivor origin, bool visible)
 {
     //Is the gun meant to be visible?
     if (visible == true)
     {
         //Give the gun a random position
         Position = new Vector2(ExtensionMethods.RandomNumber(0, 1920), ExtensionMethods.RandomNumber(0, 1080));
         //Set the sprite for this entity to be the survivor sprite
         Sprite = GraphicAssets.AssaultRifleSprite;
         //Collisition radius is 30 for the survivor
         CollisionRadius = 30;
         //Set the survivor to alive, since he is actually alive..
         IsAlive = true;
     }
     //Origin is equal to origin
     Origin = origin;
     //The offset for this sprite so that the bullet appears to come out of the barrel of the gun
     WeaponOffset = new Vector2(150, 50);
     //Set the weapon cooldown
     WeaponCoolDown = 10;
     //Set the amount of ammunition
     Ammunition = 50;
     //Set the gunshot
     Gunshot     = SoundAssets.AssaultRifle;
     SpriteColor = Color.White;
 }
 /// <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();
     }
 }
Example #6
0
        public static void NewGame(bool HumanDirector, int survivors)
        {
            //Reset all the things we need to reset
            Director = null;
            SurvivorList.Clear();
            WorldDirector.LevelCounter = 0;
            //Reset everything in the world
            GameEntities.Clear();
            NewEntities.Clear();
            AddedEntities.Clear();
            BulletList.Clear();
            ZombieList.Clear();
            AliveSurvivorList.Clear();
            //Reset the psawning counter
            WorldDirector.spawningcounter = 0;
            //If the director is human
            if (HumanDirector)
            {
                Add(new Director(Director.DirectorPersonality.Human));
                //Now start adding the survivors
                switch (survivors)
                {
                case 2:
                {
                    Add(new Survivor(PlayerIndex.One));
                    break;
                }

                case 3:
                {
                    Add(new Survivor(PlayerIndex.One));
                    Add(new Survivor(PlayerIndex.Three));
                    break;
                }

                case 4:
                {
                    Add(new Survivor(PlayerIndex.One));
                    Add(new Survivor(PlayerIndex.Three));
                    Add(new Survivor(PlayerIndex.Four));
                    break;
                }
                }
            }
            else
            {
                //Check the amount of survivors and spawn the number of survivors
                switch (survivors)
                {
                case 1:
                {
                    Add(new Survivor(PlayerIndex.One));
                    break;
                }

                case 2:
                {
                    Add(new Survivor(PlayerIndex.One));
                    Add(new Survivor(PlayerIndex.Two));
                    break;
                }

                case 3:
                {
                    Add(new Survivor(PlayerIndex.One));
                    Add(new Survivor(PlayerIndex.Two));
                    Add(new Survivor(PlayerIndex.Three));
                    break;
                }

                case 4:
                {
                    Add(new Survivor(PlayerIndex.One));
                    Add(new Survivor(PlayerIndex.Two));
                    Add(new Survivor(PlayerIndex.Three));
                    Add(new Survivor(PlayerIndex.Four));
                    break;
                }
                }
                //So it's an AI, pick one of the three personalities
                switch (ExtensionMethods.RandomNumber(1, 3))
                {
                case 1:
                {
                    Director dir = new Director(Director.DirectorPersonality.Swarmer);
                    Director = dir;
                    Add(Director);
                    break;
                }

                case 2:
                {
                    Director dir = new Director(Director.DirectorPersonality.Spammer);
                    Director = dir;
                    Add(Director);
                    break;
                }

                case 3:
                {
                    Director dir = new Director(Director.DirectorPersonality.Bully);
                    Director = dir;
                    Add(Director);
                    break;
                }
                }
            }
        }
Example #7
0
        /// <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();
            }
        }