public GameScene(MyGame myGame, IGameFactory gameFactory, List <Block> blocks, Catcher catcher, int score) { _blocks = blocks; _catcher = catcher; _score = score; _myGame = myGame; _gameFactory = gameFactory; _collisionDetection = new CollisionDetection(); _collisionDetection.Hit += delegate(CollisionEventArgs e) { ++_score; _blocks.Remove(e.Block); }; _collisionDetection.Hit += gameFactory.BlockHit; _collisionDetection.Miss += e => new NewRecordScene(_myGame, _score, _gameFactory.Difficulty); _scoreFont = _myGame.Content.Load <SpriteFont>("ScoreFont"); _previousState = Keyboard.GetState(); }
public EscMenuScene(MyGame myGame, IScene gameScene) { _myGame = myGame; _gameScene = gameScene; _pauseTextFont = _myGame.Content.Load <SpriteFont>("ScoreFont"); _previousState = Keyboard.GetState(); _pauseText = System.Configuration.ConfigurationManager.AppSettings["PauseText"]; }
public EndMenuScene(MyGame myGame, int score, List <Record> records) { _myGame = myGame; _score = score; _records = records; _restartGameText = System.Configuration.ConfigurationManager.AppSettings["RestartGameText"]; _menuFont = myGame.Content.Load <SpriteFont>("MenuFont"); _scoreFont = _myGame.Content.Load <SpriteFont>("ScoreFont"); _recordFont = _myGame.Content.Load <SpriteFont>("ErrorFont"); _restartGame = new Button(new Rectangle((int)(myGame.WindowResolution.X - _buttonWidth) / 2, (int)myGame.WindowResolution.Y - _buttonHeight - 10, _buttonWidth, _buttonHeight), _menuFont, _restartGameText); _restartGame.Click += (b, e) => _myGame.CurrentScene = new DifficultyScene(_myGame); }
public DifficultyScene(MyGame myGame) { _myGame = myGame; _menuFont = myGame.Content.Load <SpriteFont>("MenuFont"); _difficultyText = System.Configuration.ConfigurationManager.AppSettings["DifficultyText"]; _easyText = System.Configuration.ConfigurationManager.AppSettings["EasyText"]; _hardText = System.Configuration.ConfigurationManager.AppSettings["HardText"]; _easy = new Button(new Rectangle((int)(myGame.WindowResolution.X - _buttonWidth) / 2, _buttonSpace, _buttonWidth, _buttonHeight), _menuFont, _easyText); _hard = new Button(new Rectangle((int)(myGame.WindowResolution.X - _buttonWidth) / 2, _buttonSpace * 2 + _buttonHeight, _buttonWidth, _buttonHeight), _menuFont, _hardText); _easy.Click += delegate { _myGame.CurrentScene = new GameScene(_myGame, new EasyGameFactory(_myGame.WindowResolution)); }; _hard.Click += delegate { _myGame.CurrentScene = new GameScene(_myGame, new HardGameFactory(myGame.WindowResolution)); }; }
public MainMenuScene(MyGame myGame) { _myGame = myGame; _menuFont = _myGame.Content.Load <SpriteFont>("MenuFont"); _startGame = new Button(new Rectangle((int)(_myGame.WindowResolution.X - _buttonWidth) / 2, _buttonSpace, _buttonWidth, _buttonHeight), _myGame.Content.Load <SpriteFont>("MenuFont"), System.Configuration.ConfigurationManager.AppSettings["StartGameText"]); _loadGame = new Button(new Rectangle((int)(_myGame.WindowResolution.X - _buttonWidth) / 2, _buttonSpace * 2 + _buttonHeight, _buttonWidth, _buttonHeight), _myGame.Content.Load <SpriteFont>("MenuFont"), System.Configuration.ConfigurationManager.AppSettings["LoadGameText"]); _unsuccesfulLoadText = System.Configuration.ConfigurationManager.AppSettings["UnsuccesfulLoadText"]; _startGame.Click += (b, e) => myGame.CurrentScene = new DifficultyScene(_myGame); _loadGame.Click += Load; unsuccesfulLoad = false; }
public NewRecordScene(MyGame myGame, int score, Difficulties difficulty) { _myGame = myGame; _score = score; _difficulty = difficulty; _records = difficulty == Difficulties.Easy ? _myGame.EasyRecords : _myGame.HardRecords; _scoreFont = _myGame.Content.Load <SpriteFont>("ScoreFont"); _menuFont = _myGame.Content.Load <SpriteFont>("MenuFont"); _newRecordText = System.Configuration.ConfigurationManager.AppSettings["NewRecordText"]; _enterNameText = System.Configuration.ConfigurationManager.AppSettings["EnterNameText"]; _name = ""; _previous = Keyboard.GetState(); if (_records.Count == 10 && _score <= _records[9]._score) { _myGame.CurrentScene = new EndMenuScene(_myGame, _score, _records); } else { _myGame.CurrentScene = this; } }
public GameScene(MyGame myGame, IGameFactory gameFactory) : this(myGame, gameFactory, new List <Block>(), gameFactory.GetCatcher(), 0) { }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. Game1.sSpriteBatch = new SpriteBatch(GraphicsDevice); //mSpriteBatch = new SpriteBatch(GraphicsDevice); // Define camera window bounds Camera.SetCameraWindow(new Vector2(10f, 20f), 100f); // Create the primitives. mGraphicsObjects = new TexturedPrimitive[kNumObjects]; mGraphicsObjects[0] = new TexturedPrimitive( Content.Load <Texture2D>("UWB-JPG"), // Image file name new Vector2(15f, 25f), // Position to draw new Vector2(10f, 10f)); // Size to draw //new Vector2(10, 10), // Position to draw //new Vector2(30, 30)); // Size to draw mGraphicsObjects[1] = new TexturedPrimitive( Content.Load <Texture2D>("UWB-JPG"), new Vector2(35f, 60f), new Vector2(50f, 50f)); //new Vector2(200, 200), //new Vector2(100, 100)); mGraphicsObjects[2] = new TexturedPrimitive( Content.Load <Texture2D>("UWB-PNG"), new Vector2(105f, 25f), new Vector2(10f, 10f)); //new Vector2(50, 10), //new Vector2(30, 30)); mGraphicsObjects[3] = new TexturedPrimitive( Content.Load <Texture2D>("UWB-PNG"), new Vector2(90f, 60f), new Vector2(35f, 35f)); //new Vector2(50, 200), //new Vector2(100, 100)); mUWBLogo = new TexturedPrimitive(Content.Load <Texture2D>("UWB-PNG"), new Vector2(30, 30), new Vector2(20, 20)); vida = 5; score = 0; placarVida = new TexturedPrimitive[10]; blocosNaTela = 0; nivelAtual = 1; int posicaoX = 13; int posicaoY = 92; int j = 0; for (int i = 0; i < 10; i++) { placarVida[i] = new TexturedPrimitive(Content.Load <Texture2D>("Block Breaker Esfera"), mVidaPosition, mVidaSize); placarVida[i].mPosition = new Vector2(posicaoX, posicaoY); posicaoX += 6; } mBall = new SoccerBall(mSoccerPosition, mSoccerBallRadius * 2f); mEsfera = new Esfera(mEsferaPosition, mEsferaSize); mBastao = new Bastao(mBastaoPosition, mBastaoSize); //mBloco = new BlocoAzul(mBlocoPosition, mBlocoSize); //carrega Nivel 1 mBlocoAzulNivel1 = new BlocoAzul[40]; posicaoX = 15; posicaoY = 85; j = 0; for (int i = 0; i < 40; i++) { mBlocoAzulNivel1[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoAzulNivel1[i].mPosition = new Vector2(posicaoX, posicaoY); posicaoX += 10; j++; if (j == 10) { posicaoX = 15; posicaoY -= 5; j = 0; } } //carrega Nivel 2 mBlocoAmareloNivel2 = new BlocoAmarelo[10]; mBlocoAmareloQuebradoNivel2 = new BlocoAzul[10]; timerBlocoAmareloNivel2 = new int[10]; timerBlocoAmareloNivel2existing = new bool[10]; posicaoX = 15; posicaoY = 85; j = 0; for (int i = 0; i < 10; i++) { mBlocoAmareloNivel2[i] = new BlocoAmarelo(mBlocoPosition, mBlocoSize); mBlocoAmareloNivel2[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoAmareloQuebradoNivel2[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoAmareloQuebradoNivel2[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoAmareloQuebradoNivel2[i].existe = false; timerBlocoAmareloNivel2[i] = 0; timerBlocoAmareloNivel2existing[i] = false; posicaoX += 10; j++; } mBlocoAzulNivel2 = new BlocoAzul[20]; posicaoX = 15; posicaoY = 70; j = 0; for (int i = 0; i < 20; i++) { mBlocoAzulNivel2[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoAzulNivel2[i].mPosition = new Vector2(posicaoX, posicaoY); posicaoX += 10; j++; if (j == 10) { posicaoX = 15; posicaoY -= 15; j = 0; } } //carrega Nivel 3 mBlocoAmareloNivel3 = new BlocoAmarelo[20]; mBlocoAmareloQuebradoNivel3 = new BlocoAzul[20]; timerBlocoAmareloNivel3 = new int[20]; timerBlocoAmareloNivel3existing = new bool[20]; mBlocoAzulNivel3 = new BlocoAzul[20]; posicaoX = 15; posicaoY = 85; j = 0; for (int i = 0; i < 20; i++) { mBlocoAmareloNivel3[i] = new BlocoAmarelo(mBlocoPosition, mBlocoSize); mBlocoAmareloNivel3[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoAmareloQuebradoNivel3[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoAmareloQuebradoNivel3[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoAmareloQuebradoNivel3[i].existe = false; timerBlocoAmareloNivel3[i] = 0; timerBlocoAmareloNivel3existing[i] = false; posicaoX += 10; j++; if (j == 10) { posicaoX = 15; posicaoY -= 30; j = 0; } } posicaoX = 15; posicaoY = 70; j = 0; for (int i = 0; i < 20; i++) { mBlocoAzulNivel3[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoAzulNivel3[i].mPosition = new Vector2(posicaoX, posicaoY); posicaoX += 10; j++; if (j == 10) { posicaoX = 15; posicaoY -= 5; j = 0; } } //carrega nivel 4 mBlocoAzulNivel4 = new BlocoAzul[18]; mBlocoAmareloNivel4 = new BlocoAmarelo[10]; mBlocoAmareloQuebradoNivel4 = new BlocoAzul[10]; timerBlocoAmareloNivel4 = new int[10]; timerBlocoAmareloNivel4existing = new bool[10]; mBlocoMarromNivel4 = new BlocoMarrom[4]; mBlocoMarromQuebradoNivel4 = new BlocoAmarelo[4]; timerBlocoMarromNivel4 = new int[4]; timerBlocoMarromNivel4existing = new bool[4]; mBlocoMarromQuebrado2Nivel4 = new BlocoAzul[4]; timerBlocoMarrom2Nivel4 = new int[4]; timerBlocoMarrom2Nivel4existing = new bool[4]; posicaoX = 15; posicaoY = 55; j = 0; for (int i = 0; i < 18; i++) { mBlocoAzulNivel4[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoAzulNivel4[i].mPosition = new Vector2(posicaoX, posicaoY); if (i == 13) { posicaoX += 20; } posicaoX += 10; j++; if (j == 10) { posicaoX = 15; posicaoY += 5; j = 0; } } posicaoX = 15; posicaoY = 65; j = 0; for (int i = 0; i < 10; i++) { mBlocoAmareloNivel4[i] = new BlocoAmarelo(mBlocoPosition, mBlocoSize); mBlocoAmareloNivel4[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoAmareloQuebradoNivel4[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoAmareloQuebradoNivel4[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoAmareloQuebradoNivel4[i].existe = false; timerBlocoAmareloNivel4[i] = 0; timerBlocoAmareloNivel4existing[i] = false; if (i == 2) { posicaoX += 40; } if (i == 7) { posicaoX += 60; } posicaoX += 10; j++; if (j == 6) { posicaoX = 15; posicaoY += 5; j = 0; } } posicaoX = 15; posicaoY = 75; j = 0; for (int i = 0; i < 4; i++) { mBlocoMarromNivel4[i] = new BlocoMarrom(mBlocoPosition, mBlocoSize); mBlocoMarromNivel4[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoMarromQuebradoNivel4[i] = new BlocoAmarelo(mBlocoPosition, mBlocoSize); mBlocoMarromQuebradoNivel4[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoMarromQuebradoNivel4[i].existe = false; timerBlocoMarromNivel4[i] = 0; timerBlocoMarromNivel4existing[i] = false; mBlocoMarromQuebrado2Nivel4[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoMarromQuebrado2Nivel4[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoMarromQuebrado2Nivel4[i].existe = false; timerBlocoMarrom2Nivel4[i] = 0; timerBlocoMarrom2Nivel4existing[i] = false; if (i == 0 || i == 2) { posicaoX = 105; } j++; if (j == 2) { posicaoX = 15; posicaoY += 5; } } //carrega nivel 5 mBlocoAzulNivel5 = new BlocoAzul[10]; mBlocoAmareloNivel5 = new BlocoAmarelo[10]; mBlocoAmareloQuebradoNivel5 = new BlocoAzul[10]; timerBlocoAmareloNivel5 = new int[10]; timerBlocoAmareloNivel5existing = new bool[10]; mBlocoMarromNivel5 = new BlocoMarrom[28]; mBlocoMarromQuebradoNivel5 = new BlocoAmarelo[28]; timerBlocoMarromNivel5 = new int[28]; timerBlocoMarromNivel5existing = new bool[28]; mBlocoMarromQuebrado2Nivel5 = new BlocoAzul[28]; timerBlocoMarrom2Nivel5 = new int[28]; timerBlocoMarrom2Nivel5existing = new bool[28]; mBlocoVermelhoNivel5 = new BlocoVermelho[4]; mBlocoVermelhoQuebradoNivel5 = new BlocoMarrom[4]; timerBlocoVermelhoNivel5 = new int[4]; timerBlocoVermelhoNivel5existing = new bool[4]; mBlocoVermelhoQuebrado2Nivel5 = new BlocoAmarelo[4]; timerBlocoVermelho2Nivel5 = new int[4]; timerBlocoVermelho2Nivel5existing = new bool[4]; mBlocoVermelhoQuebrado3Nivel5 = new BlocoAzul[4]; timerBlocoVermelho3Nivel5 = new int[4]; timerBlocoVermelho3Nivel5existing = new bool[4]; posicaoX = 15; posicaoY = 55; j = 0; for (int i = 0; i < 10; i++) { mBlocoAzulNivel5[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoAzulNivel5[i].mPosition = new Vector2(posicaoX, posicaoY); posicaoX += 10; } posicaoX = 15; posicaoY = 60; for (int i = 0; i < 10; i++) { mBlocoAmareloNivel5[i] = new BlocoAmarelo(mBlocoPosition, mBlocoSize); mBlocoAmareloNivel5[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoAmareloQuebradoNivel5[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoAmareloQuebradoNivel5[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoAmareloQuebradoNivel5[i].existe = false; timerBlocoAmareloNivel5[i] = 0; timerBlocoAmareloNivel5existing[i] = false; posicaoX += 10; } posicaoX = 15; posicaoY = 65; for (int i = 0; i < 28; i++) { mBlocoMarromNivel5[i] = new BlocoMarrom(mBlocoPosition, mBlocoSize); mBlocoMarromNivel5[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoMarromQuebradoNivel5[i] = new BlocoAmarelo(mBlocoPosition, mBlocoSize); mBlocoMarromQuebradoNivel5[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoMarromQuebradoNivel5[i].existe = false; timerBlocoMarromNivel5[i] = 0; timerBlocoMarromNivel5existing[i] = false; mBlocoMarromQuebrado2Nivel5[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoMarromQuebrado2Nivel5[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoMarromQuebrado2Nivel5[i].existe = false; timerBlocoMarrom2Nivel5[i] = 0; timerBlocoMarrom2Nivel5existing[i] = false; if (i == 0 || i == 4 || i == 8 || i == 2 || i == 6 || i == 14) { posicaoX += 20; } else if (i == 3 || i == 7 || i == 15 || i == 17) { posicaoX = 15; posicaoY += 5; } else if (i == 1 || i == 5) { posicaoX += 50; } else if (i == 16) { posicaoX += 90; } else { posicaoX += 10; } } posicaoX = 45; posicaoY = 80; for (int i = 0; i < 4; i++) { mBlocoVermelhoNivel5[i] = new BlocoVermelho(mBlocoPosition, mBlocoSize); mBlocoVermelhoNivel5[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoVermelhoQuebradoNivel5[i] = new BlocoMarrom(mBlocoPosition, mBlocoSize); mBlocoVermelhoQuebradoNivel5[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoVermelhoQuebradoNivel5[i].existe = false; timerBlocoVermelhoNivel5[i] = 0; timerBlocoVermelhoNivel5existing[i] = false; mBlocoVermelhoQuebrado2Nivel5[i] = new BlocoAmarelo(mBlocoPosition, mBlocoSize); mBlocoVermelhoQuebrado2Nivel5[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoVermelhoQuebrado2Nivel5[i].existe = false; timerBlocoVermelho2Nivel5[i] = 0; timerBlocoVermelho2Nivel5existing[i] = false; mBlocoVermelhoQuebrado3Nivel5[i] = new BlocoAzul(mBlocoPosition, mBlocoSize); mBlocoVermelhoQuebrado3Nivel5[i].mPosition = new Vector2(posicaoX, posicaoY); mBlocoVermelhoQuebrado3Nivel5[i].existe = false; timerBlocoVermelho3Nivel5[i] = 0; timerBlocoVermelho3Nivel5existing[i] = false; posicaoX += 10; } //fim dos niveis // Load the images. //mJPGImage = Content.Load<Texture2D>("UWB-JPG"); //mPNGImage = Content.Load<Texture2D>("UWB-PNG"); background = Content.Load <Texture2D>("Salty present 2015"); levels = new Texture2D[6]; levels[0] = Content.Load <Texture2D>("IPCA Nivel 1"); levels[1] = Content.Load <Texture2D>("IPCA Nivel 2"); levels[2] = Content.Load <Texture2D>("IPCA Nivel 3"); levels[3] = Content.Load <Texture2D>("IPCA Nivel 4"); levels[4] = Content.Load <Texture2D>("IPCA Nivel 5"); levels[5] = Content.Load <Texture2D>("IPCA"); //lifeLost = Content.Load<SoundEffect>("Life Lost"); //stageClear = Content.Load<SoundEffect>("Stage Clear"); mTheGame = new MyGame(); // TODO: use this.Content to load your game content here }
static void Main() { using (var game = new MyGame(new FileScoreRepository())) game.Run(); }