This commit is contained in:
lq 2024-11-29 09:44:45 +08:00
parent dddce7611a
commit 55d17b0835
7 changed files with 235 additions and 0 deletions

View File

@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ArrangementItem : MonoBehaviour
{
public Image image;
public Text name;
public Text duty;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DateItem : MonoBehaviour
{
public Text dateText;
CalendarPanel calendarPanel;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void OnDaySelected(int day)
{
DateTime selectedDate = new DateTime(calendarPanel.currentDate.Year, calendarPanel.currentDate.Month, day);
calendarPanel.selectedDateText.text = "Ñ¡ÔñµÄÈÕÆÚ: " + selectedDate.ToString("yyyyÄêMMÔÂddÈÕ");
}
}

View File

@ -0,0 +1,62 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MaterialItem : MonoBehaviour
{
[Header("组件")]
public Text materialText; // 显示物资数量的文本
public Image materialImage; // 物资图标
public Text materialNameText; // 物资名称文本
public Image hightImage; // 高亮图像
[Header("数据")]
public int materialNum = 0; // 物资数量
public string materialName; // 物资名称
// Start is called before the first frame update
void Start()
{
materialText.text = materialNum.ToString(); // 初始化数量显示
UpdateHighlightImage(); // 初始化高亮图像
}
// 增加物资数量
public void AddNum()
{
materialNum++;
materialText.text = materialNum.ToString();
UpdateHighlightImage(); // 更新高亮图像
}
// 减少物资数量
public void SubtractNum()
{
if (materialNum > 0)
{
materialNum--;
materialText.text = materialNum.ToString();
UpdateHighlightImage(); // 更新高亮图像
}
}
// 更新高亮图像的显示状态
private void UpdateHighlightImage()
{
if (materialNum > 0)
{
hightImage.gameObject.SetActive(true); // 显示高亮图像
}
else
{
hightImage.gameObject.SetActive(false); // 隐藏高亮图像
}
}
// 获取物资数量
public int GetMaterialNum()
{
return materialNum;
}
}

View File

@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PeopleItem : MonoBehaviour
{
public Text nameText; // 人员名字显示
public Button button; // 按钮,用来选择人员
public Color defaultColor = Color.white; // 默认颜色
public Color addedColor = Color.gray; // 已添加颜色
public Color selectedColor = Color.yellow; // 选中颜色
public string Name { get; private set; } // 角色名字
private bool isAdded; // 是否已添加
private bool isSelected; // 是否选中
public delegate void ClickHandler();
public event ClickHandler onClick; // 点击事件
// 设置人员项
public void Setup(string name, bool added)
{
Name = name;
nameText.text = name;
SetAdded(added);
button.onClick.AddListener(OnButtonClick);
}
// 设置已添加状态
public void SetAdded(bool added)
{
isAdded = added;
nameText.color = isAdded ? addedColor : defaultColor;
}
// 设置选中状态
public void SetSelected(bool selected)
{
isSelected = selected;
nameText.fontSize = isSelected ? 24 : 14; // 选中后字体增大
nameText.color = isSelected ? selectedColor : (isAdded ? addedColor : defaultColor);
}
// 按钮点击事件
private void OnButtonClick()
{
onClick?.Invoke();
}
}

View File

@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PersonnelItem : MonoBehaviour
{
public Text sceneText;
public Image personnelImage;
public Text personnelNum;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SceneItem : MonoBehaviour
{
public Text sceneName;
public Image sceneImage;
public Image maskImage;
public bool IsOpen { get; set; } = true;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Tools : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
//ʵÀý»¯Ô¤ÖÆÌå
public void InstantiatePrefab(GameObject prefab, Transform content, int Num)
{
for (int i = 0; i < Num; i++)
{
GameObject item = GameObject.Instantiate<GameObject>(prefab, content);
}
}
}