public void HandleBrickCollision(List <BrickHit> bricksHit) { collisionManager.bricksHit = GetBricksHit(bricksHit); if (collisionManager.HitBrick(out BrickType type)) { BrickHitEventArgs brickHitArgs = new BrickHitEventArgs(bricksHit[0].Number); OnBrickHit?.Invoke(this, brickHitArgs); --levelManager.GetCurrent().BeatableBricksNumber; Scores++; ExecuteAdditionalEffect(type); } }
/// <summary> /// Obsluha kolize s nejakym objektem /// </summary> /// <param name="gameObject"> /// Objekt se kterym doslo ke srazce /// </param> public override void OnCollide(IGameObject gameObject) { // pokud jsem narazil na micek if (gameObject is Ball ball) { var collision = false; var index = 0; // zjisti jestli a do jake cihly jsem narazil while (!collision && index < _bricks.Count) { var brick = _bricks[index]; // jestli narazim do cihly if (brick.Intersects(ball)) { // dej to vedet micku ball.OnCollide(brick); // dej to vedet vys OnBrickHit?.Invoke(brick); // smaz cihlu _gameManager.GameCanvas.Children.Remove(brick.View); _bricks.Remove(brick); // jedna a dost collision = true; } index++; } // pokud v seznamu nejsou cihly, pak by mel byt konec levelu if (_bricks.Count == 0) { OnCompleted?.Invoke(); } } }