OldBlueWater/BlueWater/Assets/02.Scripts/UiManager.cs

68 lines
2.0 KiB
C#
Raw Normal View History

2023-08-17 03:42:12 +00:00
using Doozy.Runtime.Reactor.Animators;
using Sirenix.OdinInspector;
2023-08-17 03:42:12 +00:00
using UnityEngine;
2023-08-31 06:46:13 +00:00
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
2023-08-17 03:42:12 +00:00
{
2023-08-31 06:46:13 +00:00
public class UiManager : Singleton<UiManager>
{
[Title("Card")]
private Transform cardLayoutGroup;
public UIAnimator CardLayoutGroupAnimator { get; set; }
2023-08-31 06:46:13 +00:00
[Title("TakeAim")]
private GameObject takeAim;
private Texture2D cursorTexture;
private bool isTakeAim;
2023-08-17 03:42:12 +00:00
2023-08-31 06:46:13 +00:00
private void Init()
{
cardLayoutGroup = transform.Find("CardLayoutGroup");
CardLayoutGroupAnimator = cardLayoutGroup.GetComponent<UIAnimator>();
takeAim = transform.Find("Aim").gameObject;
}
2023-08-17 03:42:12 +00:00
2023-08-31 06:46:13 +00:00
protected override void OnAwake()
{
Init();
}
2023-08-29 04:23:27 +00:00
2023-08-31 06:46:13 +00:00
private void Start()
{
CursorTextureChange();
AssaultCardInit();
}
2023-08-17 03:42:12 +00:00
2023-08-31 06:46:13 +00:00
public void AddCard() //TODO Test button and function, delete later
{
Instantiate(DataManager.Inst.assaultCard, cardLayoutGroup);
}
2023-08-31 06:46:13 +00:00
public void AimOnOff(bool isOn)
{
takeAim.SetActive(isOn);
isTakeAim = isOn;
}
2023-08-30 15:36:22 +00:00
2023-08-31 06:46:13 +00:00
private void CursorTextureChange()
{
cursorTexture = DataManager.Inst.cursorTexture;
//var hotSpot = new Vector2(cursorTexture.width / 2f, cursorTexture.height / 2f);
var hotSpot = Vector2.zero;
Cursor.SetCursor(cursorTexture, hotSpot, CursorMode.Auto);
}
2023-08-30 15:36:22 +00:00
2023-08-31 06:46:13 +00:00
private void AssaultCardInit()
2023-08-30 15:36:22 +00:00
{
2023-08-31 06:46:13 +00:00
for (int i = 0; i < DataManager.Inst.CardList.Count; i++)
{
var obj = Instantiate(DataManager.Inst.assaultCard, cardLayoutGroup);
var draggableCard = obj.GetComponent<DraggableCard>();
draggableCard.card = DataManager.Inst.GetCardDictionaryFromKey(DataManager.Inst.CardList[i]);
draggableCard.CardInit();
}
2023-08-30 15:36:22 +00:00
}
}
2023-08-17 03:42:12 +00:00
}