using System.Collections; using System.Collections.Generic; using DG.Tweening; using UnityEngine; using UnityEngine.UI; public class BubbleCard : MonoBehaviour { [SerializeField] GameObject _leftItem; [SerializeField] GameObject _rightItem; public bool IsLeftCarrot { get; private set; } public bool IsGoldCarrot { get; private set; } public bool IsSkullStone { get; private set; } public bool IsFever { get; private set; } float APPEAR_GOLD_CARROT_RATE; float APPEAR_SKULL_RATE; void Awake() { APPEAR_GOLD_CARROT_RATE = 100f; APPEAR_SKULL_RATE = 200f; } public void SetScale(int index, float moveTime) { Vector3 scale = index == 10 ? new Vector3(1.2f, 1.2f, 1.2f) : index == 11 ? new Vector3(1.5f, 1.5f, 1.5f) : index == 0 ? new Vector3(0.5f, 0.5f, 0.5f) : Vector3.one; _leftItem.transform.DOScale(scale, moveTime); _rightItem.transform.DOScale(scale, moveTime); } public void SetCard(bool isFever) { IsFever = isFever; string defaultPath = "Prefabs/HorseRush/Image/"; // 좌우 중 어떤쪽이 당근일지 랜덤 bool isLeftCarrot = Random.Range(0, 2) == 0; IsLeftCarrot = isLeftCarrot; GameObject carrotObject = isLeftCarrot ? _leftItem : _rightItem; GameObject stoneObject = isLeftCarrot ? _rightItem : _leftItem; if (isFever) { IsGoldCarrot = true; carrotObject.GetComponent().sprite = Resources.Load(defaultPath + "Bubble_Fever"); stoneObject.GetComponent().sprite = Resources.Load(defaultPath + "Bubble_Fever"); } else { // HorseRushManager.Instance.APPEAR_GOLD_CARROT_RATE bool isGoldCarrot = Random.Range(0, 10000) <= APPEAR_GOLD_CARROT_RATE; IsGoldCarrot = isGoldCarrot; bool isSkullStone = Random.Range(0, 10000) <= APPEAR_SKULL_RATE; IsSkullStone = isSkullStone; carrotObject.GetComponent().sprite = Resources.Load(defaultPath + (isGoldCarrot ? "Bubble_GoldedCarrot" : "Bubble_Carrot")); stoneObject.GetComponent().sprite = Resources.Load(defaultPath + (isSkullStone ? "Bubble_Stun" : "Bubble_Stone")); } } public void SetOpacity(int index, bool isFever) { if (!isFever) { float opacity = Mathf.Clamp01(index / 10f); _leftItem.GetComponent().color = new Color(1f, 1f, 1f, opacity); _rightItem.GetComponent().color = new Color(1f, 1f, 1f, opacity); } else { // 12: 100%, 11: 60%, 10 : 30%, 이하 0% float opacity = index == 12 ? 1f : index >= 11 ? 0.5f : 0.1f; _leftItem.GetComponent().color = new Color(1f, 1f, 1f, opacity); _rightItem.GetComponent().color = new Color(1f, 1f, 1f, opacity); } } }