using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using static UnityEditor.Experimental.GraphView.GraphView; using static UnityEngine.GraphicsBuffer; public class UseObjects : MonoBehaviour { private Transform parentObject; // 父物体(包含所有子物体) private GameObject player;//玩家 public JSONReader js; //警戒物品使用 public GameObject warningPrefab; // 警戒锥道具模型 public GameObject polePrefab; // 警戒杆道具模型 public GameObject tapePrefab; // 隔离警示带模型 public float maxDistance = 10f; // 最大直接距离10米 public bool hasTape = false; // 是否携带隔离警示带 private List warningObjects = new List(); // 存储所有警戒类道具 //物品交付 public List potentialTargets; // 所有可能成为交付对象的目标列表 public Button deliverButton; // 交付按钮 public float deliveryRange = 1f; // 交付范围半径 private GameObject currentTarget; // 当前最近的交付目标 private bool islogistics;//角色是否为后勤保障组; private bool isdelivery;//是否开启交付 [System.Serializable] public class EmergencyItem { public string itemName; // 道具名称 public bool isConsumable; // 是否消耗品 (1=是,0=否) public int validTime; // 有效时间:-1(无限),0 或正数(有限时间) } // 模拟物品的字段配置 public Dictionary itemConfigs = new Dictionary(); void Start() { parentObject = GameObject.Find("fireEquip").transform; player=GameObject.FindGameObjectWithTag("Player"); // 初始化模拟物品数据 InitializeItemConfigs(3001); // 隐藏交付按钮 deliverButton.gameObject.SetActive(false); deliverButton.onClick.AddListener(HandleDelivery); // 为每个子物体添加点击事件 foreach (Transform child in parentObject) { Button childButton = child.GetComponent