|
|
|
using AX.MessageSystem;
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
public class WoundedInfo : MonoBehaviour
|
|
|
|
{
|
|
|
|
public Text woundedAll;
|
|
|
|
public Text woundedRescued;
|
|
|
|
public Text woundedUnrescued;
|
|
|
|
public static event Func<IntData, IntData> getAllWoundedCount;
|
|
|
|
public static event Func<IntData, IntData> getWoundedRescuedCount;
|
|
|
|
public static event Func<IntData, IntData> getWoundedUnrescuedCount;
|
|
|
|
void Awake()
|
|
|
|
{
|
|
|
|
woundedAll = transform.Find("WoundedAll").GetComponent<Text>();
|
|
|
|
woundedRescued = transform.Find("WoundedRescued").GetComponent<Text>();
|
|
|
|
woundedUnrescued = transform.Find("WoundedUnrescued").GetComponent<Text>();
|
|
|
|
MessageDispatcher.AddListener("SomeoneOutOfTrap", UpdateInfoListener); //开启窗口时,每当有人被营救,更新显示信息
|
|
|
|
}
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
|
|
|
MessageDispatcher.RemoveListener("SomeoneOutOfTrap", UpdateInfoListener); //开启窗口时,每当有人被营救,更新显示信息
|
|
|
|
}
|
|
|
|
private void OnEnable()
|
|
|
|
{
|
|
|
|
UpdateInfo();
|
|
|
|
}
|
|
|
|
void UpdateInfoListener(IMessage obj)
|
|
|
|
{
|
|
|
|
UpdateInfo();
|
|
|
|
}
|
|
|
|
void UpdateInfo()
|
|
|
|
{
|
|
|
|
IntData dataAll = new IntData(0);
|
|
|
|
if (getAllWoundedCount != null)
|
|
|
|
{
|
|
|
|
dataAll = getAllWoundedCount(dataAll);
|
|
|
|
}
|
|
|
|
woundedAll.text = dataAll.value.ToString();
|
|
|
|
|
|
|
|
IntData dataRescued = new IntData(0);
|
|
|
|
if (getWoundedRescuedCount != null)
|
|
|
|
{
|
|
|
|
dataRescued = getWoundedRescuedCount(dataRescued);
|
|
|
|
}
|
|
|
|
woundedRescued.text = dataRescued.value.ToString();
|
|
|
|
|
|
|
|
woundedUnrescued.text = (dataAll.value - dataRescued.value).ToString();
|
|
|
|
}
|
|
|
|
}
|