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.
899 lines
31 KiB
899 lines
31 KiB
using AX.NetworkSystem; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using AX.MessageSystem; |
|
using System; |
|
using UnityEngine.UI; |
|
using AX.InputSystem; |
|
|
|
/// <summary> |
|
/// 出水物体流量改变同步信息 |
|
/// </summary> |
|
public class FlowChangeData |
|
{ |
|
public long SenderId; |
|
public long GameObjId; |
|
public float Flow; |
|
} |
|
public class FireManControl : MonoBehaviour |
|
{ |
|
|
|
/// <summary> |
|
/// 当前使用的技能 |
|
/// </summary> |
|
public FireManSkills WorkType; |
|
public bool IsSprayWater; |
|
|
|
private Animator anim; |
|
|
|
private float Speed; |
|
private Transform shuiqiang; |
|
/// <summary> |
|
/// 消防员水枪 |
|
/// </summary> |
|
private Transform FiremanHose; |
|
//public GameObject FrothPrefabs; |
|
//public GameObject WaterFlowerPrefabs; |
|
//public GameObject WaterFogPrefabs; |
|
//public GameObject WaterStraightPrefabs; |
|
|
|
public SprayParticleType SelectParticleType; |
|
//粒子大小 |
|
public float ParticleSize = 0.2f; |
|
|
|
public float MaxSize = 0.4f; |
|
public float MinSize = 0.0f; |
|
|
|
public GameObject CurrentParticle; |
|
/// <summary> |
|
/// 水流量,如果设为私有的,同步只能改属性,然后属性改变又会同步,同步过来改这个值 |
|
/// </summary> |
|
public float flow; |
|
/// <summary> |
|
/// 剩余时间 |
|
/// </summary> |
|
public int RemainTime; |
|
/// <summary> |
|
/// 剩余水量 |
|
/// </summary> |
|
public float RemainWater; |
|
|
|
/// <summary> |
|
/// 出水纵向旋转 |
|
/// </summary> |
|
private float MinVrotate = -75; |
|
private float MaxVrotate = 15; |
|
private float NowVrotate = -20f; |
|
/// <summary> |
|
/// 出水横向旋转 |
|
/// </summary> |
|
// private float MinHrotate = -180; |
|
// private float MaxHrotate = 180; |
|
private float NowHrotate; |
|
|
|
private float timer = 1f; |
|
|
|
public SprayMode spraymode = SprayMode.WaterGun19; |
|
|
|
/// <summary> |
|
/// 水量用完 |
|
/// </summary> |
|
public bool waterrunoutof = false; |
|
private BaseGameObjInfo basegameinfo; |
|
private FireManWaterHoseManager waterhosemanage; |
|
private bool isFirstAirOrMoving = false; |
|
|
|
public Vector3 tagSearcehRoomStartPoint = Vector3.zero;//侦察消防员的起始点 |
|
|
|
/// <summary> |
|
/// 是否在移动或者急救伤员 |
|
/// </summary> |
|
public bool IsFirstAirOrMoving |
|
{ |
|
get |
|
{ |
|
return isFirstAirOrMoving; |
|
} |
|
|
|
set |
|
{ |
|
isFirstAirOrMoving = value; |
|
if (value == true) |
|
{ |
|
GetComponent<AgentController>().pathFindEnable = false; |
|
if (FireManSkillPanelController.Instance) |
|
{ |
|
FireManSkillPanelController.Instance.SetSkillDisable(); |
|
} |
|
} |
|
else |
|
{ |
|
GetComponent<AgentController>().pathFindEnable = true; |
|
if (FireManSkillPanelController.Instance) |
|
{ |
|
FireManSkillPanelController.Instance.SetSkillEnable(); |
|
} |
|
} |
|
} |
|
} |
|
public FireManSkills workType |
|
{ |
|
get |
|
{ |
|
return WorkType; |
|
} |
|
|
|
set |
|
{ |
|
WorkType = value; |
|
FiremanWorktypeChangeSyncData worksync = new FiremanWorktypeChangeSyncData(); |
|
worksync.SendUserID = CurrentUserInfo.mySelf.Id; |
|
worksync.worktype = value; |
|
worksync.gameObjID = GetComponent<BaseGameObjInfo>().gameObjID; |
|
worksync.UserID = GetComponent<BaseGameObjInfo>().UserID; |
|
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "FIREMAN_WORKTYPECHANGE_SYNC", worksync); |
|
} |
|
} |
|
|
|
public float Flow |
|
{ |
|
get |
|
{ |
|
return flow; |
|
} |
|
|
|
set |
|
{ |
|
flow = value; |
|
//if (GetComponent<FireManWaterHoseManager>().WaterLineConnent) |
|
//{ |
|
// GetComponent<FireManWaterHoseManager>().WaterLineConnent.GetComponent<ParentLinesMessage>().HasWaterCross = value > 0 ? true : false; |
|
//} |
|
//流量修改时重新分流 |
|
if (GetComponent<FireManWaterHoseManager>()) |
|
{ |
|
if (GetComponent<FireManWaterHoseManager>().ConnentSource) |
|
{ |
|
if (GetComponent<FireManWaterHoseManager>().ConnentSource.GetComponent<TruckMessage>()) |
|
{//直接水源是车辆 |
|
float remain = CheckWaterRemain(GetComponent<FireManWaterHoseManager>().WaterSourceLine); |
|
if (remain > 0 || remain == -100) |
|
{//水源有水 |
|
if (GetComponent<FireManWaterHoseManager>().ConnentSource.GetComponent<TruckMessage>()) |
|
{//直接水源为水源车辆 |
|
// GetComponent<FireManWaterHoseManager>().ConnentSource.GetComponent<TruckBindWaterSource>().Flow += ; |
|
GetComponent<FireManWaterHoseManager>().ConnentSource.GetComponent<WaterSource>().TotalFlowChange(basegameinfo.gameObjID, flow); |
|
} |
|
} |
|
else |
|
{ |
|
Debug.Log("水源没水了"); |
|
} |
|
} |
|
else |
|
{//直接连接的消防设施 |
|
// GetComponent<FireManWaterHoseManager>().ConnentSource.GetComponent<WaterSource>().TotalFlow += (value - prveflow); |
|
GetComponent<FireManWaterHoseManager>().ConnentSource.GetComponent<WaterSource>().TotalFlowChange(basegameinfo.gameObjID, flow); |
|
} |
|
} |
|
} |
|
|
|
//流量同步 |
|
FlowChangeData arg = new FlowChangeData |
|
{ |
|
SenderId = CurrentUserInfo.mySelf.Id, |
|
GameObjId = GetComponent<BaseGameObjInfo>().gameObjID, |
|
Flow = value, |
|
}; |
|
NetworkManager.Default.SendAsync("FLOW_CHANGE_SYNC", arg); |
|
} |
|
} |
|
|
|
|
|
|
|
void Start() |
|
{ |
|
basegameinfo = GetComponent<BaseGameObjInfo>(); |
|
waterhosemanage = GetComponent<FireManWaterHoseManager>(); |
|
anim = GetComponent<Animator>(); |
|
shuiqiang = TransformHelper.FindChild(transform, "shuiqiang"); |
|
|
|
//shuiqiang.gameObject.SetActive(true); |
|
//GetComponent<Animator>().SetBool("isInSitu", true); |
|
// NowVrotate = shuiqiang.transform.localRotation.eulerAngles.y; |
|
// NowVrotate = -20f; |
|
//NowHrotate = transform.eulerAngles.x; |
|
//NowHrotate = transform.localRotation.eulerAngles.y; |
|
FiremanHose = shuiqiang.Find("Hose"); |
|
|
|
//if (FrothPrefabs == null) |
|
//{ |
|
// FrothPrefabs = Resources.Load<GameObject>("Particle/Froth"); |
|
//} |
|
//if (WaterFlowerPrefabs == null) |
|
// WaterFlowerPrefabs = Resources.Load<GameObject>("Particle/WaterFlower"); |
|
//if (WaterFogPrefabs == null) |
|
// WaterFogPrefabs = Resources.Load<GameObject>("Particle/WaterFog"); |
|
//if (WaterStraightPrefabs == null) |
|
// WaterStraightPrefabs = Resources.Load<GameObject>("Particle/WaterStraight"); |
|
//MessageDispatcher.AddListener("SPRAY_WATER", Changeflow); |
|
//MessageDispatcher.AddListener("RUN_OUR_OF_WATER", CloseSpray); |
|
|
|
GetRealtimeConsume.getAllRealtimeConsume += addMyRealtimeConsume; //统计实时流量 |
|
|
|
MessageDispatcher.AddListener("ArrivedDestination", ArrivedDestination); |
|
} |
|
|
|
/// <summary> |
|
/// 消防员到达目的地 |
|
/// </summary> |
|
/// <param name="obj"></param> |
|
private void ArrivedDestination(IMessage obj) |
|
{ |
|
var data = (long)obj.Data; |
|
if (data == GetComponent<CloneGameObjInfo>().gameObjID) |
|
{ |
|
if (workType == FireManSkills.TagSearchRoom) |
|
{//这里会进两次:到达侦察点进入一次;回到侦察起始点一次 |
|
|
|
//回到侦察起始点后。注意:不能与下面的if块调换位置 |
|
if (tagSearcehRoomStartPoint == Vector3.zero) |
|
{ |
|
//侦察技能状态结束 |
|
workType = FireManSkills.None; |
|
ChangeUINameCmdArgs arg = new ChangeUINameCmdArgs(); |
|
arg.gameObjID = GetComponent<CloneGameObjInfo>().gameObjID; |
|
arg.Value = GetComponent<CloneGameObjInfo>().FullName; |
|
MessageDispatcher.SendMessage("CHANGE_HEAD_NAME", arg); |
|
|
|
//提示侦察信息 |
|
string tagSearchRoomInfo = GetTagSearchRoomInfo(); |
|
LoadPromptWin.Instance.LoadFailTextPromptWindow(tagSearchRoomInfo, 6f); |
|
} |
|
|
|
//到达侦察点后,触发回到侦察起始点的寻路 |
|
if (tagSearcehRoomStartPoint != Vector3.zero) |
|
{ |
|
GetComponent<AgentController>().AutoPathFinding(tagSearcehRoomStartPoint); |
|
tagSearcehRoomStartPoint = Vector3.zero; |
|
} |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 获取侦察信息 |
|
/// </summary> |
|
/// <returns></returns> |
|
private string GetTagSearchRoomInfo() |
|
{ |
|
string result = ""; |
|
|
|
Transform Pdister = GameObject.Find("P_AllParent").transform.Find("P_Disasters"); |
|
string comburent = ""; |
|
string position = ""; |
|
FireSpreadCtrl[] fireNormal = Pdister.Find("P_FireNormal").GetComponentsInChildren<FireSpreadCtrl>(); |
|
for (int i = 0; i < fireNormal.Length; i++) |
|
{ |
|
string thisfirecomburent = fireNormal[i].fireAttribute.comburent; |
|
string thisfireposition = fireNormal[i].fireAttribute.position; |
|
if (!comburent.Contains(thisfirecomburent)) |
|
{ |
|
comburent += thisfirecomburent; |
|
comburent += " "; |
|
} |
|
if (!position.Contains(thisfireposition)) |
|
{ |
|
position += thisfireposition; |
|
position += " "; |
|
} |
|
} |
|
|
|
if (position.Trim().Length > 0) |
|
{ |
|
result += "* 火灾位置为:" + position + "\n"; |
|
} |
|
else |
|
{ |
|
result += "* 火灾位置为:" + "不详" + "\n"; |
|
} |
|
|
|
if (comburent.Trim().Length > 0) |
|
{ |
|
result += "* 燃烧物为:" + comburent + "\n"; |
|
} |
|
else |
|
{ |
|
result += "* 燃烧物为:" + "不详" + "\n"; |
|
} |
|
|
|
int wonder = Pdister.transform.Find("P_Wounded").childCount; |
|
int Trapped = Pdister.transform.Find("P_TrappedPerson").childCount; |
|
string trap = wonder + Trapped > 0 ? "* 有被困人员" : "* 没有被困人员"; |
|
result += trap + "\n"; |
|
|
|
int dangerous = Pdister.transform.Find("P_DangerousCargo").childCount; |
|
result += dangerous > 0 ? "* 有危险品" : "* 没有危险品"; |
|
|
|
return result; |
|
} |
|
|
|
void Update() |
|
{ |
|
if (workType == FireManSkills.SprayWater) |
|
{ |
|
timer -= Time.deltaTime; |
|
if (timer <= 0) |
|
{ |
|
KeyValuePair<int, float> remain = GetWaterAndTimeRemain(waterhosemanage.WaterSourceLine); |
|
RemainTime = remain.Key; |
|
RemainWater = remain.Value; |
|
if (remain.Key != -100) |
|
{ |
|
if (remain.Key <= 0 || remain.Value <= 0) |
|
{//没水了 |
|
stopSpray(); |
|
} |
|
} |
|
|
|
if (GetComponentInChildren<ParticleControlOfType>() && GetComponentInChildren<ParticleControlOfType>().particleType == SprayParticleType.Froth) |
|
{//出的是泡沫,直接水源的泡沫 |
|
float remainfoam = CheckFoamRemain(); |
|
if (remainfoam == -100 || remainfoam > 0) |
|
{//直接水源有泡沫 |
|
GetComponent<FireManWaterHoseManager>().ConnentSource.GetComponent<WaterSource>().UserFoam((Flow / 0.97f) * 0.03f); |
|
} |
|
else |
|
{ |
|
stopSpray(); |
|
//LoadPromptWin.Instance.LoadTextPromptWindow("泡沫量不足", 1f); |
|
} |
|
} |
|
timer = 1; |
|
} |
|
} |
|
|
|
//if (workType == FireManSkills.SprayWater) |
|
//{ |
|
// if(waterrunoutof==false) |
|
// { |
|
// timer -= Time.deltaTime; |
|
// if (timer <= 0) |
|
// { |
|
// GameObject watersource = GetComponent<FireManWaterHoseManager>().ConnentSource; |
|
// if (watersource!=null) |
|
// { |
|
// watersource.GetComponent<WaterSource>().UserWater(Flow); |
|
// var watertimepair = watersource.GetComponent<WaterSource>().GetRemainTimeAndWater(); |
|
// RemainTime = watertimepair.Key; |
|
// RemainWater = watertimepair.Value; |
|
// } |
|
|
|
// timer = 1f; |
|
// } |
|
// } |
|
//} |
|
//if (gameObject==FireManSkillPanelController.Instance.SelectFireMan) |
|
//{ |
|
// if (GetComponentInChildren<ParticleControlOfType>()) |
|
// { |
|
// ParticleSize = GetComponentInChildren<ParticleControlOfType>().GetScaleValue(); |
|
// } |
|
//} |
|
} |
|
/// <summary> |
|
/// 出水动画 |
|
/// </summary> |
|
/// <param name="islay"></param> |
|
public void SetLay(bool islay) |
|
{ |
|
shuiqiang.gameObject.SetActive(islay); |
|
anim.SetBool("isInSitu", islay); |
|
|
|
} |
|
public void SetParticleType(SprayParticleType type) |
|
{ |
|
switch (type) |
|
{ |
|
case SprayParticleType.Froth: |
|
setShowParticle(type); |
|
SelectParticleType = SprayParticleType.Froth; |
|
CurrentParticle.GetComponentInChildren<ParticleControlOfType>(true).SetScaleValue(0.95f); |
|
ParticleSize = 0.95f; |
|
break; |
|
case SprayParticleType.WaterFlower: |
|
setShowParticle(type); |
|
SelectParticleType = SprayParticleType.WaterFlower; |
|
CurrentParticle.GetComponentInChildren<ParticleControlOfType>(true).SetScaleValue(2f); |
|
ParticleSize = 2f; |
|
break; |
|
case SprayParticleType.WaterFog: |
|
setShowParticle(type); |
|
SelectParticleType = SprayParticleType.WaterFog; |
|
CurrentParticle.GetComponentInChildren<ParticleControlOfType>(true).SetScaleValue(1.7f); |
|
ParticleSize = 1.7f; |
|
break; |
|
case SprayParticleType.WaterStraight: |
|
setShowParticle(type); |
|
SelectParticleType = SprayParticleType.WaterStraight; |
|
CurrentParticle.GetComponentInChildren<ParticleControlOfType>(true).SetScaleValue(0.2f); |
|
ParticleSize = 0.2f; |
|
break; |
|
} |
|
|
|
} |
|
private void setShowParticle(SprayParticleType type) |
|
{ |
|
for (int i = 0; i < FiremanHose.childCount; i++) |
|
{ |
|
if (type.ToString() == FiremanHose.GetChild(i).name) |
|
{ |
|
FiremanHose.GetChild(i).gameObject.SetActive(true); |
|
CurrentParticle = FiremanHose.GetChild(i).gameObject; |
|
} |
|
else |
|
{ |
|
FiremanHose.GetChild(i).gameObject.SetActive(false); |
|
} |
|
|
|
} |
|
|
|
} |
|
void OnEnable() |
|
{ |
|
GetUsers.PicTransferableCheck += checkPicTrans; |
|
RescueTeamManager.getAllRescueTeams += addMyRescue; |
|
} |
|
void OnDisable() |
|
{ |
|
GetUsers.PicTransferableCheck -= checkPicTrans; |
|
RescueTeamManager.getAllRescueTeams -= addMyRescue; |
|
//MessageDispatcher.RemoveListener("SPRAY_WATER", Changeflow); |
|
//MessageDispatcher.RemoveListener("RUN_OUR_OF_WATER", CloseSpray); |
|
} |
|
void OnDestroy() |
|
{ |
|
GetUsers.PicTransferableCheck -= checkPicTrans; |
|
RescueTeamManager.getAllRescueTeams -= addMyRescue; |
|
// MessageDispatcher.RemoveListener("SPRAY_WATER", Changeflow); |
|
//MessageDispatcher.RemoveListener("RUN_OUR_OF_WATER", CloseSpray); |
|
|
|
GetRealtimeConsume.getAllRealtimeConsume -= addMyRealtimeConsume; |
|
|
|
MessageDispatcher.RemoveListener("ArrivedDestination", ArrivedDestination); |
|
} |
|
|
|
private FloatData addMyRealtimeConsume(FloatData data) |
|
{ |
|
data.value += Flow; |
|
return data; |
|
} |
|
|
|
/// <summary> |
|
/// 连接的水源没有水了 |
|
/// </summary> |
|
/// <param name="obj"></param> |
|
private void CloseSpray(IMessage obj) |
|
{ |
|
// Debug.Log("over22"); |
|
if (workType == FireManSkills.SprayWater) |
|
{ |
|
long watersourceId = (long)obj.Data; |
|
long thiswaterid = -1; |
|
if (GetComponent<FireManWaterHoseManager>().ConnentSource != null) |
|
{ |
|
thiswaterid = GetComponent<FireManWaterHoseManager>().ConnentSource.GetComponent<BaseGameObjInfo>().gameObjID; |
|
} |
|
// Debug.Log(thiswaterid); |
|
if (watersourceId == thiswaterid) |
|
{ |
|
waterrunoutof = true; |
|
Flow = 0; |
|
workType = FireManSkills.None; |
|
if (FireManSkillPanelController.Instance) |
|
{ |
|
if (FireManSkillPanelController.Instance.SelectFireMan == gameObject) |
|
{ |
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().isOn = false; |
|
} |
|
} |
|
for (int i = 0; i < FiremanHose.childCount; i++) |
|
{ |
|
// Destroy(FiremanHose.GetChild(i).gameObject); |
|
if (FiremanHose.GetChild(i).gameObject.activeInHierarchy) |
|
{ |
|
FiremanHose.GetChild(i).gameObject.SetActive(false); |
|
} |
|
} |
|
SpraySyncData spraysync = new SpraySyncData(); |
|
spraysync.SendUserID = CurrentUserInfo.mySelf.Id; |
|
spraysync.IsOn = false; |
|
// spraysync.spraytype = SprayParticleType.WaterStraight; |
|
spraysync.gameObjID = basegameinfo.gameObjID; |
|
//spraysync.UserID = GetComponent<BaseGameObjInfo>().UserID; |
|
//spraysync.gameObjType = .GetComponent<BaseGameObjInfo>().gameObjType; |
|
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync); |
|
} |
|
} |
|
} |
|
public void DestoryPartical() |
|
{ |
|
for (int i = 0; i < FiremanHose.childCount; i++) |
|
{ |
|
//Destroy(FiremanHose.GetChild(i).gameObject); |
|
FiremanHose.GetChild(i).gameObject.SetActive(false); |
|
} |
|
} |
|
/// <summary> |
|
/// 连接的水源流量计算 |
|
/// </summary> |
|
/// <param name="obj"></param> |
|
private void Changeflow(IMessage obj) |
|
{ |
|
var info = (flowchangeinfo)obj.Data; |
|
if (info.ChangObjId == basegameinfo.gameObjID) |
|
{ |
|
GameObject watersource = GetComponent<FireManWaterHoseManager>().ConnentSource; |
|
if (watersource != null) |
|
{ |
|
watersource.GetComponent<WaterSource>().SetTotalFlow(new KeyValuePair<GameObject, float>(gameObject, Flow), info.IsAdd); |
|
} |
|
|
|
} |
|
} |
|
|
|
List<CloneGameObjInfo> checkPicTrans(List<CloneGameObjInfo> list, bool checkLevel) |
|
{ |
|
if (checkLevel) //需检查此消防员是否是自己下级 |
|
{ |
|
long userID = GetComponent<CloneGameObjInfo>().UserID; |
|
UserData data = CurrentUserInfo.room.FindUserById(userID); |
|
if (checkIsMine(data) && workType == FireManSkills.PictureTransmission) //是自己的下级,并且开启了4G图传技能 |
|
{ |
|
list.Add(GetComponent<CloneGameObjInfo>()); |
|
GetComponent<FireManMapIcon>().updateMap = true; |
|
return list; |
|
} |
|
else |
|
{ |
|
GetComponent<FireManMapIcon>().updateMap = false; |
|
return list; |
|
} |
|
} |
|
else //不用检查是否为自己下属 |
|
{ |
|
if (workType == FireManSkills.PictureTransmission) |
|
{ |
|
list.Add(GetComponent<CloneGameObjInfo>()); |
|
GetComponent<FireManMapIcon>().updateMap = true; |
|
return list; |
|
} |
|
else |
|
{ |
|
GetComponent<FireManMapIcon>().updateMap = false; |
|
return list; |
|
} |
|
} |
|
} |
|
bool checkIsMine(UserData userData) |
|
{ |
|
long id = userData.Org.ParentId; |
|
int lv = userData.Org.Level; |
|
/* |
|
//演习模式下 |
|
if (GameSettings.othersSettings.mode == Mode.manoeuvre && id == CurrentUserInfo.mySelf.) |
|
{ |
|
return true; |
|
} |
|
//练习模式下 |
|
else if (GameSettings.othersSettings.mode == Mode.Practice && id == CurrentUserInfo.organization.Id) |
|
{ |
|
return true; |
|
} |
|
else if (id == 0) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
UserData parentData = CurrentUserInfo.room.FindUserById(id); |
|
if (parentData != null) |
|
{ |
|
return checkIsMine(parentData); |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} */ |
|
if (lv > CurrentUserInfo.organization.Level) |
|
{ |
|
return true; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
|
|
public void Up() |
|
{ |
|
// NowVrotate = shuiqiang.transform.localRotation.eulerAngles.y; |
|
NowHrotate = transform.localRotation.eulerAngles.y; |
|
//NowVrotate = Mathf.Clamp((NowVrotate + 5), MinVrotate, MaxVrotate); |
|
if (NowVrotate < MaxVrotate) |
|
{ |
|
NowVrotate += 5; |
|
} |
|
else |
|
{ |
|
NowVrotate = MaxVrotate; |
|
} |
|
shuiqiang.transform.localRotation = Quaternion.Euler(18.4f, NowVrotate, 0); |
|
SprayRotateSyncData arg = new SprayRotateSyncData(); |
|
arg.SendUserID = CurrentUserInfo.mySelf.Id; |
|
arg.gameObjID = basegameinfo.gameObjID; |
|
arg.Vroatet = NowVrotate; |
|
arg.Hrotate = NowHrotate; |
|
NetworkManager.Default.SendAsync("FIREMAN_SPRAY_ROTATE_SYNC", arg); |
|
} |
|
|
|
public void Down() |
|
{ |
|
//NowVrotate = shuiqiang.transform.localRotation.eulerAngles.y; |
|
NowHrotate = transform.localRotation.eulerAngles.y; |
|
if (NowVrotate > MinVrotate) |
|
{ |
|
NowVrotate -= 5; |
|
} |
|
else |
|
{ |
|
NowVrotate = MinVrotate; |
|
} |
|
shuiqiang.transform.localRotation = Quaternion.Euler(18.4f, NowVrotate, 0); |
|
SprayRotateSyncData arg = new SprayRotateSyncData(); |
|
arg.SendUserID = CurrentUserInfo.mySelf.Id; |
|
arg.gameObjID = basegameinfo.gameObjID; |
|
arg.Vroatet = NowVrotate; |
|
arg.Hrotate = NowHrotate; |
|
NetworkManager.Default.SendAsync("FIREMAN_SPRAY_ROTATE_SYNC", arg); |
|
} |
|
|
|
public void Left() |
|
{ |
|
// NowVrotate = shuiqiang.transform.localRotation.eulerAngles.y; |
|
|
|
NowHrotate = transform.localRotation.eulerAngles.y - 5; |
|
//NowHrotate = Mathf.Clamp((NowHrotate - 5), MinHrotate, MaxHrotate); |
|
transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles.x, NowHrotate, transform.localRotation.eulerAngles.z); |
|
SprayRotateSyncData arg = new SprayRotateSyncData(); |
|
arg.SendUserID = CurrentUserInfo.mySelf.Id; |
|
arg.gameObjID = basegameinfo.gameObjID; |
|
arg.Vroatet = NowVrotate; |
|
arg.Hrotate = NowHrotate; |
|
NetworkManager.Default.SendAsync("FIREMAN_SPRAY_ROTATE_SYNC", arg); |
|
} |
|
|
|
public void Right() |
|
{ |
|
//NowVrotate = shuiqiang.transform.localRotation.eulerAngles.y; |
|
|
|
NowHrotate = transform.localRotation.eulerAngles.y + 5; |
|
//NowHrotate = Mathf.Clamp((NowHrotate + 5), MinHrotate, MaxHrotate); |
|
transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles.x, NowHrotate, transform.localRotation.eulerAngles.z); |
|
SprayRotateSyncData arg = new SprayRotateSyncData(); |
|
arg.SendUserID = CurrentUserInfo.mySelf.Id; |
|
arg.gameObjID = basegameinfo.gameObjID; |
|
arg.Vroatet = NowVrotate; |
|
arg.Hrotate = NowHrotate; |
|
NetworkManager.Default.SendAsync("FIREMAN_SPRAY_ROTATE_SYNC", arg); |
|
} |
|
/// <summary> |
|
/// 添加正在执行营救的人员中队名称 |
|
/// </summary> |
|
/// <param name="data"></param> |
|
/// <returns></returns> |
|
private List<string> addMyRescue(List<string> data) |
|
{ |
|
if (workType == FireManSkills.FristAid || workType == FireManSkills.Guidance || workType == FireManSkills.Move || workType == FireManSkills.Pacify || workType == FireManSkills.Save) |
|
{ |
|
long userid = GetComponent<CloneGameObjInfo>().UserID; |
|
string teamName = CurrentUserInfo.room.FindUserById(userid).Org.DisplayName; |
|
if (!data.Contains(teamName)) |
|
{ |
|
data.Add(teamName); |
|
} |
|
} |
|
return data; |
|
} |
|
|
|
|
|
/// <summary> |
|
/// 连接水源时造成的水源信息修改 |
|
/// </summary> |
|
/// <param name="watersourcevalue">直接水源上的两条线路信息总和</param> |
|
/// <param name="directionId">直接水源id</param> |
|
/// <param name="linenum">连接的哪条线路</param> |
|
public void ChangeWaterSourceLineInfo(long directionId, int linenum) |
|
{ |
|
List<List<long>> go = CloneBySerialize.Clone(GetDirectWaterSourceInfo(directionId)); |
|
go.Insert(0, new List<long> { directionId }); |
|
if (linenum == 0) |
|
{ |
|
GetComponent<FireManWaterHoseManager>().WaterSourceLine = go; |
|
Debug.Log(name + "水源信息更改"); |
|
} |
|
} |
|
/// <summary> |
|
/// 获取直接水源上的所有水源信息 |
|
/// </summary> |
|
/// <param name="directtionId">直接水源ID</param> |
|
/// <returns></returns> |
|
public List<List<long>> GetDirectWaterSourceInfo(long directtionId) |
|
{ |
|
List<List<long>> go = new List<List<long>>(); |
|
GameObject dirobj = EntitiesManager.Instance.GetEntityByID(directtionId); |
|
if (dirobj.GetComponent<TruckBindWaterSource>()) |
|
{ |
|
TruckBindWaterSource dirTBC = dirobj.GetComponent<TruckBindWaterSource>(); |
|
List<List<long>> line1 = CloneBySerialize.Clone(dirTBC.WaterSourceLine1); |
|
List<List<long>> line2 = CloneBySerialize.Clone(dirTBC.WaterSourceLine2); |
|
line1.Reverse(); |
|
line2.Reverse(); |
|
int count = line1.Count >= line2.Count ? line1.Count : line2.Count; |
|
//List<List<long>> go = new List<List<long>>(count); |
|
for (int i = 0; i < count; i++) |
|
{ |
|
List<long> depth = new List<long>(); |
|
if (i < line1.Count) |
|
{ |
|
for (int j = 0; j < line1[i].Count; j++) |
|
{ |
|
depth.Add(line1[i][j]); |
|
} |
|
} |
|
if (i < line2.Count) |
|
{ |
|
for (int j = 0; j < line2[i].Count; j++) |
|
{ |
|
depth.Add(line2[i][j]); |
|
} |
|
} |
|
|
|
go.Add(depth); |
|
} |
|
go.Reverse(); |
|
} |
|
else |
|
{//消防设施没有进水口 |
|
|
|
} |
|
|
|
return go; |
|
} |
|
|
|
/// <summary> |
|
/// 检查当前水源线是否还有多少水 |
|
/// </summary> |
|
/// <param name="watersouce"></param> |
|
/// <returns></returns> |
|
public float CheckWaterRemain(List<List<long>> watersouce) |
|
{ |
|
float allremain = 0; |
|
|
|
for (int i = 0; i < watersouce.Count; i++) |
|
{ |
|
for (int j = 0; j < watersouce[i].Count; j++) |
|
{ |
|
WaterSource ws = EntitiesManager.Instance.GetEntityByID(watersouce[i][j]).GetComponent<WaterSource>(); |
|
if (ws.TotalWater != -100) |
|
{ |
|
allremain += (ws.TotalWater - ws.AllUserWater); |
|
} |
|
else |
|
{ |
|
allremain = -100; |
|
break; |
|
} |
|
} |
|
} |
|
|
|
return allremain; |
|
} |
|
public KeyValuePair<int, float> GetWaterAndTimeRemain(List<List<long>> waterline) |
|
{ |
|
KeyValuePair<int, float> remain = new KeyValuePair<int, float>(); |
|
// float allflow = 0; |
|
float remainwater = 0; |
|
List<long> allwatersource = new List<long>(); |
|
for (int i = 0; i < waterline.Count; i++) |
|
{ |
|
for (int j = 0; j < waterline[i].Count; j++) |
|
{ |
|
if (!allwatersource.Contains(waterline[i][j])) |
|
{ |
|
allwatersource.Add(waterline[i][j]); |
|
} |
|
} |
|
} |
|
for (int i = 0; i < allwatersource.Count; i++) |
|
{ |
|
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; |
|
if (remainwater == -100) |
|
{ |
|
remaintime = -100; |
|
} |
|
else |
|
{ |
|
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); |
|
|
|
|
|
return remain; |
|
} |
|
void stopSpray() |
|
{ |
|
Flow = 0; |
|
RemainTime = 0; |
|
RemainWater = 0; |
|
SetLay(false); |
|
DestoryPartical(); |
|
GetComponent<LayWaterHose>().EndLay(); |
|
workType = FireManSkills.None; |
|
if (FireManSkillPanelController.Instance && FireManSkillPanelController.Instance.SelectFireMan == gameObject) |
|
{ |
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().isOn = false; |
|
} |
|
SpraySyncData spraysync = new SpraySyncData(); |
|
spraysync.SendUserID = CurrentUserInfo.mySelf.Id; |
|
spraysync.IsOn = false; |
|
spraysync.gameObjID = basegameinfo.gameObjID; |
|
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync); |
|
|
|
} |
|
public float CheckFoamRemain() |
|
{ |
|
float remain = 0; |
|
WaterSource ws = GetComponent<FireManWaterHoseManager>().ConnentSource.GetComponent<WaterSource>(); |
|
if (ws.foam) |
|
{ |
|
if (ws.TotalFoam != -100) |
|
{ |
|
remain = ws.TotalFoam - ws.AllUserFoam; |
|
} |
|
else |
|
{ |
|
remain = -100; |
|
} |
|
} |
|
return remain; |
|
} |
|
}
|
|
|