Пример #1
0
        public void SetFactory()
        {
            int possibility = random.Next(100) + 1;

            if (possibility <= bonusPossibility)
            {
                currentbrickFactory = BonusBrickFactory.GetInstance();
            }
            else
            {
                currentbrickFactory = SimpleBrickFactory.GetInstance();
            }
        }
Пример #2
0
        public void MoveToNextLevel()
        {
            ballManager.ResetBalls();
            bonusManager.ResetBonuses();

            scoreManager.AddScore(levelManager.CurrentLevelNumber * 1000);

            BonusBrickFactory.GetInstance().SetAllBonusesAvailable();

            if (levelManager.CurrentLevelNumber < levelManager.LevelCount)
            {
                levelManager.MoveNext();
            }
            else
            {
                OnGameOver?.Invoke();
            }
        }
Пример #3
0
 public static BonusBrickFactory GetInstance()
 {
     return(instance ?? (instance = new BonusBrickFactory()));
 }
Пример #4
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            base.Initialize();


            screenHeight = graphics.PreferredBackBufferHeight;
            screenWidth  = graphics.PreferredBackBufferWidth;


            levelManager = LevelManager <PinballLevel> .GetInstance();

            gameManager = GameManager.GetInstance();

            int width  = 7;
            int height = 20;

            bound = new Bound(
                size: new Point(graphics.PreferredBackBufferWidth / width, graphics.PreferredBackBufferHeight / height),
                transform: new Transform(new Vector2(graphics.PreferredBackBufferWidth * (width - 1) / (width * 2),
                                                     graphics.PreferredBackBufferHeight * (height - 1) / height),
                                         new Vector2(0.4f * graphics.PreferredBackBufferHeight / 600, 0)),
                clientWindow: new Rectangle(0, 0, screenWidth, screenHeight))
            {
                Body = { Texture = contentManager.textures["BoundTexture"] }
            };

            gameManager.Init(levelManager, bound, new Rectangle(0, 0, screenWidth, screenHeight));
            //levelManager.Initialize();

            SimpleBrickFactory sbf = SimpleBrickFactory.GetInstance();

            sbf.Initialize(contentManager.textures["SimpleBrickTexture"]);
            BonusBrickFactory bbf = BonusBrickFactory.GetInstance();

            bbf.Initialize(contentManager.textures["SimpleBrickTexture"], contentManager.bonusTextures,
                           fallingVelocity: 0.3f * graphics.PreferredBackBufferHeight / 500,
                           size: new Point(20 * screenHeight / 500, 20 * screenHeight / 500));
            bbf.DefaultBonusMethod = BonusTypes.AddScoreBonus;



            ball = new Ball(contentManager.textures["BallTexture"],
                            frameSize: new Point(300, 300),
                            sheetSize: new Point(6, 5),
                            frameCollision: 75,
                            frameCount: 29,
                            position: new Vector2(),
                            velocity: new Vector2(0.25f * graphics.PreferredBackBufferHeight / 600, -0.25f * graphics.PreferredBackBufferHeight / 600),
                            millisecondsPerFrame: 30);
            ball.Body.Transform.ModifyScale(0.1f * graphics.PreferredBackBufferHeight / 500);



            //ui = PlayInterface.GetInstance();


            //ui.ScreenWindow = new Rectangle(0, 0, screenWidth, screenHeight);
            //ui.LifeBall = ball.Clone();

            ballManager = BallManager.GetInstance();
            ballManager.Init(ball.Clone());
            ballManager.GameBallPrototype = ball.Clone();

            //ui.LifeBall = ballManager.InterfaceBallPrototype;
            //ui.LifeBall = ball.Sprite;

            PinballLevelCreator levelCreator = PinballLevelCreator.GetInstance();

            levelCreator.Initialize(
                boardSize: new Point(20, 20),
                offset: new Point(50 * screenHeight / 500, 50 * screenHeight / 500),
                brickSize: new Point((screenWidth - 2 * 50 * screenHeight / 500) / 20, (screenHeight - 50 * screenHeight / 500 - 200 * screenHeight / 500) / 20),
                bound: bound,
                bonusPossibility: 30);



            //gameManager.ScreenRect =
            levelManager.AddLevels(levelCreator.CreateFromBitmapList(contentManager.maps));

            stateManager = StateManager.GetInstance();
            stateManager.Init(this);
            StartGame();
        }