示例#1
0
 private void Improve(MainDevice mainDevice)
 {
     Game.GameObjectCollection.Add(new BubbleLabel(Game, "Life!", CenterPosition));
     Game.Lifes++;
 }
示例#2
0
 public void StartLevel(int levelNumber)
 {
     GameObjectCollection.Clear();
     GameObjectCollection.Add(new Background(this));
     var bf = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.All, this));
     /*_level = new Level(null, 3, 5, 3, 2, 3);
     var position = new Vector2(Settings.Instance.Width/2 - Settings.Instance.PlaygroundBlockWidth*144/2,
                                Settings.Instance.Height/2 - Settings.Instance.PlaygroundBlockHeight*81/2);
     _playground = new Playground(this, position, 144, 81);
     _level = new Level(_playground, 3, 5, 3, 2, 3);
     using (var stream = File.Create("level3.pg"))
     {
         bf.Serialize(stream, _level);
     }*/
     _level = new Level(null, levelNumber, 1, 1, 0, 0);
     using (FileStream stream = File.OpenRead(string.Format("level{0}.pg", levelNumber)))
     {
         _level = (Level) bf.Deserialize(stream);
     }
     _playground = _level.Playground;
     _statisticsPanel = new StatisticsPanel(this);
     _mainDevice = new MainDevice(this) {Position = _playground.StartPosition};
     _camera.Focus = _mainDevice;
     _camera.Position = _mainDevice.Position;
     _drawablesWithoutTransform = new List<IDrawable>();
     _bonusGenerator = new BonusGenerator(this);
     DrawWithoutTransform(_statisticsPanel);
     GameObjectCollection.Add(_playground);
     GameObjectCollection.Add(_mainDevice);
     GameObjectCollection.Add(new ZoomingEffect(this, 0.4f, 1f, 0.4f));
     GameObjectCollection.Add(_bonusGenerator);
     var safePositions = new Queue<Vector2>();
     safePositions.Enqueue(_playground.Position + new Vector2(200));
     safePositions.Enqueue(_playground.Position + new Vector2(_playground.Width, _playground.Height) -
                           new Vector2(200));
     safePositions.Enqueue(_playground.Position + new Vector2(_playground.Width, 0) - new Vector2(200, -200));
     safePositions.Enqueue(_playground.Position + new Vector2(0, _playground.Height) - new Vector2(-200, 200));
     safePositions.Enqueue(_playground.Position + new Vector2(300));
     safePositions.Enqueue(_playground.Position + new Vector2(_playground.Width, _playground.Height) -
                           new Vector2(300));
     safePositions.Enqueue(_playground.Position + new Vector2(_playground.Width, 0) - new Vector2(300, -300));
     safePositions.Enqueue(_playground.Position + new Vector2(0, _playground.Height) - new Vector2(-300, 300));
     for (int i = 0; i < _level.HardBalls; i++)
     {
         GameObjectCollection.Add(new HardBall(this, safePositions.Dequeue()));
     }
     for (int i = 0; i < _level.SoftBalls; i++)
     {
         GameObjectCollection.Add(new SoftBall(this, safePositions.Dequeue()));
     }
     for (int i = 0; i < _level.Mines; i++)
     {
         GameObjectCollection.Add(new Mine(this, _playground.Position + new Vector2(200 + 150*i, 30)));
     }
     _playground.Completed += (sender, args) => NextLevel();
     TimeLeft = TimeSpan.FromSeconds(61);
     _scoresTimer = new GameTimer(TimeSpan.FromSeconds(10));
     GC.Collect();
 }