Beispiel #1
0
 protected PlaygroundBlock(Playground playground, Point point)
     : base(playground.Game)
 {
     _playground = playground;
     _positionOnPlayground = point;
     Init();
 }
        public PlaygroundBlockGenerator(Playground playground, int height, int width)
        {
            Requires.NotNull(playground, "playground");
            Requires.Range(height > 0, "height");
            Requires.Range(width > 0, "width");

            _playground = playground;
            _height = height;
            _width = width;
        }
Beispiel #3
0
 public Level(Playground playground, int levelNumber, int startLifes, int hardBalls, int softBalls, int mines)
 {
     Requires.Range(levelNumber > 0, "levelNumber");
     Requires.Range(startLifes > 0, "startLifes");
     Requires.Range(hardBalls >= 0, "hardBalls");
     Requires.Range(softBalls >= 0, "softBalls");
     Requires.Range(mines >= 0, "mines");
     _playground = playground;
     _levelNumber = levelNumber;
     _startLifes = startLifes;
     _hardBalls = hardBalls;
     _softBalls = softBalls;
     _mines = mines;
 }
Beispiel #4
0
 public PathBlock(Playground playground, Point point)
     : base(playground, point)
 {
 }
Beispiel #5
0
 public BorderBlock(Playground playground, Point point)
     : base(playground, point)
 {
 }
Beispiel #6
0
 public GroundBlock(Playground playground, Point point)
     : base(playground, point)
 {
 }
Beispiel #7
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();
 }