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; }