112 lines
3.9 KiB
C#
112 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BlueWater.Audios;
|
|
using UnityEngine;
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
|
namespace BlueWater.Tycoons
|
|
{
|
|
public class TycoonManager : Singleton<TycoonManager>
|
|
{
|
|
|
|
[field: Title("캐릭터 스테이터스")]
|
|
[field: SerializeField, CLabel("최대 체력")]
|
|
public int MaxHeart { get; set; } = 3;
|
|
|
|
[field: SerializeField, CLabel("현재 체력")]
|
|
private int CurrentHeart;
|
|
[field: SerializeField, CLabel("무적")]
|
|
public bool Invincibility = false;
|
|
public int _CurrentHeart { get => CurrentHeart; set { if (!Invincibility) { CurrentHeart = value;}}}
|
|
|
|
[field: SerializeField, CLabel("이동 속도")]
|
|
public float Chracter_Speed { get; set; } = 1.0f;
|
|
|
|
[field: Title("음식 스테이터스")]
|
|
[field: SerializeField, CLabel("Liquid A")]
|
|
public int LiquidA { get; set; } = 1000;
|
|
[field: SerializeField, CLabel("Liquid B")]
|
|
public int LiquidB { get; set; } = 1000;
|
|
[field: SerializeField, CLabel("Liquid C")]
|
|
public int LiquidC { get; set; } = 1000;
|
|
[field: SerializeField, CLabel("Liquid D")]
|
|
public int LiquidD { get; set; } = 1000;
|
|
[field: SerializeField, CLabel("Liquid E")]
|
|
public int LiquidE { get; set; } = 1000;
|
|
[field: SerializeField, CLabel("Garnish A")]
|
|
public int GarnishA { get; set; } = 1000;
|
|
[field: SerializeField, CLabel("Garnish B")]
|
|
public int GarnishB { get; set; } = 1000;
|
|
|
|
[field: Title("컴포넌트")]
|
|
[field: SerializeField]
|
|
public CustomerTableController CustomerTableController { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public TycoonStageController TycoonStageController { get; private set; }
|
|
|
|
[SerializeField]
|
|
private string _dailyBgm;
|
|
|
|
[SerializeField, Required]
|
|
private LevelDataSo _levelDataSo;
|
|
private Dictionary<string, LevelData> _levelDatas;
|
|
|
|
[SerializeField, Required]
|
|
private CardDataSo _cardDataSo;
|
|
private Dictionary<string, CardData> _cardDatas;
|
|
|
|
public Action OnTycoonOpenedEvent;
|
|
public Action OnTycoonClosedEvent;
|
|
|
|
|
|
|
|
protected override void OnAwake()
|
|
{
|
|
InitializeComponents();
|
|
_levelDatas = InitializeDictionary(_levelDataSo.Datas, data => data.Idx);
|
|
_cardDatas = InitializeDictionary(_cardDataSo.Datas, data => data.Idx);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
if (!string.IsNullOrEmpty(_dailyBgm))
|
|
{
|
|
AudioManager.Instance.PlayBgm(_dailyBgm);
|
|
}
|
|
}
|
|
|
|
[Button("컴포넌트 초기화")]
|
|
private void InitializeComponents()
|
|
{
|
|
CustomerTableController = GetComponent<CustomerTableController>();
|
|
TycoonStageController = GetComponent<TycoonStageController>();
|
|
}
|
|
|
|
|
|
private Dictionary<string, T> InitializeDictionary<T>(List<T> dataList, Func<T, string> keySelector)
|
|
{
|
|
return dataList.ToDictionary(keySelector);
|
|
}
|
|
|
|
public T GetDataByIdx<T>(Dictionary<string, T> dataDictionary, string idx) where T : class
|
|
{
|
|
if (dataDictionary.TryGetValue(idx, out var data))
|
|
return data;
|
|
|
|
Debug.LogError($"{idx}와 일치하는 아이템이 없습니다.");
|
|
return null;
|
|
}
|
|
|
|
public int GetTotalItemCount<T>(Dictionary<string, T> dataDictionary)
|
|
{
|
|
return dataDictionary.Count;
|
|
}
|
|
|
|
public LevelData GetLevelDataByIdx(string idx) => GetDataByIdx(_levelDatas, idx);
|
|
public CardData GetCardDataByIdx(string idx) => GetDataByIdx(_cardDatas, idx);
|
|
|
|
}
|
|
} |