Пример #1
0
 public PlatformObject(float x, float y, BlockObject.Ground state) :
     base(Load.MapTextureNature, new Sprite("Content.ground.natureXml.xml"), new Vector2(x, y))
 {
     this.state = state;
     this.x     = x;
     this.y     = y;
 }
Пример #2
0
        /// <summary>
        /// Convert a graphical block into a physical wall
        /// </summary>
        /// <param name="bl">A block object</param>
        /// <returns>List of walls</returns>
        public List <Rectangle>[] walls_of_ground(BlockObject bl)
        {
            BlockObject.Ground ground = bl.state;

            List <Rectangle>[] walls = new List <Rectangle> [4];

            for (int i = 0; i < 4; i++)
            {
                walls[i] = new List <Rectangle>();
            }

            List <BlockObject.Ground> rightsG = new List <BlockObject.Ground> {
                BlockObject.Ground.LeftGround, BlockObject.Ground.LeftDurt, BlockObject.Ground.BottomLeft2Durt, BlockObject.Ground.LeftPlatform
            };
            List <BlockObject.Ground> leftsG = new List <BlockObject.Ground> {
                BlockObject.Ground.RightGround, BlockObject.Ground.RightDurt, BlockObject.Ground.BottomRight2Durt, BlockObject.Ground.RightPlatform
            };
            List <BlockObject.Ground> bottomsG = new List <BlockObject.Ground> {
                BlockObject.Ground.LeftGround, BlockObject.Ground.MiddleGround, BlockObject.Ground.RightGround, BlockObject.Ground.RightEGround, BlockObject.Ground.LeftEGround, BlockObject.Ground.LeftPlatform, BlockObject.Ground.RightPlatform, BlockObject.Ground.MiddlePlatform
            };
            List <BlockObject.Ground> roofsG = new List <BlockObject.Ground> {
                BlockObject.Ground.BottomDurt, BlockObject.Ground.BottomLeft2Durt, BlockObject.Ground.BottomRight2Durt, BlockObject.Ground.LeftPlatform, BlockObject.Ground.RightPlatform, BlockObject.Ground.MiddlePlatform
            };

            const int pixelOffset = 20;
            const int magicBorder = 10;

            if (leftsG.Exists(e => e == ground))
            {
                walls[(int)Wall.left].Add(new Rectangle((int)(bl.Position.X + 3 * bl.w / 4), (int)bl.Position.Y + pixelOffset, (int)(bl.w / 4), (int)(bl.h - pixelOffset * 2)));
            }

            if (rightsG.Exists(e => e == ground))
            {
                walls[(int)Wall.right].Add(new Rectangle((int)bl.Position.X, (int)bl.Position.Y + pixelOffset, (int)(bl.w / 4), (int)(bl.h - pixelOffset * 2)));
            }

            if (roofsG.Exists(e => e == ground))
            {
                walls[(int)Wall.roof].Add(new Rectangle((int)bl.Position.X + magicBorder, (int)(bl.Position.Y + (bl.h / 2)), (int)(bl.w - 2 * magicBorder), (int)bl.h / 2));
            }

            if (bottomsG.Exists(e => e == ground))
            {
                walls[(int)Wall.bottom].Add(new Rectangle((int)bl.Position.X + magicBorder, (int)(bl.Position.Y), (int)(bl.w - 2 * magicBorder), (int)bl.h / 2));
            }


            return(walls);
        }
Пример #3
0
 public SavePlatformObject(float x, float y, BlockObject.Ground state)
 {
     this.x     = x;
     this.y     = y;
     this.state = state;
 }