Scriptum/Assets/Scripts/REFACTORING/Application/UI/Task/TaskUIManager.cs
2023-01-10 04:21:36 +01:00

69 lines
1.6 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;
}
public void ChangeTaskIssue(string taskName, string newContent)
{
Elements.Where(task => task.Title == taskName).First().description = newContent;
UpdateList();
}
}