프로필 카드 애니메이션 및 선택
This commit is contained in:
parent
a5d0c77aae
commit
1a186fa277
|
|
@ -2811,6 +2811,12 @@ MonoBehaviour:
|
|||
- {fileID: 1908634719}
|
||||
- {fileID: 1483615885}
|
||||
- {fileID: 1374291675}
|
||||
posLeft: {x: -232, y: 0, z: 0}
|
||||
posCenter: {x: 0, y: 0, z: 0}
|
||||
posRight: {x: 232, y: 0, z: 0}
|
||||
scaleCenter: 1
|
||||
scaleSide: 0.7
|
||||
animDuration: 0.3
|
||||
--- !u!1 &90196064
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ public class SaveMgr : MonoBehaviourSingletonTemplate<SaveMgr>
|
|||
public void Open_Image() { ++m_SaveData.GirlUnLockIndex; }
|
||||
public int Get_UnLockIndex() { return m_SaveData.GirlUnLockIndex; }
|
||||
public int Get_SelectGirlID() { return m_SaveData.SelectGirlID; }
|
||||
public void Set_SelectGirlID(int id) { m_SaveData.SelectGirlID = id; Save(); }
|
||||
public int Get_ImageCount(int girlid)
|
||||
{
|
||||
var lst = table_album.Ins.Get_DataList(girlid);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,30 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class LobbyCenterProfileUI : MonoBehaviour
|
||||
{
|
||||
// 카드는 3개만 있으면 됨
|
||||
// 움직이는 연출 후 UI 갱신하면 될 듯
|
||||
public ProfileCard[] arr_profileCard;
|
||||
|
||||
int curGirl = 0;
|
||||
bool isAnimating = false;
|
||||
|
||||
// 위치 프리셋 (UI 좌표)
|
||||
Vector2 posLeft = new Vector2(-772, 178.3f);
|
||||
Vector2 posCenter = new Vector2(0, 178.3f);
|
||||
Vector2 posRight = new Vector2(772, 178.3f);
|
||||
float scaleCenter = 1f;
|
||||
float scaleSide = 0.7f;
|
||||
|
||||
public float animDuration = 0.3f;
|
||||
|
||||
public void Set()
|
||||
{
|
||||
if (curGirl == 0) curGirl = SaveMgr.Ins.Get_SelectGirlID();
|
||||
else
|
||||
{
|
||||
if (arr_profileCard[1].IsObtain())
|
||||
SaveMgr.Ins.Set_SelectGirlID(curGirl);
|
||||
}
|
||||
|
||||
var pre_girl = curGirl - 1;
|
||||
if (pre_girl <= 0) pre_girl = 8;
|
||||
|
|
@ -23,12 +37,141 @@ public class LobbyCenterProfileUI : MonoBehaviour
|
|||
arr_profileCard[2].Set(next_girl);
|
||||
}
|
||||
|
||||
public void OnClick_Arrow(int add)
|
||||
public void OnClick_Arrow(int dir)
|
||||
{
|
||||
curGirl += add;
|
||||
if (curGirl <= 0) curGirl = 8;
|
||||
if (isAnimating) return;
|
||||
StartCoroutine(Co_MoveCard(dir));
|
||||
}
|
||||
|
||||
IEnumerator Co_MoveCard(int dir)
|
||||
{
|
||||
isAnimating = true;
|
||||
|
||||
float elapsed = 0f;
|
||||
|
||||
RectTransform left = arr_profileCard[0].rect;
|
||||
RectTransform center = arr_profileCard[1].rect;
|
||||
RectTransform right = arr_profileCard[2].rect;
|
||||
|
||||
ProfileCard newCard = null;
|
||||
RectTransform movingRect = null;
|
||||
|
||||
if (dir == 1) // 오른쪽으로 이동
|
||||
{
|
||||
newCard = arr_profileCard[0];
|
||||
movingRect = newCard.rect;
|
||||
movingRect.anchoredPosition = posRight + new Vector2(500, 0);
|
||||
movingRect.localScale = Vector3.one * scaleSide;
|
||||
|
||||
Vector2 startPosNew = movingRect.anchoredPosition;
|
||||
Vector2 startPosC = center.anchoredPosition;
|
||||
Vector2 startPosR = right.anchoredPosition;
|
||||
|
||||
Vector2 targetPosNew = posRight;
|
||||
Vector2 targetPosC = posLeft;
|
||||
Vector2 targetPosR = posCenter;
|
||||
|
||||
Vector3 startScaleNew = movingRect.localScale;
|
||||
Vector3 startScaleC = center.localScale;
|
||||
Vector3 startScaleR = right.localScale;
|
||||
|
||||
Vector3 targetScaleNew = Vector3.one * scaleSide;
|
||||
Vector3 targetScaleC = Vector3.one * scaleSide;
|
||||
Vector3 targetScaleR = Vector3.one * scaleCenter;
|
||||
|
||||
while (elapsed < animDuration)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
float t = Mathf.Clamp01(elapsed / animDuration);
|
||||
|
||||
movingRect.anchoredPosition = Vector2.Lerp(startPosNew, targetPosNew, t);
|
||||
center.anchoredPosition = Vector2.Lerp(startPosC, targetPosC, t);
|
||||
right.anchoredPosition = Vector2.Lerp(startPosR, targetPosR, t);
|
||||
|
||||
movingRect.localScale = Vector3.Lerp(startScaleNew, targetScaleNew, t);
|
||||
center.localScale = Vector3.Lerp(startScaleC, targetScaleC, t);
|
||||
right.localScale = Vector3.Lerp(startScaleR, targetScaleR, t);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// 보정
|
||||
movingRect.anchoredPosition = targetPosNew;
|
||||
center.anchoredPosition = targetPosC;
|
||||
right.anchoredPosition = targetPosR;
|
||||
|
||||
movingRect.localScale = targetScaleNew;
|
||||
center.localScale = targetScaleC;
|
||||
right.localScale = targetScaleR;
|
||||
|
||||
// 배열 회전 (0→1, 1→2, 2→0)
|
||||
var temp = arr_profileCard[0];
|
||||
arr_profileCard[0] = arr_profileCard[1];
|
||||
arr_profileCard[1] = arr_profileCard[2];
|
||||
arr_profileCard[2] = temp;
|
||||
|
||||
curGirl = curGirl + 1;
|
||||
if (curGirl > 8) curGirl = 1;
|
||||
}
|
||||
else if (dir == -1) // 왼쪽으로 이동
|
||||
{
|
||||
newCard = arr_profileCard[2];
|
||||
movingRect = newCard.rect;
|
||||
movingRect.anchoredPosition = posLeft + new Vector2(-500, 0);
|
||||
movingRect.localScale = Vector3.one * scaleSide;
|
||||
|
||||
Vector2 startPosNew = movingRect.anchoredPosition;
|
||||
Vector2 startPosL = left.anchoredPosition;
|
||||
Vector2 startPosC = center.anchoredPosition;
|
||||
|
||||
Vector2 targetPosNew = posLeft;
|
||||
Vector2 targetPosL = posCenter;
|
||||
Vector2 targetPosC = posRight;
|
||||
|
||||
Vector3 startScaleNew = movingRect.localScale;
|
||||
Vector3 startScaleL = left.localScale;
|
||||
Vector3 startScaleC = center.localScale;
|
||||
|
||||
Vector3 targetScaleNew = Vector3.one * scaleSide;
|
||||
Vector3 targetScaleL = Vector3.one * scaleCenter;
|
||||
Vector3 targetScaleC = Vector3.one * scaleSide;
|
||||
|
||||
while (elapsed < animDuration)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
float t = Mathf.Clamp01(elapsed / animDuration);
|
||||
|
||||
movingRect.anchoredPosition = Vector2.Lerp(startPosNew, targetPosNew, t);
|
||||
left.anchoredPosition = Vector2.Lerp(startPosL, targetPosL, t);
|
||||
center.anchoredPosition = Vector2.Lerp(startPosC, targetPosC, t);
|
||||
|
||||
movingRect.localScale = Vector3.Lerp(startScaleNew, targetScaleNew, t);
|
||||
left.localScale = Vector3.Lerp(startScaleL, targetScaleL, t);
|
||||
center.localScale = Vector3.Lerp(startScaleC, targetScaleC, t);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// 보정
|
||||
movingRect.anchoredPosition = targetPosNew;
|
||||
left.anchoredPosition = targetPosL;
|
||||
center.anchoredPosition = targetPosC;
|
||||
|
||||
movingRect.localScale = targetScaleNew;
|
||||
left.localScale = targetScaleL;
|
||||
center.localScale = targetScaleC;
|
||||
|
||||
// 배열 회전 (0→2, 1→0, 2→1)
|
||||
var temp = arr_profileCard[2];
|
||||
arr_profileCard[2] = arr_profileCard[1];
|
||||
arr_profileCard[1] = arr_profileCard[0];
|
||||
arr_profileCard[0] = temp;
|
||||
|
||||
curGirl = curGirl - 1;
|
||||
if (curGirl <= 0) curGirl = 8;
|
||||
}
|
||||
|
||||
Set();
|
||||
isAnimating = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,10 +8,16 @@ public class ProfileCard : MonoBehaviour
|
|||
public Image i_girl, i_openbtn;
|
||||
public TextMeshProUGUI[] texts; // 0 이름, 1 카운트
|
||||
public GameObject go_lock, go_openbtn, go_viewbtn;
|
||||
public RectTransform rect;
|
||||
|
||||
girltabledata m_Data;
|
||||
AsyncOperationHandle m_Handle;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
rect = GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
public void Set(int girlid)
|
||||
{
|
||||
m_Data = table_girl.Ins.Get_Data(girlid);
|
||||
|
|
@ -50,6 +56,16 @@ public class ProfileCard : MonoBehaviour
|
|||
}
|
||||
return false;
|
||||
}
|
||||
public bool IsObtain()
|
||||
{
|
||||
var pregirl = m_Data.n_GirlID - 1;
|
||||
if (pregirl > 0)
|
||||
{
|
||||
var lst = table_album.Ins.Get_DataList(pregirl);
|
||||
return lst.Count == SaveMgr.Ins.Get_ImageCount(pregirl) && SaveMgr.Ins.Get_ImageCount(m_Data.n_GirlID) > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnClick_Profile()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue