void OnSpawnLauncherDrag(EntityCommonSpawnLaunch launcher, PointerEventData dat) { if (mCurSpawnLauncherReady != launcher) { return; } Vector2 pos = dat.pointerPressRaycast.worldPosition; Vector2 pointerPos = pointer.position; mLastDir = pos - pointerPos; mLastDist = mLastDir.magnitude; if (mLastDist > 0f) { mLastDir /= mLastDist; } bool valid = Vector2.Angle(Vector2.up, mLastDir) <= launchAngleLimit && mLastDist >= launchRadiusMin; SetPointerActive(valid); if (valid) { pointer.position = dat.pointerPressRaycast.worldPosition; } }
void OnSpawnLauncherDragEnd(EntityCommonSpawnLaunch launcher, PointerEventData dat) { if (mCurSpawnLauncherReady != launcher) { return; } //launch if (mIsPointerActive) { SetPointerActive(false); mCurSpawnLauncherReady.Launch(mLastDir, GetLaunchForce()); } mCurSpawnLauncherReady = null; }
void OnSpawnLauncherDragBegin(EntityCommonSpawnLaunch launcher, PointerEventData dat) { mCurSpawnLauncherReady = launcher; }