144 lines
3.5 KiB
C#
144 lines
3.5 KiB
C#
using System.Text;
|
|
using UnityEngine;
|
|
|
|
public class StoryComputerSystem : MonoBehaviour
|
|
{
|
|
[Header("Computer State")]
|
|
[SerializeField] private bool isPowerOn = false;
|
|
|
|
[Header("Affection Check Characters")]
|
|
[SerializeField] private CharacterData[] characters;
|
|
|
|
public bool IsPowerOn => isPowerOn;
|
|
|
|
public void TogglePower()
|
|
{
|
|
isPowerOn = !isPowerOn;
|
|
|
|
Debug.Log(isPowerOn
|
|
? "[StoryComputer] 컴퓨터 전원이 켜졌습니다."
|
|
: "[StoryComputer] 컴퓨터 전원이 꺼졌습니다.");
|
|
|
|
if (isPowerOn)
|
|
{
|
|
PrintCurrentState();
|
|
}
|
|
}
|
|
|
|
public void SaveFromComputer()
|
|
{
|
|
if (!CanUseComputer()) return;
|
|
|
|
StoryManager.Instance.Save();
|
|
Debug.Log("[StoryComputer] 현재 스토리 상태를 저장했습니다.");
|
|
}
|
|
|
|
public void LoadFromComputer()
|
|
{
|
|
if (!CanUseComputer()) return;
|
|
|
|
bool success = StoryManager.Instance.Load();
|
|
|
|
if (success)
|
|
{
|
|
Debug.Log("[StoryComputer] 저장된 스토리 상태를 불러왔습니다.");
|
|
PrintCurrentState();
|
|
}
|
|
else
|
|
{
|
|
Debug.LogWarning("[StoryComputer] 불러올 저장 파일이 없습니다.");
|
|
}
|
|
}
|
|
|
|
public void ResetStoryFromComputer()
|
|
{
|
|
if (!CanUseComputer()) return;
|
|
|
|
StoryManager.Instance.ResetAll();
|
|
Debug.Log("[StoryComputer] 스토리 상태를 초기화했습니다.");
|
|
PrintCurrentState();
|
|
}
|
|
|
|
public void PrintCurrentState()
|
|
{
|
|
if (StoryManager.Instance == null)
|
|
{
|
|
Debug.LogWarning("[StoryComputer] StoryManager가 없습니다.");
|
|
return;
|
|
}
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.AppendLine("========== 현재 스토리 상태 ==========");
|
|
sb.AppendLine($"메인 진행도: {StoryManager.Instance.MainProgress}");
|
|
sb.AppendLine();
|
|
|
|
sb.AppendLine("공룡별 호감도:");
|
|
|
|
if (characters == null || characters.Length == 0)
|
|
{
|
|
sb.AppendLine("- 등록된 캐릭터 없음");
|
|
}
|
|
else
|
|
{
|
|
foreach (CharacterData character in characters)
|
|
{
|
|
if (character == null) continue;
|
|
|
|
int affection = StoryManager.Instance.GetAffection(character);
|
|
sb.AppendLine($"- {character.name}: {affection}");
|
|
}
|
|
}
|
|
|
|
sb.AppendLine("====================================");
|
|
|
|
Debug.Log(sb.ToString());
|
|
}
|
|
|
|
private bool CanUseComputer()
|
|
{
|
|
if (!isPowerOn)
|
|
{
|
|
Debug.LogWarning("[StoryComputer] 컴퓨터 전원이 꺼져 있어서 사용할 수 없습니다.");
|
|
return false;
|
|
}
|
|
|
|
if (StoryManager.Instance == null)
|
|
{
|
|
Debug.LogWarning("[StoryComputer] StoryManager가 씬에 없습니다.");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
[ContextMenu("TEST / Power Toggle")]
|
|
private void TestPowerToggle()
|
|
{
|
|
TogglePower();
|
|
}
|
|
|
|
[ContextMenu("TEST / Save")]
|
|
private void TestSave()
|
|
{
|
|
SaveFromComputer();
|
|
}
|
|
|
|
[ContextMenu("TEST / Load")]
|
|
private void TestLoad()
|
|
{
|
|
LoadFromComputer();
|
|
}
|
|
|
|
[ContextMenu("TEST / Reset Story")]
|
|
private void TestReset()
|
|
{
|
|
ResetStoryFromComputer();
|
|
}
|
|
|
|
[ContextMenu("TEST / Print State")]
|
|
private void TestPrintState()
|
|
{
|
|
PrintCurrentState();
|
|
}
|
|
} |