using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class RescuedValue : MonoBehaviour { private IntData trappedData = new IntData(0); private IntData woundedData = new IntData(0); public static event Func getAllRescuedTrapped; public static event Func getAllRescuedWounded; void OnEnable() { trappedData.Clear(); woundedData.Clear(); if(getAllRescuedTrapped != null) { trappedData = getAllRescuedTrapped(trappedData); } if (getAllRescuedWounded != null) { woundedData = getAllRescuedWounded(woundedData); } GetComponent().text = "重伤员" + woundedData.value.ToString() + "人,轻伤员" + trappedData.value.ToString() + "人"; } } /// /// 统计人员数用,封装int为引用类型 /// public class IntData { public int value; public IntData(int initValue) { value = initValue; } public void Clear() { value = 0; } }