DEG-165 [Feat] 집안일 후 랜덤 하게 랜덤 강화

This commit is contained in:
99jamin 2025-05-14 14:18:22 +09:00
parent 4ffed3b1d1
commit c36be7ab93
2 changed files with 46 additions and 1 deletions

View File

@ -31,6 +31,8 @@ public class UpgradeManager : Singleton<UpgradeManager>
private RectTransform backgroundRectTransform;
private List<Button> cards = new List<Button>();
private bool isHome = false;
public void Start()
{
if(canvas == null)
@ -82,6 +84,36 @@ public class UpgradeManager : Singleton<UpgradeManager>
}
}
}
/// <summary>
/// 랜덤한 강화 카드 1장
/// </summary>
public void StartUpgradeInHome()
{
isHome = true;
DrawStatNumber();
//배경 패널 생성
if(backgroundRectTransform == null)
backgroundRectTransform = Instantiate(backgroundPanel,canvas.transform).GetComponent<RectTransform>();
//배경 패널 애니메이션 적용
backgroundRectTransform.gameObject.SetActive(true);
StartCoroutine(CoFade(backgroundRectTransform.gameObject, 0f,0.7f,0.2f));
EnsureCardListSize(3);
if(cards[0] == null)
cards[0] = Instantiate(upgradeButton, backgroundRectTransform);
cards[0].gameObject.SetActive(true);
cards[0].GetComponent<UpgradeCard>().Init((StatType)stats[0]);
StartCoroutine(CoFade(cards[0].gameObject, 0f,1f,0.4f, () =>
{
cards[0].GetComponent<CanvasGroup>().interactable = true;
}));
}
/// <summary>
@ -130,13 +162,15 @@ public class UpgradeManager : Singleton<UpgradeManager>
public void DestroyUpgradeCard()
{
// 카드 비활성화
if (stats.Count == 0)
if (stats.Count == 0 || isHome)
{
StartCoroutine(CoFade(cards[0].gameObject, 1f,0f,0.4f,() =>
{
cards[0].gameObject.SetActive(false);
backgroundRectTransform.gameObject.SetActive(false);
}));
isHome = false;
}
else
{

View File

@ -5,6 +5,7 @@ using System.Text;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using Random = UnityEngine.Random;
public class InteractionAnimationPanelController : MonoBehaviour
{
@ -107,6 +108,16 @@ public class InteractionAnimationPanelController : MonoBehaviour
//패널 닫고 애니메이션 null처리
HidePanel();
_autoHideCoroutine = null;
if (actionType == ActionType.Housework)
{
var chance = 0.7f; // 30% 확률
if (Random.value < chance)
{
UpgradeManager.Instance.StartUpgradeInHome();
}
}
}
private void HidePanel()