翻页声音逻辑

This commit is contained in:
yangjing 2022-02-15 15:54:40 +08:00
parent aabaecc1d2
commit 5b5c2be9e4
2 changed files with 13 additions and 5 deletions

View File

@ -81,11 +81,11 @@ public class LevelPage : PageView
private void PlayScrollPage() private void PlayScrollPage()
{ {
AudioManager.Instance.PlaySound(AudioType.TurnPage); AudioManager.Instance.PlaySound(AudioType.TurnPage, 0.7f);
} }
private void PlayReachEdge() private void PlayReachEdge()
{ {
AudioManager.Instance.PlaySound(AudioType.ReachEdge); AudioManager.Instance.PlaySound(AudioType.ReachEdge, 0.7f);
} }
} }

View File

@ -65,6 +65,11 @@ public abstract class PageView : MonoBehaviour, IBeginDragHandler, IEndDragHandl
if (currentPageIndex != index) if (currentPageIndex != index)
{ {
currentPageIndex = index; currentPageIndex = index;
if (pWithScroll)
{
OnScrollPage?.Invoke();
}
} }
if (pWithScroll) if (pWithScroll)
@ -73,8 +78,6 @@ public abstract class PageView : MonoBehaviour, IBeginDragHandler, IEndDragHandl
isDrag = false; isDrag = false;
startTime = 0; startTime = 0;
stopMove = false; stopMove = false;
OnScrollPage?.Invoke();
} }
else else
{ {
@ -85,7 +88,6 @@ public abstract class PageView : MonoBehaviour, IBeginDragHandler, IEndDragHandl
} }
else else
{ {
OnReachEdge?.Invoke();
//Debug.LogError("页码不存在"); //Debug.LogError("页码不存在");
} }
} }
@ -110,6 +112,7 @@ public abstract class PageView : MonoBehaviour, IBeginDragHandler, IEndDragHandl
{ {
float posX = rect.horizontalNormalizedPosition; float posX = rect.horizontalNormalizedPosition;
posX += ((posX - startDragHorizontal) * sensitivity); posX += ((posX - startDragHorizontal) * sensitivity);
float tTempPosX = posX;
posX = posX < 1 ? posX : 1; posX = posX < 1 ? posX : 1;
posX = posX > 0 ? posX : 0; posX = posX > 0 ? posX : 0;
int index = 0; int index = 0;
@ -124,6 +127,11 @@ public abstract class PageView : MonoBehaviour, IBeginDragHandler, IEndDragHandl
} }
} }
PageTo(index); PageTo(index);
if (tTempPosX > 1 || tTempPosX < 0)
{
OnReachEdge?.Invoke();
}
} }
private void NotifyPageChange() private void NotifyPageChange()