미니게임 게임종료 체크 빠르게

This commit is contained in:
Ino 2025-09-24 05:50:18 +09:00
parent 1f246ae489
commit 9110ba5276
4 changed files with 42 additions and 33 deletions

View File

@ -56,6 +56,8 @@ MonoBehaviour:
m_image: {fileID: 613301010048255497}
go_effect: {fileID: 1752936709684462252}
m_Rigidbody2D: {fileID: 1260999574391235090}
velocityThreshold: 0.1
requiredStopDuration: 0.2
--- !u!222 &2007710277984516474
CanvasRenderer:
m_ObjectHideFlags: 0

View File

@ -11361,7 +11361,6 @@ GameObject:
m_Component:
- component: {fileID: 420248621}
- component: {fileID: 420248622}
- component: {fileID: 420248623}
m_Layer: 5
m_Name: Bot
m_TagString: Finish
@ -11383,10 +11382,10 @@ RectTransform:
m_Children: []
m_Father: {fileID: 1999037950}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: -25}
m_SizeDelta: {x: 0, y: 50}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!61 &420248622
BoxCollider2D:
@ -11432,20 +11431,8 @@ BoxCollider2D:
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Size: {x: 1080, y: 50}
m_Size: {x: 5000, y: 100}
m_EdgeRadius: 0
--- !u!114 &420248623
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 420248620}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 970655c7570620b4b81080ce46bbd866, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &422178259
GameObject:
m_ObjectHideFlags: 0
@ -25687,7 +25674,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: -44, y: 0}
m_AnchoredPosition: {x: -200, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!61 &993386007
@ -42619,7 +42606,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: 44, y: 0}
m_AnchoredPosition: {x: 200, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!61 &1626145305

View File

@ -136,7 +136,7 @@ public class Game_Lucky : MonoBehaviour
{
updateTime = false;
list_dropobj.ForEach(f => f.GetComponent<LuckyGameObj>().StopObj());
yield return new WaitForSecondsRealtime(3f);
yield return new WaitForSecondsRealtime(0.5f);
m_Game_Lucky_Result.Set(m_Amount);
StopAllCoroutines();
}
@ -184,15 +184,13 @@ public class Game_Lucky : MonoBehaviour
// tf_cup을 터치한 위치의 x 값만 받아서 거기에 위치시킴
Vector3 cupPos = tf_cup.position;
cupPos.x = worldPos.x;
cupPos.x = Mathf.Clamp(worldPos.x, Cup_minX, Cup_maxX);
tf_cup.position = cupPos;
// 회전 시작 (목표: -150도)
targetZ = -150f;
isRotating = true;
list_dropobj.ForEach(f => f.GetComponent<LuckyGameObj>().Tilt_Cup());
SoundInfo.Ins.Play_OneShot((eSound)Random.Range(14, 16));
}
@ -212,6 +210,7 @@ public class Game_Lucky : MonoBehaviour
if (Mathf.Approximately(newZ, targetZ))
{
isRotating = false;
list_dropobj.ForEach(f => f.GetComponent<LuckyGameObj>().Tilt_Cup());
}
}

View File

@ -10,13 +10,39 @@ public class LuckyGameObj : MonoBehaviour
public Rigidbody2D m_Rigidbody2D;
ProtectedInt32 m_Amount;
bool isCollision;
bool isTiltCup, isCollision;
public float velocityThreshold = 0.1f; // 이 값 이하이면 "거의 없음"으로 판단
float stoppedTime = 0f;
public float requiredStopDuration = 0.2f; // 0.2초 이상 멈춰야 인정
void Update()
{
if (isTiltCup && !isCollision && IsAlmostStopped())
{
Debug.Log("움직임이 거의 없음");
Set_Collision(0);
}
}
bool IsAlmostStopped()
{
bool almostStoppedNow =
m_Rigidbody2D.linearVelocity.sqrMagnitude < velocityThreshold * velocityThreshold &&
Mathf.Abs(m_Rigidbody2D.angularVelocity) < velocityThreshold;
if (almostStoppedNow)
stoppedTime += Time.deltaTime;
else
stoppedTime = 0f;
return stoppedTime >= requiredStopDuration;
}
public void Init(Vector3 pos)
{
transform.localPosition = pos;
isCollision = false;
isTiltCup = isCollision = false;
m_image.enabled = true;
go_effect.SetActive(false);
m_Amount = 1; m_Amount.Obfuscate();
@ -30,19 +56,14 @@ public class LuckyGameObj : MonoBehaviour
public void Tilt_Cup()
{
StartCoroutine(Co_Update());
}
IEnumerator Co_Update()
{
yield return new WaitForSeconds(20f);
if (!isCollision) Set_Collision(0);
isTiltCup = true;
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (isCollision || collision == null) return;
if (!isTiltCup || isCollision || collision == null) return;
//Debug.Log(collision.collider.tag + " : " + collision.collider.name);
switch (collision.collider.tag)
{
case "Player":