From 64f30c4c95063cbfc55368b045d8c46f85b44b7a Mon Sep 17 00:00:00 2001 From: Ino Date: Sun, 28 Sep 2025 17:27:12 +0900 Subject: [PATCH] =?UTF-8?q?"<=20=EB=BD=91=EA=B8=B0=20=EB=AF=B8=EB=8B=88?= =?UTF-8?q?=EA=B2=8C=EC=9E=84=20=EA=B0=9C=EC=84=A0=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=20>=201.=20=EC=BB=B5=ED=9E=88=EC=96=B4=EB=A1=9C=EC=99=80=20?= =?UTF-8?q?=EA=B0=99=EC=9D=B4=20X2,=20+=EB=B0=9C=ED=8C=90=EC=97=90=20?= =?UTF-8?q?=EB=8B=BF=EC=9C=BC=EB=A9=B4=20=EC=8B=A4=EC=A0=9C=20=EC=88=98?= =?UTF-8?q?=EB=9F=89=EC=9D=B4=20=EB=8A=98=EC=96=B4=EB=82=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=B2=98=EB=A6=AC=20=EA=B0=80=EB=8A=A5=ED=95=98?= =?UTF-8?q?=EB=8B=A4=EB=A9=B4=20=EC=88=98=EC=A0=95=20=EB=B0=94=EB=9E=8D?= =?UTF-8?q?=EB=8B=88=EB=8B=A4.=202.=20=EC=9A=B0=EC=B8=A1=20=EC=98=88?= =?UTF-8?q?=EC=8B=9C=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EC=99=80=20=EA=B0=99?= =?UTF-8?q?=EC=9D=B4=20=ED=8A=B9=EC=A0=95=20=EC=98=81=EC=97=AD=20=EB=82=B4?= =?UTF-8?q?=EC=97=90=20=EB=96=A8=EC=96=B4=EC=A7=84=20=EC=9E=AC=ED=99=94?= =?UTF-8?q?=EB=A7=8C=20=EC=8A=B5=EB=93=9D=20=EA=B0=80=EB=8A=A5=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=88=98=EC=A0=95=20=EA=B0=80=EB=8A=A5=ED=95=A0?= =?UTF-8?q?=EC=A7=80=20=EB=AC=B8=EC=9D=98=EB=93=9C=EB=A6=BD=EB=8B=88?= =?UTF-8?q?=EB=8B=A4.=20->=20=EA=B3=B5=EC=88=98=EA=B0=80=20=ED=81=AC?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8B=A4=EB=A9=B4=20=EA=B0=80=EA=B8=89?= =?UTF-8?q?=EC=A0=81=20=EC=9A=B0=EC=B8=A1=20=ED=99=94=EB=A9=B4=EA=B0=99?= =?UTF-8?q?=EC=9D=B4=20=ED=8A=B9=EC=A0=95=20=EC=98=81=EC=97=AD=EC=97=90=20?= =?UTF-8?q?=EB=93=9C=EB=9E=8D=20=EB=90=9C=20=EC=9E=AC=ED=99=94=EB=A7=8C=20?= =?UTF-8?q?=EC=8A=B5=EB=93=9D=EC=B2=98=EB=A6=AC=ED=95=98=EA=B3=A0=20?= =?UTF-8?q?=EB=82=98=EB=A8=B8=EC=A7=84=20=EC=8A=B5=EB=93=9D=20=EB=AA=BB?= =?UTF-8?q?=ED=95=98=EA=B2=8C=20=EC=B2=98=EB=A6=AC=ED=95=98=EB=A0=A4?= =?UTF-8?q?=EA=B3=A0=20=ED=95=A9=EB=8B=88=EB=8B=A4.=203.=20=EB=BD=91?= =?UTF-8?q?=EA=B8=B0=20=EB=AF=B8=EB=8B=88=EA=B2=8C=EC=9E=84=EC=97=90?= =?UTF-8?q?=EB=8A=94=20=EC=BA=90=EB=A6=AD=ED=84=B0=EB=A5=BC=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=ED=95=B4=EB=8F=84=20=EB=90=A0=20=EA=B2=83=20=EA=B0=99?= =?UTF-8?q?=EC=8A=B5=EB=8B=88=EB=8B=A4."?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/ResWork/GameData/LuckyGameObj.prefab | 1 + Assets/Scenes/SampleScene.unity | 44 ++++++++++++++++++-- Assets/Scripts/Game/Game_Lucky.cs | 43 ++++++++++++++++++- Assets/Scripts/Game/LuckyGameCupCounter.cs | 16 +++++++ Assets/Scripts/Game/LuckyGameObj.cs | 46 +++++++++++++++------ 5 files changed, 134 insertions(+), 16 deletions(-) diff --git a/Assets/ResWork/GameData/LuckyGameObj.prefab b/Assets/ResWork/GameData/LuckyGameObj.prefab index 491db7d..fd8ec36 100644 --- a/Assets/ResWork/GameData/LuckyGameObj.prefab +++ b/Assets/ResWork/GameData/LuckyGameObj.prefab @@ -56,6 +56,7 @@ MonoBehaviour: m_image: {fileID: 613301010048255497} go_effect: {fileID: 1752936709684462252} m_Rigidbody2D: {fileID: 1260999574391235090} + m_Collider2D: {fileID: 1301368102676062178} velocityThreshold: 0.1 requiredStopDuration: 0.2 --- !u!222 &2007710277984516474 diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index b076557..5ef21df 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -45782,6 +45782,7 @@ RectTransform: - {fileID: 1757808306} - {fileID: 1190514304} - {fileID: 163624062} + - {fileID: 1693537320} - {fileID: 2127274534} - {fileID: 1950932324} - {fileID: 1534428862} @@ -45828,6 +45829,7 @@ MonoBehaviour: tf_cupin: {fileID: 1836599685} tf_fallobjs: {fileID: 1190514304} tf_refillobjs: {fileID: 163624062} + tf_addobjs: {fileID: 1693537320} list_randomblock: - {fileID: 1007280070} - {fileID: 233736480} @@ -47745,7 +47747,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: -67.1} + m_AnchoredPosition: {x: 0, y: -65} m_SizeDelta: {x: 25, y: 145} m_Pivot: {x: 0.5, y: 0.5} --- !u!61 &1299004173 @@ -62835,6 +62837,41 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1687355703} m_CullTransparentMesh: 1 +--- !u!1 &1693537319 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1693537320} + m_Layer: 5 + m_Name: AddObjs + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1693537320 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1693537319} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1257193656} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &1695390283 GameObject: m_ObjectHideFlags: 0 @@ -72804,7 +72841,7 @@ BoxCollider2D: m_UsedByEffector: 0 m_CompositeOperation: 0 m_CompositeOrder: 0 - m_Offset: {x: 53.40808, y: 0} + m_Offset: {x: 65.19798, y: 0} m_SpriteTilingProperty: border: {x: 0, y: 0, z: 0, w: 0} pivot: {x: 0, y: 0} @@ -72814,7 +72851,7 @@ BoxCollider2D: drawMode: 0 adaptiveTiling: 0 m_AutoTiling: 0 - m_Size: {x: 131.81615, y: 205.8} + m_Size: {x: 155.39597, y: 205.8} m_EdgeRadius: 0 --- !u!222 &1957117011 CanvasRenderer: @@ -72837,6 +72874,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: objectCount: 0 + refillobjectCount: 0 --- !u!1 &1957241714 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Game/Game_Lucky.cs b/Assets/Scripts/Game/Game_Lucky.cs index ce6fae7..9b482b3 100644 --- a/Assets/Scripts/Game/Game_Lucky.cs +++ b/Assets/Scripts/Game/Game_Lucky.cs @@ -18,6 +18,7 @@ public class Game_Lucky : MonoBehaviour public Transform tf_cupin; // 컵 안 (공들이 들어가는 위치 부모) public Transform tf_fallobjs; // 컵 안에서 밖으로 떨어지는 공들의 부모 public Transform tf_refillobjs; // 리필 공들 + public Transform tf_addobjs; // 추가 공들 (+, x 에 의해 추가되는 공들) List list_dropobj = new List(); public List list_randomblock; @@ -60,6 +61,14 @@ public class Game_Lucky : MonoBehaviour obj.gameObject.SetActive(false); } texts[4].text = $"x{table_GlobalValue.Ins.Get_Int("LuckyGame_RefillAmount")}"; + + // 기본 공 + 리필 공 에 최고 배수만큼 미리 생성 + var addobjAmount = (TotalBubbleAmount + refill) * 5; + for (int i = 0; i < addobjAmount; i++) + { + var obj = DSUtil.Get_Clone(go_dropobj, tf_addobjs); + obj.gameObject.SetActive(false); + } } public void Set() @@ -106,6 +115,8 @@ public class Game_Lucky : MonoBehaviour if (list_dropobj.Count > TotalBubbleAmount) { var moveCount = list_dropobj.Count - TotalBubbleAmount; + var maxRefiil = table_GlobalValue.Ins.Get_Int("LuckyGame_RefillAmount") << 1; + if (moveCount > maxRefiil) moveCount = maxRefiil; for (int i = 0; i < moveCount; i++) { list_dropobj[0].transform.SetParent(tf_refillobjs); @@ -114,6 +125,17 @@ public class Game_Lucky : MonoBehaviour } } + if (list_dropobj.Count > TotalBubbleAmount) + { + var moveCount = list_dropobj.Count - TotalBubbleAmount; + for (int i = 0; i < moveCount; i++) + { + list_dropobj[0].transform.SetParent(tf_addobjs); + list_dropobj[0].gameObject.SetActive(false); + list_dropobj.RemoveAt(0); + } + } + StartCoroutine(Co_Block()); Set_Ball(); @@ -281,7 +303,7 @@ public class Game_Lucky : MonoBehaviour public void OnClick_Refill() { - if (m_RefillCount > 0) + if (!isRefill && m_RefillCount > 0) { --m_RefillCount; m_RefillCount.Obfuscate(); @@ -294,6 +316,7 @@ public class Game_Lucky : MonoBehaviour { isRefill = true; tf_cup.rotation = Quaternion.Euler(0, 0, 0); + m_LuckyGameCupCounter.StartRefill(); for (int i = 0; i < table_GlobalValue.Ins.Get_Int("LuckyGame_RefillAmount"); i++) { @@ -310,6 +333,24 @@ public class Game_Lucky : MonoBehaviour } } + while (m_LuckyGameCupCounter.refillobjectCount < table_GlobalValue.Ins.Get_Int("LuckyGame_RefillAmount")) + yield return null; + + m_LuckyGameCupCounter.EndRefill(); isRefill = false; } + + public void Add_Ball(Vector3 pos) + { + for (int i = 0; i < tf_addobjs.childCount; i++) + { + var child = tf_addobjs.GetChild(i); + if (!child.gameObject.activeInHierarchy) + { + list_dropobj.Add(child.gameObject); + child.GetComponent().Init_Add(pos, tf_fallobjs); + break; + } + } + } } \ No newline at end of file diff --git a/Assets/Scripts/Game/LuckyGameCupCounter.cs b/Assets/Scripts/Game/LuckyGameCupCounter.cs index fa7cbf1..80c51fc 100644 --- a/Assets/Scripts/Game/LuckyGameCupCounter.cs +++ b/Assets/Scripts/Game/LuckyGameCupCounter.cs @@ -4,12 +4,25 @@ using UnityEngine; public class LuckyGameCupCounter : MonoBehaviour { public int objectCount = 0; + public int refillobjectCount = 0; Action m_actcount; + bool isRefill; public void Set(Action actcount) { m_actcount = actcount; + EndRefill(); + } + + public void StartRefill() + { + isRefill = true; + } + public void EndRefill() + { + refillobjectCount = 0; + isRefill = false; } void OnTriggerEnter2D(Collider2D other) @@ -18,6 +31,9 @@ public class LuckyGameCupCounter : MonoBehaviour { objectCount++; m_actcount(objectCount); + + if (isRefill) + ++refillobjectCount; } } diff --git a/Assets/Scripts/Game/LuckyGameObj.cs b/Assets/Scripts/Game/LuckyGameObj.cs index ce249c2..0907c6b 100644 --- a/Assets/Scripts/Game/LuckyGameObj.cs +++ b/Assets/Scripts/Game/LuckyGameObj.cs @@ -7,9 +7,9 @@ public class LuckyGameObj : MonoBehaviour public Image m_image; public GameObject go_effect; public Rigidbody2D m_Rigidbody2D; + public Collider2D m_Collider2D; - ProtectedInt32 m_Amount; - bool isInCup, isCollision; + bool isInCup, isCollision, isRandomBlock; public float velocityThreshold = 0.1f; // 이 값 이하이면 "거의 없음"으로 판단 float stoppedTime = 0f; public float requiredStopDuration = 0.2f; // 0.2초 이상 멈춰야 인정 @@ -46,10 +46,22 @@ public class LuckyGameObj : MonoBehaviour transform.localPosition = pos; tf_fallobjs = tffallobjs; - isCollision = false; - isInCup = m_image.enabled = true; + isRandomBlock = isCollision = false; + m_Collider2D.enabled = isInCup = m_image.enabled = true; + go_effect.SetActive(false); + m_Rigidbody2D.bodyType = RigidbodyType2D.Dynamic; + } + public void Init_Add(Vector3 pos, Transform tffallobjs) + { + gameObject.SetActive(true); + + transform.parent = tffallobjs; + transform.localPosition = pos; + tf_fallobjs = tffallobjs; + + isInCup = isCollision = false; + isRandomBlock = m_Collider2D.enabled = m_image.enabled = true; go_effect.SetActive(false); - m_Amount = 1; m_Amount.Obfuscate(); m_Rigidbody2D.bodyType = RigidbodyType2D.Dynamic; } @@ -71,7 +83,7 @@ public class LuckyGameObj : MonoBehaviour switch (collision.collider.tag) { case "Player": - Set_Collision(m_Amount); + Set_Collision(1); break; case "Finish": Set_Collision(0); @@ -84,9 +96,16 @@ public class LuckyGameObj : MonoBehaviour switch (collision.tag) { case "RandomBlock": - var lrb = collision.GetComponent(); - m_Amount = lrb.Get_Value(m_Amount); - m_Amount.Obfuscate(); + if (!isRandomBlock) + { + isRandomBlock = true; + var lrb = collision.GetComponent(); + var addAmount = lrb.Get_Value(1); + for (int i = 0; i < addAmount - 1; i++) + { // 공 추가하기 + LobbyUI.Ins.m_Game_Lucky.Add_Ball(transform.localPosition); + } + } break; case "LuckyGameCupTrigger": isInCup = true; @@ -96,10 +115,12 @@ public class LuckyGameObj : MonoBehaviour void OnTriggerExit2D(Collider2D other) { - if (other.CompareTag("LuckyGameCupTrigger")) + switch (other.tag) { - isInCup = false; - transform.parent = tf_fallobjs; + case "LuckyGameCupTrigger": + isInCup = false; + transform.parent = tf_fallobjs; + break; } } @@ -108,6 +129,7 @@ public class LuckyGameObj : MonoBehaviour SoundInfo.Ins.Play_OneShot((eSound)Random.Range(16, 19)); LobbyUI.Ins.m_Game_Lucky.Add_Amount(amount); m_image.enabled = false; + m_Collider2D.enabled = false; go_effect.SetActive(true); isCollision = true; }