コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        public void CollectPrize(Prize.ePrize pPrize)
        {
            switch (pPrize)
            {
            case Prize.ePrize.Shield:
                mShieldActive = true;
                break;

            case Prize.ePrize.ExtraLife:
                mNumLives++;
                break;

            case Prize.ePrize.ExtraTime:
                Game.CurrentLevel.mTimeRemainingSecs += 20;
                break;

            case Prize.ePrize.Pause:
                Game.CurrentLevel.mPauseTime += 5;
                break;

            case Prize.ePrize.Dinamite:
                Game.CurrentLevel.mDinamiteAllBalls = true;
                break;
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pPrize"></param>
        /// <param name="pPos"></param>
        public void AddPrize(Prize.ePrize pPrize, Vector2 pPos)
        {
            Prize p = new Prize(pPrize);

            p.LoadContents();
            p.mPos = pPos;
            mPrizes.Add(p);
        }
コード例 #3
0
ファイル: Brick.cs プロジェクト: iayucar/PANG
        /// <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);
        }
コード例 #4
0
        /// <summary>
        /// Kills a ball and creates the next balls
        /// </summary>
        /// <param name="b"></param>
        public void KillBall(Ball b)
        {
            // Ball Hit by arrow
            mBalls.Remove(b);

            // Check if we should add prize
            if (b.BallSize != eBallSize.S)
            {
                Random r = new Random(DateTime.Now.Millisecond);
                double f = r.NextDouble();
                if (f > 0.15f)
                {
                    int          numPrizes = Enum.GetValues(typeof(Prize.ePrize)).Length;
                    int          prize     = (int)(f * numPrizes);
                    Prize.ePrize type      = (Prize.ePrize)prize;
                    if (type != Prize.ePrize.None)
                    {
                        AddPrize(type, b.mPos);
                    }
                }
            }

            // Create 2 new balls
            if (b.BallSize != eBallSize.S)
            {
                eBallSize newSize             = Ball.GetNextSize(b.BallSize);
                float     newVerticalVelocity = -Math.Min(Math.Abs(b.mVelocity.Y), Ball.GetMaxVelY(newSize));

                Ball b1 = new Ball(newSize, b.BallType);
                b1.LoadContents();
                b1.mPos        = b.Center - new Maths.Vector2(b1.Radius * 2f, b1.Radius);
                b1.mVelocity.X = -Math.Abs(b.mVelocity.X);
                b1.mVelocity.Y = newVerticalVelocity;

                Ball b2 = new Ball(newSize, b.BallType);
                b2.LoadContents();
                b2.mPos        = b.Center + new Maths.Vector2(0, -b2.Radius);
                b2.mVelocity.X = Math.Abs(b.mVelocity.X);
                b2.mVelocity.Y = newVerticalVelocity;

                // First call to OnFrameMove to update positions and velocities
                b1.OnFrameMove(0.001f);
                b2.OnFrameMove(0.001f);
                mBalls.Add(b1);
                mBalls.Add(b2);
            }
        }
コード例 #5
0
ファイル: Brick.cs プロジェクト: iayucar/PANG
        /// <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);
            }
        }