public UnityServices() { GameService = new UnityGameService(); InputService = new UnityInputService(); TimeService = new UnityTimeService(); BoardFactory = new WoodBoardFactory(); }
public override bool CheckDragging(out Vector3?vector3) { var touches = UnityInputService.GetTouches(); if ( touches != null && touches.Length == 1 && ( touches[0].phase == TouchPhase.Began || ( _currentlyDragging && ( touches[0].phase == TouchPhase.Stationary || touches[0].phase == TouchPhase.Moved ) ) ) ) { _currentlyDragging = true; _draggingFingerId = touches[0].fingerId; vector3 = touches[0].position; return(true); } _currentlyDragging = false; vector3 = null; return(false); }
public override bool CheckDragEnd(out Vector3?vector3) { if (UnityInputService.GetMouseButtonUp(0)) { vector3 = UnityInputService.GetMousePosition(); return(true); } vector3 = null; return(false); }
public override bool CheckSelection(out Vector3?vector3) { var touches = UnityInputService.GetTouches(); if (touches != null && touches.Length == 1 && touches[0].phase == TouchPhase.Began) { vector3 = touches[0].position; return(true); } vector3 = null; return(false); }
/// <summary> /// 初始化所有服务 /// </summary> private void InitService(Contexts contexts) { UnityInputService inputService = new UnityInputService(); ConfigService configService = new ConfigService(); UnityViewService unityViewService = new UnityViewService(contexts); EntityFactoryService entityFactoryService = new EntityFactoryService(contexts, configService); UnityAudioService unityAudioService = new UnityAudioService(); contexts.meta.ReplaceInputService(inputService); contexts.meta.ReplaceEntityFactoryService(entityFactoryService); contexts.meta.ReplaceUnityAudioService(unityAudioService); contexts.meta.ReplaceConfigService(configService); services = new Services(inputService, configService, unityViewService, entityFactoryService, unityAudioService); }
public override bool CheckDragEnd(out Vector3?vector3) { var touches = UnityInputService.GetTouches(); if ( touches != null && _draggingFingerId != -1 && ( touches.Length > 1 || touches[0].phase == TouchPhase.Ended || touches[0].phase == TouchPhase.Canceled ) ) { vector3 = touches.Single(x => x.fingerId == _draggingFingerId).position; _draggingFingerId = -1; return(true); } vector3 = null; return(false); }