コード例 #1
0
ファイル: Ball.cs プロジェクト: iayucar/PANG
        /// <summary>
        ///
        /// </summary>
        public Ball(eBallSize pSize, eBallType pType) : base()
        {
            mScaleFactorX = 5f;
            mScaleFactorY = 5f;

            mBallSize = pSize;
            mBallType = pType;

            // Create rectangles with sprite information for balls
            if (mSpriteRectangles == null || mSpriteRectangles.Count == 0)
            {
                Dictionary <eBallSize, SMX.Maths.Rectangle> dictRed, dictBlue, dictGreen;
                dictRed   = new Dictionary <eBallSize, SMX.Maths.Rectangle>();
                dictGreen = new Dictionary <eBallSize, SMX.Maths.Rectangle>();
                dictBlue  = new Dictionary <eBallSize, SMX.Maths.Rectangle>();

                dictRed.Add(eBallSize.XL, new Rectangle {
                    X = 1, Y = 6, Width = 48, Height = 40
                });
                dictRed.Add(eBallSize.L, new Rectangle {
                    X = 52, Y = 13, Width = 32, Height = 26
                });
                dictRed.Add(eBallSize.M, new Rectangle {
                    X = 86, Y = 19, Width = 16, Height = 14
                });
                dictRed.Add(eBallSize.S, new Rectangle {
                    X = 106, Y = 23, Width = 8, Height = 7
                });

                dictBlue.Add(eBallSize.XL, new Rectangle {
                    X = 1, Y = 56, Width = 48, Height = 40
                });
                dictBlue.Add(eBallSize.L, new Rectangle {
                    X = 52, Y = 63, Width = 32, Height = 26
                });
                dictBlue.Add(eBallSize.M, new Rectangle {
                    X = 86, Y = 69, Width = 16, Height = 14
                });
                dictBlue.Add(eBallSize.S, new Rectangle {
                    X = 106, Y = 73, Width = 8, Height = 7
                });

                dictGreen.Add(eBallSize.XL, new Rectangle {
                    X = 1, Y = 105, Width = 48, Height = 40
                });
                dictGreen.Add(eBallSize.L, new Rectangle {
                    X = 52, Y = 112, Width = 32, Height = 26
                });
                dictGreen.Add(eBallSize.M, new Rectangle {
                    X = 86, Y = 118, Width = 16, Height = 14
                });
                dictGreen.Add(eBallSize.S, new Rectangle {
                    X = 106, Y = 122, Width = 8, Height = 7
                });

                mSpriteRectangles.Add(eBallType.Red, dictRed);
                mSpriteRectangles.Add(eBallType.Blue, dictBlue);
                mSpriteRectangles.Add(eBallType.Green, dictGreen);
            }
        }
コード例 #2
0
ファイル: Ball.cs プロジェクト: iayucar/PANG
        /// <summary>
        /// Creates and configures a ball from an XML node
        /// </summary>
        /// <param name="pBallNd"></param>
        /// <returns></returns>
        public static Ball FromXml(System.Xml.XmlNode pBallNd)
        {
            eBallSize size = (eBallSize)Enum.Parse(typeof(eBallSize), pBallNd.Attributes["Size"].Value);
            eBallType type = (eBallType)Enum.Parse(typeof(eBallType), pBallNd.Attributes["Type"].Value);
            Ball      b    = new Ball(size, type);

            b.mOriginalPosition = b.mPos = SMX.Maths.Vector2.ReadVector2FromXmlAttribute(pBallNd, "Position");
            return(b);
        }