private void FixedUpdate() { if (colliderInContact) { if (!CollidersAreTouching(GetOtherColliderRect(colliderInContact))) { colliderInContact = null; } } foreach (Collider2D collider in CustomArkanoidPhysics.GetWallTypeColliders()) { if (collider == null) { return; } if (collider != colliderInContact && CollidersAreTouching(GetOtherColliderRect((BoxCollider2D)collider))) { colliderInContact = (BoxCollider2D)collider; CustomBoxCollider wallScript = collider.gameObject.GetComponent <CustomBoxCollider>(); movementComponent.Direction = wallScript.ResolveCollision(movementComponent.Direction, movementComponent.PreviousPosition); return; } } }
private void LoadLevel(uint levelNumber) { EventBus.ClearAll(); CustomArkanoidPhysics.ClearAll(); Initialize(); switch (levelNumber) { case 1: currentLevel = 1; SceneManager.LoadScene("Level1"); break; case 2: currentLevel = 2; SceneManager.LoadScene("Level2"); break; case 3: currentLevel = 3; SceneManager.LoadScene("Level3"); break; default: currentLevel = 3; SceneManager.LoadScene("Level3"); break; } }
private void Initialize() { EventBus.Subscribe <BrickRegisteredEvent>(RegisterBrick); EventBus.Subscribe <BrickDestroyedEvent>(OnBrickDestroyed); EventBus.Subscribe <BallRegisteredEvent>(RegisterBall); EventBus.Subscribe <BallDestroyedEvent>(OnBallDestroyed); EventBus.Subscribe <SpawnExtraBallEvent>(OnSpawnExtraBallEvent); allBricks.Clear(); allBalls.Clear(); CustomArkanoidPhysics.SetUp(); }
private void LateUpdate() { BoxCollider2D paddleCollider = CustomArkanoidPhysics.GetPaddleCollider(); if (paddleCollider == null) { return; } if (GetThisColliderRect().Overlaps(GetOtherColliderRect(paddleCollider))) { ActivateBonus(); } }