示例#1
0
        //Idealement le nom et la taille du tileset vont tous aller dans le fichier lvl.dat ou wtv, et on va juste passer game et levelName
        public Level(ZombieGame game, string levelName)
            : base(game)
        {
            StreamReader levelData      = new StreamReader("Content/Levels/" + levelName + ".dat");
            string       tilesetName    = levelData.ReadLine();
            int          tilesetRows    = int.Parse(levelData.ReadLine());
            int          tilesetColumns = int.Parse(levelData.ReadLine());

            Height = int.Parse(levelData.ReadLine());
            Width  = int.Parse(levelData.ReadLine());

            TileType = new int[Height, Width];

            for (int i = 0; i < Height; ++i)
            {
                string[] numbers = levelData.ReadLine().Split(' ');

                for (int j = 0; j < Width; ++j)
                {
                    TileType[i, j] = int.Parse(numbers[j]);
                }
            }

            ZombieGame = game;
            Tileset    = new Tileset(ZombieGame.TextureMgr.Find(tilesetName), tilesetRows, tilesetColumns);
        }
示例#2
0
 public Shotgun(ZombieGame game, Vector2 initPos)
     : base(game, initPos, NAME, DAMAGE, 96, 96, 12, FIRE_RATE, BULLET_SPEED, false, RELOAD_TIME)
 {
     Emitters.Add(new ParticleEmitter(game, 50, false, FIRE_RATE, new Vector2(Sprite.Position.X - EMITTERS_OFFSET, Sprite.Position.Y)));
     Emitters.Add(new ParticleEmitter(game, 50, false, FIRE_RATE, new Vector2(Sprite.Position.X + EMITTERS_OFFSET, Sprite.Position.Y)));
     ShotgunPump = game.SfxMgr.Find("ShotgunPump");
 }
示例#3
0
        public AnimatedSprite(ZombieGame game, string fileName, int frames, int lines, Vector2 position, float depth, float updateTime)
            : base(game, fileName, position, depth)
        {
            Frames = frames;
            Lines = lines;

            CurLine = 0;
            CurFrame = 0;
            IsLooping = false;
            UpdateTime = updateTime;
            ElapsedTime = 0.0f;

            FrameWidth = Width / Frames;
            FrameHeight = Height / Lines;

            Rectangles = new Rectangle[Lines, Frames]; //Like a matrix, the first index is the row (line), the second the column (frame)

            for (int i = 0; i < Lines; ++i)
            {
                for (int j = 0; j < Frames; ++j)
                {
                    Rectangles[i, j] = new Rectangle(j * FrameWidth, i * FrameHeight, FrameWidth, FrameHeight);
                }
            }
        }
示例#4
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (ZombieGame game = new ZombieGame())
     {
         game.Run();
     }
 }
示例#5
0
        //Idealement le nom et la taille du tileset vont tous aller dans le fichier lvl.dat ou wtv, et on va juste passer game et levelName
        public Level(ZombieGame game, string levelName)
            : base(game)
        {
            StreamReader levelData = new StreamReader("Content/Levels/" + levelName + ".dat");
            string tilesetName = levelData.ReadLine();
            int tilesetRows = int.Parse(levelData.ReadLine());
            int tilesetColumns = int.Parse(levelData.ReadLine());
            Height = int.Parse(levelData.ReadLine());
            Width = int.Parse(levelData.ReadLine());

            TileType = new int[Height, Width];

            for (int i = 0; i < Height; ++i)
            {
                string[] numbers = levelData.ReadLine().Split(' ');

                for (int j = 0; j < Width; ++j)
                {
                    TileType[i, j] = int.Parse(numbers[j]);
                }
            }

            ZombieGame = game;
            Tileset = new Tileset(ZombieGame.TextureMgr.Find(tilesetName), tilesetRows, tilesetColumns);
        }
示例#6
0
        public AnimatedSprite(ZombieGame game, string fileName, int frames, int lines, Vector2 position, float depth, float updateTime)
            : base(game, fileName, position, depth)
        {
            Frames = frames;
            Lines  = lines;

            CurLine     = 0;
            CurFrame    = 0;
            IsLooping   = false;
            UpdateTime  = updateTime;
            ElapsedTime = 0.0f;

            FrameWidth  = Width / Frames;
            FrameHeight = Height / Lines;

            Rectangles = new Rectangle[Lines, Frames]; //Like a matrix, the first index is the row (line), the second the column (frame)

            for (int i = 0; i < Lines; ++i)
            {
                for (int j = 0; j < Frames; ++j)
                {
                    Rectangles[i, j] = new Rectangle(j * FrameWidth, i * FrameHeight, FrameWidth, FrameHeight);
                }
            }
        }
示例#7
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (ZombieGame game = new ZombieGame())
     {
         game.Run();
     }
 }
示例#8
0
 public Shotgun(ZombieGame game, Vector2 initPos)
     : base(game, initPos, NAME, DAMAGE, 96, 96, 12, FIRE_RATE, BULLET_SPEED, false, RELOAD_TIME)
 {
     Emitters.Add(new ParticleEmitter(game, 50, false, FIRE_RATE, new Vector2(Sprite.Position.X - EMITTERS_OFFSET, Sprite.Position.Y)));
     Emitters.Add(new ParticleEmitter(game, 50, false, FIRE_RATE, new Vector2(Sprite.Position.X + EMITTERS_OFFSET, Sprite.Position.Y)));
     ShotgunPump = game.SfxMgr.Find("ShotgunPump");
 }
示例#9
0
 public Camera(ZombieGame game)
     : base(game)
 {
     ZombieGame = game;
     View = game.GraphicsDevice.Viewport;
     PlayerSize = new Vector2(game.Player.Sprite.FrameWidth, game.Player.Sprite.FrameHeight);
     ScreenSize = new Vector2(game.Graphics.PreferredBackBufferWidth, game.Graphics.PreferredBackBufferHeight);
 }
示例#10
0
 public Enemy(ZombieGame game, Vector2 initPos, string spriteName, int spriteFrames, int spriteLines, float depth, float updateTime, int maxHealth, int damage, float maxSpeed, float attackDelay)
     : base(game, spriteName, spriteFrames, spriteLines, initPos, depth, updateTime, maxHealth, maxSpeed)
 {
     Damage           = damage;
     Sprite.IsLooping = true;
     DamageSound      = ZombieGame.SfxMgr.Find(spriteName + "Damage");
     AttackDelay      = attackDelay;
 }
示例#11
0
 public Camera(ZombieGame game)
     : base(game)
 {
     ZombieGame = game;
     View       = game.GraphicsDevice.Viewport;
     PlayerSize = new Vector2(game.Player.Sprite.FrameWidth, game.Player.Sprite.FrameHeight);
     ScreenSize = new Vector2(game.Graphics.PreferredBackBufferWidth, game.Graphics.PreferredBackBufferHeight);
 }
示例#12
0
 public Particle(ZombieGame game, string fileName, Vector2 position, Vector2 direction, float life, float depth, float speed)
     : base(game, fileName, position, depth)
 {
     Direction = direction;
     Life      = life;
     Speed     = speed;
     IsAlive   = true;
 }
示例#13
0
 public Enemy(ZombieGame game, Vector2 initPos, string spriteName, int spriteFrames, int spriteLines, float depth, float updateTime, int maxHealth, int damage, float maxSpeed, float attackDelay)
     : base(game, spriteName, spriteFrames, spriteLines, initPos, depth, updateTime, maxHealth, maxSpeed)
 {
     Damage = damage;
     Sprite.IsLooping = true;
     DamageSound = ZombieGame.SfxMgr.Find(spriteName + "Damage");
     AttackDelay = attackDelay;
 }
示例#14
0
 public Particle(ZombieGame game, string fileName, Vector2 position, Vector2 direction, float life, float depth, float speed)
     : base(game, fileName, position, depth)
 {
     Direction = direction;
     Life = life;
     Speed = speed;
     IsAlive = true;
 }
示例#15
0
 public Player(ZombieGame game, Vector2 initPos)
     : base(game, SPRITE_NAME, SPRITE_FRAMES, SPRITE_LINES, initPos, DEPTH, UPDATE_TIME, MAX_HEALTH, MAX_SPEED)
 {
     GunBelt = new List <Tuple <string, Gun> >();
     PopulateGunBelt(game, initPos);
     CurrentGun     = 0;
     Gun            = GunBelt[CurrentGun].Item2;
     Gun.IsSelected = true;
 }
示例#16
0
 public Player(ZombieGame game, Vector2 initPos)
     : base(game, SPRITE_NAME, SPRITE_FRAMES, SPRITE_LINES, initPos, DEPTH, UPDATE_TIME, MAX_HEALTH, MAX_SPEED)
 {
     GunBelt = new List<Tuple<string, Gun>>();
     PopulateGunBelt(game, initPos);
     CurrentGun = 0;
     Gun = GunBelt[CurrentGun].Item2;
     Gun.IsSelected = true;
 }
示例#17
0
 public Emitter(ZombieGame game, int maxParticles, bool automaticSpawn, float timeBetweenSpawn)
     : base(game)
 {
     ZombieGame = game;
     TimeBetweenSpawn = timeBetweenSpawn;
     AutomaticSpawn = automaticSpawn;
     TimeSinceLastSpawn = 0.0f;
     ActiveParticles = new LinkedList<Particle>();
 }
示例#18
0
 public Pickable(ZombieGame game, string spriteName, int spriteFrames, int spriteLines, Vector2 spawningLocation, float depth, float updateTime)
     : base(game)
 {
     ZombieGame       = game;
     IsPickedUp       = false;
     SpawningLocation = spawningLocation;
     Sprite           = new AnimatedSprite(ZombieGame, spriteName, spriteFrames, spriteLines, spawningLocation, depth, updateTime);
     HoveringSprite   = new AnimatedSprite(ZombieGame, "Pickme", 1, 1, new Vector2(spawningLocation.X - 24.0f, spawningLocation.Y - 20.0f), depth, updateTime);
     //Ajout le pickupsound
 }
示例#19
0
 public Pickable(ZombieGame game, string spriteName, int spriteFrames, int spriteLines, Vector2 spawningLocation, float depth, float updateTime)
     : base(game)
 {
     ZombieGame = game;
     IsPickedUp = false;
     SpawningLocation = spawningLocation;
     Sprite = new AnimatedSprite(ZombieGame, spriteName, spriteFrames, spriteLines, spawningLocation, depth, updateTime);
     HoveringSprite = new AnimatedSprite(ZombieGame, "Pickme", 1, 1, new Vector2(spawningLocation.X - 24.0f, spawningLocation.Y - 20.0f), depth, updateTime);
     //Ajout le pickupsound
 }
示例#20
0
 public Emitter(ZombieGame game, int maxItems, bool automaticSpawn, float timeBetweenSpawn, Vector2 position)
     : base(game)
 {
     ZombieGame         = game;
     MaxItems           = maxItems;
     AutomaticSpawn     = automaticSpawn;
     TimeBetweenSpawn   = timeBetweenSpawn;
     TimeSinceLastSpawn = TimeBetweenSpawn;
     Position           = position;
 }
示例#21
0
 public Emitter(ZombieGame game, int maxItems, bool automaticSpawn, float timeBetweenSpawn, Vector2 position)
     : base(game)
 {
     ZombieGame = game;
     MaxItems = maxItems;
     AutomaticSpawn = automaticSpawn;
     TimeBetweenSpawn = timeBetweenSpawn;
     TimeSinceLastSpawn = TimeBetweenSpawn;
     Position = position;
 }
示例#22
0
 public Character(ZombieGame game, string spriteName, int spriteFrames, int spriteLines, Vector2 initPos, float depth, float updateTime, int maxHealth, float maxSpeed)
     : base(game)
 {
     ZombieGame = game;
     Sprite = new AnimatedSprite(ZombieGame, spriteName, spriteFrames, spriteLines, initPos, depth, updateTime);
     MaxHealth = maxHealth;
     Health = MaxHealth;
     IsAlive = true;
     MaxSpeed = maxSpeed;
     DamageSound = ZombieGame.SfxMgr.Find("DefaultDamage");
 }
示例#23
0
 public Character(ZombieGame game, string spriteName, int spriteFrames, int spriteLines, Vector2 initPos, float depth, float updateTime, int maxHealth, float maxSpeed)
     : base(game)
 {
     ZombieGame  = game;
     Sprite      = new AnimatedSprite(ZombieGame, spriteName, spriteFrames, spriteLines, initPos, depth, updateTime);
     MaxHealth   = maxHealth;
     Health      = MaxHealth;
     IsAlive     = true;
     MaxSpeed    = maxSpeed;
     DamageSound = ZombieGame.SfxMgr.Find("DefaultDamage");
 }
示例#24
0
 public Gun(ZombieGame game, Vector2 initPos)
     : base(game)
 {
     ZombieGame = game;
     Sprite = new Sprite(ZombieGame, "Pistol", initPos, 0.0f);
     Sprite.Origin = new Vector2(0, Sprite.Height / 2);
     Sprite.Rotation = 3 * MathHelper.PiOver2;
     Emitters = new List<Emitter>();
     Emitters.Add(new Emitter(ZombieGame, 100, false, PISTOL_FIRE_RATE));
     IsShooting = false;
     GunShotSound = ZombieGame.SfxMgr.Find("PistolShot");
 }
示例#25
0
        private void PopulateGunBelt(ZombieGame game, Vector2 initPos)
        {
            Pistol pistol = new Pistol(game, initPos);

            pistol.IsPickedUp = true; // Player starts with the pistol picked up
            Shotgun shotgun = new Shotgun(game, initPos);
            SMG     smg     = new SMG(game, initPos);

            GunBelt.Add(new Tuple <string, Gun>("Pistol", pistol));
            GunBelt.Add(new Tuple <string, Gun>("Shotgun", shotgun));
            GunBelt.Add(new Tuple <string, Gun>("SMG", smg));
            NumberOfGuns = GunBelt.Count;
        }
示例#26
0
        public Gun(ZombieGame game, Vector2 initPos, string gunName, int damage, int maxAmmo, int ammo,
                   int clipSize, float fireRate, float bulletSpeed, bool infiniteAmmo, float reloadingTime)
            : base(game)
        {
            ZombieGame    = game;
            GunName       = gunName;
            Damage        = damage;
            InfiniteAmmo  = infiniteAmmo;
            ReloadingTime = reloadingTime;

            MaxAmmo  = maxAmmo;
            Ammo     = ammo;
            ClipSize = clipSize;

            if (!InfiniteAmmo)
            {
                if (Ammo >= ClipSize)
                {
                    ClipAmmo = ClipSize;
                }
                else
                {
                    ClipAmmo = Ammo;
                }

                Ammo -= ClipAmmo;
            }
            else
            {
                ClipAmmo = ClipSize;
            }

            FireRate    = fireRate;
            BulletSpeed = bulletSpeed;

            Sprite          = new Sprite(ZombieGame, GunName, initPos, 0.0f);
            Sprite.Origin   = new Vector2(0, Sprite.Height / 2);
            Sprite.Rotation = 3 * MathHelper.PiOver2;

            Emitters = new List <ParticleEmitter>();

            IsShooting     = false;
            IsReloading    = false;
            GunShotSound   = ZombieGame.SfxMgr.Find(GunName + "Shot");
            GunReloadSound = ZombieGame.SfxMgr.Find(GunName + "Reload");

            IsSelected = false;
            IsPickedUp = false;
        }
示例#27
0
 public Sprite(ZombieGame game, string fileName, Vector2 position, float depth)
     : base(game)
 {
     ZombieGame = game;
     SpriteSheet = ZombieGame.TextureMgr.Find(fileName);
     Position = position;
     Rotation = 0.0f;
     Scale = 1.0f;
     Color = Color.White;
     Origin = Vector2.Zero;
     Effects = SpriteEffects.None;
     Depth = depth;
     Height = SpriteSheet.Height;
     Width = SpriteSheet.Width;
 }
示例#28
0
 public Sprite(ZombieGame game, string fileName, Vector2 position, float depth)
     : base(game)
 {
     ZombieGame  = game;
     SpriteSheet = ZombieGame.TextureMgr.Find(fileName);
     Position    = position;
     Rotation    = 0.0f;
     Scale       = 1.0f;
     Color       = Color.White;
     Origin      = Vector2.Zero;
     Effects     = SpriteEffects.None;
     Depth       = depth;
     Height      = SpriteSheet.Height;
     Width       = SpriteSheet.Width;
 }
示例#29
0
        public Gun(ZombieGame game, Vector2 initPos, string gunName, int damage, int maxAmmo, int ammo,
            int clipSize, float fireRate, float bulletSpeed, bool infiniteAmmo, float reloadingTime)
            : base(game)
        {
            ZombieGame = game;
            GunName = gunName;
            Damage = damage;
            InfiniteAmmo = infiniteAmmo;
            ReloadingTime = reloadingTime;

            MaxAmmo = maxAmmo;
            Ammo = ammo;
            ClipSize = clipSize;

            if (!InfiniteAmmo)
            {
                if (Ammo >= ClipSize)
                    ClipAmmo = ClipSize;
                else
                    ClipAmmo = Ammo;

                Ammo -= ClipAmmo;
            }
            else
                ClipAmmo = ClipSize;

            FireRate = fireRate;
            BulletSpeed = bulletSpeed;

            Sprite = new Sprite(ZombieGame, GunName, initPos, 0.0f);
            Sprite.Origin = new Vector2(0, Sprite.Height / 2);
            Sprite.Rotation = 3 * MathHelper.PiOver2;

            Emitters = new List<ParticleEmitter>();

            IsShooting = false;
            IsReloading = false;
            GunShotSound = ZombieGame.SfxMgr.Find(GunName + "Shot");
            GunReloadSound = ZombieGame.SfxMgr.Find(GunName + "Reload");

            IsSelected = false;
            IsPickedUp = false;
        }
示例#30
0
 public GunPickable(ZombieGame game, Vector2 spawningLocation, string gunName)
     : base(game, gunName, 1, 1, spawningLocation, DEPTH, UPDATE_TIME)
 {
     ZombieGame = game;
     GunName    = gunName;
 }
示例#31
0
        private void PopulateGunBelt(ZombieGame game, Vector2 initPos)
        {
            Pistol pistol = new Pistol(game, initPos);
            pistol.IsPickedUp = true; // Player starts with the pistol picked up
            Shotgun shotgun = new Shotgun(game, initPos);
            SMG smg = new SMG(game, initPos);

            GunBelt.Add(new Tuple<string, Gun>("Pistol", pistol));
            GunBelt.Add(new Tuple<string, Gun>("Shotgun", shotgun));
            GunBelt.Add(new Tuple<string, Gun>("SMG", smg));
            NumberOfGuns = GunBelt.Count;
        }
示例#32
0
 public Zombie(ZombieGame game, Vector2 initPos)
     : base(game, initPos, SPRITE_NAME, SPRITE_FRAMES, SPRITE_LINES, DEPTH, UPDATE_TIME, MAX_HEALTH, MAX_DAMAGE, MAX_SPEED, ATTACK_DELAY)
 {
 }
示例#33
0
 public ParticleEmitter(ZombieGame game, int maxParticles, bool automaticSpawn, float timeBetweenSpawn, Vector2 position)
     : base(game, maxParticles, automaticSpawn, timeBetweenSpawn, position)
 {
     ActiveParticles = new List<Particle>();
 }
示例#34
0
 public Zombie(ZombieGame game, Vector2 initPos)
     : base(game, initPos, SPRITE_NAME, SPRITE_FRAMES, SPRITE_LINES, DEPTH, UPDATE_TIME, MAX_HEALTH, MAX_DAMAGE, MAX_SPEED, ATTACK_DELAY)
 {
 }
示例#35
0
 public FpsDisplay(ZombieGame game, string fontName)
     : base(game)
 {
     ZombieGame = game;
     FontName = fontName;
 }
示例#36
0
 public HUD(ZombieGame game, string fontName)
     : base(game)
 {
     ZombieGame = game;
     FontName   = fontName;
 }
示例#37
0
 public HUD(ZombieGame game, string fontName)
     : base(game)
 {
     ZombieGame = game;
     FontName = fontName;
 }
示例#38
0
 public GunPickable(ZombieGame game, Vector2 spawningLocation, string gunName)
     : base(game, gunName, 1, 1, spawningLocation, DEPTH, UPDATE_TIME)
 {
     ZombieGame = game;
     GunName = gunName;
 }
示例#39
0
 public ResourceManager(ZombieGame game)
 {
     ZombieGame = game;
     Resources  = new List <BaseResource <T> >();
 }
示例#40
0
 public SMG(ZombieGame game, Vector2 initPos)
     : base(game, initPos, NAME, DAMAGE, 1000, 320, 32, FIRE_RATE, BULLET_SPEED, false, RELOAD_TIME)
 {
     Emitters.Add(new ParticleEmitter(game, 50, false, FIRE_RATE, Sprite.Position));
 }
示例#41
0
 public SMG(ZombieGame game, Vector2 initPos)
     : base(game, initPos, NAME, DAMAGE, 1000, 320, 32, FIRE_RATE, BULLET_SPEED, false, RELOAD_TIME)
 {
     Emitters.Add(new ParticleEmitter(game, 50, false, FIRE_RATE, Sprite.Position));
 }
示例#42
0
 public Character(ZombieGame game, string spriteName, int spriteFrames, int spriteLines, Vector2 initPos, float depth)
     : base(game)
 {
     ZombieGame = game;
     Sprite = new AnimatedSprite(ZombieGame, spriteName, spriteFrames, spriteLines, initPos, depth);
 }
示例#43
0
 public ParticleEmitter(ZombieGame game, int maxParticles, bool automaticSpawn, float timeBetweenSpawn, Vector2 position)
     : base(game, maxParticles, automaticSpawn, timeBetweenSpawn, position)
 {
     ActiveParticles = new List <Particle>();
 }
示例#44
0
 public FpsDisplay(ZombieGame game, string fontName)
     : base(game)
 {
     ZombieGame = game;
     FontName   = fontName;
 }
示例#45
0
 public EnemySpawner(ZombieGame game, int maxEnemies, bool automaticSpawn, float timeBetweenSpawn, Vector2 position)
     : base(game, maxEnemies, automaticSpawn, timeBetweenSpawn, position)
 {
     ActiveEnemies = new LinkedList<Enemy>();
 }
示例#46
0
 public EnemySpawner(ZombieGame game, int maxEnemies, bool automaticSpawn, float timeBetweenSpawn, Vector2 position)
     : base(game, maxEnemies, automaticSpawn, timeBetweenSpawn, position)
 {
     ActiveEnemies = new LinkedList <Enemy>();
 }
示例#47
0
 public Player(ZombieGame game, Vector2 initPos)
     : base(game, SPRITE_NAME, SPRITE_FRAMES, SPRITE_LINES, initPos, DEPTH)
 {
 }
示例#48
0
 public Ennemy(ZombieGame game, Vector2 initPos, float maxSpeed)
     : base(game, SPRITE_NAME, SPRITE_FRAMES, SPRITE_LINES, initPos, DEPTH)
 {
     MaxSpeed = maxSpeed;
 }