Ejemplo n.º 1
0
        public UIManager(Main game)
            : base(game)
        {
            this.depth = 0.05f;

            List<AnimatedTextureData> heartAni = new List<AnimatedTextureData>();
            heartAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("heartFull"));
            heartAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("heartEmpty"));

            List<AnimatedTextureData> keyAni = new List<AnimatedTextureData>();
            keyAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("keyEmpty"));
            keyAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("keyFull"));

            List<AnimatedTextureData> coinNumberAni = new List<AnimatedTextureData>();
            coinNumberAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("coinZero"));
            coinNumberAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("coinOne"));
            coinNumberAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("coinTwo"));
            coinNumberAni.Add((AnimatedTextureData)SpriteManager.GAME.TEXTUREMANAGER.Get("coinThree"));

            this.heartOne = new ModularAnimatedSprite("heartOne",
                heartAni,
                new SpritePresentationInfo(heartAni[0].FRAMESOURCES[0], depth),
                new SpritePositionInfo(new Vector2(5, 5), heartAni[0].FRAMEWIDTH, heartAni[0].FRAMEHEIGHT),
                10);

            this.heartTwo= new ModularAnimatedSprite("heartTwo",
                heartAni,
                new SpritePresentationInfo(heartAni[0].FRAMESOURCES[0], depth),
                new SpritePositionInfo(new Vector2(63, 5), heartAni[0].FRAMEWIDTH, heartAni[0].FRAMEHEIGHT),
                10);

            this.heartThree = new ModularAnimatedSprite("heartThree",
                heartAni,
                new SpritePresentationInfo(heartAni[0].FRAMESOURCES[0], depth),
                new SpritePositionInfo(new Vector2(121, 5), heartAni[0].FRAMEWIDTH, heartAni[0].FRAMEHEIGHT),
                10);

            this.coin = new Sprite("coin",
                SpriteManager.GAME.TEXTUREMANAGER.Get("hud_spritesheet"),
                new SpritePresentationInfo(new Rectangle(55, 0, 47, 47), depth),
                new SpritePositionInfo(new Vector2(5, 55), 47, 47));

            this.coinX = new Sprite("coinX",
                SpriteManager.GAME.TEXTUREMANAGER.Get("hud_spritesheet"),
                new SpritePresentationInfo(new Rectangle(0, 239, 30, 28), depth),
                new SpritePositionInfo(new Vector2(60, 65), 30, 28));

            this.coinNumber = new ModularAnimatedSprite("coinNumber",
                coinNumberAni,
                new SpritePresentationInfo(coinNumberAni[0].FRAMESOURCES[0], depth),
                new SpritePositionInfo(new Vector2(95, 60), coinNumberAni[0].FRAMEWIDTH, coinNumberAni[0].FRAMEHEIGHT),
                10);

            this.key = new ModularAnimatedSprite("key",
                keyAni,
                new SpritePresentationInfo(keyAni[0].FRAMESOURCES[0], depth),
                new SpritePositionInfo(new Vector2(10, 112), keyAni[0].FRAMEWIDTH, keyAni[0].FRAMEHEIGHT),
                10);
        }
Ejemplo n.º 2
0
        public UIManager(Main game)
            : base(game)
        {
            this.depth = 0.05f;

            this.healthBar = new Sprite("healthBar",
                SpriteManager.GAME.TEXTUREMANAGER.Get("HealthBar"),
                new SpritePresentationInfo(new Rectangle(0, 0, 128, 26), depth),
                new SpritePositionInfo(new Vector2(10, 15), 128, 28));

            this.key = new Sprite("keySheet",
                SpriteManager.GAME.TEXTUREMANAGER.Get("keySheet"),
                new SpritePresentationInfo(new Rectangle(0, 0, 58, 58), depth),
                new SpritePositionInfo(new Vector2(10, 50), 58, 58));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Simple BSP + Bounding Box intersection method
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public static bool Intersects(Sprite a, Sprite b)
 {
     if (isBSPCollision(a.POSITIONINFO.SECTORNUMBER, b.POSITIONINFO.SECTORNUMBER))
     {
         if (Collision.Intersects(a.POSITIONINFO.BOUNDS, b.POSITIONINFO.BOUNDS))
         {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 4
0
        //http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Coll_Detection_Overview.php
        public static Vector2 IntersectsNonAA(Sprite a, Sprite b)
        {
            if (Intersects(a, b)) //BSP + Bounding Box
            {
                mat1to2 = a.POSITIONINFO.WORLDMATRIX * b.POSITIONINFO.INVERSEWORLDMATRIX;
                //widthA = a.TEXTUREDATA.Width();
                //heightA = a.TEXTUREDATA.Height();
                //widthB = b.TEXTUREDATA.Width();
                //heightB = b.TEXTUREDATA.Height();
                widthA = a.PRESENTATIONINFO.SOURCERECTANGLE.Width;
                heightA = a.PRESENTATIONINFO.SOURCERECTANGLE.Height;
                widthB = b.PRESENTATIONINFO.SOURCERECTANGLE.Width;
                heightB = b.PRESENTATIONINFO.SOURCERECTANGLE.Height;

                //loop for width of A
                for (int x1 = 0; x1 < widthA; x1++)
                {
                    //loop of height of A
                    for (int y1 = 0; y1 < heightA; y1++)
                    {
                        //(0, 0) to (a.w, a.h)
                        pos1 = new Vector2(x1, y1);
                        //corresponding b value
                        pos2 = Vector2.Transform(pos1, mat1to2);
                        x2 = (int)Math.Round(pos2.X);
                        y2 = (int)Math.Round(pos2.Y);

                        //check if within b bounds.
                        if (((x2 >= 0) && (x2 < widthB))
                            && ((y2 >= 0) && (y2 < heightB)))
                        {
                            //
                            if (a.TEXTUREDATA.TEXTURECOLORDATA2D != null && b.TEXTUREDATA.TEXTURECOLORDATA2D != null && x2 < b.TEXTUREDATA.TEXTURECOLORDATA2D.GetLength(0))
                            {
                                if ((a.TEXTUREDATA.TEXTURECOLORDATA2D[x1, y1].A > alphaThreshold) && (b.TEXTUREDATA.TEXTURECOLORDATA2D[x2, y2].A > alphaThreshold))
                                {
                                    return Vector2.Transform(pos1, a.POSITIONINFO.WORLDMATRIX);
                                }
                            }
                        }
                    }
                } //Non AA CDCR
            }
            return new Vector2(-1, -1);
        }
Ejemplo n.º 5
0
 public static bool Intersects(SpriteShell a, Sprite b)
 {
     if (isBSPCollision(a.sectorNumber, b.POSITIONINFO.SECTORNUMBER))
     {
         if (Collision.Intersects(a.bounds, b.POSITIONINFO.BOUNDS))
         {
             return true;
         }
     }
     return false;
 }