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.
97 lines
4.0 KiB
97 lines
4.0 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using AX.MessageSystem; |
|
using System; |
|
using UnityEngine.UI; |
|
|
|
public class EngineItem : MonoBehaviour |
|
{ |
|
|
|
public Organization org; |
|
public KeyValuePair<FireCarEngine, int> tpyeCar = new KeyValuePair<FireCarEngine, int>(); |
|
// Use this for initialization |
|
void Start() |
|
{ |
|
MessageDispatcher.AddListener("UPDATE_FIREDEPLOY_EMGINE", UpadteFireDeployEngine); |
|
} |
|
|
|
private void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("UPDATE_FIREDEPLOY_EMGINE", UpadteFireDeployEngine); |
|
} |
|
|
|
private void UpadteFireDeployEngine(IMessage obj) |
|
{ |
|
var data = (KeyValuePair<FireCarEngine, Organization>)obj.Data; |
|
|
|
if (data.Key != null) |
|
{//车辆 |
|
//克隆一个,数量少一个,更改数据层;保证下一次打开作战部署窗口读取的数据正确 |
|
if (org == data.Value && tpyeCar.Key == data.Key) |
|
{ |
|
for (int i = 0; i < FireEnginesData.Instance.GetAllCas()[data.Value.DisplayName].Count; i++) |
|
{ |
|
if (FireEnginesData.Instance.GetAllCas()[data.Value.DisplayName][i].Key.TypeName == data.Key.TypeName) |
|
{ |
|
FireEnginesData.Instance.GetAllCas()[data.Value.DisplayName][i] = |
|
new KeyValuePair<FireCarEngine, int>(FireEnginesData.Instance.GetAllCas()[data.Value.DisplayName][i].Key, |
|
FireEnginesData.Instance.GetAllCas()[data.Value.DisplayName][i].Value - 1); |
|
|
|
//更新UI |
|
if (FireEnginesData.Instance.GetAllCas().ContainsKey(data.Value.DisplayName)) |
|
{ |
|
transform.Find("Text").GetComponent<Text>().text = |
|
FireEnginesData.Instance.GetAllCas()[data.Value.DisplayName][i].Key.TypeName + |
|
"(" + |
|
FireEnginesData.Instance.GetAllCas()[data.Value.DisplayName][i].Value |
|
+ ")"; |
|
} |
|
} |
|
} |
|
} |
|
|
|
} |
|
else |
|
{//消防员 |
|
if (org == data.Value && tpyeCar.Key == null) |
|
{ |
|
if (GameSettings.othersSettings.mode == Mode.manoeuvre) |
|
{ |
|
if (GameSettings.othersSettings.FireEngines_Dic.ContainsKey(data.Value.DisplayName)) |
|
{ |
|
GameSettings.othersSettings.FireEngines_Dic[data.Value.DisplayName] = |
|
GameSettings.othersSettings.FireEngines_Dic[data.Value.DisplayName] - 1; |
|
} |
|
//更新UI |
|
if (FireEnginesData.Instance.GetAllPersons().ContainsKey(data.Value.DisplayName)) |
|
{ |
|
transform.Find("Text").GetComponent<Text>().text = |
|
"消防员" + "(" + GameSettings.othersSettings.FireEngines_Dic[data.Value.DisplayName] + ")"; |
|
} |
|
} |
|
else |
|
{ |
|
//克隆一个,数量少一个,更改数据层;保证下一次打开作战部署窗口读取的数据正确 |
|
if (FireEnginesData.Instance.GetAllPersons().ContainsKey(data.Value.DisplayName)) |
|
{ |
|
FireEnginesData.Instance.GetAllPersons()[data.Value.DisplayName] = |
|
FireEnginesData.Instance.GetAllPersons()[data.Value.DisplayName] - 1; |
|
} |
|
//更新UI |
|
if (FireEnginesData.Instance.GetAllPersons().ContainsKey(data.Value.DisplayName)) |
|
{ |
|
transform.Find("Text").GetComponent<Text>().text = |
|
"消防员" + "(" + FireEnginesData.Instance.GetAllPersons()[data.Value.DisplayName] + ")"; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
|
|
} |
|
}
|
|
|