ºÇ½ª¹¹¿·¡§ orika_ex_miyako 2023ǯ10·î12Æü(ÌÚ) 17:15:25ÍúÎò
¡¡Á°²ó¤Î³¤¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡UniTask¤ÈUniRx¤ò»ÈÍѤ·¤Æ Final Fantasy¤ÎATB¥²¡¼¥¸¤Î¤è¤¦¤Ê¡¢°ìÄê»þ´Ö¤¬·Ð²á¤¹¤ë¤È¥¤¥Ù¥ó¥È¤Î½àÈ÷¤¬À°¤¦¥·¥¹¥Æ¥à¤ò¼ÂÁõ¤¹¤ëÎã¤Ç¤¹¡£
¤³¤³¤Ç¤Ï¥Ü¥¿¥ó¤¬²¡¤»¤ë¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¡£
¡ã¼ÂÁõÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¡¡Model ¥¯¥é¥¹¤Î¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤È¡¢¥¹¥È¥ê¡¼¥à¤Ë¤Ä¤¤¤Æ¤Î¾ÜºÙ¤ÊÀâÌÀ¤ò¹Ô¤¤¤Þ¤¹¡£
¤Þ¤¿¤½¤ì¤Ëȼ¤Ã¤¿ Presenter ¥¯¥é¥¹¤Î¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£
¡¡ºÇ¸å¤Ë View ¥¯¥é¥¹¤ÇÍøÍѤ·¤Æ¤¤¤ë
public IObservable<Unit> OnAttackButtonClick => attackButton.OnClickAsObservable() ¥×¥í¥Ñ¥Æ¥£¤ÎÀâÌÀ¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£
¡¡
¡¡ATBModel_Mono ¤Ï MonoBehaviour ¤Ø¤ÎɳÉÕ¤±¤¬¤¢¤ë¤¿¤á¡¢¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î°Í¸´Ø·¸¤¬È¯À¸¤·¤Þ¤¹¡£
¡¡UniRx ¤Ç¤Ï MonoBehaviour ¤òÍøÍѤ·¤Ê¤¯¤Æ¤â Update ¥á¥½¥Ã¥É¤ÈƱ¤¸µ¡Ç½¤ò»ý¤Ä½èÍý¤ò¼ÂÁõ¤Ç¤¤ë¤¿¤á¡¢
²¼µ¤Î¤è¤¦¤Ê·Á¤Ç½èÍý¤ò¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤¹¤ë¤³¤È¤Ç¤âµ¡Ç½¤·¤Þ¤¹¡£
¡¡¤½¤³¤Ç ATBModel_Mono ¥¯¥é¥¹¤ÎÂå¤ï¤ê¤Ë¡¢ MonoBehaviour ¤Î·Ñ¾µ¤Î¤Ê¤¤ Model ¥¯¥é¥¹¤È¤·¤Æ ATBModel ¥¯¥é¥¹¤ò¿·¤·¤¯ºîÀ®¤·¤Þ¤¹¡£
¡¡MonoBehaviour ¤Î·Ñ¾µ¤¬¤Ê¤¯¤Ê¤ê¤Þ¤·¤¿¡£¤½¤Î¤¿¤á¤³¤Î¥¯¥é¥¹¤Ï new ¤·¤Æ¥¤¥ó¥¹¥¿¥ó¥¹¤òºîÀ®¤·¤ÆÍøÍѤ¹¤ë·Á¼°¤Ë¤Ê¤ê¤Þ¤¹¡£
¤Þ¤¿ SetTriggerATB ¥á¥½¥Ã¥É¤Ç¤Ï¤Ê¤¯¡¢¥³¥ó¥¹¥È¥é¥¯¥¿¥á¥½¥Ã¥É¤È¡¢¤½¤Î°ú¿ô¤òÍøÍѤ·¤Æ¥á¥ó¥ÐÊÑ¿ô¤Î½é´üÀßÄê¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£
¡¡MonoBehaviour ¤ÈɳÉÕ¤¤¤Æ¤¤¤¿ UpdateAsObservable ¥á¥½¥Ã¥É¤ÎÂå¤ï¤ê¤Ë¡¢ÀÅŪ¥á¥½¥Ã¥É¤Ç¤¢¤ë Observable.EveryUpdate ¥á¥½¥Ã¥É¤òÍøÍѤ¹¤ë¤³¤È¤ÇÂåÍѤ·¤Æ¤¤¤Þ¤¹¡£
¤³¤Á¤é¤Î¥á¥½¥Ã¥É¤Ï MonoBehaviour ¤Ë¤ÏɳÉÕ¤¤¤Æ¤¤¤Ê¤¤¥á¥½¥Ã¥É¤Ç¤¢¤ë¤¿¤á¡¢AddTo ¥á¥½¥Ã¥É¤Ë¤è¤ê¡¢¥é¥¤¥Õ¥µ¥¤¥¯¥ë¤ò´ÉÍý¤·¤Æ¤¤¤Þ¤¹¡£
¡¡¤Ê¤ª¡¢using UnityEngine; ¤ÎÀë¸À¤Ï¡¢ Time ¥¯¥é¥¹¤òÍøÍѤ¹¤ë¤¿¤á¤ËɬÍפǤ¹¡£
¡¡Observable.EveryUpdate() ¤Ë¤è¤ë¥¹¥È¥ê¡¼¥à¤Ï¡¢AddTo ¥á¥½¥Ã¥É¤òÍøÍѤ¹¤ë¤³¤È¤Ë¤è¤ê¡¢ºîÀ®¤ÈƱ»þ¤Ë CompositeDisposable¤Ë¼«Æ°Åª¤ËÄɲ䵤ì¤Þ¤¹¡£
¤³¤Î¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤¬ÇË´þ¤µ¤ì¤ë¤È¤¤ËDispose¥á¥½¥Ã¥É¤¬¸Æ¤Ó½Ð¤µ¤ì¡¢¤½¤ì¤Ë¤è¤Ã¤ÆCompositeDisposable¤Ë´Þ¤Þ¤ì¤ëÁ´¤Æ¤Î¥¹¥È¥ê¡¼¥à¤¬¼«Æ°Åª¤Ë²òÊü¤µ¤ì¤Þ¤¹
¡¡¤³¤Î¤È¤¡¢AddTo ¥á¥½¥Ã¥É¤Î°ú¿ô¤Ë¤Ï this ¤Ï½ñ¤±¤Þ¤»¤ó¡£
Íýͳ¤Ï MonoBehaviour ¤ò·Ñ¾µ¤·¤Æ¤¤¤Ê¤¤¤¿¤á¤Ç¤¹¡£
¡¡MonoBehaviour¤ÏComponent¤ò·Ñ¾µ¤·¤Æ¤ª¤ê¡¢Component¤ÏObject¤ò·Ñ¾µ¤·¤Æ¤¤¤Þ¤¹¡£
Object¤Ë¤ÏIDisposable¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤¿¤á¡¢MonoBehaviour¤ä¤½¤ÎÇÉÀ¸¥¯¥é¥¹¤Ç¤¢¤ë¥¹¥¯¥ê¥×¥È¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Ç¤âAddTo(this)¤¬ÍøÍѤǤ¤Þ¤¹¡£
¡¡°ìÊý¡¢°ìÈÌŪ¤ÊC#¥¯¥é¥¹¤ÏIDisposable¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤¤¿¤á¡¢this ¤È¤Ï½ñ¤±¤Þ¤»¤ó¡£
AddTo()¤ÎÌá¤êÃͤòÊÝ»ý¤¹¤ëCompositeDisposable¥ª¥Ö¥¸¥§¥¯¥È¤òÊÌÅÓºîÀ®¤·¤Æ¡¢¤½¤³¤Ë¥¹¥È¥ê¡¼¥à¤òÄɲ䷤Ƥ¤¤Þ¤¹¡£
¤½¤·¤Æ¡¢¤½¤ÎCompositeDisposable¥ª¥Ö¥¸¥§¥¯¥È¤ÏɬÍפ˱þ¤¸¤ÆÌÀ¼¨Åª¤ËDispose¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
private readonly CompositeDisposable disposables = new (); // ATB¤ò²óÉü¤¹¤ë¥¹¥È¥ê¡¼¥à Observable.EveryUpdate() .Where(_ => CurrentATB.Value < MaxATB) .Subscribe(_ => CurrentATB.Value += RecoveryRate * Time.deltaTime) .AddTo(disposables); // ¥¹¥È¥ê¡¼¥à¤¬À¸À®¤µ¤ì¤¿»þ¤Ë¼«Æ°Åª¤Ë CompositeDisposable ¤ËÄɲà /// <summary> /// ¥ª¥Ö¥¸¥§¥¯¥È(¥¤¥ó¥¹¥¿¥ó¥¹)¤¬ÇË´þ¤µ¤ì¤ë¤È¤¤ËCompositeDisposable¤ÎDispose¤â¸Æ¤Ó½Ð¤¹ /// </summary> public void Dispose() { // Dispose ¥á¥½¥Ã¥É¤¬¸Æ¤Ð¤ì¤¿¤È¤¤Ë¡¢CompositeDisposable ¤Ë´Þ¤Þ¤ì¤ëÁ´¤Æ¤Î¥¹¥È¥ê¡¼¥à¤¬¼«Æ°Åª¤Ë²òÊü disposables.Dispose(); }
¡¡¥¯¥é¥¹¤¬ MonoBehaviour ¤ò·Ñ¾µ¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢OnDestroy ¥á¥½¥Ã¥É¤¬ÍøÍѤǤ¤Ê¤¤¤¿¤á¡¢
Âå¤ï¤ê¤Ë IDisposable ¤ò¼ÂÁõ¤·¡¢Dispose ¥á¥½¥Ã¥É¤Ç¥¹¥È¥ê¡¼¥à¤ò¼êÆ°¤Ç²òÊü¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
¡¡º£²óÀë¸À¤ÇÍøÍѤ·¤Æ¤¤¤ë CompositeDisposable ¤Ï IDisposable ¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤ò¼ÂÁõ¤·¤Æ¤¤¤Þ¤¹¡£
Dispose() ¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤Ç¡¢ÊÝ»ý¤·¤Æ¤¤¤ëÁ´¤Æ¤Î IDisposable ¥ª¥Ö¥¸¥§¥¯¥È (¥¹¥È¥ê¡¼¥à) ¤òÇË´þ¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢CompositeDisposable ¤òÍøÍѤ¹¤ë¤³¤È¤Ç¡¢Ê£¿ô¤Î¥¹¥È¥ê¡¼¥à¤ò¤Þ¤È¤á¤Æ´ÉÍý¤¹¤ë¤³¤È¤¬¤Ç¤¡¢´Êñ¤Ë°ì³ç¤Ç Dispose() ¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡½èÍý¤Îή¤ì¤È¤·¤Æ¤Ï¡¢Observable ¤Ë AddTo(disposables) ¤òÄɲ乤뤳¤È¤Ç¡¢¥¹¥È¥ê¡¼¥à¤¬À¸À®¤µ¤ì¤¿»þ¤Ë¼«Æ°Åª¤Ë CompositeDisposable ¤ËÄɲ䵤ì¤Þ¤¹¡£
¤½¤·¤Æ¡¢Dispose ¥á¥½¥Ã¥É¤¬¸Æ¤Ð¤ì¤¿¤È¤¤Ë¡¢CompositeDisposable ¤Ë´Þ¤Þ¤ì¤ëÁ´¤Æ¤Î¥¹¥È¥ê¡¼¥à¤¬¼«Æ°Åª¤Ë²òÊü¤µ¤ì¤Þ¤¹¡£
¡¡¤½¤Î¤¿¤á¡¢ATBModel¥¯¥é¥¹¤Î¾ì¹ç¤Ï¡¢Dispose ¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤Ç¡¢AddTo(disposables) ¤ÇÅÐÏ¿¤µ¤ì¤¿¥¹¥È¥ê¡¼¥à¤ò¼êÆ°¤Ç²òÊü¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
¡¡¤³¤Î¤è¤¦¤Ê½¤Àµ¤ò¹Ô¤¦¤È¡¢Presenter ¦¤Î Awake ¥á¥½¥Ã¥ÉÆâ¤Î½èÍý¤âÊѹ¹¤¬É¬ÍפǤ¹¡£
SetTriggerATB ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤·¤Æ¤¤¤¿Éôʬ¤Ç¡¢Âå¤ï¤ê¤Ë Model ¤ò¥¤¥ó¥¹¥¿¥ó¥¹¤·¤Æ¥³¥ó¥¹¥È¥é¥¯¥¿¥á¥½¥Ã¥É¤Ë°ú¿ô¤òÅϤ¹¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¡£
¡¡¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤¬½ªÎ»¤·¤Þ¤·¤¿¤Î¤Ç¡¢Æ°ºî¤ò³Îǧ¤·¤Þ¤¹¡£
¡¡ºÇ½é¤Ë ATBController ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥¢¥¿¥Ã¥Á¤µ¤ì¤Æ¤¤¤ë ATBModel_Mono ¥¯¥é¥¹¤ò Remove ¤·¤Þ¤¹¡£
¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü
¡¡ATBModel ¥¯¥é¥¹¤Ï MonoBehaviour ¤Î·Ñ¾µ¤Î¤Ê¤¤¥¯¥é¥¹¤Ç¤¢¤ë¤¿¤á¡¢¥²¡¼¥à¼Â¹Ô»þ¤Ë Presenter ¤Ë¤è¤Ã¤Æ¥¤¥ó¥¹¥¿¥ó¥¹¤¬À¸À®¤µ¤ì¤ÆÍøÍѤǤ¤ë¾õÂ֤ˤʤê¤Þ¤¹¡£
¡¡¤½¤Î¸å¥²¡¼¥à¤ò¼Â¹Ô¤·¤Æ¤¯¤À¤µ¤¤¡£
º£¤Þ¤Ç¤ÈƱ¤¸¤è¤¦¤Ë¥²¡¼¥¸¤¬Î¯¤Þ¤ê¡¢¥Ü¥¿¥ó¤¬²¡¤»¡¢ºÆÅÙ¡¢¥²¡¼¥¸¤¬Î¯¤Þ¤ë¤È¤¤¤¦¥µ¥¤¥¯¥ë¤¬Æ°¤¤¤Æ¤¤¤ë¤«¤ò³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£
¡¡View ¥¯¥é¥¹¤Ë¤Ï OnAttackButtonClick ¥×¥í¥Ñ¥Æ¥£¤òÍÑ°Õ¤·¤Æ¤¤¤Þ¤¹¡£
¤³¤Î¥×¥í¥Ñ¥Æ¥£¤ò Subscribe ¤¹¤ë¤³¤È¤Ç¡¢³°Éô¥¯¥é¥¹¤Ç¤â¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¥¤¥Ù¥ó¥È¤ò¸¡ÃΤ¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
¡¡¤³¤Î¤è¤¦¤ÊÀ߷פˤ¹¤ë¤³¤È¤Ç¡¢¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¤Ë¤è¤Ã¤Æ¼Â¹Ô¤µ¤ì¤ëÆâÉôŪ¤Ê½èÍý¤òÈëÆ¿¤·¤¿¤Þ¤Þ¡¢
³°Éô¥¯¥é¥¹¤Ë¤ª¤¤¤Æ¤Ï¡¢¥¤¥Ù¥ó¥È¤ò¸¡ÃΤ·¤¿¤³¤È¤òÍøÍѤ·¤¿½èÍý¤ò½ñ¤¯¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
¡¡¤³¤ÎÎã¤Ç¤Ï¡¢Start ¥á¥½¥Ã¥ÉÆâ¤Ç Button ¤Ë OnClickAsObservable ¤òºîÀ®¤·¡¢Subscribe ¤·¤Æ¥¯¥ê¥Ã¥¯¥¤¥Ù¥ó¥È¤òºîÀ®¤·¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢¤³¤Î¥¯¥é¥¹°Ê³°¤Î³°Éô¥¯¥é¥¹¤Ç¤Ï¡¢¥¯¥ê¥Ã¥¯¥¤¥Ù¥ó¥È¤ò´¶ÃΤ¹¤ë¼êÃʤ¬¤¢¤ê¤Þ¤»¤ó¡£
¡¡¤½¤¦¤Ê¤Ã¤¿¤È¤¤ËÍøÍѤ¹¤ëÊýË¡¤¬¡¢Button ¼«ÂΤò public ¤Ë¤¹¤ë¤«¡¢¥×¥í¥Ñ¥Æ¥£¤ä GetAttackButton ¤Î¤è¤¦¤Ê¥²¥Ã¥¿¡¼¥á¥½¥Ã¥É¤òºîÀ®¤·¤Æ¤ª¤¤¤Æ¡¢
³°Éô¥¯¥é¥¹¤Ë¤ª¤¤¤Æ¡¢Ä¾ÀÜ Button ¤Ë¥¢¥¯¥»¥¹¤ò¹Ô¤¤¡¢¥¯¥ê¥Ã¥¯¥¤¥Ù¥ó¥È¤ò³°Éô¥¯¥é¥¹¤ÇºîÀ®¤¹¤ë¥Ñ¥¿¡¼¥ó¤Ç¤¹¡£
¡¡²¼µ¤Î¤è¤¦¤Ê¤â¤Î¤Ë¤Ê¤ê¤Þ¤¹¡£
ATBPresenter.cs
¡¡¤É¤Á¤é¤Î¥Ñ¥¿¡¼¥ó¤òÍøÍѤ·¤¿¾ì¹ç¤Ç¤â¡¢Button ¤Ï»²¾È¤µ¤ì¤ë¤À¤±¤Ç¤Ï¤Ê¤¯¡¢¹ØÆɤνèÍý¤â¹Ô¤¦¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
¤³¤Î¼ÂÁõÊýË¡¤Ç¤¹¤È¥¯¥é¥¹¤ÎÁ·ë¹ç²½¤¬¤Ç¤¤Æ¤ª¤é¤º¡¢¹ØÆɽèÍý¤Î½¤Àµ¤ò¹Ô¤¦¤È¡¢View ¥¯¥é¥¹¤Ë¤â±Æ¶Á¤¬½Ð¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¤¤Þ¤¹¡£
¡¡¤³¤¦¤¤¤Ã¤¿¥±¡¼¥¹¤Ï¤Ê¤ë¤Ù¤¯Èò¤±¤¿Êý¤¬¤è¤¤¤Ç¤¹¡£
¡¡¤³¤ÎÊýË¡¤ò²óÈò¤¹¤ë¼êÃʤȤ·¤Æ¡¢View ¥¯¥é¥¹Æâ¤Ë¤¢¤ë OnAttackButtonClick ¥×¥í¥Ñ¥Æ¥£¤òÍøÍѤ·¤Þ¤¹¡£
¤³¤ì¤¬º£²óÀâÌÀ¤·¤Æ¤¤¤ë¡¢¥¯¥é¥¹ÆâÉô¤Î½èÍý¤ÏÈëÆ¿¤·¤¿¤Þ¤Þ¡¢³°Éô¥¯¥é¥¹¤Ë¥¯¥ê¥Ã¥¯¥¤¥Ù¥ó¥È¤òÄÌÃΤµ¤»¤ë¤¿¤á¤Îµ¡Ç½¤Ç¤¹¡£
¡¡²¼µ¤Î¤è¤¦¤Ê¼ÂÁõ¤ò¹Ô¤¦¤³¤È¤Ç¡¢ATBView Æâ¤Î Button ¼«ÂΤÏÈëÆ¿(private ¤Î¤Þ¤Þ¤Ë)¤·¡¢OnClickAsObservable ¤Î Subscribe ½èÍý¤Ï¤³¤Î¥¯¥é¥¹¤Ç¹Ô¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
¤Þ¤¿¡¢OnClickAsObservable ¤ò Subscribe ¤¹¤ë½èÍý¤¬¤Ê¤¯¤Æ¤â¡¢¥¯¥ê¥Ã¥¯¥¤¥Ù¥ó¥È¤ò³°Éô¥¯¥é¥¹¤ËÄ󶡤Ǥ¤ë¾å¡¢Subscribe ¤·¤¿ºÝ¤ÎÆâÍƤϳ°Éô¥¯¥é¥¹¤Ë¤Ï±Æ¶Á¤·¤Þ¤»¤ó¡£
¡¡¥¯¥ê¥Ã¥¯¤·¤¿¡¢¤È¤¤¤¦¥¤¥Ù¥ó¥È¤Î¤ß¤ò³°Éô¤«¤é»²¾È¤·¤Æ Subscribe ¤Ç¤¤ë¡¢¤È¤¤¤¦Ìõ¤Ç¤¹¡£
ATBView.cs
¡¡OnAttackButtonClick ¤Ï attackButton¤Î¥¯¥ê¥Ã¥¯¥¤¥Ù¥ó¥È¤ò´¶ÃΤ·¡¢³°Éô¥¯¥é¥¹¤ÇSubscribe¤µ¤ì¤¿»þ¤Ë¤½¤ÎÆâÍƤò¼Â¹Ô¤·¤Þ¤¹¡£
¡¡Start¥á¥½¥Ã¥É¤Ç¹Ô¤Ã¤Æ¤¤¤ëSubscribe¤ÎÆâÍƤϡ¢OnAttackButtonClick¤ËÂФ¹¤ëÆâÉôŪ¤Ê¼ÂÁõ¤Ç¤¢¤ê¡¢³°Éô¥¯¥é¥¹¤Ë±Æ¶Á¤òµÚ¤Ü¤¹¤³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¡£
Subscribe¤µ¤ì¤ë¤Þ¤ÇÆâÉô¤ÇÊÝ»ý¤µ¤ì¡¢³°Éô¤«¤é¤ÏÈëÆ¿¤µ¤ì¤Þ¤¹¡£
¡¡³°Éô¥¯¥é¥¹¤Ç¤¢¤ë View ¥¯¥é¥¹¤Î Button ¤Î¥¯¥ê¥Ã¥¯¥¤¥Ù¥ó¥È¤òľÀÜÌ¿Î᤻¤º¤Ë¡¢
OnAttackButtonClick ¥×¥í¥Ñ¥Æ¥£¤ò»È¤¦¤³¤È¤Ç¡¢¥¯¥ê¥Ã¥¯¥¤¥Ù¥ó¥È¤Î¤ß¤Î¹ØÆɤò¹Ô¤¦¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
¡¡¸À¤¤´¹¤¨¤ë¤È¡¢Presenter ¦¤Ï¡¢Button ¤Ç¤¢¤ë¤«¤É¤¦¤«¤Ï´ØÍ¿¤»¤º(ÃΤé¤Ê¤¤¾õÂÖ)¡¢²¿¤é¤«¤Î¥¤¥Ù¥ó¥È¤ËÂФ·¤Æ¹ØÆɤò¹Ô¤¦¤È¤¤¤¦¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
Presenter ¤Ï OnAttackButtonClick ¥×¥í¥Ñ¥Æ¥£¤Î»²¾ÈÀè¤Þ¤Ç¤Ï¸«¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢Button ¤Ç¤¢¤ë¤«¤É¤¦¤«¤ÏÉÔÌä¤Î¾õÂ֤Ǥ¹¡£
¤³¤Î¤è¤¦¤Ë½èÍý¤òÃÖ¤´¹¤¨¤ë¤³¤È¤Ç¡¢¤è¤ê½èÍý¤òÃê¾Ý²½¤·¤Æ¼ÂÁõ¤¹¤ë¤³¤È¤¬½ÐÍè¤Æ¤¤¤Þ¤¹¡£
ATBPresenter.cs
¡¡view.OnAttackButtonClick ¤Ë¤è¤ê¡¢ATBView ¥¯¥é¥¹Æâ¤Ç¼ÂÁõ¤µ¤ì¤¿¹¶·â¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¥¤¥Ù¥ó¥È¤ò³°Éô¥¯¥é¥¹¤«¤éľÀÜ Subscribe ¤¹¤ëɬÍפ¬¤Ê¤¯¤Ê¤ê¡¢
ATBView ¥¯¥é¥¹¤Î¥×¥é¥¤¥Ù¡¼¥È¤Ê¼ÂÁõ¤Î¾ÜºÙ¤ò±£Ê乤뤳¤È¤¬¤Ç¤¤Þ¤¹¡£¤Þ¤¿¡¢View ¥¯¥é¥¹¤Ë¤ª¤¤¤Æ OnClickAsObservable ¤ÎÍøÍÑÍ̵¤Ë¤«¤«¤ï¤é¤º¡¢¥¯¥ê¥Ã¥¯¥¤¥Ù¥ó¥È¤ò´¶ÃΤǤ¤Þ¤¹¡£
¡¡¤³¤ì¤Ë¤è¤ê ATBView ¥¯¥é¥¹¤Î¼ÂÁõ¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤¡¢¤½¤ì¤Ë¤è¤Ã¤Æ³°Éô¥¯¥é¥¹¤Î½èÍý¤Ë±Æ¶Á¤òÍ¿¤¨¤ë¤³¤È¤¬¤Ê¤¯¡¢¥³¡¼¥É¤ÎÊݼéÀ¤¬¸þ¾å¤·¤Þ¤¹¡£
¤Þ¤¿¡¢¤³¤ÎÊýË¡¤Ë¤è¤ê¡¢³°Éô¥¯¥é¥¹¤¬ ATBView ¥¯¥é¥¹¤Ë°Í¸¤¹¤ë¤³¤È¤¬¾¯¤Ê¤¯¤Ê¤ê¡¢Á·ë¹ç²½¤¬Â¥¿Ê¤µ¤ì¤Þ¤¹¡£
¡¡Å¬Àڤʥץí¥Ñ¥Æ¥£¤òºîÀ®¤·¤ÆÍøÍѤ¹¤ë¤³¤È¤Ë¤è¤ê¡¢¥«¥×¥»¥ë²½¤ÈÁ·ë¹ç²½¤ËÌòΩ¤Á¤Þ¤¹¡£
¡¡°Ê¾å¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡MVP ¥Ñ¥¿¡¼¥ó¤Î¼ÂÁõ¤Ë¤Ä¤¤¤Æ¤Ï¡¢Presenter ¤Ç¹Ô¤¦¹ØÆɽèÍý¤ò¤É¤Î¤è¤¦¤Ë¤·¤Æ¹Ô¤¦¤«¤ò¹Í¤¨¤ÆÀ߷פ¹¤ë¤È¡¢¤è¤ê¤è¤¤¥³¡¼¥Ç¥£¥ó¥°¤¬¹Ô¤¨¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
- ¥«¥Æ¥´¥ê¡§
- ¿Ê³Ø/¥¹¥¯¡¼¥ë
- ¥×¥í¥°¥é¥ß¥ó¥°
¥³¥á¥ó¥È¤ò¤«¤¯