コード例 #1
0
        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;
                }
            }
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        private void LateUpdate()
        {
            BoxCollider2D paddleCollider = CustomArkanoidPhysics.GetPaddleCollider();

            if (paddleCollider == null)
            {
                return;
            }

            if (GetThisColliderRect().Overlaps(GetOtherColliderRect(paddleCollider)))
            {
                ActivateBonus();
            }
        }