| | 1 | | using System; |
| | 2 | | using UnityEngine.EventSystems; |
| | 3 | |
|
| | 4 | | public interface IFirstPersonModeController |
| | 5 | | { |
| | 6 | | event Action OnClick; |
| | 7 | |
|
| | 8 | | void Initialize(IFirstPersonModeView firstPersonModeView, ITooltipController tooltipController); |
| | 9 | | void Dispose(); |
| | 10 | | void Click(); |
| | 11 | | void ShowTooltip(BaseEventData eventData, string tooltipText); |
| | 12 | | void HideTooltip(); |
| | 13 | | } |
| | 14 | |
|
| | 15 | | public class FirstPersonModeController : IFirstPersonModeController |
| | 16 | | { |
| | 17 | | public event Action OnClick; |
| | 18 | |
|
| | 19 | | internal IFirstPersonModeView firstPersonModeView; |
| | 20 | | internal ITooltipController tooltipController; |
| | 21 | |
|
| | 22 | | public void Initialize(IFirstPersonModeView firstPersonModeView, ITooltipController tooltipController) |
| | 23 | | { |
| 3 | 24 | | this.firstPersonModeView = firstPersonModeView; |
| 3 | 25 | | this.tooltipController = tooltipController; |
| | 26 | |
|
| 3 | 27 | | firstPersonModeView.OnFirstPersonModeClick += Click; |
| 3 | 28 | | firstPersonModeView.OnShowTooltip += ShowTooltip; |
| 3 | 29 | | firstPersonModeView.OnHideTooltip += HideTooltip; |
| 3 | 30 | | } |
| | 31 | |
|
| | 32 | | public void Dispose() |
| | 33 | | { |
| 3 | 34 | | firstPersonModeView.OnFirstPersonModeClick -= Click; |
| 3 | 35 | | firstPersonModeView.OnShowTooltip -= ShowTooltip; |
| 3 | 36 | | firstPersonModeView.OnHideTooltip -= HideTooltip; |
| 3 | 37 | | } |
| | 38 | |
|
| 2 | 39 | | public void Click() { OnClick?.Invoke(); } |
| | 40 | |
|
| | 41 | | public void ShowTooltip(BaseEventData eventData, string tooltipText) |
| | 42 | | { |
| 1 | 43 | | tooltipController.ShowTooltip(eventData); |
| 1 | 44 | | tooltipController.SetTooltipText(tooltipText); |
| 1 | 45 | | } |
| | 46 | |
|
| 2 | 47 | | public void HideTooltip() { tooltipController.HideTooltip(); } |
| | 48 | | } |