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.
103 lines
3.4 KiB
103 lines
3.4 KiB
using AX.MessageSystem; |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class BlizzardCannonAttribute : ToolAttribute { |
|
|
|
public GameObject water;//需要控制的物体 |
|
public WaterReceiver receiver; |
|
protected override void Awake() |
|
{ |
|
water = transform.Find("paokou/tai/Hose/WaterStraight").gameObject; |
|
water.SetActive(false); |
|
receiver = GetComponent<WaterReceiver>(); |
|
gameObjType = CloneObjType.BlizzardCannon; |
|
typeName = "暴风雪炮"; |
|
MessageDispatcher.AddListener("WaterSourceChanged", WaterSourceChanged); |
|
MessageDispatcher.AddListener("WaterSeparaterChange", WaterseparadChange); |
|
base.Awake(); |
|
} |
|
protected override void OnDestroy() |
|
{ |
|
base.OnDestroy(); |
|
MessageDispatcher.RemoveListener("WaterSourceChanged", WaterSourceChanged); |
|
MessageDispatcher.RemoveListener("WaterSeparaterChange", WaterseparadChange); |
|
} |
|
|
|
private void WaterseparadChange(IMessage obj) |
|
{ |
|
var data = (Waterseparadata)obj.Data; |
|
var msg = GetComponent<CloneGameObjInfo>(); |
|
if (msg.gameObjID == data.receiveId) |
|
{ |
|
receiver.hasSupplier = data.IsContent; |
|
if (msg.gameObjID == data.receiveId && data.IsContent == false && task == "灭火") |
|
{ |
|
|
|
task = "待命"; |
|
Execute(task); |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 执行任务 |
|
/// </summary> |
|
/// <param name="TaskName"></param> |
|
protected override void Execute(string TaskName) |
|
{ |
|
task = TaskName; |
|
if (TaskName.Contains("灭火")) |
|
{ |
|
//if (receiver.hasSupplier == true) |
|
//{ |
|
// water.SetActive(true); |
|
//} |
|
//else |
|
//{ |
|
// ResourceLoadWindow.Instance.LoadTextHintWindow("请先连接水源", 2); |
|
// task = "待命"; |
|
//} |
|
if (receiver.hasSupplier == true) |
|
{ |
|
//WaterType type = GetSupplerWaterType(receiver); |
|
//if (type == WaterType.foam || type == WaterType.both) |
|
{ |
|
water.SetActive(true); |
|
} |
|
//else |
|
//{ |
|
// ResourceLoadWindow.Instance.LoadTextHintWindow("请先连接泡沫源", 2); |
|
//} |
|
} |
|
else |
|
{ |
|
ResourceLoadWindow.Instance.LoadTextHintWindow("请先连接水源", 2); |
|
} |
|
} |
|
else |
|
{ |
|
water.SetActive(false); |
|
} |
|
} |
|
private WaterType GetSupplerWaterType(WaterReceiver receiver) |
|
{ |
|
WaterType type = WaterType.none; |
|
GameObject waterline = EntitiesManager.Instance.GetEntityByID(receiver.waterlinelist[0]); |
|
GameObject suppler = EntitiesManager.Instance.GetEntityByID(waterline.GetComponent<WaterLineInfo>().SupplierID); |
|
type = suppler.GetComponent<WaterSupplier>().WaterReceiverType; |
|
return type; |
|
} |
|
private void WaterSourceChanged(IMessage obj) |
|
{ |
|
var data = (WaterConnectionData)obj.Data; |
|
var msg = GetComponent<CloneGameObjInfo>(); |
|
if (msg.gameObjID == data.receiverID && data.connected == false && task == "灭火") |
|
{ |
|
task = "待命"; |
|
Execute(task); |
|
} |
|
} |
|
}
|
|
|