Inheritance: IContent
Ejemplo n.º 1
0
        /// <summary>
        ///     Initializes a new Player class.
        /// </summary>
        /// <param name="texture">The Texture.</param>
        /// <param name="texture2">The ErasedTexture.</param>
        public Player(Texture2D texture, Texture2D texture2)
        {
            _erased = texture2;
            Bounds = new Polygon(new Vector2(1, 6), new Vector2(5, 4), new Vector2(11, 0), new Vector2(22, 0), new Vector2(28, 6),
                new Vector2(28, 11), new Vector2(31, 15), new Vector2(28, 21), new Vector2(19, 21), new Vector2(18, 23),
                new Vector2(9, 23), new Vector2(0, 13), new Vector2(1, 7));
            _pen = new Pen(Color.White, 1);
            _spriteSheet = new AnimatedSpriteSheet(texture) {AutoUpdate = true};
            _spriteSheet.Add(new Keyframe(new Rectangle(0, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(32, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(64, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(96, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(128, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(160, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(192, 0, 32, 24), 100));

            _spriteSheet.Add(new Keyframe(new Rectangle(224, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(256, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(288, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(320, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(352, 0, 32, 24), 100));

            Position = new Vector2(300, 230);
            Velocity = new Vector2(0, 0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new EntityComposer class.
        /// </summary>
        public EntityComposer()
        {
            Projectiles = new List<Projectile>();
            Enemies = new List<Enemy>();
            Explosions = new List<Explosion>();
            Input = SGL.QueryComponents<InputManager>();
            _scoreIndicators = new List<ScoreIndicator>();
            Score = 0;
            _random = new GameRandom();

            var contentManager = SGL.QueryComponents<ContentManager>();

            var playerTexture = contentManager.Load<Texture2D>("shipAnimation.png");
            _projectileTexture = contentManager.Load<Texture2D>("laser.png");
            _enemyTexture = contentManager.Load<Texture2D>("mineAnimation.png");
            _explosionTexture = contentManager.Load<Texture2D>("explosion.png");
            EnableHPBars = true;

            _laserFire = new SoundEffect(SGL.QueryResource<Sound>("laserFire.wav"),
                AudioManager.Instance.SoundEffectGroups[0]);
            _explosion = new SoundEffect(SGL.QueryResource<Sound>("explosion.wav"),
                AudioManager.Instance.SoundEffectGroups[0]);

            AudioManager.Instance.SoundEffectGroups[0].MasterVolume = 0.05f;

            Player = new Player(playerTexture);
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Initializes a new PipeManager class.
 /// </summary>
 /// <param name="pipeBody">The PipeBody.</param>
 /// <param name="pipeBottom">The PipeBottom head.</param>
 /// <param name="pipeTop">The PipeTop head.</param>
 public PipeManager(Texture2D pipeBody, Texture2D pipeBottom, Texture2D pipeTop)
 {
     _pipes = new List<Pipe>();
     _pipeBody = pipeBody;
     _pipeBottom = pipeBottom;
     _pipeTop = pipeTop;
     _random = new GameRandom();
     Opacity = 1f;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new Minimap class.
 /// </summary>
 /// <param name="entityComposer">The EntityComposer.</param>
 public Minimap(EntityComposer entityComposer)
 {
     _enemyPositions = new List<Vector2>();
     _currentEntityComposer = entityComposer;
     _projectilePositions = new List<Vector2>();
     _magicNumberX = 800/Width;
     _magicNumberY = 800/Height;
     Visible = true;
     _minimap = SGL.QueryComponents<ContentManager>().Load<Texture2D>("minimap.png");
 }
Ejemplo n.º 5
0
        public override void LoadContent(ContentManager content)
        {
            grassTexture2D = content.Load<Texture2D>("tile_grass.png");

            tiles = new List<Tile>
                {
                    new Tile(0, 0, this.grassTexture2D),
                    new Tile(128, 128, this.grassTexture2D),
                    new Tile(128, 160, this.grassTexture2D),
                    new Tile(128, 192, this.grassTexture2D)
                };
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new Player class.
        /// </summary>
        /// <param name="playerTexture">The PlayerTexture.</param>
        public Player(Texture2D playerTexture)
        {
            Sprite = new AnimatedSpriteSheet(playerTexture) {AutoUpdate = true};

            Sprite.Add(new Keyframe(new Rectangle(0, 0, 115, 69), 50));
            Sprite.Add(new Keyframe(new Rectangle(115, 0, 115, 69), 50));
            Sprite.Add(new Keyframe(new Rectangle(230, 0, 115, 69), 50));
            Sprite.Add(new Keyframe(new Rectangle(345, 0, 115, 69), 50));
            Sprite.Add(new Keyframe(new Rectangle(460, 0, 115, 69), 50));
            Sprite.Add(new Keyframe(new Rectangle(575, 0, 115, 69), 50));
            Sprite.Add(new Keyframe(new Rectangle(690, 0, 115, 69), 50));
            Sprite.Add(new Keyframe(new Rectangle(805, 0, 115, 69), 50));

            Position = new Vector2(0, 190);
            Health = 100;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new Skybox class.
        /// </summary>
        /// <param name="skyTextures">The SkyTextures.</param>
        public Skybox(Texture2D[] skyTextures)
        {
            //Skybox supports 3 layers, background, layer 1, layer 2

            _background = skyTextures[0];
            _layer1 = skyTextures[1];
            _layer2 = skyTextures[2];

            _backgroundPosition = new Vector2(0, 0);
            _layer1Position1 = new Vector2(0, 0);
            _layer2Position1 = new Vector2(0, 0);

            _layer1Position2 = new Vector2(800, 0);
            _layer2Position2 = new Vector2(800, 0);

            _layer1Position3 = new Vector2(1600, 0);
            _layer2Position3 = new Vector2(1600, 0);

            IsActive = true;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new Enemy class.
        /// </summary>
        /// <param name="enemyTexture">The EnemyTexture.</param>
        public Enemy(Texture2D enemyTexture)
        {
            Sprite = new AnimatedSpriteSheet(enemyTexture) {AutoUpdate = true};

            Sprite.Add(new Keyframe(new Rectangle(0, 0, 47, 61), 30));
            Sprite.Add(new Keyframe(new Rectangle(47, 0, 47, 61), 30));
            Sprite.Add(new Keyframe(new Rectangle(94, 0, 47, 61), 30));
            Sprite.Add(new Keyframe(new Rectangle(141, 0, 47, 61), 30));
            Sprite.Add(new Keyframe(new Rectangle(188, 0, 47, 61), 30));
            Sprite.Add(new Keyframe(new Rectangle(235, 0, 47, 61), 30));
            Sprite.Add(new Keyframe(new Rectangle(282, 0, 47, 61), 30));
            Sprite.Add(new Keyframe(new Rectangle(329, 0, 47, 61), 30));

            Position = new Vector2(0, 0);
            Health = 100;
            MaximumHealth = Health;
            Velocity = 0.1f;
            _isVisible = true;
            EnableHPBar = true;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new Explosion class.
        /// </summary>
        /// <param name="explosionTexture">The ExplosionTexture.</param>
        public Explosion(Texture2D explosionTexture)
        {
            Sprite = new AnimatedSpriteSheet(explosionTexture) {AutoUpdate = true};

            Sprite.Add(new Keyframe(new Rectangle(0, 0, 133.5f, 134), 20));
            Sprite.Add(new Keyframe(new Rectangle(133.5f, 0, 133.5f, 134), 20));
            Sprite.Add(new Keyframe(new Rectangle(267, 0, 133.5f, 134), 20));
            Sprite.Add(new Keyframe(new Rectangle(400.5f, 0, 133.5f, 134), 20));
            Sprite.Add(new Keyframe(new Rectangle(534, 0, 133.5f, 134), 20));
            Sprite.Add(new Keyframe(new Rectangle(667.5f, 0, 133.5f, 134), 20));
            Sprite.Add(new Keyframe(new Rectangle(801, 0, 133.5f, 134), 20));
            Sprite.Add(new Keyframe(new Rectangle(934.5f, 0, 133.5f, 134), 20));
            Sprite.Add(new Keyframe(new Rectangle(1068, 0, 133.5f, 134), 20));
            Sprite.Add(new Keyframe(new Rectangle(1201.5f, 0, 133.5f, 134), 20));
            Sprite.Add(new Keyframe(new Rectangle(1335, 0, 133.5f, 134), 20));
            Sprite.Add(new Keyframe(new Rectangle(1468.5f, 0, 133.5f, 134), 20));

            Position = new Vector2(0, 0);
            _isVisible = true;
            RemainingLifeTime = 300;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 /// <param name="position">The Position.</param>
 /// <param name="opacity">The Opacity.</param>
 public void DrawTexture(Texture2D texture, Vector2 position, float opacity = 1f)
 {
     DrawTexture(texture, position, Color.White, opacity);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Loads the content.
 /// </summary>
 /// <param name="content">The ContentManager.</param>
 public override void LoadContent(ContentManager content)
 {
     _background = content.Load<Texture2D>("endMenu.png");
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Loads the content.
 /// </summary>
 /// <param name="content">The ContentManager.</param>
 public override void LoadContent(ContentManager content)
 {
     _menuBackground = content.Load<Texture2D>("alternativeMenu.png");
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new Projectile class.
 /// </summary>
 /// <param name="projectileTexture">The ProjectileTexture.</param>
 public Projectile(Texture2D projectileTexture)
 {
     Texture = projectileTexture;
     Position = new Vector2(0);
     Bounds = new Rectangle(Position, new Vector2(46, 16));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Tile"/> class.
 /// </summary>
 /// <param name="x">
 /// The x.
 /// </param>
 /// <param name="y">
 /// The y.
 /// </param>
 /// <param name="texture2D">
 /// The texture 2 d.
 /// </param>
 public Tile(int x, int y, Texture2D texture2D)
     : this(new Vector2(x, y), texture2D)
 {
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Tile"/> class.
 /// </summary>
 /// <param name="location">
 /// The location.
 /// </param>
 /// <param name="texture2D">
 /// The texture 2 d.
 /// </param>
 public Tile(Vector2 location, Texture2D texture2D)
 {
     this.Location = location;
     this.Texture2D = texture2D;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 /// <param name="source">The SourceRectangle.</param>
 /// <param name="destination">The DestinationRectangle.</param>
 /// <param name="opacity">The Opacity.</param>
 public void DrawTexture(Texture2D texture, Rectangle source, Rectangle destination, float opacity = 1f)
 {
     DrawTexture(texture, source, destination, Color.White, opacity);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 /// <param name="source">The SourceRectangle.</param>
 /// <param name="destination">The DestinationRectangle.</param>
 /// <param name="color">The Color.</param>
 /// <param name="opacity">The Opacity.</param>
 public void DrawTexture(Texture2D texture, Rectangle source, Rectangle destination, Color color,
     float opacity = 1f)
 {
     Renderer.DrawTexture(texture.Texture, source, destination, color, opacity);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 /// <param name="rectangle">The Rectangle.</param>
 /// <param name="opacity">The Opacity.</param>
 public virtual void DrawTexture(Texture2D texture, Rectangle rectangle, float opacity = 1f)
 {
     DrawTexture(texture, rectangle, Color.White, opacity);
 }
Ejemplo n.º 19
0
 /// <summary>
 ///     Initializes a new Instructions class.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 public Instructions(Texture2D texture)
 {
     _texture = texture;
     _position = new Vector2(291, 215);
     _font = new Font("Segoe UI", 11, TypefaceStyle.Regular);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Initializes a new SpriteSheet class.
 /// </summary>
 /// <param name="texture2D">The Texture2D.</param>
 public SpriteSheet(Texture2D texture2D)
 {
     Texture2D = texture2D;
     Rectangle = Rectangle.Empty;
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 /// <param name="position">The Position.</param>
 /// <param name="opacity">The Opacity.</param>
 /// <param name="color">The Color.</param>
 public void DrawTexture(Texture2D texture, Vector2 position, Color color, float opacity = 1f)
 {
     Renderer.DrawTexture(texture.Texture, position, color, opacity);
 }
Ejemplo n.º 22
0
 /// <summary>
 ///     Initializes the AnimatedBackground class.
 /// </summary>
 /// <param name="bgTexture">The BackgroundTexture.</param>
 public AnimatedBackground(Texture2D bgTexture)
 {
     _texture = bgTexture;
     _position1 = new Vector2(0, 0);
     _position2 = new Vector2(638, 0);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Draws a Texture.
 /// </summary>
 /// <param name="texture">The Texture.</param>
 /// <param name="rectangle">The Rectangle.</param>
 /// <param name="opacity">The Opacity.</param>
 /// <param name="color">The Color.</param>
 public void DrawTexture(Texture2D texture, Rectangle rectangle, Color color, float opacity = 1f)
 {
     Renderer.DrawTexture(texture.Texture, rectangle, color, opacity);
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Initializes a new AnimatedSpriteSheet class.
 /// </summary>
 /// <param name="texture2D">The Texture2D.</param>
 public AnimatedSpriteSheet(Texture2D texture2D)
     : base(texture2D)
 {
     _keyframes = new List<Keyframe>();
 }