2024-05-02 07:36:39 +00:00
|
|
|
using System;
|
2023-08-10 06:39:59 +00:00
|
|
|
using System.Collections.Generic;
|
2024-05-02 07:36:39 +00:00
|
|
|
using System.IO;
|
2024-04-15 16:03:56 +00:00
|
|
|
using System.Linq;
|
2024-05-02 07:36:39 +00:00
|
|
|
using Newtonsoft.Json;
|
2023-08-17 03:42:12 +00:00
|
|
|
using Sirenix.OdinInspector;
|
2024-05-02 07:36:39 +00:00
|
|
|
using UnityEditor;
|
2023-08-10 06:39:59 +00:00
|
|
|
using UnityEngine;
|
2024-04-30 00:11:59 +00:00
|
|
|
using UnityEngine.SceneManagement;
|
2023-08-10 06:39:59 +00:00
|
|
|
|
2023-08-31 06:46:13 +00:00
|
|
|
// ReSharper disable once CheckNamespace
|
|
|
|
namespace BlueWaterProject
|
2023-08-10 06:39:59 +00:00
|
|
|
{
|
2023-08-31 06:46:13 +00:00
|
|
|
public class DataManager : Singleton<DataManager>
|
|
|
|
{
|
2024-01-02 21:39:53 +00:00
|
|
|
[field: Title("Inventory")]
|
2024-04-30 00:11:59 +00:00
|
|
|
[field: SerializeField] public PlayerInventory OceanInventory { get; private set; } = new();
|
|
|
|
[field: SerializeField] public PlayerInventory CombatInventory { get; private set; } = new();
|
|
|
|
public PlayerInventory CurrentInventory { get; set; }
|
2024-01-18 09:01:04 +00:00
|
|
|
public int Gold { get; set; } = 0;
|
2023-08-23 01:10:33 +00:00
|
|
|
|
2023-08-31 06:46:13 +00:00
|
|
|
[Title("DataBase", "GameObject")]
|
|
|
|
public GameObject mouseSpot;
|
|
|
|
public GameObject boat;
|
|
|
|
public GameObject assaultCard;
|
2023-09-11 01:55:36 +00:00
|
|
|
public GameObject radarTargetUi;
|
2023-10-30 15:45:05 +00:00
|
|
|
public GameObject vomit;
|
2023-09-11 01:55:36 +00:00
|
|
|
|
|
|
|
[Title("DataBase", "Particle")]
|
|
|
|
public GameObject nukeFire;
|
|
|
|
public GameObject grenadeFire;
|
2024-01-02 08:17:10 +00:00
|
|
|
public GameObject emojiHeart;
|
|
|
|
public GameObject emojiPuke;
|
|
|
|
public GameObject emojiAnger;
|
2023-09-11 01:55:36 +00:00
|
|
|
|
2023-08-31 06:46:13 +00:00
|
|
|
[Title("DataBase", "Sprites")]
|
|
|
|
public Sprite[] cardType;
|
|
|
|
public Texture2D cursorTexture;
|
2023-09-12 05:37:15 +00:00
|
|
|
public Sprite enemyMarker;
|
2024-01-21 09:05:43 +00:00
|
|
|
public Sprite scallion;
|
|
|
|
public Sprite tomato;
|
|
|
|
public Sprite onion;
|
|
|
|
public Sprite kingCrabMeat;
|
2024-01-22 03:06:16 +00:00
|
|
|
public Sprite beer;
|
2024-05-02 07:36:39 +00:00
|
|
|
|
|
|
|
[Title("DataBase", "UI")]
|
|
|
|
public UiDataBase UiDataBaseSo { get; private set; }
|
|
|
|
|
|
|
|
[field: Space(5)]
|
2024-04-15 16:03:56 +00:00
|
|
|
[field: SerializeField] public NpcDataSO NpcDataSo { get; private set; }
|
|
|
|
|
2024-01-02 21:39:53 +00:00
|
|
|
private void Init()
|
2023-08-31 06:46:13 +00:00
|
|
|
{
|
2024-04-30 00:11:59 +00:00
|
|
|
if (SceneManager.GetActiveScene().name == "02.Ocean")
|
|
|
|
{
|
|
|
|
CurrentInventory = OceanInventory;
|
|
|
|
}
|
|
|
|
else if (SceneManager.GetActiveScene().name == "02.Combat_2D")
|
|
|
|
{
|
|
|
|
CurrentInventory = CombatInventory;
|
|
|
|
}
|
2023-08-31 06:46:13 +00:00
|
|
|
}
|
2023-08-29 03:41:24 +00:00
|
|
|
|
2024-01-02 21:39:53 +00:00
|
|
|
protected override void OnAwake()
|
2023-08-29 03:41:24 +00:00
|
|
|
{
|
2024-01-02 21:39:53 +00:00
|
|
|
Init();
|
2024-01-24 02:08:45 +00:00
|
|
|
if (gameObject.GetComponent<Upd>() == null)
|
|
|
|
{
|
|
|
|
gameObject.AddComponent<Upd>();
|
|
|
|
}
|
2023-08-29 03:41:24 +00:00
|
|
|
}
|
2024-04-15 16:03:56 +00:00
|
|
|
|
|
|
|
public NpcData GetNpcData(int idx)
|
|
|
|
{
|
|
|
|
var data = NpcDataSo.npcDataList.FirstOrDefault(d => d.idx == idx);
|
|
|
|
if(data == null)
|
|
|
|
{
|
|
|
|
Debug.LogWarning($"NPC Data for index {idx} not found.");
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2024-01-24 02:08:45 +00:00
|
|
|
|
2023-08-31 06:46:13 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Dictionary 초기화 함수
|
|
|
|
/// </summary>
|
|
|
|
private Dictionary<string, T> CreateDictionaryFromList<T>(List<T> list, int capacity) where T : IIdx
|
|
|
|
{
|
|
|
|
var newDictionary = new Dictionary<string, T>(capacity);
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
{
|
|
|
|
newDictionary.Add(item.Idx, item);
|
|
|
|
}
|
2023-08-29 03:41:24 +00:00
|
|
|
|
2023-08-31 06:46:13 +00:00
|
|
|
return newDictionary;
|
|
|
|
}
|
2024-04-22 17:52:54 +00:00
|
|
|
|
|
|
|
[ContextMenu("Json To So")]
|
|
|
|
public void MakeDataSoFromJson()
|
|
|
|
{
|
2024-05-02 07:36:39 +00:00
|
|
|
NpcDataSo.npcDataList = GetJsonData<List<NpcData>>("JSON/customer_table.json");
|
|
|
|
|
|
|
|
#if UNITY_EDITOR_OSX || UNITY_EDITOR_WIN
|
|
|
|
EditorUtility.SetDirty(NpcDataSo);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
private static T GetJsonData<T>(string path)
|
|
|
|
{
|
|
|
|
var jsonString = File.ReadAllText(SystemPath.GetPath(path));
|
|
|
|
var data = JsonConvert.DeserializeObject<T>(jsonString);
|
|
|
|
return data;
|
2024-04-22 17:52:54 +00:00
|
|
|
}
|
2023-08-31 06:46:13 +00:00
|
|
|
}
|
2023-08-10 06:39:59 +00:00
|
|
|
}
|