You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
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<IntData, IntData> getAllRescuedTrapped; |
|
public static event Func<IntData, IntData> getAllRescuedWounded; |
|
void OnEnable() |
|
{ |
|
trappedData.Clear(); |
|
woundedData.Clear(); |
|
if(getAllRescuedTrapped != null) |
|
{ |
|
trappedData = getAllRescuedTrapped(trappedData); |
|
} |
|
if (getAllRescuedWounded != null) |
|
{ |
|
woundedData = getAllRescuedWounded(woundedData); |
|
} |
|
GetComponent<Text>().text = "重伤员" + woundedData.value.ToString() + "人,轻伤员" + trappedData.value.ToString() + "人"; |
|
} |
|
} |
|
/// <summary> |
|
/// 统计人员数用,封装int为引用类型 |
|
/// </summary> |
|
public class IntData |
|
{ |
|
public int value; |
|
public IntData(int initValue) |
|
{ |
|
value = initValue; |
|
} |
|
public void Clear() |
|
{ |
|
value = 0; |
|
} |
|
}
|
|
|