|
|
|
@ -156,12 +156,18 @@ public class LayWaterHose : MonoBehaviour
|
|
|
|
|
// Update is called once per frame |
|
|
|
|
void Update() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if (!flag) |
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//Debug.Log(flag+"//"+ agent.velocity.magnitude ); |
|
|
|
|
if (flag && agent.velocity.magnitude > 0) //开启“铺设水带”,并且开始寻路时才会执行 |
|
|
|
|
{ |
|
|
|
|
remainlenght = GetComponent<FireManWaterHoseManager>().WaterHoseLenghtRemain; |
|
|
|
|
|
|
|
|
|
if (remainlenght <= 0) |
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
endPoint = transform.position; |
|
|
|
|
//LayLenght= GetSelfConsumedLength(); |
|
|
|
|
if (remainlenght > 0 && remainlenght <= 0.5f) //临界带 |
|
|
|
@ -335,72 +341,84 @@ public class LayWaterHose : MonoBehaviour
|
|
|
|
|
//如果当前起始位置与上一次铺设的末点距离较近,则认为此次铺设是上一次铺设的继续 |
|
|
|
|
if (endPoint != Vector3.zero && Vector3.Distance(transform.position, endPoint) < 5) |
|
|
|
|
{ |
|
|
|
|
//如果放下期间已经被别人捡起,重新铺设 |
|
|
|
|
if (ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectFireman != null) |
|
|
|
|
if (ParentLayHose) |
|
|
|
|
{ |
|
|
|
|
lengthDic.Clear(); |
|
|
|
|
if (GetComponent<FireManWaterHoseManager>().WaterHoseLenghtRemain <= 0) |
|
|
|
|
//如果放下期间已经被别人捡起,重新铺设 |
|
|
|
|
if (ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectFireman != null) |
|
|
|
|
{ |
|
|
|
|
if (IsselfCurrent) |
|
|
|
|
lengthDic.Clear(); |
|
|
|
|
if (GetComponent<FireManWaterHoseManager>().WaterHoseLenghtRemain <= 0) |
|
|
|
|
{ |
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("未装备水带或水带已用完", 1f); |
|
|
|
|
if (IsselfCurrent) |
|
|
|
|
{ |
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("未装备水带或水带已用完", 1f); |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//ParentLayHose = EntitiesManager.Instance.CreateObj(ParentLayHosePrefabs, Vector3.zero, |
|
|
|
|
// WaterHoses.transform, EntitiesManager.Instance.CreateObjID(CurrentUserInfo.mySelf.Id)); // Instantiate(ParentLayHosePrefabs, WaterHoses.transform); |
|
|
|
|
ParentLayHose = Instantiate(ParentLayHosePrefabs, WaterHoses.transform); |
|
|
|
|
//ParentLayHose.GetComponent<BaseGameObjInfo>().gameObjID = EntitiesManager.Instance.CreateObjID(CurrentUserInfo.mySelf.Id); |
|
|
|
|
ParentLayHose.name = "LayWaterHose" + creatnum; |
|
|
|
|
creatnum++; |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectFireman = gameObject; |
|
|
|
|
allInits.Clear(); |
|
|
|
|
AddInit(); |
|
|
|
|
endPoint = transform.position; |
|
|
|
|
flag = true; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//如果放下期间没有被别人捡起,继续铺设 |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
//更新消防员可用水带 |
|
|
|
|
if (ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().RemainLenght > 0) |
|
|
|
|
{ |
|
|
|
|
//if((GetComponent<FireManWaterHoseManager>().OverLenght==0)) |
|
|
|
|
//ParentLayHose = EntitiesManager.Instance.CreateObj(ParentLayHosePrefabs, Vector3.zero, |
|
|
|
|
// WaterHoses.transform, EntitiesManager.Instance.CreateObjID(CurrentUserInfo.mySelf.Id)); // Instantiate(ParentLayHosePrefabs, WaterHoses.transform); |
|
|
|
|
ParentLayHose = Instantiate(ParentLayHosePrefabs, WaterHoses.transform); |
|
|
|
|
//ParentLayHose.GetComponent<BaseGameObjInfo>().gameObjID = EntitiesManager.Instance.CreateObjID(CurrentUserInfo.mySelf.Id); |
|
|
|
|
ParentLayHose.name = "LayWaterHose" + creatnum; |
|
|
|
|
creatnum++; |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectFireman = gameObject; |
|
|
|
|
allInits.Clear(); |
|
|
|
|
AddInit(); |
|
|
|
|
endPoint = transform.position; |
|
|
|
|
if (!GetComponent<AgentController>().pathFindEnable) |
|
|
|
|
{ |
|
|
|
|
//GetComponent<FireManWaterHoseManager>().WaterHoseLenghtRemain = |
|
|
|
|
// GetComponent<FireManWaterHoseManager>().NowRemainWaterHose * 20 + ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().RemainLenght+GetComponent<FireManWaterHoseManager>().OverLenght; |
|
|
|
|
//GetComponent<FireManWaterHoseManager>().NowRemainWaterHose = GetComponent<FireManWaterHoseManager>().NowRemainWaterHose + ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().UseNum; |
|
|
|
|
GetComponent<FireManWaterHoseManager>().CalculateBeforelay(ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().RemainLenght, ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().UseNum); |
|
|
|
|
GetComponent<AgentController>().pathFindEnable = true; |
|
|
|
|
} |
|
|
|
|
flag = true; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//更新消防员水源信息 |
|
|
|
|
if (ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().WaterSource != null) |
|
|
|
|
//如果放下期间没有被别人捡起,继续铺设 |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (issync == false) |
|
|
|
|
//更新消防员可用水带 |
|
|
|
|
if (ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().RemainLenght > 0) |
|
|
|
|
{ |
|
|
|
|
gameObject.GetComponent<FireManWaterHoseManager>().ResetWaterSourceConnectInfo |
|
|
|
|
(true, ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectWater, |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectFoam, ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().WaterSource, |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectWaterHose); |
|
|
|
|
if (/*FindObjectOfType<FireManSkillPanelController>()*/FireManSkillPanelController.Instance) |
|
|
|
|
//if((GetComponent<FireManWaterHoseManager>().OverLenght==0)) |
|
|
|
|
{ |
|
|
|
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true; |
|
|
|
|
//GetComponent<FireManWaterHoseManager>().WaterHoseLenghtRemain = |
|
|
|
|
// GetComponent<FireManWaterHoseManager>().NowRemainWaterHose * 20 + ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().RemainLenght+GetComponent<FireManWaterHoseManager>().OverLenght; |
|
|
|
|
//GetComponent<FireManWaterHoseManager>().NowRemainWaterHose = GetComponent<FireManWaterHoseManager>().NowRemainWaterHose + ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().UseNum; |
|
|
|
|
GetComponent<FireManWaterHoseManager>().CalculateBeforelay(ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().RemainLenght, ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().UseNum); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//更新消防员水源信息 |
|
|
|
|
if (ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().WaterSource != null) |
|
|
|
|
{ |
|
|
|
|
if (issync == false) |
|
|
|
|
{ |
|
|
|
|
gameObject.GetComponent<FireManWaterHoseManager>().ResetWaterSourceConnectInfo |
|
|
|
|
(true, ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectWater, |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectFoam, ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().WaterSource, |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectWaterHose); |
|
|
|
|
if (/*FindObjectOfType<FireManSkillPanelController>()*/FireManSkillPanelController.Instance) |
|
|
|
|
{ |
|
|
|
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (issync == false) |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (issync == false) |
|
|
|
|
{ |
|
|
|
|
gameObject.GetComponent<FireManWaterHoseManager>().ResetWaterSourceConnectInfo(false, false, false, null, null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!GetComponent<AgentController>().pathFindEnable) |
|
|
|
|
{ |
|
|
|
|
gameObject.GetComponent<FireManWaterHoseManager>().ResetWaterSourceConnectInfo(false, false, false, null, null); |
|
|
|
|
GetComponent<AgentController>().pathFindEnable = true; |
|
|
|
|
} |
|
|
|
|
flag = true; |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectFireman = gameObject; |
|
|
|
|
} |
|
|
|
|
flag = true; |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectFireman = gameObject; |
|
|
|
|
//AddInit(); |
|
|
|
|
} |
|
|
|
|
//AddInit(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//如果当前起始位置与上一次铺设的末点距离较远,则认为开始一段新的铺设,不会收回上一次铺设的管线 |
|
|
|
@ -413,25 +431,36 @@ public class LayWaterHose : MonoBehaviour
|
|
|
|
|
{ |
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("未装备水带或水带已用完", 1f); |
|
|
|
|
} |
|
|
|
|
GetComponent<AgentController>().pathFindEnable = false; |
|
|
|
|
allInits.Clear(); |
|
|
|
|
AddInit(); |
|
|
|
|
endPoint = Vector3.zero; |
|
|
|
|
flag = false; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
ParentLayHose = Instantiate(ParentLayHosePrefabs, WaterHoses.transform); |
|
|
|
|
ParentLayHose.name = "LayWaterHose" + creatnum; |
|
|
|
|
creatnum++; |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectFireman = gameObject; |
|
|
|
|
//GetComponent<FireManWaterHoseManager>().TackUpLenght = 0; |
|
|
|
|
//如果铺设时消防员被管线连接,给该水带赋值水源信息 |
|
|
|
|
if (GetComponent<FireManWaterHoseManager>().IsConnentWaterLine) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
FireManWaterHoseManager thisFireman = GetComponent<FireManWaterHoseManager>(); |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().BindWaterSource(thisFireman.hasWaterConnect, thisFireman.hasFoamConnect, thisFireman.ConnentSource, thisFireman.WaterLineConnent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
allInits.Clear(); |
|
|
|
|
AddInit(); |
|
|
|
|
endPoint = transform.position; |
|
|
|
|
flag = true; |
|
|
|
|
ParentLayHose = Instantiate(ParentLayHosePrefabs, WaterHoses.transform); |
|
|
|
|
ParentLayHose.name = "LayWaterHose" + creatnum; |
|
|
|
|
creatnum++; |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().ConnectFireman = gameObject; |
|
|
|
|
//GetComponent<FireManWaterHoseManager>().TackUpLenght = 0; |
|
|
|
|
//如果铺设时消防员被管线连接,给该水带赋值水源信息 |
|
|
|
|
if (GetComponent<FireManWaterHoseManager>().IsConnentWaterLine) |
|
|
|
|
{ |
|
|
|
|
FireManWaterHoseManager thisFireman = GetComponent<FireManWaterHoseManager>(); |
|
|
|
|
ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().BindWaterSource(thisFireman.hasWaterConnect, thisFireman.hasFoamConnect, thisFireman.ConnentSource, thisFireman.WaterLineConnent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
allInits.Clear(); |
|
|
|
|
AddInit(); |
|
|
|
|
endPoint = transform.position; |
|
|
|
|
if (!GetComponent<AgentController>().pathFindEnable) |
|
|
|
|
{ |
|
|
|
|
GetComponent<AgentController>().pathFindEnable = true; |
|
|
|
|
} |
|
|
|
|
flag = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -451,7 +480,7 @@ public class LayWaterHose : MonoBehaviour
|
|
|
|
|
public void StartSprayingLay(bool issync = false) |
|
|
|
|
{ |
|
|
|
|
agent.SetDestination(transform.position); |
|
|
|
|
if (!GetComponent<AgentController>().pathFindEnable) |
|
|
|
|
//if (!GetComponent<AgentController>().pathFindEnable) |
|
|
|
|
{ |
|
|
|
|
GetComponent<AgentController>().pathFindEnable = true; |
|
|
|
|
} |
|
|
|
@ -464,6 +493,16 @@ public class LayWaterHose : MonoBehaviour
|
|
|
|
|
} |
|
|
|
|
if (endPoint != Vector3.zero && Vector3.Distance(transform.position, endPoint) < 5) |
|
|
|
|
{ |
|
|
|
|
if (ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().RemainLenght > 0) |
|
|
|
|
{ |
|
|
|
|
//if((GetComponent<FireManWaterHoseManager>().OverLenght==0)) |
|
|
|
|
{ |
|
|
|
|
//GetComponent<FireManWaterHoseManager>().WaterHoseLenghtRemain = |
|
|
|
|
// GetComponent<FireManWaterHoseManager>().NowRemainWaterHose * 20 + ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().RemainLenght+GetComponent<FireManWaterHoseManager>().OverLenght; |
|
|
|
|
//GetComponent<FireManWaterHoseManager>().NowRemainWaterHose = GetComponent<FireManWaterHoseManager>().NowRemainWaterHose + ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().UseNum; |
|
|
|
|
GetComponent<FireManWaterHoseManager>().CalculateBeforelay(ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().RemainLenght, ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().UseNum); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().WaterSource != null) |
|
|
|
|
{ |
|
|
|
|
if (issync == false) |
|
|
|
@ -491,6 +530,7 @@ public class LayWaterHose : MonoBehaviour
|
|
|
|
|
// GetComponent<FireManWaterHoseManager>().NowRemainWaterHose = GetComponent<FireManWaterHoseManager>().NowRemainWaterHose + ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().UseNum; |
|
|
|
|
GetComponent<FireManWaterHoseManager>().CalculateBeforelay(ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().RemainLenght, ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().UseNum); |
|
|
|
|
flag = true; |
|
|
|
|
GetComponent<AgentController>().pathFindEnable = true; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
@ -502,8 +542,17 @@ public class LayWaterHose : MonoBehaviour
|
|
|
|
|
AddInit(); //将当前位置作为起点 |
|
|
|
|
endPoint = transform.position; |
|
|
|
|
lengthDic.Clear(); |
|
|
|
|
|
|
|
|
|
remainlenght = GetComponent<FireManWaterHoseManager>().WaterHoseLenghtRemain; |
|
|
|
|
if (remainlenght <= 0) |
|
|
|
|
{ |
|
|
|
|
GetComponent<AgentController>().pathFindEnable = false; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
GetComponent<AgentController>().pathFindEnable = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// GetComponent<AgentController>().pathFindEnable = true; |
|
|
|
|
canreinit = false; |
|
|
|
|
flag = true; |
|
|
|
|
spraying = true; |
|
|
|
@ -564,6 +613,14 @@ public class LayWaterHose : MonoBehaviour
|
|
|
|
|
GetComponent<FireManControl>().workType == FireManSkills.SprayWater) |
|
|
|
|
{ |
|
|
|
|
GetComponent<AgentController>().pathFindEnable = false; |
|
|
|
|
remainlenght = GetComponent<FireManWaterHoseManager>().WaterHoseLenghtRemain; |
|
|
|
|
if (remainlenght <= 0 && GetSelfConsumedLength() < 1f) |
|
|
|
|
{ |
|
|
|
|
allInits.Clear(); //与之前铺设的水带切断联系 |
|
|
|
|
AddInit(); //将当前位置作为起点 |
|
|
|
|
endPoint = Vector3.zero; |
|
|
|
|
lengthDic.Clear(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// StartCoroutine(closespraytoggle()); |
|
|
|
|
//if (!(endPoint != Vector3.zero && Vector3.Distance(transform.position, endPoint) < 5)) |
|
|
|
@ -950,7 +1007,7 @@ public class LayWaterHose : MonoBehaviour
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("距离太远,无法自动拿起管线", 1f); |
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("距离放下水带太远,无法自动拿起管线,请靠近当前放下管线或者重新连接水源", 1f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|