예제 #1
0
        // +++ event handler ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        void OnBallHitsPlayer(object sender, object eventArgs)
        {
            currentDirection = DirectionLogic.CalcRandomBounceFromPlayer(currentDirection);
            currentSpeed    += 1f;

            ballTransform.position = new Vector3(
                ballTransform.position.x,
                ballConfig.rangeY * Mathf.Sign(ballTransform.position.y),
                0f
                );
        }
예제 #2
0
        public void OnEnter()
        {
            // reset modified speed to original value
            currentSpeed = ballConfig.startSpeed;

            // subscribe to interesting events
            if (nvp_EventManager_scr.INSTANCE != null)
            {
                nvp_EventManager_scr.INSTANCE.SubscribeToEvent(GameEvents.onBallHitsPlayer, OnBallHitsPlayer);
                nvp_EventManager_scr.INSTANCE.SubscribeToEvent(GameEvents.onChangeDirectionInStartScreen, OnChangeDirectionByEvent);
            }

            // randomize starting direction
            currentDirection = DirectionLogic.GetRandomDirection();

            // internal state change
            currentStateAction = OnUpdate;
        }