From 143ccc2bab4839aacfd16b5596137676ee6b5859 Mon Sep 17 00:00:00 2001 From: Ino Date: Sat, 13 Sep 2025 05:15:49 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=9E=84=20=EC=A2=85=EB=A3=8C=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4?= 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 | 12 +++--- Assets/Scripts/Game/Game_Lucky.cs | 38 ++++++++++++++--- Assets/Scripts/Game/LuckyGameObj.cs | 47 ++++++++++++++++++--- 4 files changed, 78 insertions(+), 20 deletions(-) diff --git a/Assets/ResWork/GameData/LuckyGameObj.prefab b/Assets/ResWork/GameData/LuckyGameObj.prefab index 2a79ed4..543329d 100644 --- a/Assets/ResWork/GameData/LuckyGameObj.prefab +++ b/Assets/ResWork/GameData/LuckyGameObj.prefab @@ -55,6 +55,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_image: {fileID: 613301010048255497} go_effect: {fileID: 1752936709684462252} + m_Rigidbody2D: {fileID: 1260999574391235090} --- !u!222 &2007710277984516474 CanvasRenderer: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 2bffb29..c59787a 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -3102,7 +3102,7 @@ GameObject: - component: {fileID: 420248623} m_Layer: 5 m_Name: Bot - m_TagString: Untagged + m_TagString: Finish m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -7555,11 +7555,11 @@ GameObject: - component: {fileID: 993386007} m_Layer: 5 m_Name: Left - m_TagString: Untagged + m_TagString: Finish m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &993386006 RectTransform: m_ObjectHideFlags: 0 @@ -11608,11 +11608,11 @@ GameObject: - component: {fileID: 1626145305} m_Layer: 5 m_Name: Right - m_TagString: Untagged + m_TagString: Finish m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &1626145304 RectTransform: m_ObjectHideFlags: 0 @@ -15341,7 +15341,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &1999037950 RectTransform: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Game/Game_Lucky.cs b/Assets/Scripts/Game/Game_Lucky.cs index cca9c5a..0f6ca96 100644 --- a/Assets/Scripts/Game/Game_Lucky.cs +++ b/Assets/Scripts/Game/Game_Lucky.cs @@ -1,4 +1,5 @@ using GUPS.AntiCheat.Protected; +using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; @@ -20,6 +21,8 @@ public class Game_Lucky : MonoBehaviour bool bRotCup = false; ProtectedFloat m_Time; ProtectedInt32 _get; public int m_Amount { get { return _get; } set { _get = value; _get.Obfuscate(); } } + ProtectedInt32 _bb; public int m_BubbleAmount { get { return _bb; } set { _bb = value; _bb.Obfuscate(); } } + ProtectedInt32 TotalBubbleAmount = 50; public void Set() { @@ -34,7 +37,8 @@ public class Game_Lucky : MonoBehaviour // list_dropobj.Count 가 0 이면 50개 생성해서 tf_cupin 안에 넣기 if (list_dropobj.Count == 0) { - for (int i = 0; i < 50; i++) + TotalBubbleAmount.Obfuscate(); + for (int i = 0; i < TotalBubbleAmount; i++) { GameObject obj = Instantiate(go_dropobj, tf_cupin); obj.transform.localPosition = Get_CupInLocalPos(); @@ -58,6 +62,7 @@ public class Game_Lucky : MonoBehaviour Time.timeScale = 1f; m_Time = 30f; m_Time.Obfuscate(); m_Amount = 0; + m_BubbleAmount = 0; } void Set_Texts() @@ -66,7 +71,28 @@ public class Game_Lucky : MonoBehaviour texts[1].text = m_Amount.ToString(); } - public void Add_Amount(int amout) { m_Amount += amout; Set_Texts(); } + public void Add_Amount(int amout) + { + m_Amount += amout; + Set_Texts(); + + ++m_BubbleAmount; + if (m_BubbleAmount >= TotalBubbleAmount) + GameOver(); + } + + void GameOver() + { + StartCoroutine(Co_GameOver()); + } + + IEnumerator Co_GameOver() + { + list_dropobj.ForEach(f => f.GetComponent().StopObj()); + yield return new WaitForSecondsRealtime(3f); + // TODO : 결과 보여주기 (결과 화면 나갈 때, Time.timeScale = 1f; 필수) + gameObject.SetActive(false); // 지금은 그냥 나가기 + } Vector3 Get_CupInLocalPos() { @@ -109,6 +135,8 @@ public class Game_Lucky : MonoBehaviour // 회전 시작 (목표: -150도) targetZ = -150f; isRotating = true; + + list_dropobj.ForEach(f => f.GetComponent().Tilt_Cup()); } private void Update() @@ -136,11 +164,7 @@ public class Game_Lucky : MonoBehaviour Debug.Log(m_Time); Set_Texts(); if (m_Time <= 0f) - { - Time.timeScale = 0f; - // TODO : 결과 보여주기 (Time.timeScale = 1f; 필수) - gameObject.SetActive(false); // 지금은 그냥 나가기 - } + GameOver(); } } } \ No newline at end of file diff --git a/Assets/Scripts/Game/LuckyGameObj.cs b/Assets/Scripts/Game/LuckyGameObj.cs index d2bb6c3..9f5e188 100644 --- a/Assets/Scripts/Game/LuckyGameObj.cs +++ b/Assets/Scripts/Game/LuckyGameObj.cs @@ -1,4 +1,5 @@ using GUPS.AntiCheat.Protected; +using System.Collections; using UnityEngine; using UnityEngine.UI; @@ -6,26 +7,58 @@ public class LuckyGameObj : MonoBehaviour { public Image m_image; public GameObject go_effect; + public Rigidbody2D m_Rigidbody2D; ProtectedInt32 m_Amount; + bool isCollision; public void Init(Vector3 pos) { + transform.localPosition = pos; + + isCollision = false; m_image.enabled = true; go_effect.SetActive(false); m_Amount = 1; m_Amount.Obfuscate(); - transform.localPosition = pos; + m_Rigidbody2D.bodyType = RigidbodyType2D.Dynamic; + } + + public void StopObj() + { + m_Rigidbody2D.bodyType = RigidbodyType2D.Kinematic; + } + + public void Tilt_Cup() + { + StartCoroutine(Co_Update()); + } + + IEnumerator Co_Update() + { + yield return new WaitForSeconds(20f); + if (!isCollision) Set_Collision(0); } private void OnCollisionEnter2D(Collision2D collision) { - if (collision == null) return; + if (isCollision || collision == null) return; - if (collision.collider.tag == "Player") - { // 재화 획득 - LobbyUI.Ins.m_Game_Lucky.Add_Amount(m_Amount); - m_image.enabled = false; - go_effect.SetActive(true); + switch (collision.collider.tag) + { + case "Player": + Set_Collision(m_Amount); + break; + case "Finish": + Set_Collision(0); + break; } } + + void Set_Collision(int amount) + { + LobbyUI.Ins.m_Game_Lucky.Add_Amount(amount); + m_image.enabled = false; + go_effect.SetActive(true); + isCollision = true; + } } \ No newline at end of file