Exemple #1
0
        /// <summary>
        /// Drop a random powerup type at a random coordinate on the map
        /// </summary>
        public static void DropPowerup()
        {
            var           coords = MainGame.ActiveMap.PathTiles[Random.Next(MainGame.ActiveMap.PathTiles.Count)].Coordinate;
            PowerupConfig pc     = MainGame.PowerupConfigs.ElementAt(Random.Next(MainGame.PowerupConfigs.Count)).Value;
            Powerup       p      = new Powerup(Game, coords * 40, new Vector2(40, 40), pc);

            MainGame.Sprites.Add(p);
        }
Exemple #2
0
        private void InitialiseTopdown()
        {
            GameState = GameState.PLAYINGTOPDOWN;

            //We don't use gravity in this world as its topdown
            World.Gravity = new Vector2(0);
            //Set space friction, so this is how much an object will decelarate by, by default. Prevents permanent sliding
            World.SpaceFriction = 0.95f;
            Sprites             = new List <Sprite>();

            //Set up the scene controller with drop rate of powerups and new enemies
            SceneController.Game      = this;
            SceneController.DropRate  = 200;
            SceneController.EnemyRate = 200;

            //Configs for bullets and powerups
            //Change these numbers to customise the effects of them
            BulletConfig rpg    = new BulletConfig(BulletTypes.Rocket, 25, Rocket, new Rectangle(0, 0, 20, 20), 500, 0, new TimeSpan(0, 0, 0, 1));
            BulletConfig smg    = new BulletConfig(BulletTypes.Bullet, 40, Bullet, new Rectangle(0, 0, 20, 20), 50, 0, new TimeSpan(0, 0, 0, 0, 50));
            BulletConfig pistol = new BulletConfig(BulletTypes.Bullet, 40, Bullet, new Rectangle(0, 0, 20, 20), 60, 0, new TimeSpan(0, 0, 0, 0, 200));

            PowerupConfig rpgP    = new PowerupConfig(PowerupType.RPG, RPG, new Rectangle(8, 8, 32, 32), 20, 1, new TimeSpan(0, 0, 0, 6), 0);
            PowerupConfig smgP    = new PowerupConfig(PowerupType.SMG, SMG, new Rectangle(8, 8, 32, 32), 500, 1, new TimeSpan(0, 0, 0, 5), 0);
            PowerupConfig ammoP   = new PowerupConfig(PowerupType.Ammo, Pistol, new Rectangle(8, 8, 32, 32), 100, 1, new TimeSpan(0, 0, 0, 8), 0);
            PowerupConfig speedP  = new PowerupConfig(PowerupType.Speed, Speed, new Rectangle(8, 8, 32, 32), 0, 0.2f, new TimeSpan(0, 0, 0, 6), 0);
            PowerupConfig healthP = new PowerupConfig(PowerupType.Health, Health, new Rectangle(8, 8, 32, 32), 0, 1, new TimeSpan(0, 0, 0, 5), 50);

            BulletConfigs = new Dictionary <WeaponTypes, BulletConfig>
            {
                { WeaponTypes.RPG, rpg },
                { WeaponTypes.SMG, smg },
                { WeaponTypes.Pistol, pistol }
            };

            PowerupConfigs = new Dictionary <PowerupType, PowerupConfig>
            {
                { PowerupType.RPG, rpgP },
                { PowerupType.SMG, smgP },
                { PowerupType.Ammo, ammoP },
                { PowerupType.Speed, speedP },
                { PowerupType.Health, healthP }
            };

            TopdownHero = new TopdownHero(this, new Vector2(32, 415), new Vector2(32, 32), new Vector2(0.2f, 0.2f), 1)
            {
                Texture     = Player,
                TextureRect = Player.Bounds,
                Visible     = true
            };
            Sprites.Add(TopdownHero);

            //Add some starter enemies
            Enemy e  = new Enemy(this, Zombie, Zombie.Bounds, new Vector2(400, 780), new Vector2(30), new Vector2(0.1f), 1),
                  e2 = new Enemy(this, Zombie, Zombie.Bounds, new Vector2(500, 780), new Vector2(30), new Vector2(0.1f), 1),
                  e3 = new Enemy(this, Zombie, Zombie.Bounds, new Vector2(800, 780), new Vector2(30), new Vector2(0.1f), 1);

            Sprites.AddRange(new List <Enemy>()
            {
                e, e2, e3
            });

            //Add moving box obstacles
            Box b  = new Box(this, BoxTex, new Vector2(30), 16, new Vector2(0.2f), 0.2f);
            Box b2 = new Box(this, BoxTex, new Vector2(550, 600), 16, new Vector2(0.2f), 0.2f);
            Box b3 = new Box(this, BoxTex, new Vector2(770, 80), 16, new Vector2(0.2f), 0.2f);

            Sprites.AddRange(new List <Box>()
            {
                b, b2, b3
            });
            AStar.TileSize = 40;
        }