Scriptum/Assets/Scripts/REFACTORING/Application/UI/Task/TaskUIManager.cs
2022-12-21 12:20:49 +01:00

61 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
[Serializable]
public class TaskUIManager : UIBaseManager<Task>
{
public const string ITEM_LOCALIZATION = "UiPanels/";
public const string PANEL_NAME = "TaskPanel";
public static new TaskUIManager Instance { get; protected set; }
public override void Awake()
{
if (Instance == null)
{
Instance = this;
}
else
{
Destroy(gameObject);
}
}
public override void SetupPanel()
{
base.SetupPanel();
// setup models list
DynamicPanel.GetComponent<TaskPanelController>().SetUp(Elements);
}
public override void UpdateList()
{
// condition for situation where eg player want to pick up item when inventory / equipment is closed
if (DynamicPanel)
DynamicPanel.GetComponent<TaskPanelController>().BuildPanelContent(Elements);
}
public List<Task> FindTaskByName(string taskTitle)
{
return Elements.Where(task => task.Title == taskTitle).ToList();
}
public void RemoveByName(string name)
{
Elements.RemoveAll(task => task.Title == name);
UpdateList();
}
protected override GameObject GetTemplatePanel()
{
// Resources = default path - Asset/Resources ... .obj
return Resources.Load(ITEM_LOCALIZATION + PANEL_NAME) as GameObject;
}
}