2024-11-29 16:19:12 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class DutyItem : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Image dutyImage;
|
2024-11-30 23:32:17 +08:00
|
|
|
|
public Text dutyNameText;
|
2024-12-01 04:58:16 +08:00
|
|
|
|
public Button button;
|
2024-12-01 15:06:22 +08:00
|
|
|
|
public int leader;
|
2024-12-04 16:37:51 +08:00
|
|
|
|
public int dutyId;
|
2024-12-01 04:58:16 +08:00
|
|
|
|
public Color defaultColor = Color.white; // Ĭ<><C4AC><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
public Color addedColor = Color.gray; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
public Color selectedColor = Color.yellow; // ѡ<><D1A1><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
|
|
|
|
|
public string dutyName { get; private set; } // <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
|
|
|
|
|
private bool isAdded; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private bool isSelected; // <20>Ƿ<EFBFBD>ѡ<EFBFBD><D1A1>
|
|
|
|
|
|
|
|
|
|
public delegate void ClickHandler();
|
|
|
|
|
public event ClickHandler onClick; // <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
2024-11-29 16:19:12 +08:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2024-12-01 15:06:22 +08:00
|
|
|
|
|
2024-11-29 16:19:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
2024-12-01 15:06:22 +08:00
|
|
|
|
|
2024-11-29 16:19:12 +08:00
|
|
|
|
}
|
2024-12-01 04:58:16 +08:00
|
|
|
|
public void Setup(string name, bool added)
|
|
|
|
|
{
|
|
|
|
|
dutyName = name;
|
|
|
|
|
dutyNameText.text = name;
|
|
|
|
|
SetAdded(added);
|
|
|
|
|
button.onClick.AddListener(OnButtonClick);
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
public void SetAdded(bool added)
|
|
|
|
|
{
|
|
|
|
|
isAdded = added;
|
|
|
|
|
dutyNameText.color = isAdded ? addedColor : defaultColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>״̬
|
|
|
|
|
public void SetSelected(bool selected)
|
|
|
|
|
{
|
|
|
|
|
isSelected = selected;
|
|
|
|
|
dutyNameText.fontSize = isSelected ? 24 : 14; // ѡ<>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
dutyNameText.color = isSelected ? selectedColor : (isAdded ? addedColor : defaultColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
private void OnButtonClick()
|
|
|
|
|
{
|
|
|
|
|
onClick?.Invoke();
|
|
|
|
|
}
|
2024-12-01 15:06:22 +08:00
|
|
|
|
|
|
|
|
|
}
|