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.
413 lines
17 KiB
413 lines
17 KiB
4 years ago
|
using AX.MessageSystem;
|
||
|
using AX.NetworkSystem;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class FireRobotSkillPanelController : MonoBehaviour {
|
||
|
|
||
|
[Rename("选中的机器人")]
|
||
|
public GameObject SelectRobot;
|
||
|
|
||
|
[Rename("机器人技能panel")]
|
||
|
public Transform RobotSkillPanel;
|
||
|
[Rename("铺设水带")]
|
||
|
public ToggleRecordByAC LayWaterHoseToggle;
|
||
|
[Rename("收起管线")]
|
||
|
public ToggleRecordByAC PackUpLine;
|
||
|
[Rename("出水")]
|
||
|
public ToggleRecordByAC SprayWater;
|
||
|
[Rename("出泡沫")]
|
||
|
public ToggleRecordByAC SprayFroth;
|
||
|
|
||
|
[Rename("装备选择")]
|
||
|
public ToggleRecordByAC EquipSelect;
|
||
|
[Rename("背包")]
|
||
|
public ToggleRecordByAC Backpack;
|
||
|
/// <summary>
|
||
|
/// 出水UI
|
||
|
/// </summary>
|
||
|
public Transform LayWaterPanel;
|
||
|
private static FireRobotSkillPanelController instance;
|
||
|
public static FireRobotSkillPanelController Instance
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return instance;
|
||
|
}
|
||
|
}
|
||
|
// Use this for initialization
|
||
|
void Start () {
|
||
|
instance = this;
|
||
|
LayWaterHoseToggle.OutInterFaceToggle = LayWaterHoseChange;
|
||
|
PackUpLine.OutInterFaceToggle = PickUpLineChange;
|
||
|
SprayFroth.OutInterFaceToggle = SprayFrothChange;
|
||
|
SprayWater.OutInterFaceToggle = SprayWaterChange;
|
||
|
EquipSelect.OutInterFaceToggle = EquipSelectChange;
|
||
|
Backpack.OutInterFaceToggle = BackpackChange;
|
||
|
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update () {
|
||
|
|
||
|
}
|
||
|
public void SelectFireRobot(GameObject select)
|
||
|
{
|
||
|
SelectRobot = select;
|
||
|
switch (select.GetComponent<FireRobotController>().WorkType)
|
||
|
{
|
||
|
case FireRobotSkill.待命:
|
||
|
ResertRobotSkill();
|
||
|
break;
|
||
|
case FireRobotSkill.出水:
|
||
|
SprayWater.GetComponent<Toggle>().interactable = true;
|
||
|
SprayWater.GetComponent<Toggle>().isOn = true;
|
||
|
break;
|
||
|
case FireRobotSkill.出泡沫:
|
||
|
SprayFroth.GetComponent<Toggle>().interactable = true;
|
||
|
SprayFroth.GetComponent<Toggle>().isOn = true;
|
||
|
break;
|
||
|
case FireRobotSkill.铺设水带:
|
||
|
LayWaterHoseToggle.GetComponent<Toggle>().isOn = true;
|
||
|
break;
|
||
|
case FireRobotSkill.收起水带:
|
||
|
PackUpLine.GetComponent<Toggle>().isOn = true;
|
||
|
break;
|
||
|
case FireRobotSkill.装备选择:
|
||
|
EquipSelect.GetComponent<Toggle>().isOn = true;
|
||
|
break;
|
||
|
case FireRobotSkill.背包:
|
||
|
Backpack.GetComponent<Toggle>().isOn = true;
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
if (SelectRobot.GetComponent<FireRobotWaterHoseManage>())
|
||
|
{
|
||
|
FireRobotWaterHoseManage f = SelectRobot.GetComponent<FireRobotWaterHoseManage>();
|
||
|
if (f.IsConnentWaterSource && f.hasFoamConnect)
|
||
|
{
|
||
|
SprayFroth.GetComponent<Toggle>().interactable = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SprayFroth.GetComponent<Toggle>().interactable = false;
|
||
|
}
|
||
|
if (f.IsConnentWaterSource && f.hasWaterConnect)
|
||
|
{
|
||
|
SprayWater.GetComponent<Toggle>().interactable = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SprayWater.GetComponent<Toggle>().interactable = false;
|
||
|
}
|
||
|
}
|
||
|
if (SelectRobot.GetComponent<FireRobotController>().WorkType==FireRobotSkill.出水||
|
||
|
SelectRobot.GetComponent<FireRobotController>().WorkType==FireRobotSkill.出泡沫)
|
||
|
{
|
||
|
if (!LayWaterPanel.gameObject.activeInHierarchy)
|
||
|
{
|
||
|
LayWaterPanel.gameObject.SetActive(true);
|
||
|
}
|
||
|
GetComponent<LayWaterPanel>().SetShowEnable();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
private void BackpackChange(bool value)
|
||
|
{
|
||
|
if (value)
|
||
|
{
|
||
|
//SelectRobot.GetComponent<FireRobotController>().WorkType = FireRobotSkill.背包;
|
||
|
UIManager.ShowView<UIViewBag>();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SelectRobot.GetComponent<FireRobotController>().WorkType = FireRobotSkill.待命;
|
||
|
UIManager.HideView<UIViewEquipLib>();
|
||
|
UIManager.HideView<UIViewBag>();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void EquipSelectChange(bool value)
|
||
|
{
|
||
|
if (value)
|
||
|
{
|
||
|
//SelectRobot.GetComponent<FireRobotController>().WorkType = FireRobotSkill.装备选择;
|
||
|
UIManager.ShowView<UIViewEquipLib>();
|
||
|
UIManager.ShowView<UIViewBag>();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SelectRobot.GetComponent<FireRobotController>().WorkType = FireRobotSkill.待命;
|
||
|
UIManager.HideView<UIViewEquipLib>();
|
||
|
UIManager.HideView<UIViewBag>();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void SprayWaterChange(bool value)
|
||
|
{
|
||
|
FireRobotController controller = SelectRobot.GetComponent<FireRobotController>();
|
||
|
if (value)
|
||
|
{
|
||
|
//本身就是出水状态
|
||
|
if (controller.WorkType == FireRobotSkill.出水)
|
||
|
{
|
||
|
if(SelectRobot.GetComponent<AgentController>().pathFindEnable==false)
|
||
|
{
|
||
|
SelectRobot.GetComponent<AgentController>().pathFindEnable = true;
|
||
|
LayWaterPanel.gameObject.SetActive(true);
|
||
|
if (SelectRobot.GetComponent<FireRobotWaterHoseManage>().ConnentSource)
|
||
|
{
|
||
|
if (SelectRobot.GetComponent<FireRobotWaterHoseManage>().ConnentSource.GetComponent<WaterSource>().hasover)
|
||
|
{
|
||
|
controller.DestoryPartical();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//启用出水铺设
|
||
|
}
|
||
|
GetComponent<LayWaterPanel>().SetShowEnable();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//开启出水
|
||
|
else
|
||
|
{
|
||
|
if(SelectRobot.GetComponent<FireRobotWaterHoseManage>().ConnentSource)
|
||
|
{
|
||
|
float remain = SelectRobot.GetComponent<FireRobotController>().CheckWaterRemain(SelectRobot.GetComponent<FireRobotWaterHoseManage>().WaterSourceLine);
|
||
|
if (!(remain>0||remain==-100))
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("剩余水量不足",1f);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
controller.WorkType = FireRobotSkill.出水;
|
||
|
controller.SetParticleType(SprayParticleType.WaterStraight);
|
||
|
// SelectRobot.GetComponent<AgentController>().pathFindEnable = true;
|
||
|
LayWaterPanel.gameObject.SetActive(true);
|
||
|
GetComponent<LayWaterPanel>().SetShowEnable();
|
||
|
|
||
|
if (SelectRobot.GetComponent<FireRobotLayWaterHose>().remainlenght <= 0)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("未装备水带或水带已用完", 1f);
|
||
|
}
|
||
|
SelectRobot.GetComponent<FireRobotLayWaterHose>().StartSprayingLay();
|
||
|
|
||
|
|
||
|
//连接水源流量设置
|
||
|
//MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = true, ChangObjId = SelectRobot.GetComponent<BaseGameObjInfo>().gameObjID });
|
||
|
//出水同步
|
||
|
SpraySyncData spraysync = new SpraySyncData();
|
||
|
spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
spraysync.IsOn = true;
|
||
|
spraysync.spraytype = SprayParticleType.WaterStraight;
|
||
|
spraysync.size = SelectRobot.GetComponent<FireRobotController>().ParticleSize;
|
||
|
spraysync.gameObjID = SelectRobot.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
// spraysync.UserID = SelectRobot.GetComponent<BaseGameObjInfo>().UserID;
|
||
|
// spraysync.gameObjType = SelectRobot.GetComponent<BaseGameObjInfo>().gameObjType;
|
||
|
NetworkManager.Default.SendAsync("SPRAY_WATER_SYNC", spraysync);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SelectRobot.GetComponent<FireRobotController>().WorkType = FireRobotSkill.待命;
|
||
|
LayWaterPanel.gameObject.SetActive(false);
|
||
|
if (SelectRobot.GetComponent<FireRobotController>().Flow!=0)
|
||
|
{
|
||
|
SelectRobot.GetComponent<FireRobotController>().Flow = 0;
|
||
|
}
|
||
|
|
||
|
SelectRobot.GetComponent<AgentController>().pathFindEnable = false;
|
||
|
|
||
|
SelectRobot.GetComponent<FireRobotController>().DestoryPartical();
|
||
|
//MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = false, ChangObjId = SelectRobot.GetComponent<BaseGameObjInfo>().gameObjID });
|
||
|
//停止出水及同步
|
||
|
SelectRobot.GetComponent<FireRobotController>().DestoryPartical();
|
||
|
SelectRobot.GetComponent<FireRobotLayWaterHose>().JugeLenght();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void SprayFrothChange(bool value)
|
||
|
{
|
||
|
FireRobotController controller = SelectRobot.GetComponent<FireRobotController>();
|
||
|
if (value)
|
||
|
{
|
||
|
//本身就是出水状态
|
||
|
if (controller.WorkType == FireRobotSkill.出泡沫)
|
||
|
{
|
||
|
if (SelectRobot.GetComponent<AgentController>().pathFindEnable == false)
|
||
|
{
|
||
|
SelectRobot.GetComponent<AgentController>().pathFindEnable = true;
|
||
|
LayWaterPanel.gameObject.SetActive(true);
|
||
|
if (SelectRobot.GetComponent<FireRobotWaterHoseManage>().ConnentSource)
|
||
|
{
|
||
|
if (SelectRobot.GetComponent<FireRobotWaterHoseManage>().ConnentSource.GetComponent<WaterSource>().hasover)
|
||
|
{
|
||
|
controller.DestoryPartical();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//启用出水铺设
|
||
|
}
|
||
|
GetComponent<LayWaterPanel>().SetShowEnable();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//开启出水
|
||
|
else
|
||
|
{
|
||
|
if (SelectRobot.GetComponent<FireRobotWaterHoseManage>().ConnentSource)
|
||
|
{
|
||
|
float remain = SelectRobot.GetComponent<FireRobotController>().CheckWaterRemain(SelectRobot.GetComponent<FireRobotWaterHoseManage>().WaterSourceLine);
|
||
|
if (!(remain > 0 || remain == -100))
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("剩余水量不足", 1f);
|
||
|
return;
|
||
|
}
|
||
|
float remainfoam = SelectRobot.GetComponent<FireRobotController>().CheckFoamRemain();
|
||
|
if (!(remainfoam==-100||remainfoam>0))
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("剩余泡沫量不足", 1f);
|
||
|
}
|
||
|
}
|
||
|
controller.WorkType = FireRobotSkill.出泡沫;
|
||
|
controller.SetParticleType(SprayParticleType.Froth);
|
||
|
// SelectRobot.GetComponent<AgentController>().pathFindEnable = true;
|
||
|
LayWaterPanel.gameObject.SetActive(true);
|
||
|
GetComponent<LayWaterPanel>().SetShowEnable();
|
||
|
|
||
|
//出水铺设水带
|
||
|
|
||
|
if (SelectRobot.GetComponent<FireRobotLayWaterHose>().remainlenght <= 0)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("未装备水带或水带已用完", 1f);
|
||
|
}
|
||
|
SelectRobot.GetComponent<FireRobotLayWaterHose>().StartSprayingLay();
|
||
|
|
||
|
//连接水源流量设置
|
||
|
//MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = true, ChangObjId = SelectRobot.GetComponent<BaseGameObjInfo>().gameObjID });
|
||
|
//出水同步
|
||
|
SpraySyncData spraysync = new SpraySyncData();
|
||
|
spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
spraysync.IsOn = true;
|
||
|
spraysync.spraytype = SprayParticleType.Froth;
|
||
|
spraysync.size = SelectRobot.GetComponent<FireRobotController>().ParticleSize;
|
||
|
spraysync.gameObjID = SelectRobot.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
NetworkManager.Default.SendAsync("SPRAY_WATER_SYNC", spraysync);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SelectRobot.GetComponent<FireRobotController>().WorkType = FireRobotSkill.待命;
|
||
|
LayWaterPanel.gameObject.SetActive(false);
|
||
|
if (SelectRobot.GetComponent<FireRobotController>().Flow != 0)
|
||
|
{
|
||
|
SelectRobot.GetComponent<FireRobotController>().Flow = 0;
|
||
|
}
|
||
|
//禁用寻路
|
||
|
SelectRobot.GetComponent<AgentController>().pathFindEnable = false;
|
||
|
|
||
|
//MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = false, ChangObjId = SelectRobot.GetComponent<BaseGameObjInfo>().gameObjID });
|
||
|
SelectRobot.GetComponent<FireRobotController>().DestoryPartical();
|
||
|
SelectRobot.GetComponent<FireRobotLayWaterHose>().JugeLenght();
|
||
|
//SpraySyncData spraysync = new SpraySyncData();
|
||
|
//spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
//spraysync.IsOn = false;
|
||
|
//spraysync.gameObjID = SelectRobot.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
//NetworkManager.Default.SendAsync("SPRAY_WATER_SYNC", spraysync);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void PickUpLineChange(bool value)
|
||
|
{
|
||
|
SelectRobot.GetComponent<FireRobotController>().WorkType = FireRobotSkill.待命;
|
||
|
if (value)
|
||
|
{
|
||
|
// SelectRobot.GetComponent<FireRobotController>().WorkType = FireRobotSkill.收起水带;
|
||
|
if (SelectRobot.GetComponent<FireRobotController>().WorkType==FireRobotSkill.出水||
|
||
|
SelectRobot.GetComponent<FireRobotController>().WorkType == FireRobotSkill.出泡沫)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("请先停止出水", 1f);
|
||
|
return;
|
||
|
}
|
||
|
SelectRobot.GetComponent<FireRobotLayWaterHose>().PickUpLayHose();
|
||
|
SelectRobot.GetComponent<AgentController>().pathFindEnable = true;
|
||
|
BaseNetworkSyncDate sync = new BaseNetworkSyncDate()
|
||
|
{
|
||
|
gameObjID = SelectRobot.GetComponent<BaseGameObjInfo>().gameObjID,
|
||
|
SendUserID = CurrentUserInfo.mySelf.Id
|
||
|
};
|
||
|
NetworkManager.Default.SendAsync("FIREROBOT_PICKUPLINE_SYNC", sync);
|
||
|
|
||
|
PackUpLine.GetComponent<Toggle>().isOn = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void LayWaterHoseChange(bool value)
|
||
|
{
|
||
|
if (value)
|
||
|
{
|
||
|
if (SelectRobot.GetComponent<FireRobotLayWaterHose>().remainlenght<=0)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("未装备水带或水带已用完", 1f);
|
||
|
LayWaterHoseToggle.GetComponent<Toggle>().isOn = false;
|
||
|
return;
|
||
|
}
|
||
|
SelectRobot.GetComponent<FireRobotController>().WorkType = FireRobotSkill.铺设水带;
|
||
|
SelectRobot.GetComponent<AgentController>().pathFindEnable = true;
|
||
|
SelectRobot.GetComponent<FireRobotLayWaterHose>().StartLay();
|
||
|
|
||
|
LayerWaterHoseSyncData syncarg = new LayerWaterHoseSyncData();
|
||
|
syncarg.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
syncarg.IsBegin = true;
|
||
|
syncarg.gameObjID = SelectRobot.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
NetworkManager.Default.SendAsync( "FIREROBOT_LAYWATERHOSE_SYNC", syncarg);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (SelectRobot.GetComponent<FireRobotController>().WorkType == FireRobotSkill.铺设水带)
|
||
|
{
|
||
|
if (SelectRobot.GetComponent<FireRobotLayWaterHose>().GetSelfConsumedLength()>0.2f)
|
||
|
{
|
||
|
SelectRobot.GetComponent<AgentController>().pathFindEnable = false;
|
||
|
LayerWaterHoseSyncData syncarg = new LayerWaterHoseSyncData();
|
||
|
syncarg.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
syncarg.IsBegin = false;
|
||
|
syncarg.gameObjID = SelectRobot.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
NetworkManager.Default.SendAsync("FIREROBOT_LAYWATERHOSE_SYNC", syncarg);
|
||
|
}
|
||
|
}
|
||
|
SelectRobot.GetComponent<FireRobotController>().WorkType = FireRobotSkill.待命;
|
||
|
SelectRobot.GetComponent<FireRobotLayWaterHose>().JugeLenght();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 重置机器人技能UI及选择机器人
|
||
|
/// </summary>
|
||
|
public void ResertRobotSkill()
|
||
|
{
|
||
|
//SelectFireMan = select;
|
||
|
Toggle[] all = RobotSkillPanel.GetComponentsInChildren<Toggle>();
|
||
|
for (int i = 0; i < all.Length; i++)
|
||
|
{
|
||
|
if (all[i].isOn)
|
||
|
{
|
||
|
all[i].isOn = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|