public void update() { if (m_seqengine.CanSwipe) // 엔진이 idle일 때만 반응 { var forward = m_seqengine.m_snapshotTraveler.SwipeForwardDirection; bool needClearSkip = false; if (!m_keepSkipping && m_fastUntilNextIdle) // 계속 스킵하는 상태는 아니고 다음 idle까지만 스킵하는 경우인지 { needClearSkip = true; } else if (m_keepSkipping && (m_seqengine.m_snapshotTraveler.CurrentIsSwipeOption || forward == FSNInGameSetting.FlowDirection.None || !m_seqengine.SwipeDirectionAvailable(forward))) // 계속 스킵해야하는 상태인데 선택지를 만난 경우, 혹은 더이상 진행할 수 없는 경우 { needClearSkip = true; } if (needClearSkip) // 스킵 상태 해제 { m_keepSkipping = false; m_fastUntilNextIdle = false; Time.timeScale = c_timeRatio_normal; } if (m_keepSkipping || m_fastUntilNextIdle) // 스킵 해제 조건을 처리하고 나서도 어쨌든 현재 스킵해야하는 상황이면...진행 { m_seqengine.FullSwipe(forward, 0); } } }
/// <summary> /// swipe 변위 보내기 /// </summary> public void Swipe(FSNInGameSetting.FlowDirection direction, float distance) { if (m_enginePause) // 엔진 일시정지시에는 이벤트 처리를 받지 않는다. { return; } m_swippedAnyway = true; // 어쨌든 swipe를 하긴 했음. release 하더라도 메뉴 토글은 콜하지 않도록 if (!m_swipeCompleted && m_seqEngine.CanSwipe) // swipe 가능한 상태 { var engine = FSNEngine.Instance; m_swipeDirection = direction; // 민 방향을 보관해둔다 var dirvalid = m_seqEngine.SwipeDirectionAvailable(direction); if (dirvalid) // 밀 수 있는 방향일 때 { float weight = engine.InGameSetting.SwipeWeight; float maxdist = (direction == FSNInGameSetting.FlowDirection.Left || direction == FSNInGameSetting.FlowDirection.Right)? engine.ScreenXSize : engine.ScreenYSize; // 해당 방향으로 최대한 밀 수 있는 거리 float fullDist = weight * maxdist; float curSwipeRatio = Mathf.Pow(distance / fullDist, 0.5f); // 드래그할 때 약간 저항을 주기 위해 if (curSwipeRatio < 1.0f) // 아직 덜 밀었을 때 { //m_seqEngine.PartialSwipe(direction, curSwipeRatio * c_partialSwipeLimit);// Partial swipe m_seqEngine.PartialSwipe(direction, curSwipeRatio); // Partial swipe m_swipeRatio = curSwipeRatio; if (!m_swipeEventSent || m_swipeEventSentWasWrongDir) // 아직 이벤트를 보낸 적이 없거나 잘못된 방향으로 이벤트를 보냈을 경우 { ExecuteSwipeEvent((obj, param) => { obj.OnTryingSwipe(direction); // 옳은 방향으로 swipe 이벤트 }); m_swipeEventSent = true; m_swipeEventSentWasWrongDir = false; } } else if (!m_swipeCompleted) // 완전히 밀었을 때, 아직 이전에 완전히 밀지는 않았을 경우 { m_seqEngine.FullSwipe(direction, c_partialSwipeLimit); // Full swipe m_swipeRatio = 0; m_swipeCompleted = true; ExecuteSwipeEvent( (obj, param) => { obj.OnTryingSwipe(direction); // swipe완료 이벤트 }); } } else { // 밀 수 없는 방향일 때 if (!m_swipeEventSent || !m_swipeEventSentWasWrongDir) // 아직 이벤트를 보낸 적이 없거나 올바른 방향으로 이벤트를 보냈을 경우 { ExecuteSwipeEvent((obj, param) => { obj.OnTryingSwipeToWrongDirection(direction); // 잘못된 방향으로 swipe 이벤트 }); m_swipeEventSent = true; m_swipeEventSentWasWrongDir = true; } } } }