57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using Data.ScriptableObjects;
|
|
using Types.Items;
|
|
using UnityEngine;
|
|
|
|
|
|
// DebugManager is a singleton that persists between scenes and is used to log debug messages.
|
|
// It is used to trigger events for testing purposes. As well as give items to the player.
|
|
// It is also used to spawn items in the world.
|
|
namespace Managers
|
|
{
|
|
public class DebugManager : MonoBehaviour
|
|
{
|
|
public PlayerManager playerManager;
|
|
public static DebugManager Instance { get; private set; }
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
HotkeyManager.Instance.RegisterHotkey("Give Random Item", KeyCode.F2, GiveRandomItem);
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
private void GiveRandomItem()
|
|
{
|
|
var item = ItemDatabase.Instance.GetRandomItemByType(ItemType.Consumable);
|
|
|
|
// playerManager.AddItemToInventorySlot(item);
|
|
}
|
|
|
|
public void SpawnItemInWorld(GameItem item)
|
|
{
|
|
var itemPrefab = PrefabManager.Instance.GetItemPrefab();
|
|
Instantiate(itemPrefab, new Vector3(0, 0, 0), Quaternion.identity);
|
|
// todo: assign to a tile in the world
|
|
}
|
|
|
|
public void SpawnItemInWorld(GameItem item, Vector3 position)
|
|
{
|
|
var itemPrefab = PrefabManager.Instance.GetItemPrefab();
|
|
Instantiate(itemPrefab, position, Quaternion.identity);
|
|
}
|
|
|
|
// spawn box in world with random items in it
|
|
public void SpawnBoxInWorld()
|
|
{
|
|
// var boxPrefab = PrefabManager.Instance.GetBoxPrefab();
|
|
// Instantiate(boxPrefab, new Vector3(0, 0, 0), Quaternion.identity);
|
|
}
|
|
}
|
|
} |