Example #1
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here



            List <BaseBall> removeList = new List <BaseBall>();

            PlayerBall.getInstance().upDate(Game.Window.ClientBounds);

            ScoreBoard.getInstance().upDate();

            if (wallmg.checkBall(PlayerBall.getInstance()))
            {
                //越界要做的事情,默认把位置修改回
            }

            foreach (BaseBall ball in ballList)
            {
                ball.upDate(Game.Window.ClientBounds);


                if (ball.getRect().Intersects(PlayerBall.getInstance().getRect()))
                {
                    if (ball.impactBall(PlayerBall.getInstance()))
                    {
                        //小球被吃
                        removeList.Add(ball);
                    }
                    else
                    {
                        //被大的球吃到了
                        if (PlayerBall.getInstance().impactBall(ball))
                        {//交给player处理事件,返回true表示游戏结束
                         //玩家死亡
                        }
                        removeList.Add(ball);
                    }
                }


                if (!wallmg.checkBall(ball) && ball.isOutDo()) //检测超界,并且交给球处理超界事件
                {                                              //检测是否超出边界
                    removeList.Add(ball);
                }
            }

            foreach (BaseBall rball in  removeList)
            {
                ballList.Remove(rball);//删除超出边界的球
            }

            //交给关卡类 随机生成球
            BaseBall newball = Chapters.getInstance().getBaseBall();

            if (newball != null)
            {
                ballList.Add(newball);
            }

            Chapters.getInstance().check();

            base.Update(gameTime);
        }
Example #2
0
 public static void init(SpriteFont font, SpriteFont bigFont)
 {
     instance = new ScoreBoard(font, bigFont);
 }