using GUPS.AntiCheat.Protected; using GUPS.AntiCheat.Protected.Collection; using System; using System.Collections; using TMPro; using UnityEngine; using UnityEngine.UI; using Random = UnityEngine.Random; //public enum eRandomBlock { Minus, Plus, Multiplier, Divide } public enum eRandomBlock { Plus, Multiplier } public class LuckyRandomBlock : MonoBehaviour { public RectTransform m_rt; public Image i_bg; public TextMeshProUGUI t_value; eRandomBlock m_BlockType; ProtectedInt32 m_Value; bool isMoving; ProtectedList list_value = new ProtectedList { 1, 2, 3, 4, 5 }; public void Init() { // BlockType 랜덤 (Enum 전체 범위에서 선택) int typeCount = Enum.GetValues(typeof(eRandomBlock)).Length; m_BlockType = (eRandomBlock)Random.Range(0, typeCount); // Value 랜덤 (리스트에서 하나 뽑기) int randIndex = Random.Range(0, list_value.Count); m_Value = list_value[randIndex]; switch (m_BlockType) { //case eRandomBlock.Minus: t_value.text = $"-{m_Value}"; // i_bg.sprite = UIAtlasMgr.Ins.Get_Sprite("block 1_lucky mini game"); // break; case eRandomBlock.Plus: t_value.text = $"+{m_Value}"; i_bg.sprite = UIAtlasMgr.Ins.Get_Sprite("block 2_lucky mini game"); break; case eRandomBlock.Multiplier: t_value.text = $"x{m_Value}"; i_bg.sprite = UIAtlasMgr.Ins.Get_Sprite("block 3_lucky mini game"); break; //case eRandomBlock.Divide: t_value.text = $"÷{m_Value}"; // i_bg.sprite = UIAtlasMgr.Ins.Get_Sprite("block 4_lucky mini game"); // break; } var global = table_GlobalValue.Ins; var width = Random.Range(global.Get_Int("LuckyBlockWithdMin"), global.Get_Int("LuckyBlockWithdMax")); var height = Random.Range(global.Get_Int("LuckyBlockHeightMin"), global.Get_Int("LuckyBlockHeightMax")); m_rt.sizeDelta = new Vector2(width, height); m_rt.anchoredPosition = new Vector3(width << 1, 0f); isMoving = false; } public void Move() { StartCoroutine(Co_Move()); } IEnumerator Co_Move() { isMoving = true; var global = table_GlobalValue.Ins; var MoveSpeed = Random.Range(global.Get_Int("LuckyBlockSpeedMin"), global.Get_Int("LuckyBlockSpeedMax")); //m_rt.anchoredPosition = new Vector3(300f, 0f); while (transform.localPosition.x > -Screen.width) { yield return null; m_rt.anchoredPosition = new Vector3(m_rt.anchoredPosition.x - MoveSpeed * Time.deltaTime, 0f); } Init(); } public bool IsMoving() { return isMoving; } public bool IsCrossCenter() { return m_rt.anchoredPosition.x <= -(Screen.width >> 1); } public bool IsCrossTwoThirds() { return m_rt.anchoredPosition.x <= -(Screen.width * 2 / 3); } public int Get_Value(int amount) { switch (m_BlockType) { //case eRandomBlock.Minus: return amount - m_Value; case eRandomBlock.Plus: return amount + m_Value; case eRandomBlock.Multiplier: return amount * m_Value; //case eRandomBlock.Divide: return amount / m_Value; } return 0; } }