Browse Source

同步高层修改

develop
曹衍涛 5 years ago
parent
commit
8d88b6e7f4
  1. 23
      Assets/Scripts/Common/Cars/AgentController.cs
  2. 18
      Assets/Scripts/Common/Fireman/FireManControl.cs
  3. 28
      Assets/Scripts/DongYouLiQing/BaseCommander/FiremanSkill/Associated/TruckBindWaterSource.cs
  4. 195
      Assets/Scripts/DongYouLiQing/BaseCommander/FiremanSkill/LayWaterHose/LayWaterHose.cs
  5. 12
      Assets/Scripts/DongYouLiQing/BaseCommander/SkillPanel/FireManSkillPanelController.cs

23
Assets/Scripts/Common/Cars/AgentController.cs

@ -31,7 +31,7 @@ public class AgentController : MonoBehaviour
public bool pathFindEnable; public bool pathFindEnable;
private bool begionmove = false; private bool begionmove = false;
private BaseGameObjInfo gameobjinfo; private BaseGameObjInfo gameobjinfo;
// public bool FixedArmFlag; // public bool FixedArmFlag;
private void Awake() private void Awake()
{ {
@ -57,7 +57,7 @@ public class AgentController : MonoBehaviour
//check for mouse input //check for mouse input
void Update() void Update()
{ {
if (begionmove==true) if (begionmove == true)
{ {
if (gameobjinfo.gameObjType == CloneObjType.fireman) if (gameobjinfo.gameObjType == CloneObjType.fireman)
{ {
@ -67,11 +67,11 @@ public class AgentController : MonoBehaviour
{ {
SenderId = CurrentUserInfo.mySelf.Id, SenderId = CurrentUserInfo.mySelf.Id,
GameObjId = gameobjinfo.gameObjID, GameObjId = gameobjinfo.gameObjID,
Hitpoint=pointhit, Hitpoint = pointhit,
EndRotation = new Vector3(transform.rotation.eulerAngles.x, EndRotation = new Vector3(transform.rotation.eulerAngles.x,
transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z) transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z)
}; };
NetworkManager.Default.SendAsync("ABJUST_ROTATION_SYNC",arg); NetworkManager.Default.SendAsync("ABJUST_ROTATION_SYNC", arg);
begionmove = false; begionmove = false;
} }
} }
@ -119,7 +119,7 @@ public class AgentController : MonoBehaviour
{ {
if (GetComponent<FireRobotController>()) if (GetComponent<FireRobotController>())
{ {
if (GetComponent<FireRobotController>().WorkType== FireRobotSkill.|| if (GetComponent<FireRobotController>().WorkType == FireRobotSkill. ||
GetComponent<FireRobotController>().WorkType == FireRobotSkill.) GetComponent<FireRobotController>().WorkType == FireRobotSkill.)
{ {
if (GetComponent<FireRobotLayWaterHose>().remainlenght < 0.5f) if (GetComponent<FireRobotLayWaterHose>().remainlenght < 0.5f)
@ -128,6 +128,19 @@ public class AgentController : MonoBehaviour
} }
} }
} }
if (GetComponent<FireManControl>())
{
if (GetComponent<FireManControl>().WorkType == FireManSkills.SprayFoam ||
GetComponent<FireManControl>().WorkType == FireManSkills.SprayWater
)
{
if (GetComponent<LayWaterHose>().remainlenght < 0.5f)
{
return;
}
}
}
begionmove = true; begionmove = true;
var data = (PathFindingCmdArgs)obj.Data; var data = (PathFindingCmdArgs)obj.Data;
pointhit = data.hitPoint; pointhit = data.hitPoint;

18
Assets/Scripts/Common/Fireman/FireManControl.cs

@ -742,13 +742,17 @@ public class FireManControl : MonoBehaviour
} }
else else
{ {
float realewater = 0;//实际分到的水量=自己的流量/直接水源的总流量*直接水源总水量 if (waterhosemanage.ConnentSource)
float dirTotalFlow = waterhosemanage.ConnentSource.GetComponent<WaterSource>().TotalFlow; {
realewater = (Flow / dirTotalFlow) * remainwater; float realewater = 0;//实际分到的水量=自己的流量/直接水源的总流量*直接水源总水量
if (Flow != 0) float dirTotalFlow = waterhosemanage.ConnentSource.GetComponent<WaterSource>().TotalFlow;
remaintime = Mathf.CeilToInt(realewater / Flow); realewater = (Flow / dirTotalFlow) * remainwater;
else if (Flow != 0)
remaintime = 0; remaintime = Mathf.CeilToInt(realewater / Flow);
else
remaintime = 0;
}
} }
remain = new KeyValuePair<int, float>(remaintime, remainwater); remain = new KeyValuePair<int, float>(remaintime, remainwater);

28
Assets/Scripts/DongYouLiQing/BaseCommander/FiremanSkill/Associated/TruckBindWaterSource.cs

@ -2256,20 +2256,24 @@ public class TruckBindWaterSource : MonoBehaviour
} }
for (int i = 0; i < allwatersource.Count; i++) for (int i = 0; i < allwatersource.Count; i++)
{ {
WaterSource ws = EntitiesManager.Instance.GetEntityByID(allwatersource[i]).GetComponent<WaterSource>(); if (EntitiesManager.Instance.GetEntityByID(allwatersource[i]))
if (ws.TotalWater != -100)
{ {
remainwater += (ws.TotalWater - ws.AllUserWater); WaterSource ws = EntitiesManager.Instance.GetEntityByID(allwatersource[i]).GetComponent<WaterSource>();
//if (ws.GetComponent<TruckBindWaterSource>()) if (ws.TotalWater != -100)
//{ {
// allflow += ws.GetComponent<TruckBindWaterSource>().Flow; remainwater += (ws.TotalWater - ws.AllUserWater);
//} //if (ws.GetComponent<TruckBindWaterSource>())
} //{
else // allflow += ws.GetComponent<TruckBindWaterSource>().Flow;
{ //}
remainwater = -100; }
break; else
{
remainwater = -100;
break;
}
} }
} }
int remaintime = 0; int remaintime = 0;
//allflow += Flow; //allflow += Flow;

195
Assets/Scripts/DongYouLiQing/BaseCommander/FiremanSkill/LayWaterHose/LayWaterHose.cs

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

12
Assets/Scripts/DongYouLiQing/BaseCommander/SkillPanel/FireManSkillPanelController.cs

@ -915,10 +915,14 @@ public class FireManSkillPanelController : MonoBehaviour
//InputManager.skill = true; //InputManager.skill = true;
SelectFireMan.GetComponent<FireManControl>().workType = FireManSkills.LayWaterHose; SelectFireMan.GetComponent<FireManControl>().workType = FireManSkills.LayWaterHose;
if (!SelectFireMan.GetComponent<AgentController>().pathFindEnable)
{ //if (SelectFireMan.GetComponent<FireManWaterHoseManager>().WaterHoseLenghtRemain <= 0)
SelectFireMan.GetComponent<AgentController>().pathFindEnable = true; //{
} // LoadPromptWin.Instance.LoadTextPromptWindow("未装备水带或水带已用完", 1f);
// LayWaterHoseToggle.transform.Find("Label").GetComponent<Text>().text = "放下水带";
// return;
//}
SelectFireMan.GetComponent<LayWaterHose>().StartLay(); SelectFireMan.GetComponent<LayWaterHose>().StartLay();
LayWaterHoseToggle.transform.Find("Label").GetComponent<Text>().text = "放下水带"; LayWaterHoseToggle.transform.Find("Label").GetComponent<Text>().text = "放下水带";

Loading…
Cancel
Save