Exemplo n.º 1
0
 public Block(string name, TextureData textureData,
             SpritePresentationInfo spritePresentationInfo,
                 SpritePositionInfo spritePositionInfo)
     : base(name, textureData, spritePresentationInfo, spritePositionInfo)
 {
     this.health = 5;
 }
Exemplo n.º 2
0
        public Player(string name, List<AnimatedTextureData> animationsList,
                    SpritePresentationInfo spritePresentationInfo,
                    SpritePositionInfo spritePositionInfo,
                    int frameRate)
            : base(name, animationsList,
                    spritePresentationInfo,
                    spritePositionInfo,
                    frameRate)
        {
            this.moveAmount = 0;
            this.velocity = Vector2.Zero;
            this.acceleration = 0.0015f;
            this.direction = Vector2.Zero;
            this.gravity = 0.0025f;
            this.jumpPower = 1.6f;
            this.springJumpPower = 2f;
            this.oldPos = new Vector2(spritePositionInfo.TRANSLATIONX, spritePositionInfo.TRANSLATIONY);
            this.hasKey = false;
            this.coins = 0;
            this.health = 3; // 3 health? 3 hearts?
            this.invulnerable = false;
            this.invulnerableTimer = 0;

            this.levelStartPos = spritePositionInfo.TRANSLATION;

            this.coinsTaken = new List<Block>();
            this.keysTaken = new List<Block>();

            this.jump = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("jump");
            this.pickup = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("pickup");
            this.hurt = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("hurt");
            this.endGame = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("endGame");
        }
Exemplo n.º 3
0
 public DynamicBlock(string name, List<AnimatedTextureData> animationsList,
             SpritePresentationInfo spritePresentationInfo,
             SpritePositionInfo spritePositionInfo,
             int frameRate)
     : base(name, animationsList, spritePresentationInfo, spritePositionInfo, frameRate)
 {
 }
Exemplo n.º 4
0
 public Cloud(float speed, string name, TextureData textureData,
             SpritePresentationInfo spritePresentationInfo,
                 SpritePositionInfo spritePositionInfo)
     : base(name, textureData, spritePresentationInfo, spritePositionInfo)
 {
     this.speed = speed;
     this.moveAmount = 0;
 }
 //for some of the values to be passed into AnimatedSprite I took them out and assumed they
 //would use "generic values". Especially for the repeat bool, it would cause trouble if
 //set to false. Could extend it further to return to "base" animaiton when dont with an
 //animation if needed.
 //(Current implementation would remove the sprite after one animation is done if
 //set to fasle)
 public ModularAnimatedSprite(string name, List<AnimatedTextureData> animationsList,
             SpritePresentationInfo spritePresentationInfo,
             SpritePositionInfo spritePositionInfo,
             int frameRate)
     : base(name, animationsList[0], spritePresentationInfo, spritePositionInfo,
         frameRate, 0, true)
 {
     this.animationsList = animationsList;
     this.currentAnimation = 0;
 }
Exemplo n.º 6
0
 public Enemy(Vector2 startPoint, Vector2 endPoint, int numberOfSteps, string name, List<AnimatedTextureData> animationsList,
             SpritePresentationInfo spritePresentationInfo,
             SpritePositionInfo spritePositionInfo,             
             int frameRate)
     : base(name, animationsList, spritePresentationInfo, spritePositionInfo, frameRate)
 {
     this.startPoint = startPoint;
     this.endPoint = endPoint;
     this.numberOfSteps = numberOfSteps;
     this.step = (endPoint - startPoint) / numberOfSteps;
 }
Exemplo n.º 7
0
        public Sprite(string name, TextureData textureData, 
                    SpritePresentationInfo spritePresentationInfo,
                        SpritePositionInfo spritePositionInfo)
        {
            this.name = name;
            this.textureData = textureData;
            this.spritePresentationInfo = spritePresentationInfo;
            this.spritePositionInfo = spritePositionInfo;

            //make sure we set first time around
            this.sectorNumber = Collision.getSectorNumber(this.POSITIONINFO.BOUNDS);
        }
Exemplo n.º 8
0
        public AnimatedSprite(string name, AnimatedTextureData animatedTextureData,
                    SpritePresentationInfo spritePresentationInfo,
                        SpritePositionInfo spritePositionInfo,
                            int frameRate, int startFrame, bool bRepeatAnimation)
            : base(name, animatedTextureData, spritePresentationInfo, spritePositionInfo)
        {
            this.animatedTextureData = animatedTextureData;// (AnimatedTextureData)animatedTextureData.Clone();
            this.TEXTUREDATA.TEXTURECOLORDATA2D = animatedTextureData[0];

            this.frameRate = frameRate;
            timeBetweenFrameInMs = 1000.0 / frameRate; //time between each frame if they play at frameRate per second (e.g. 24fps gives timeBetweenFrameInMs = 1000ms/24 per second)
            timeSinceLastFrameInMs = timeBetweenFrameInMs; //means no initial delay in animation
            this.startFrame = startFrame;
            currentFrame = startFrame;
            this.bRepeatAnimation = bRepeatAnimation;
        }
Exemplo n.º 9
0
        public Player(string name, List<AnimatedTextureData> animationsList,
                    SpritePresentationInfo spritePresentationInfo,
                    SpritePositionInfo spritePositionInfo,
                    int frameRate)
            : base(name, animationsList,
                    spritePresentationInfo,
                    spritePositionInfo,
                    frameRate)
        {
            this.moveAmount = 0;
            this.velocity = Vector2.Zero;
            this.acceleration = 0.0015f;
            this.direction = Vector2.Zero;
            this.gravity = 0.0025f;
            this.jumpPower = 1.6f;
            this.springJumpPower = 2f;
            this.oldPos = new Vector2(spritePositionInfo.TRANSLATIONX, spritePositionInfo.TRANSLATIONY);
            this.hasKey = false;
            this.coins = 0;
            this.health = 4; // 3 health? 3 hearts?
            this.invulnerable = false;
            this.invulnerableTimer = 0;

            this.levelStartPos = spritePositionInfo.TRANSLATION;

            this.destructablesRemoved = new List<Block>();
            this.shadowsRemoved = new List<Rectangle>();
            this.keysTaken = new List<Block>();

            this.jump = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("jump");
            this.pickup = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("pickup");
            this.hurt = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("hurt");
            this.endGame = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("endGame");

            this.peakHeight = spritePositionInfo.TRANSLATIONY;

            this.walkingLine = new Line(0, POSITIONINFO.BOUNDS.Top, 0, POSITIONINFO.BOUNDS.Bottom);
            System.Diagnostics.Debug.WriteLine(walkingLine.start + " : " + walkingLine.end);
        }
Exemplo n.º 10
0
        public static List<Block>[] load(string path, string name, int tileWidth, int tileHeight, TextureManager textureManager)
        {
            path += name;
            String[] fileData = System.IO.File.ReadAllLines(path);
            String[] lineData = null;
            Vector2 position = Vector2.Zero;
            int textureNumber, rowCount = fileData.Length, colCount = 0;

            List<Block> collidables = new List<Block>();
            List<Block> nonCollidables = new List<Block>();
            List<Block> exits = new List<Block>();
            List<Block> springs = new List<Block>();
            List<Block> spikes = new List<Block>();
            List<Block> coins = new List<Block>();
            List<Block> key = new List<Block>();
            List<Block> destructables = new List<Block>();
            List<Block> solidCollidables = new List<Block>();

            for (int row = 0; row < rowCount; row++)
            {
                lineData = fileData[row].Split(dataFileSeparator);
                colCount = lineData.Length;
                for (int col = 0; col < colCount; col++)
                {
                    position = new Vector2(col * tileWidth, row * tileHeight);
                    textureNumber = Convert.ToInt32(lineData[col]);
                    if (textureNumber != 0) //not black
                    {

                        if (textureNumber == 1)
                        {
                            TextureData textureData = null;
                            textureData = textureManager.Get("grassTiles");
                            if (textureData != null)
                            {

                              SpritePositionInfo PositionInfo = new SpritePositionInfo(new Vector2(tileWidth * col, tileHeight * row), tileWidth, tileHeight);
                              solidCollidables.Add(getSprite(PositionInfo, textureData, textureNumber, tileWidth, tileHeight));
                            }
                        }
                        else if (textureNumber == 2)
                        {
                            TextureData textureData = null;
                            textureData = textureManager.Get("tileSheet");
                            if (textureData != null)
                            {

                                SpritePositionInfo PositionInfo = new SpritePositionInfo(new Vector2(tileWidth * col, tileHeight * row), tileWidth, tileHeight);
                                solidCollidables.Add(getSprite(PositionInfo, textureData, textureNumber, tileWidth, tileHeight));
                            }
                        }
                        else if (textureNumber > 2 && textureNumber <= 5)
                        {
                            TextureData textureData = null;
                            textureData = textureManager.Get("tileSheet");
                            if (textureData != null)
                            {

                                SpritePositionInfo PositionInfo = new SpritePositionInfo(new Vector2(tileWidth * col, tileHeight * row), tileWidth, tileHeight);
                                nonCollidables.Add(getSprite(PositionInfo, textureData, textureNumber, tileWidth, tileHeight));
                            }
                        }

                        else if (textureNumber > 5 && textureNumber <= 7)
                        {
                            TextureData textureData = null;
                            textureData = textureManager.Get("destructableTile");
                            if (textureData != null)
                            {

                                SpritePositionInfo PositionInfo = new SpritePositionInfo(new Vector2(tileWidth * col, tileHeight * row), tileWidth, tileHeight);
                                destructables.Add(getSprite(PositionInfo, textureData, textureNumber, tileWidth, tileHeight));
                            }

                        }
                        else if (textureNumber == 8)
                        {
                            TextureData textureData = null;
                            textureData = textureManager.Get("spikes");
                            if (textureData != null)
                            {
                                SpritePositionInfo PositionInfo = new SpritePositionInfo(new Vector2(tileWidth * col, tileHeight * row), tileWidth, tileHeight);
                                spikes.Add(getSprite(PositionInfo, textureData, textureNumber, tileWidth, tileHeight));
                            }

                        }
                        else if (textureNumber == 9)
                        {
                            TextureData textureData = null;
                            textureData = textureManager.Get("door");
                            if (textureData != null)
                            {
                                SpritePositionInfo PositionInfo = new SpritePositionInfo(new Vector2(tileWidth * col, tileHeight * row), tileWidth, tileHeight);
                                exits.Add(getSprite(PositionInfo, textureData, textureNumber, tileWidth, tileHeight));
                            }
                        }
                        else if (textureNumber == 10)
                        {
                            TextureData textureData = null;
                            textureData = textureManager.Get("key");
                            if (textureData != null)
                            {
                                SpritePositionInfo PositionInfo = new SpritePositionInfo(new Vector2(tileWidth * col, tileHeight * row), tileWidth, tileHeight);
                                key.Add(getSprite(PositionInfo, textureData, textureNumber, tileWidth, tileHeight));
                            }
                        }
                        //else if (textureNumber > 11 && textureNumber <= 22)
                        //{
                        //    AnimatedTextureData textureData = null;
                        //    textureData = (AnimatedTextureData)game.TextureManager.Get("grassTiles");
                        //    if (textureData != null)
                        //    {
                        //        Transform transform = new Transform(position, 0, textureData.OriginTopLeft, Vector2.One, textureData.Dimensions, true);
                        //        game.SpriteManager.Add(getForgroundSprite(game, transform, textureData, textureNumber));
                        //    }
                        //}
                        //else
                        //{
                        //    TextureData textureData = null;
                        //    textureData = TextureManager.Get(textureNumber);
                        //    if (textureData != null)
                        //    {
                        //        SpritePresentationInfo PresentationInfo = new SpritePresentationInfo(new Rectangle(576, 864, tileWidth, tileHeight), backDepth);
                        //        SpritePositionInfo PositionInfo = new SpritePositionInfo(new Vector2(tileWidth * col, tileHeight * row), tileWidth, tileHeight);
                        //        collidables.Add(getBackgroundSprite(PresentationInfo, PositionInfo, textureData, textureNumber));
                        //    }
                        //}
                      //  textureData = game.TextureManager.Get(textureNumber);

                    }
                }
            }

            List<Block>[] blocks = new List<Block>[9];
            blocks[0] = collidables;
            blocks[1] = nonCollidables;
            blocks[2] = exits;
            blocks[3] = springs;
            blocks[4] = spikes;
            blocks[5] = key;
            blocks[6] = coins;
            blocks[7] = destructables;
            blocks[8] = solidCollidables;

            return blocks;
        }
Exemplo n.º 11
0
        /*
         * Student should change this code to indicate the depth of each loaded sprite.
         * The logic of how your game instanciates different sprite types at different levels is contained in this method.
         * */
        private static Block getSprite(SpritePositionInfo PositionInfo, TextureData textureData, int textureNumber, int tileWidth, int tileHeight)
        {
            Block sprite = null;

                //think this should be static if we leave like this.

                //use layer depth to say what things dont receive light e.g. textureNumber > 20 set layerDepth = 0.5 - See RenderScene pixel shader for depth value
             //   float layerDepth = 1;
                //use textureNumber to specify what types of sprite to create e.g. PlayerSprite, Moveable
                if (textureNumber == 1)
                {
                    SpritePresentationInfo PresentationInfo = new SpritePresentationInfo(new Rectangle(60, 60, tileWidth, tileHeight), backDepth);
                    sprite = new Block("Tile" + i, textureData, PresentationInfo, PositionInfo);
                }
                else if (textureNumber == 2)
                {
                    SpritePresentationInfo PresentationInfo = new SpritePresentationInfo(new Rectangle(480, 120, tileWidth, tileHeight), backDepth);
                    sprite = new Block("Tile" + i, textureData, PresentationInfo, PositionInfo);
                }
                else if (textureNumber == 4)
                {
                    SpritePresentationInfo PresentationInfo = new SpritePresentationInfo(new Rectangle(60, 60, tileWidth, tileHeight), backDepth);
                    sprite = new Block("Tile" + i, textureData, PresentationInfo, PositionInfo);
                }
                else if (textureNumber == 6)
                {

                    SpritePresentationInfo PresentationInfo = new SpritePresentationInfo(new Rectangle(0, 0, tileWidth, tileHeight), backDepth);
                    sprite = new Block("Tile" + i, textureData, PresentationInfo, PositionInfo);

                }
                else if (textureNumber == 8)
                {

                    SpritePresentationInfo PresentationInfo =  new SpritePresentationInfo(new Rectangle(0, 0, tileWidth, tileHeight), backDepth);
                    sprite = new Block("Tile" + i, textureData, PresentationInfo, PositionInfo);
                }
                else if (textureNumber == 9)
                {

                    SpritePresentationInfo PresentationInfo = new SpritePresentationInfo(new Rectangle(0, 0, tileWidth, tileHeight), backDepth);
                    sprite = new Block("Tile" + i, textureData, PresentationInfo, PositionInfo);
                }
                else if (textureNumber == 10)
                {

                    SpritePresentationInfo PresentationInfo = new SpritePresentationInfo(new Rectangle(0, 0, tileWidth, tileHeight), backDepth);
                    sprite = new Block("Tile" + i, textureData, PresentationInfo, PositionInfo);
                }
                else
                {
                    return null;
                }

                i++;
                return sprite;
        }