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.
49 lines
1.1 KiB
49 lines
1.1 KiB
4 years ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class FireScaleValue : MonoBehaviour {
|
||
|
public static event Func<FloatData, FloatData> GetAllFireScales;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 取得过火面积
|
||
|
/// </summary>
|
||
|
public static float BurnedArea
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
FloatData area = new FloatData(0);
|
||
|
if (GetAllFireScales != null)
|
||
|
{
|
||
|
area = GetAllFireScales(area);
|
||
|
}
|
||
|
return area.value;
|
||
|
}
|
||
|
}
|
||
|
void OnEnable()
|
||
|
{
|
||
|
FloatData area = new FloatData(0);
|
||
|
if (GetAllFireScales != null)
|
||
|
{
|
||
|
area = GetAllFireScales(area);
|
||
|
}
|
||
|
GetComponent<Text>().text = area.value.ToString() + " 平方米";
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 统计过火面积、流量等使用,封装float为引用类型
|
||
|
/// </summary>
|
||
|
public class FloatData
|
||
|
{
|
||
|
public float value;
|
||
|
public FloatData(float areaValue)
|
||
|
{
|
||
|
value = areaValue;
|
||
|
}
|
||
|
public void Clear()
|
||
|
{
|
||
|
value = 0;
|
||
|
}
|
||
|
}
|