2024-12-05 16:31:46 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using DG.Tweening;
|
2024-12-06 11:52:15 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2024-12-26 17:37:30 +08:00
|
|
|
|
using UnityEngine.Windows;
|
|
|
|
|
|
2024-12-05 16:31:46 +08:00
|
|
|
|
|
|
|
|
|
public class TaskPanel : Base
|
|
|
|
|
{
|
2024-12-06 11:29:20 +08:00
|
|
|
|
public static TaskPanel instance;
|
|
|
|
|
|
2024-12-13 17:19:27 +08:00
|
|
|
|
public Transform contentTrans; // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public GameObject taskPrefab; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>
|
|
|
|
|
public JSONReader JSONReader; // JSON <20><><EFBFBD>ݶ<EFBFBD>ȡ<EFBFBD><C8A1>
|
2024-12-06 16:24:45 +08:00
|
|
|
|
|
2024-12-13 17:19:27 +08:00
|
|
|
|
public RectTransform buttonRect; // <20><>ť RectTransform
|
|
|
|
|
public Button hideBtn; // <20><><EFBFBD>ذ<EFBFBD>ť
|
2024-12-06 16:24:45 +08:00
|
|
|
|
|
2024-12-13 17:19:27 +08:00
|
|
|
|
private bool isHidden = false; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
public float moveDuration = 0.5f;
|
|
|
|
|
public float hidePositionX = 125f;
|
|
|
|
|
public float showPositionX = -198f;
|
2024-12-06 16:24:45 +08:00
|
|
|
|
|
2024-12-16 11:58:13 +08:00
|
|
|
|
public List<int> taskIDs = new List<int>();
|
|
|
|
|
|
2024-12-13 17:19:27 +08:00
|
|
|
|
private List<TaskItem> taskItems = new List<TaskItem>(); // <20><>ǰ<EFBFBD><C7B0>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
2024-12-05 16:31:46 +08:00
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2024-12-06 11:29:20 +08:00
|
|
|
|
instance = this;
|
2024-12-06 16:24:45 +08:00
|
|
|
|
hideBtn.onClick.AddListener(OnClickHideButton);
|
2024-12-26 17:37:30 +08:00
|
|
|
|
InitList();
|
|
|
|
|
InitTask(taskIDs);
|
2024-12-06 16:24:45 +08:00
|
|
|
|
}
|
2024-12-12 11:04:48 +08:00
|
|
|
|
|
2024-12-26 17:37:30 +08:00
|
|
|
|
public void InitList()
|
|
|
|
|
{
|
|
|
|
|
foreach (Task_ task in JSONReader.TaskDictionary.Values)
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(task.ID, out int taskId))
|
|
|
|
|
{
|
|
|
|
|
// ת<><D7AA><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD> taskIDs <20>б<EFBFBD>
|
|
|
|
|
taskIDs.Add(taskId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-19 15:04:19 +08:00
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public void Taskad(int id)
|
2024-12-16 11:58:13 +08:00
|
|
|
|
{
|
2024-12-19 15:04:19 +08:00
|
|
|
|
taskIDs.Add(id);
|
|
|
|
|
InitTask(taskIDs);
|
2024-12-16 11:58:13 +08:00
|
|
|
|
}
|
2024-12-19 15:04:19 +08:00
|
|
|
|
|
|
|
|
|
|
2024-12-13 17:19:27 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
2024-12-06 16:24:45 +08:00
|
|
|
|
public void OnClickHideButton()
|
|
|
|
|
{
|
|
|
|
|
if (isHidden)
|
|
|
|
|
{
|
|
|
|
|
buttonRect.DOAnchorPosX(showPositionX, moveDuration).SetEase(Ease.InOutCubic);
|
2024-12-09 09:46:52 +08:00
|
|
|
|
hideBtn.transform.Rotate(0, 0, 180f);
|
2024-12-13 17:19:27 +08:00
|
|
|
|
isHidden = false;
|
2024-12-06 16:24:45 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
buttonRect.DOAnchorPosX(hidePositionX, moveDuration).SetEase(Ease.InOutCubic);
|
2024-12-09 09:46:52 +08:00
|
|
|
|
hideBtn.transform.Rotate(0, 0, 180f);
|
2024-12-13 17:19:27 +08:00
|
|
|
|
isHidden = true;
|
2024-12-06 16:24:45 +08:00
|
|
|
|
}
|
2024-12-05 20:21:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-13 17:19:27 +08:00
|
|
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|
|
|
|
public async void InitTask(List<int> taskIds)
|
2024-12-05 20:21:15 +08:00
|
|
|
|
{
|
2024-12-13 17:19:27 +08:00
|
|
|
|
await ClearTaskItems();
|
|
|
|
|
foreach (int id in taskIds)
|
2024-12-05 20:21:15 +08:00
|
|
|
|
{
|
2024-12-13 17:19:27 +08:00
|
|
|
|
AddTask(id);
|
2024-12-11 14:24:06 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-26 17:37:30 +08:00
|
|
|
|
|
2024-12-19 15:04:19 +08:00
|
|
|
|
// <20><>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>
|
2024-12-13 17:19:27 +08:00
|
|
|
|
public void AddTask(int taskId)
|
2024-12-11 14:24:06 +08:00
|
|
|
|
{
|
2024-12-13 17:19:27 +08:00
|
|
|
|
GameObject go = Instantiate(taskPrefab, contentTrans);
|
|
|
|
|
TaskItem taskItem = go.GetComponent<TaskItem>();
|
|
|
|
|
taskItem.SetInfo(taskId, JSONReader);
|
|
|
|
|
taskItems.Add(taskItem);
|
2024-12-26 17:37:30 +08:00
|
|
|
|
go.SetActive(false);
|
2024-12-05 16:31:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-13 17:19:27 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UI
|
|
|
|
|
public void UpdateTaskUI(TaskItem taskItem)
|
2024-12-06 11:52:15 +08:00
|
|
|
|
{
|
2024-12-13 17:19:27 +08:00
|
|
|
|
// <20><><EFBFBD>Ҷ<EFBFBD>Ӧ<EFBFBD><D3A6>UI<55><EFBFBD><EEA3AC><EFBFBD>½<EFBFBD><C2BD>Ȼ<EFBFBD>״̬
|
|
|
|
|
TaskItem item = taskItems.Find(t => t.taskId == taskItem.taskId);
|
|
|
|
|
if (item != null)
|
2024-12-06 11:52:15 +08:00
|
|
|
|
{
|
2024-12-13 17:19:27 +08:00
|
|
|
|
item.UpdateTxt();
|
2024-12-06 11:52:15 +08:00
|
|
|
|
}
|
2024-12-06 11:29:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-26 17:37:30 +08:00
|
|
|
|
public void displaytask(int taskId)
|
|
|
|
|
{
|
|
|
|
|
TaskItem taskItem = taskItems.Find(t => t.overseeCond== taskId);
|
|
|
|
|
if (taskItem != null)
|
|
|
|
|
{
|
|
|
|
|
if (taskItem.ishow == 1)
|
|
|
|
|
{
|
|
|
|
|
taskItem.gameObject.SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-13 17:19:27 +08:00
|
|
|
|
// <20>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD>
|
2024-12-12 14:50:53 +08:00
|
|
|
|
public void RemoveTask(int taskId)
|
|
|
|
|
{
|
2024-12-13 17:19:27 +08:00
|
|
|
|
TaskItem taskItem = taskItems.Find(t => t.taskId == taskId);
|
|
|
|
|
if (taskItem != null)
|
2024-12-12 14:50:53 +08:00
|
|
|
|
{
|
2024-12-13 17:19:27 +08:00
|
|
|
|
taskItems.Remove(taskItem);
|
|
|
|
|
Destroy(taskItem.gameObject);
|
2024-12-12 14:50:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-13 17:19:27 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public async Task ClearTaskItems()
|
2024-12-05 16:31:46 +08:00
|
|
|
|
{
|
2024-12-13 17:19:27 +08:00
|
|
|
|
foreach (Transform child in contentTrans)
|
2024-12-06 11:29:20 +08:00
|
|
|
|
{
|
2024-12-13 17:19:27 +08:00
|
|
|
|
Destroy(child.gameObject);
|
2024-12-06 11:29:20 +08:00
|
|
|
|
}
|
2024-12-13 17:19:27 +08:00
|
|
|
|
taskItems.Clear();
|
|
|
|
|
await Task.Delay(10);
|
2024-12-05 16:31:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|