Scriptum/Assets/Scripts/REFACTORING/Application/UI/Task/TaskUIManager.cs

69 lines
1.6 KiB
C#
Raw Normal View History

2022-10-22 18:04:21 +02:00
using System;
using System.Collections.Generic;
2022-11-27 21:28:55 +01:00
using System.Linq;
2022-10-22 18:04:21 +02:00
using UnityEngine;
[Serializable]
public class TaskUIManager : UIBaseManager<Task>
{
public const string ITEM_LOCALIZATION = "UiPanels/";
public const string PANEL_NAME = "TaskPanel";
2022-11-27 21:28:55 +01:00
public static new TaskUIManager Instance { get; protected set; }
2022-12-21 12:19:57 +01:00
public override void Awake()
2022-11-27 21:28:55 +01:00
{
if (Instance == null)
{
Instance = this;
}
else
{
Destroy(gameObject);
}
}
2022-10-22 18:04:21 +02:00
public override void SetupPanel()
{
base.SetupPanel();
// setup models list
DynamicPanel.GetComponent<TaskPanelController>().SetUp(Elements);
}
public override void UpdateList()
2022-11-27 21:28:55 +01:00
{
// 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)
2022-10-22 18:04:21 +02:00
{
2022-11-27 21:28:55 +01:00
Elements.RemoveAll(task => task.Title == name);
UpdateList();
2022-10-22 18:04:21 +02:00
}
2022-11-27 21:28:55 +01:00
2022-10-22 18:04:21 +02:00
protected override GameObject GetTemplatePanel()
{
// Resources = default path - Asset/Resources ... .obj
return Resources.Load(ITEM_LOCALIZATION + PANEL_NAME) as GameObject;
}
2023-01-07 17:49:15 +01:00
public void ChangeTaskIssue(string taskName, string newContent)
{
Elements.Where(task => task.Title == taskName).First().description = newContent;
UpdateList();
}
2022-10-22 18:04:21 +02:00
}