게임 종료 조건

This commit is contained in:
Ino 2025-09-13 05:15:49 +09:00
parent 3c8b8297d7
commit 143ccc2bab
4 changed files with 78 additions and 20 deletions

View File

@ -55,6 +55,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_image: {fileID: 613301010048255497} m_image: {fileID: 613301010048255497}
go_effect: {fileID: 1752936709684462252} go_effect: {fileID: 1752936709684462252}
m_Rigidbody2D: {fileID: 1260999574391235090}
--- !u!222 &2007710277984516474 --- !u!222 &2007710277984516474
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -3102,7 +3102,7 @@ GameObject:
- component: {fileID: 420248623} - component: {fileID: 420248623}
m_Layer: 5 m_Layer: 5
m_Name: Bot m_Name: Bot
m_TagString: Untagged m_TagString: Finish
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
@ -7555,11 +7555,11 @@ GameObject:
- component: {fileID: 993386007} - component: {fileID: 993386007}
m_Layer: 5 m_Layer: 5
m_Name: Left m_Name: Left
m_TagString: Untagged m_TagString: Finish
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &993386006 --- !u!224 &993386006
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -11608,11 +11608,11 @@ GameObject:
- component: {fileID: 1626145305} - component: {fileID: 1626145305}
m_Layer: 5 m_Layer: 5
m_Name: Right m_Name: Right
m_TagString: Untagged m_TagString: Finish
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &1626145304 --- !u!224 &1626145304
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -15341,7 +15341,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &1999037950 --- !u!224 &1999037950
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -1,4 +1,5 @@
using GUPS.AntiCheat.Protected; using GUPS.AntiCheat.Protected;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
@ -20,6 +21,8 @@ public class Game_Lucky : MonoBehaviour
bool bRotCup = false; bool bRotCup = false;
ProtectedFloat m_Time; ProtectedFloat m_Time;
ProtectedInt32 _get; public int m_Amount { get { return _get; } set { _get = value; _get.Obfuscate(); } } 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() public void Set()
{ {
@ -34,7 +37,8 @@ public class Game_Lucky : MonoBehaviour
// list_dropobj.Count 가 0 이면 50개 생성해서 tf_cupin 안에 넣기 // list_dropobj.Count 가 0 이면 50개 생성해서 tf_cupin 안에 넣기
if (list_dropobj.Count == 0) 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); GameObject obj = Instantiate(go_dropobj, tf_cupin);
obj.transform.localPosition = Get_CupInLocalPos(); obj.transform.localPosition = Get_CupInLocalPos();
@ -58,6 +62,7 @@ public class Game_Lucky : MonoBehaviour
Time.timeScale = 1f; Time.timeScale = 1f;
m_Time = 30f; m_Time.Obfuscate(); m_Time = 30f; m_Time.Obfuscate();
m_Amount = 0; m_Amount = 0;
m_BubbleAmount = 0;
} }
void Set_Texts() void Set_Texts()
@ -66,7 +71,28 @@ public class Game_Lucky : MonoBehaviour
texts[1].text = m_Amount.ToString(); 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<LuckyGameObj>().StopObj());
yield return new WaitForSecondsRealtime(3f);
// TODO : 결과 보여주기 (결과 화면 나갈 때, Time.timeScale = 1f; 필수)
gameObject.SetActive(false); // 지금은 그냥 나가기
}
Vector3 Get_CupInLocalPos() Vector3 Get_CupInLocalPos()
{ {
@ -109,6 +135,8 @@ public class Game_Lucky : MonoBehaviour
// 회전 시작 (목표: -150도) // 회전 시작 (목표: -150도)
targetZ = -150f; targetZ = -150f;
isRotating = true; isRotating = true;
list_dropobj.ForEach(f => f.GetComponent<LuckyGameObj>().Tilt_Cup());
} }
private void Update() private void Update()
@ -136,11 +164,7 @@ public class Game_Lucky : MonoBehaviour
Debug.Log(m_Time); Debug.Log(m_Time);
Set_Texts(); Set_Texts();
if (m_Time <= 0f) if (m_Time <= 0f)
{ GameOver();
Time.timeScale = 0f;
// TODO : 결과 보여주기 (Time.timeScale = 1f; 필수)
gameObject.SetActive(false); // 지금은 그냥 나가기
}
} }
} }
} }

View File

@ -1,4 +1,5 @@
using GUPS.AntiCheat.Protected; using GUPS.AntiCheat.Protected;
using System.Collections;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@ -6,26 +7,58 @@ public class LuckyGameObj : MonoBehaviour
{ {
public Image m_image; public Image m_image;
public GameObject go_effect; public GameObject go_effect;
public Rigidbody2D m_Rigidbody2D;
ProtectedInt32 m_Amount; ProtectedInt32 m_Amount;
bool isCollision;
public void Init(Vector3 pos) public void Init(Vector3 pos)
{ {
transform.localPosition = pos;
isCollision = false;
m_image.enabled = true; m_image.enabled = true;
go_effect.SetActive(false); go_effect.SetActive(false);
m_Amount = 1; m_Amount.Obfuscate(); 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) private void OnCollisionEnter2D(Collision2D collision)
{ {
if (collision == null) return; if (isCollision || collision == null) return;
if (collision.collider.tag == "Player") switch (collision.collider.tag)
{ // 재화 획득 {
LobbyUI.Ins.m_Game_Lucky.Add_Amount(m_Amount); case "Player":
m_image.enabled = false; Set_Collision(m_Amount);
go_effect.SetActive(true); 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;
}
} }