From 1a186fa277475915e7bab9484ecfad7a77aab601 Mon Sep 17 00:00:00 2001 From: Ino Date: Sun, 21 Sep 2025 07:24:09 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=B9=B4?= =?UTF-8?q?=EB=93=9C=20=EC=95=A0=EB=8B=88=EB=A9=94=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EB=B0=8F=20=EC=84=A0=ED=83=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scenes/SampleScene.unity | 6 + Assets/Scripts/AttachToGameObject/SaveMgr.cs | 1 + Assets/Scripts/UI/LobbyCenterProfileUI.cs | 157 ++++++++++++++++++- Assets/Scripts/UI/ProfileCard.cs | 16 ++ 4 files changed, 173 insertions(+), 7 deletions(-) diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 333bbd0..e4cae83 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -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 diff --git a/Assets/Scripts/AttachToGameObject/SaveMgr.cs b/Assets/Scripts/AttachToGameObject/SaveMgr.cs index dfe8536..79eb91f 100644 --- a/Assets/Scripts/AttachToGameObject/SaveMgr.cs +++ b/Assets/Scripts/AttachToGameObject/SaveMgr.cs @@ -214,6 +214,7 @@ public class SaveMgr : MonoBehaviourSingletonTemplate 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); diff --git a/Assets/Scripts/UI/LobbyCenterProfileUI.cs b/Assets/Scripts/UI/LobbyCenterProfileUI.cs index c82b8f6..9ca29c8 100644 --- a/Assets/Scripts/UI/LobbyCenterProfileUI.cs +++ b/Assets/Scripts/UI/LobbyCenterProfileUI.cs @@ -1,18 +1,32 @@ 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; + var pre_girl = curGirl - 1; if (pre_girl <= 0) pre_girl = 8; arr_profileCard[0].Set(pre_girl); @@ -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 (curGirl > 8) curGirl = 1; + 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; } } \ No newline at end of file diff --git a/Assets/Scripts/UI/ProfileCard.cs b/Assets/Scripts/UI/ProfileCard.cs index 578f98c..fa2668b 100644 --- a/Assets/Scripts/UI/ProfileCard.cs +++ b/Assets/Scripts/UI/ProfileCard.cs @@ -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(); + } + 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() {