private void HitBrick(IBall currentBall, IEnumerable <int> bricksHit) { if (Bricks.GetHitBrick(bricksHit, out KeyValuePair <IBrick, int>?brick)) { brick.Value.Key.IsHit = true; --levelManager.GetCurrent().BeatableBricksNumber; GameState.Scores++; ballExtraFeatureBuilder.Create(currentBall, brick.Value.Key.Type); BrickHitEventArgs brickHitArgs = new BrickHitEventArgs(brick.Value.Value); OnBrickHitEvent?.Invoke(this, brickHitArgs); } }
private bool DetectBrickCollision(IBall ball, out List <BrickHit> bricksHit) { collisionManager.bricksHit = null; bricksHit = new List <BrickHit>(); List <IBrick> bricks = levelManager.GetCurrent().Bricks; bool result = false; int id = 0; foreach (var value in bricks) { IBrick brick = value; if (brick.Hit || !brick.IsVisible()) { ++id; continue; } if (collisionManager.Detect(brick, ball)) { bricksHit.Add(new BrickHit(id, brick)); result = true; } ++id; } return(result); }
private void InitializeNewLevel(bool restart) { ReinitBall(); if (restart) { levelManager.Restart(); } else { levelManager.MoveNext(); levelManager.Load(); } LevelEventArgs background = new LevelEventArgs(levelManager.GetCurrent().BackgroundPath); OnChangeLevel?.Invoke(this, background); }
private void CreateLevelMap(bool restartLevel) { if (restartLevel) { levelManager.Restart(); } else { levelManager.MoveNext(); levelManager.Load(); } bricks.Clear(); foreach (var brick in levelManager.GetCurrent().Bricks) { bricks.Add(brick); } }