Example #1
0
        /// <summary>
        /// Creates and configures a new brick, from an xml node
        /// </summary>
        /// <param name="pBrickNd"></param>
        /// <returns></returns>
        public static Brick FromXml(System.Xml.XmlNode pBrickNd)
        {
            eBrickSize        size = (eBrickSize)Enum.Parse(typeof(eBrickSize), pBrickNd.Attributes["Size"].Value);
            eBrickOrientation ori  = (eBrickOrientation)Enum.Parse(typeof(eBrickOrientation), pBrickNd.Attributes["Orientation"].Value);

            Prize.ePrize prize = Prize.ePrize.None;
            if (pBrickNd.Attributes["Prize"] != null)
            {
                prize = (Prize.ePrize)Enum.Parse(typeof(Prize.ePrize), pBrickNd.Attributes["Prize"].Value);
            }
            bool  breakable = bool.Parse(pBrickNd.Attributes["Breakable"].Value);
            Brick brk       = new Brick(ori, size, breakable, prize);

            brk.mPos = SMX.Maths.Vector2.ReadVector2FromXmlAttribute(pBrickNd, "Position");
            return(brk);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pOrientation"></param>
        /// <param name="pSize"></param>
        /// <param name="pBreakable"></param>
        /// <param name="pPrize"></param>
        /// <param name="pMainForm"></param>
        public Brick(eBrickOrientation pOrientation, eBrickSize pSize, bool pBreakable, Prize.ePrize pPrize) : base()
        {
            mScaleFactorX = 2f;
            mScaleFactorY = 2f;

            mOrientation = pOrientation;
            mBrickSize   = pSize;
            mBreakable   = pBreakable;
            mPrize       = pPrize;

            // Create rectangles for brick sprites
            if (mSourceRectsBreakable == null || mSourceRectsBreakable.Count == 0)
            {
                Dictionary <eBrickSize, SMX.Maths.Rectangle> dictHoriz, dictVert;
                dictHoriz = new Dictionary <eBrickSize, SMX.Maths.Rectangle>();
                dictVert  = new Dictionary <eBrickSize, SMX.Maths.Rectangle>();

                dictHoriz.Add(eBrickSize.Big, new Rectangle {
                    X = 9, Y = 8, Width = 63, Height = 14
                });
                dictHoriz.Add(eBrickSize.Med, new Rectangle {
                    X = 153, Y = 7, Width = 34, Height = 15
                });
                dictHoriz.Add(eBrickSize.Small, new Rectangle {
                    X = 241, Y = 7, Width = 21, Height = 15
                });

                dictVert.Add(eBrickSize.Big, new Rectangle {
                    X = 122, Y = 42, Width = 14, Height = 111
                });
                dictVert.Add(eBrickSize.Med, new Rectangle {
                    X = 147, Y = 107, Width = 14, Height = 46
                });
                dictVert.Add(eBrickSize.Small, new Rectangle {
                    X = 174, Y = 121, Width = 14, Height = 32
                });

                mSourceRectsBreakable.Add(eBrickOrientation.Horizontal, dictHoriz);
                mSourceRectsBreakable.Add(eBrickOrientation.Vertical, dictVert);
            }

            if (mSourceRectsNonBreakable == null || mSourceRectsNonBreakable.Count == 0)
            {
                Dictionary <eBrickSize, SMX.Maths.Rectangle> dictHoriz, dictVert;
                dictHoriz = new Dictionary <eBrickSize, SMX.Maths.Rectangle>();
                dictVert  = new Dictionary <eBrickSize, SMX.Maths.Rectangle>();

                dictHoriz.Add(eBrickSize.Big, new Rectangle {
                    X = 80, Y = 8, Width = 62, Height = 14
                });
                dictHoriz.Add(eBrickSize.Med, new Rectangle {
                    X = 195, Y = 7, Width = 34, Height = 15
                });
                dictHoriz.Add(eBrickSize.Small, new Rectangle {
                    X = 274, Y = 7, Width = 22, Height = 15
                });

                dictVert.Add(eBrickSize.Big, new Rectangle {
                    X = 9, Y = 41, Width = 14, Height = 111
                });
                dictVert.Add(eBrickSize.Med, new Rectangle {
                    X = 35, Y = 106, Width = 14, Height = 46
                });
                dictVert.Add(eBrickSize.Small, new Rectangle {
                    X = 62, Y = 121, Width = 14, Height = 31
                });

                mSourceRectsNonBreakable.Add(eBrickOrientation.Horizontal, dictHoriz);
                mSourceRectsNonBreakable.Add(eBrickOrientation.Vertical, dictVert);
            }
        }