/// <summary> /// Adds an SquidSceneComponent to the Scenecomponents collection /// </summary> /// <param name="component">The SquidSceneComponent to add</param> public void AddComponent(SquidSceneComponent component) { //conkerjo. i think we should check if it's already owned by a scene and throw an exception here component.SetOwner(this); SceneComponents.Add(component); }
public Level(Game game, Score score, Scene gameOverScene, Level nextLevel) : base(game) { this.game = game; spriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch)); soundCenter = (SoundCenter)game.Services.GetService(typeof(SoundCenter)); font = (SpriteFont)game.Services.GetService(typeof(SpriteFont)); bg = new Background(game); paddle = new Paddle(game); ball = new Ball(game); this.score = score; this.gameOverScene = gameOverScene; this.nextLevel = nextLevel; SceneComponents.Add(bg); SceneComponents.Add(paddle); SceneComponents.Add(ball); SceneComponents.Add(this.score); // pause paddle and ball until start paddle.Enabled = false; ball.Enabled = false; bricks = new List <Brick>(); CreateBricks(); }
public GamePlayScene(Game game, GameOverScene scene) : base(game) { this.game = game; this.maxBricks = bricks.GetLength(0) * bricks.GetLength(1); this.spriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch)); this.myFont = (SpriteFont)game.Services.GetService(typeof(SpriteFont)); this.myFont = game.Content.Load <SpriteFont>("Master"); this.heartlife = game.Content.Load <Texture2D>("heart_life"); this.barSprite = new BarSprite(game); this.ballSprite = new BallSprite(game, this); this.explosionSprite = new ExplosionSprite(game, new Vector2(10, 10), false); this.scene = scene; SceneComponents.Add(barSprite); SceneComponents.Add(ballSprite); SceneComponents.Add(explosionSprite); int x = 0, y = 40; for (int i = 0; i < bricks.GetLength(0); i++) { for (int j = 0; j < bricks.GetLength(1); j++) { int randomNumber = random.Next(0, 4); bricks[i, j] = new BrickSprite(this.game, this.ballSprite, this.explosionSprite, new Vector2(x, y), this, brickNames[randomNumber]); x += 80; SceneComponents.Add(bricks[i, j]); } x = 0; y += 27; } }
public Scene1(Microsoft.Xna.Framework.Game game, GraphicsDevice device) : base(game) { _game = game; Device = device; _textureCenter = (TextureCenter)game.Services.GetService(typeof(TextureCenter)); SpriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch)); SoundCenter = (SoundCenter)game.Services.GetService(typeof(SoundCenter)); Font = (SpriteFont)game.Services.GetService(typeof(SpriteFont)); _rocket = new Rocket(game); _explosion = new Explosion(game); _birds = new Bird[3]; SceneComponents.Add(_explosion); SceneComponents.Add(_rocket); for (var index = 0; index < _birds.Length; index++) { _birds[index] = new Bird(game, index); SceneComponents.Add(_birds[index]); } GenerateTerrainContour(); SetUpPlayers(); _rocket.Color = _carriages[0].Color; foreach (var carriage in _carriages) { SceneComponents.Add(carriage); } FlattenTerrainBelowPlayers(); CreateForeground(); Debug.WriteLine("Scene1 constarcot end!"); }
public override void Draw(GameTime gameTime) { foreach (var component in SceneComponents.OfType <DrawableGameComponent>().Where(component => component.Visible)) { component.Draw(gameTime); } base.Draw(gameTime); }
public override void Update(GameTime gameTime) { foreach (var component in SceneComponents.Where(component => component.Enabled)) { component.Update(gameTime); } base.Update(gameTime); }
public GameOverScene(Game game, Score score) : base(game) { this.game = game; spriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch)); soundCenter = (SoundCenter)game.Services.GetService(typeof(SoundCenter)); font = (SpriteFont)game.Services.GetService(typeof(SpriteFont)); this.score = score; SceneComponents.Add(this.score); }
public InstructionsScene(Game game, OpeningScene scene) : base(game) { this.game = game; this.scene = scene; this.spriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch)); this.myFont = game.Content.Load <SpriteFont>("Master"); this.heart = new HeartSprite(game); this.instructions = new String[NUM_INSTRUCTIONS]; this.instructions[0] = "Game Rules:"; this.instructions[1] = " 1) Move bar with arrows so that the ball wont cross the bar."; this.instructions[2] = " 2) Try to hit the bricks with the ball."; this.instructions[3] = "Press ESC to go back to the menu"; SceneComponents.Add(heart); }
public Scene1(Game game) : base(game) { this.game = game; spriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch)); breakerSprite = new Breaker(game); ballSprite = new ball(game); ballSprite.breaker = breakerSprite; SceneComponents.Add(ballSprite); SceneComponents.Add(breakerSprite); EndScene = false; Break1Sprite = game.Content.Load <Texture2D>("break1"); Break2Sprite = game.Content.Load <Texture2D>("break2"); Break3Sprite = game.Content.Load <Texture2D>("break3"); matrixX = 2; matrixY = 2; breaksPos = new Break[matrixX, matrixY]; }
public void NewGame() { SceneComponents.Clear(); Player player = new Player(Game); this.SceneComponents.Add(player); this.SceneComponents.Add(new PlantManager(Game)); this.SceneComponents.Add(new FarmPlotManager(Game)); GoodCollectionBox goodCollectionBox = new GoodCollectionBox(Game); this.SceneComponents.Add(goodCollectionBox); BadCollectionBox badCollectionBox = new BadCollectionBox(Game); this.SceneComponents.Add(badCollectionBox); GameplaySceneBackgroundAndMusicManager gameplaySceneManager = new GameplaySceneBackgroundAndMusicManager(Game); this.SceneComponents.Add(gameplaySceneManager); ScoreManager scoreManager = new ScoreManager(Game); this.SceneComponents.Add(scoreManager); TimerManager timerManager = new TimerManager(Game); this.SceneComponents.Add(timerManager); if (firstLoad) { Game.Services.AddService <Player>(player); Game.Services.AddService <ScoreManager>(scoreManager); Game.Services.AddService <TimerManager>(timerManager); Game.Services.AddService <GoodCollectionBox>(goodCollectionBox); Game.Services.AddService <BadCollectionBox>(badCollectionBox); Game.Services.AddService <GameplaySceneBackgroundAndMusicManager>(gameplaySceneManager); } firstLoad = false; base.Initialize(); }
public void ResetLevel() { foreach (var brick in bricks) { SceneComponents.Remove(brick); } bricks = new List <Brick>(); ball.ResetBall(); paddle.ResetPaddle(); CreateBricks(); started = false; won = false; ball.Enabled = false; paddle.Enabled = false; score.ResetPoints(); }
private void UpdateEntityInformation_EditorThread(CInspectorSceneComponentViewModel sceneComponentRoot, List <CInspectorEntityComponentViewModel> entityComponents, CInspectorEntityViewModel entity) { SceneComponents.Clear(); EntityComponents.Clear(); EntityInfo.Clear(); if (sceneComponentRoot != null) { SceneComponents.Add(sceneComponentRoot); } if (entityComponents != null) { EntityComponents = new ObservableCollection <CInspectorEntityComponentViewModel>(entityComponents); } if (entity != null) { EntityInfo.Add(entity); } }
private void CheckBallBricksIntersection() { Brick collidedBrick = null; foreach (var brick in bricks) { if (ball.rect.Intersects(brick.rect)) { ball.BrickCollisionDetected(brick); brick.Hit(); collidedBrick = brick; break; } } if (collidedBrick != null && !collidedBrick.Enabled) { score.AddPoints(collidedBrick.pointReward); bricks.Remove(collidedBrick); SceneComponents.Remove(collidedBrick); } }
public override void CreateBricks() { for (int y = 1; y < 5; y++) { for (int x = 1; x < 19; x++) { Brick brick = null; if (y == 2 && x > 1 && x < 18) { brick = new Coin(game); } else { brick = new Brick(game); } brick.Position = new Vector2(x * brickSize, y * brickSize); bricks.Add(brick); SceneComponents.Add(brick); } } }
public override void CreateBricks() { bricks = new List <Brick>(); for (int y = 1; y < 5; y++) { for (int x = 1; x < 19; x++) { Brick brick = null; if ((y + x) % 2 == 0) { brick = new RedBrick(game); } else { brick = new Brick(game); } brick.Position = new Vector2(x * brickSize, y * brickSize); bricks.Add(brick); SceneComponents.Add(brick); } } }