2022-10-22 18:04:21 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
using System;
|
|
|
|
|
2022-11-06 21:34:17 +01:00
|
|
|
public class TaskPanelController : PanelController<Task>
|
2022-10-22 18:04:21 +02:00
|
|
|
{
|
2022-11-06 21:34:17 +01:00
|
|
|
protected override UIBaseManager<Task> FetchUiManager() // check if need return by ref
|
2022-10-22 18:04:21 +02:00
|
|
|
{
|
|
|
|
var uiManager = GameObject.FindObjectOfType<TaskUIManager>();
|
|
|
|
|
|
|
|
// uiManager.SetPanelController(gameObject); - unnecessary
|
|
|
|
|
|
|
|
return uiManager;
|
|
|
|
}
|
2022-11-06 21:34:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
public override void BuildPanelContent(List<Task> elements)
|
2022-10-22 18:04:21 +02:00
|
|
|
{
|
2022-11-06 21:34:17 +01:00
|
|
|
base.BuildPanelContent(elements);
|
2022-10-22 18:04:21 +02:00
|
|
|
|
2022-11-27 21:28:55 +01:00
|
|
|
ClearSlots();
|
|
|
|
|
2022-11-06 21:34:17 +01:00
|
|
|
for (int i = 0; i < elements.Count; i++)
|
2022-10-22 18:04:21 +02:00
|
|
|
{
|
2022-11-06 21:34:17 +01:00
|
|
|
this.AddTask(elements[i]);
|
2022-10-22 18:04:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-06 21:34:17 +01:00
|
|
|
public void AddTask(Task _task)
|
|
|
|
{
|
|
|
|
// update TaskManager main list of task
|
|
|
|
//TaskManager.Instance.AddTask(_task);
|
|
|
|
|
|
|
|
// add task to local panel contant
|
|
|
|
GameObject newTaskBox = SetupTaskBox(_task);
|
|
|
|
|
|
|
|
// Set new Slot instance
|
|
|
|
ChildBoxList.Add(newTaskBox);
|
|
|
|
}
|
|
|
|
|
2022-10-22 18:04:21 +02:00
|
|
|
protected GameObject SetupTaskBox(Task _task)
|
|
|
|
{
|
2022-11-06 21:34:17 +01:00
|
|
|
if (ChildBoxTemplate == null)
|
2022-10-22 18:04:21 +02:00
|
|
|
throw new Exception("taskbox_template is empty");
|
|
|
|
|
2022-11-06 21:34:17 +01:00
|
|
|
GameObject _newTaskBox = MonoBehaviour.Instantiate(ChildBoxTemplate, _panelContent.transform.position, Quaternion.identity); //.GetComponent<TaskBox>();
|
2022-10-22 18:04:21 +02:00
|
|
|
|
|
|
|
_newTaskBox.transform.SetParent(_panelContent.transform);
|
|
|
|
|
|
|
|
_newTaskBox.transform.localScale = new Vector3(2.5f, 2.5f, 1.0f);
|
|
|
|
|
|
|
|
_newTaskBox.GetComponent<TaskBox>().SetTask(_task);
|
|
|
|
|
|
|
|
return _newTaskBox;
|
|
|
|
}
|
|
|
|
|
2022-11-06 21:34:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
// Ignored methods
|
|
|
|
public override void BuildPanelSlots()
|
2022-10-22 18:04:21 +02:00
|
|
|
{
|
2022-11-06 21:34:17 +01:00
|
|
|
return;
|
2022-10-22 18:04:21 +02:00
|
|
|
}
|
|
|
|
|
2022-11-06 21:34:17 +01:00
|
|
|
public override GameObject BuildSlot(int key, GameObject _parent)
|
2022-10-22 18:04:21 +02:00
|
|
|
{
|
2022-11-06 21:34:17 +01:00
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
2022-10-22 18:04:21 +02:00
|
|
|
|
2022-11-06 21:34:17 +01:00
|
|
|
public override void ClearSlots()
|
|
|
|
{
|
2022-11-27 21:28:55 +01:00
|
|
|
foreach(var taskObj in ChildBoxList)
|
|
|
|
{
|
|
|
|
DestroyImmediate(taskObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
ChildBoxList.Clear();
|
2022-10-22 18:04:21 +02:00
|
|
|
}
|
|
|
|
}
|