public void Init(LevelManager <PinballLevel> levelManager, Bound bound, Rectangle screenRect) { ballManager = BallManager.GetInstance(); bonusManager = BonusManager.GetInstance(); scoreManager = ScoreManager.GetInstance(); this.bound = bound; lifeManager = LifeManager.GetInstance(); ScreenRect = screenRect; this.levelManager = levelManager; }
public PlayState(int lives) { bonusManager = BonusManager.GetInstance(); levelManager = LevelManager <PinballLevel> .GetInstance(); ballManager = BallManager.GetInstance(); scoreManager = ScoreManager.GetInstance(); gameManager = GameManager.GetInstance(); stateManager = StateManager.GetInstance(); gui = new PlayInterface(GameManager.GetInstance().ScreenRect); gui.Initialize(ballManager.GameBallPrototype.Sprite.Clone()); gui.LivesChanged(lives); lifeManager = LifeManager.GetInstance(); lifeManager.Lives = lives; lifeManager.OnLivesChanged += LivesChanged; gameManager.OnGameOver += OnGameOver; levelManager.SetLevel(1); }
public static BallManager GetInstance() { return(instance ?? (instance = new BallManager())); }
/// <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(); }