컴퓨터 수정
This commit is contained in:
46
Assets/02_Scripts/UI/computer/HeartAffectionUI.cs
Normal file
46
Assets/02_Scripts/UI/computer/HeartAffectionUI.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class HeartAffectionUI : MonoBehaviour
|
||||
{
|
||||
[Header("채워지는 하트 10개")]
|
||||
public Image[] fillHearts;
|
||||
|
||||
[Header("퍼센트 텍스트")]
|
||||
public TMP_Text percentText;
|
||||
|
||||
[Header("호감도")]
|
||||
[Range(0, 100)]
|
||||
public int affectionPercent = 0;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SetAffection(affectionPercent);
|
||||
}
|
||||
|
||||
public void SetAffection(int percent)
|
||||
{
|
||||
affectionPercent = Mathf.Clamp(percent, 0, 100);
|
||||
|
||||
// 11% = 1.1개 하트
|
||||
// 45% = 4.5개 하트
|
||||
// 78% = 7.8개 하트
|
||||
float heartValue = affectionPercent / 10f;
|
||||
|
||||
for (int i = 0; i < fillHearts.Length; i++)
|
||||
{
|
||||
fillHearts[i].fillAmount = Mathf.Clamp01(heartValue - i);
|
||||
}
|
||||
|
||||
if (percentText != null)
|
||||
{
|
||||
percentText.text = affectionPercent + "%";
|
||||
}
|
||||
}
|
||||
|
||||
public void AddAffection(int amount)
|
||||
{
|
||||
SetAffection(affectionPercent + amount);
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/UI/computer/HeartAffectionUI.cs.meta
Normal file
2
Assets/02_Scripts/UI/computer/HeartAffectionUI.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c24b2d88eab370744b5aa15143ad93d7
|
||||
41
Assets/02_Scripts/UI/computer/MainProgressUI.cs
Normal file
41
Assets/02_Scripts/UI/computer/MainProgressUI.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class MainProgressUI : MonoBehaviour
|
||||
{
|
||||
[Header("진행도 채움 이미지")]
|
||||
public Image progressFill;
|
||||
|
||||
[Header("퍼센트 텍스트")]
|
||||
public TMP_Text percentText;
|
||||
|
||||
[Header("메인 진행도")]
|
||||
[Range(0, 100)]
|
||||
public int progressPercent = 0;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SetProgress(progressPercent);
|
||||
}
|
||||
|
||||
public void SetProgress(int percent)
|
||||
{
|
||||
progressPercent = Mathf.Clamp(percent, 0, 100);
|
||||
|
||||
if (progressFill != null)
|
||||
{
|
||||
progressFill.fillAmount = progressPercent / 100f;
|
||||
}
|
||||
|
||||
if (percentText != null)
|
||||
{
|
||||
percentText.text = progressPercent + "%";
|
||||
}
|
||||
}
|
||||
|
||||
public void AddProgress(int amount)
|
||||
{
|
||||
SetProgress(progressPercent + amount);
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/UI/computer/MainProgressUI.cs.meta
Normal file
2
Assets/02_Scripts/UI/computer/MainProgressUI.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 035493732111afa4e907adcfcbbabb3c
|
||||
58
Assets/02_Scripts/UI/computer/StoryComputerStatusBinder.cs
Normal file
58
Assets/02_Scripts/UI/computer/StoryComputerStatusBinder.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class StoryComputerStatusBinder : MonoBehaviour
|
||||
{
|
||||
[Header("메인 진행도 UI")]
|
||||
public MainProgressUI mainProgressUI;
|
||||
|
||||
[Header("호감도 UI")]
|
||||
public CharacterData character1;
|
||||
public HeartAffectionUI heartUI1;
|
||||
|
||||
public CharacterData character2;
|
||||
public HeartAffectionUI heartUI2;
|
||||
|
||||
public CharacterData character3;
|
||||
public HeartAffectionUI heartUI3;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
if (StoryManager.Instance == null)
|
||||
{
|
||||
Debug.LogWarning("[StoryComputerStatusBinder] StoryManager가 없습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 메인 진행도
|
||||
if (mainProgressUI != null)
|
||||
{
|
||||
mainProgressUI.SetProgress(StoryManager.Instance.MainProgress);
|
||||
}
|
||||
|
||||
// 1번 캐릭터 호감도
|
||||
if (character1 != null && heartUI1 != null)
|
||||
{
|
||||
int affection = StoryManager.Instance.GetAffection(character1);
|
||||
heartUI1.SetAffection(affection);
|
||||
}
|
||||
|
||||
// 2번 캐릭터 호감도
|
||||
if (character2 != null && heartUI2 != null)
|
||||
{
|
||||
int affection = StoryManager.Instance.GetAffection(character2);
|
||||
heartUI2.SetAffection(affection);
|
||||
}
|
||||
|
||||
// 3번 캐릭터 호감도
|
||||
if (character3 != null && heartUI3 != null)
|
||||
{
|
||||
int affection = StoryManager.Instance.GetAffection(character3);
|
||||
heartUI3.SetAffection(affection);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61a29f370bacd4b49b22aa78b73f3464
|
||||
29
Assets/02_Scripts/UI/computer/StoryTestButton.cs
Normal file
29
Assets/02_Scripts/UI/computer/StoryTestButton.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class StoryTestButton : MonoBehaviour
|
||||
{
|
||||
public CharacterData testCharacter;
|
||||
public int addAmount = 10;
|
||||
|
||||
[ContextMenu("TEST / Add Affection")]
|
||||
public void TestAddAffection()
|
||||
{
|
||||
if (testCharacter == null)
|
||||
{
|
||||
Debug.LogWarning("테스트 캐릭터가 없습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
StoryManager.Instance.AddAffection(testCharacter, addAmount);
|
||||
|
||||
Debug.Log($"{testCharacter.name} 호감도 +{addAmount}");
|
||||
}
|
||||
|
||||
[ContextMenu("TEST / Add Main Progress")]
|
||||
public void TestAddMainProgress()
|
||||
{
|
||||
StoryManager.Instance.MainProgress += addAmount;
|
||||
|
||||
Debug.Log($"메인 진행도 +{addAmount}");
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/UI/computer/StoryTestButton.cs.meta
Normal file
2
Assets/02_Scripts/UI/computer/StoryTestButton.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 271cab50fc082884ab7277394c185474
|
||||
Reference in New Issue
Block a user