海淀天下城电子沙盘单机版
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
3.1 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using AX.MessageSystem;
using UnityEngine;
public class HookPipeAttribute : ToolAttribute
{
public GameObject water;
public WaterReceiver receiver;
protected override void Awake()
{
water = transform.Find("WaterStraight").gameObject;
water.SetActive(false);
receiver = GetComponent<WaterReceiver>();
Tasklist = new string[] { "待命", "灭火" };
gameObjType = CloneObjType.FoamHookPipe;
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);
}
}
}
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;
}
/// <summary>
/// 执行任务
/// </summary>
/// <param name="TaskName"></param>
protected override void Execute(string TaskName)
{
task = TaskName;
if (TaskName.Contains("灭火"))
{
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 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);
}
}
}