예제 #1
0
    void Awake()
    {
        this.model = new CharacterModel();

        // view => model
        view.MovementIntentionObservable.Subscribe((CharacterModel.MovementIntention intention) => {
            this.MovementIntentionHandler(intention);
            this.model.moveIntention.Value = intention;
        });

        view.IsOnTheGroundAsObservalbe().Subscribe((bool isOnTheGround) => {
            this.model.isOnTheGround.Value = isOnTheGround;
            this.model.jumpStateMachine.LandedTransition();
        });

        view.JumpIntentionAsObservable().Subscribe((CharacterModel.JumpIntention intention) => {
            this.model.jumpIntention.Value = intention;
        });

        // model => view
        model.isNotOnTheGround.Subscribe((bool isOnTheGround) => {
            this.view.IsNotOnTheGroundChanged(isOnTheGround);
        });

        model.jumpStateMachine.onDoJump.Subscribe((Unit _) => {
            view.OnDoJump();
        });

        model.jumpStateMachine.jumpState.Subscribe(this.JumpStateChanged);
    }