Browse Source

同步高层修改

develop
曹衍涛 5 years ago
parent
commit
8d88b6e7f4
  1. 31
      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

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

@ -31,7 +31,7 @@ public class AgentController : MonoBehaviour
public bool pathFindEnable;
private bool begionmove = false;
private BaseGameObjInfo gameobjinfo;
// public bool FixedArmFlag;
// public bool FixedArmFlag;
private void Awake()
{
@ -57,7 +57,7 @@ public class AgentController : MonoBehaviour
//check for mouse input
void Update()
{
if (begionmove==true)
if (begionmove == true)
{
if (gameobjinfo.gameObjType == CloneObjType.fireman)
{
@ -67,11 +67,11 @@ public class AgentController : MonoBehaviour
{
SenderId = CurrentUserInfo.mySelf.Id,
GameObjId = gameobjinfo.gameObjID,
Hitpoint=pointhit,
Hitpoint = pointhit,
EndRotation = new Vector3(transform.rotation.eulerAngles.x,
transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z)
};
NetworkManager.Default.SendAsync("ABJUST_ROTATION_SYNC",arg);
NetworkManager.Default.SendAsync("ABJUST_ROTATION_SYNC", arg);
begionmove = false;
}
}
@ -91,7 +91,7 @@ public class AgentController : MonoBehaviour
begionmove = false;
}
}
}
}
void OnEnable()
@ -110,17 +110,17 @@ public class AgentController : MonoBehaviour
}
private void PathFinding(IMessage obj)
{
if (SelectedObjs.selectedCharacters.Contains(gameObject)
if (SelectedObjs.selectedCharacters.Contains(gameObject)
|| SelectedObjs.selectedObj == gameObject
|| SelectedObjs.selectedRolePlay == gameObject //瑙掕壊
)
{
if (pathFindEnable /*&& !FixedArmFlag*/)
{
if (GetComponent<FireRobotController>())
if (GetComponent<FireRobotController>())
{
if (GetComponent<FireRobotController>().WorkType== FireRobotSkill.||
GetComponent<FireRobotController>().WorkType == FireRobotSkill.)
if (GetComponent<FireRobotController>().WorkType == FireRobotSkill. ||
GetComponent<FireRobotController>().WorkType == FireRobotSkill.)
{
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;
var data = (PathFindingCmdArgs)obj.Data;
pointhit = data.hitPoint;

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

@ -742,13 +742,17 @@ public class FireManControl : MonoBehaviour
}
else
{
float realewater = 0;//实际分到的水量=自己的流量/直接水源的总流量*直接水源总水量
float dirTotalFlow = waterhosemanage.ConnentSource.GetComponent<WaterSource>().TotalFlow;
realewater = (Flow / dirTotalFlow) * remainwater;
if (Flow != 0)
remaintime = Mathf.CeilToInt(realewater / Flow);
else
remaintime = 0;
if (waterhosemanage.ConnentSource)
{
float realewater = 0;//实际分到的水量=自己的流量/直接水源的总流量*直接水源总水量
float dirTotalFlow = waterhosemanage.ConnentSource.GetComponent<WaterSource>().TotalFlow;
realewater = (Flow / dirTotalFlow) * remainwater;
if (Flow != 0)
remaintime = Mathf.CeilToInt(realewater / Flow);
else
remaintime = 0;
}
}
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++)
{
WaterSource ws = EntitiesManager.Instance.GetEntityByID(allwatersource[i]).GetComponent<WaterSource>();
if (ws.TotalWater != -100)
if (EntitiesManager.Instance.GetEntityByID(allwatersource[i]))
{
remainwater += (ws.TotalWater - ws.AllUserWater);
//if (ws.GetComponent<TruckBindWaterSource>())
//{
// allflow += ws.GetComponent<TruckBindWaterSource>().Flow;
//}
}
else
{
remainwater = -100;
break;
WaterSource ws = EntitiesManager.Instance.GetEntityByID(allwatersource[i]).GetComponent<WaterSource>();
if (ws.TotalWater != -100)
{
remainwater += (ws.TotalWater - ws.AllUserWater);
//if (ws.GetComponent<TruckBindWaterSource>())
//{
// allflow += ws.GetComponent<TruckBindWaterSource>().Flow;
//}
}
else
{
remainwater = -100;
break;
}
}
}
int remaintime = 0;
//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
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);
}
}

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

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

Loading…
Cancel
Save