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.
318 lines
11 KiB
318 lines
11 KiB
using AX.NetworkSystem; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.SceneManagement; |
|
using UnityEngine.UI; |
|
using AX.Network.Protocols; |
|
using System; |
|
|
|
public class PoliceCallData |
|
{ |
|
public long UserId;//发送者id; |
|
public long RoomID;//房间号 |
|
public string Name;//报警人姓名 |
|
public string Phone;//电话 |
|
public string FirePlace;//着火地点 |
|
public string FireReason;//起火原因 |
|
public string FireArea;//着火面积 |
|
public string FireLevel;//危险等级 |
|
public string HasDangerous;//是否有危险品 |
|
public string HasTrapped;//是否有伤员/被困人员 |
|
public List<KeyValuePair<long, int>> ArriveTimeList;//每个用户到达时间 |
|
} |
|
public class PoliceInfoMsgBind : MonoBehaviour |
|
{ |
|
[Rename("报警人")] |
|
public Text PoliceCallName; |
|
[Rename("报警人联系方式")] |
|
public Text PoliceCallPhone; |
|
[Rename("着火地点")] |
|
public Text FirePlace; |
|
[Rename("着火原因")] |
|
public Text FireReason; |
|
[Rename("是否有被困人员")] |
|
public Text HasTrapped; |
|
[Rename("倒计时总时间")] |
|
public Text TotalTime; |
|
private float TimeAll; |
|
private bool HasSet = false; |
|
private float timmer; |
|
|
|
public CarMoveManager CarManager; |
|
public List<bool> isExistCmdRoles; |
|
|
|
// Use this for initialization |
|
void Start() |
|
{ |
|
if (GameSettings.disasterSetting.policeCallData != null) |
|
BindPoliceCallData(GameSettings.disasterSetting.policeCallData); |
|
} |
|
|
|
//用来绑定报警人信息的方法 |
|
public void BindPoliceCallData(PoliceCallData data) |
|
{ |
|
Debug.Log(CurrentUserInfo.room.UserList.Count); |
|
//List<FireCarEngine> CarList = new List<FireCarEngine>(); |
|
PoliceCallName.text = data.Name; |
|
PoliceCallPhone.text = data.Phone; |
|
FirePlace.text = data.FirePlace; |
|
FireReason.text = data.FireReason; |
|
HasTrapped.text = data.HasTrapped; |
|
foreach (var item in data.ArriveTimeList) |
|
{ |
|
if (item.Key == CurrentUserInfo.mySelf.Id) |
|
{ |
|
TimeAll = item.Value; |
|
|
|
TotalTime.text = Mathf.FloorToInt(item.Value / 60) + " 分 " + Mathf.FloorToInt(item.Value % 60) + " 秒"; |
|
if (GameSettings.othersSettings.CarList.Count > 0) |
|
{ |
|
//foreach (var car in GameSettings.othersSettings.CarList) |
|
//{ |
|
// CarList.Add(car.Key); |
|
//} |
|
|
|
CarManager.MoveCar(TimeAll, GameSettings.othersSettings.CarList); |
|
} |
|
else |
|
{ |
|
CarManager.MoveCar(TimeAll, new List<KeyValuePair<FireCarEngine, int>>()); |
|
} |
|
} |
|
} |
|
StartCoroutine(WaitTheSet()); |
|
} |
|
IEnumerator WaitTheSet() |
|
{ |
|
yield return new WaitForSeconds(2f); |
|
HasSet = true; |
|
} |
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
if (HasSet) |
|
{ |
|
timmer += Time.deltaTime; |
|
|
|
if (timmer >= 1) |
|
{ |
|
if (Mathf.FloorToInt((TimeAll) / 60) > 0) |
|
{ |
|
TotalTime.text = Mathf.FloorToInt((TimeAll) / 60) + " 分 " + Mathf.Ceil(TimeAll) % 60 + " 秒"; |
|
} |
|
else |
|
{ |
|
TotalTime.text = Mathf.Ceil(TimeAll) % 60.0001 + " 秒"; |
|
} |
|
|
|
TimeAll -= 1; |
|
|
|
timmer = 0; |
|
} |
|
|
|
if (Mathf.FloorToInt(TimeAll) == 0) |
|
{ |
|
GeneralCommandingUpdate(); |
|
|
|
RoleUICtrl.Instance.ShowRoleUI(); |
|
NetworkManager.Default.SendAsync("FIREDEPLOY_ARRIVED_SYNC",CurrentUserInfo.organization.DisplayName); //通知各客户端有中队车辆到场 |
|
} |
|
} |
|
} |
|
|
|
|
|
private List<int> SupsId = new List<int>(); |
|
private List<int> SubsId = new List<int>(); |
|
private List<UserData> supOrgs = new List<UserData>();//当前登陆用户所有的上级 |
|
private List<UserData> subOrgs = new List<UserData>();//当前登陆用户所有的下级 |
|
|
|
//设置总指挥的逻辑处理 |
|
private void GeneralCommandingUpdate() |
|
{ |
|
if (CurrentUserInfo.organization.Level != 5 |
|
&& CurrentUserInfo.role != Role.总队指挥中心 |
|
&& CurrentUserInfo.role != Role.支队指挥中心 |
|
&& CurrentUserInfo.role != Role.导调组 |
|
&& CurrentUserInfo.role != Role.观察团 |
|
&& CurrentUserInfo.role != Role.参谋 |
|
&& CurrentUserInfo.role != Role.战斗班长) |
|
{//当前登陆用户所选角色是总队指挥,支队指挥,大队指挥,中队指挥; |
|
|
|
FindAllSupID(CurrentUserInfo.organization.ParentId); |
|
|
|
bool isExistSup = false; |
|
foreach (UserData item in CurrentUserInfo.room.UserList) |
|
{ |
|
if (SupsId.Contains(item.Org.Id) |
|
&& (item.Role == Role.总队指挥 |
|
|| item.Role == Role.支队指挥 |
|
|| item.Role == Role.大队指挥 |
|
|| item.Role == Role.中队指挥)) |
|
{//当前登陆用户的已经登陆进入房间了的直属上级或跨级上级 |
|
isExistSup = true; |
|
break; |
|
} |
|
} |
|
|
|
if (!isExistSup) |
|
{ |
|
FindAllSubID(CurrentUserInfo.organization.Id); |
|
|
|
bool isExistSub = false; |
|
foreach (UserData item in CurrentUserInfo.room.UserList) |
|
{ |
|
if (SubsId.Contains(item.Org.Id) |
|
&& (item.Role == Role.总队指挥 |
|
|| item.Role == Role.支队指挥 |
|
|| item.Role == Role.大队指挥 |
|
|| item.Role == Role.中队指挥)) |
|
{ |
|
isExistSub = true; |
|
break; |
|
} |
|
} |
|
|
|
if (!isExistSub) |
|
{ |
|
List<long> Uids = new List<long>(); |
|
foreach (UserData item in CurrentUserInfo.room.UserList) |
|
{ |
|
if ((item.Role == Role.总队指挥 |
|
|| item.Role == Role.支队指挥 |
|
|| item.Role == Role.大队指挥 |
|
|| item.Role == Role.中队指挥) |
|
&& item.UserInfo.Id != CurrentUserInfo.mySelf.Id) |
|
{//判断不为自己 |
|
|
|
Uids.Add(item.UserInfo.Id); |
|
} |
|
} |
|
|
|
if (Uids.Count == 0) |
|
{ |
|
CurrentUserInfo.generalCommanding = true; |
|
} |
|
else |
|
{ |
|
//是否存在组织机构已为总指挥 |
|
NetworkManager.Default.SendAsync("EXIST_OTHER_DEPT_ISCMD_SYNC", |
|
new KeyValuePair<long, List<long>>(CurrentUserInfo.mySelf.Id, Uids)); |
|
} |
|
|
|
} |
|
else |
|
{ |
|
CurrentUserInfo.generalCommanding = true;//设置当前登陆用户为总指挥 |
|
|
|
foreach (UserData item in CurrentUserInfo.room.UserList) |
|
{ |
|
if (CurrentUserInfo.mySelf.Id != item.UserInfo.Id) |
|
{ |
|
//通知当前登陆用户的下级移交总指挥(接收处理时设置CurrentUserInfo.generalCommanding为false) |
|
NetworkManager.Default.SendAsync("GENERAL_COMMANDING_UPDATE_SYNC", item.UserInfo.Id); |
|
} |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
FindAllSubID(CurrentUserInfo.organization.Id); |
|
|
|
bool isExistSub = false; |
|
foreach (UserData item in CurrentUserInfo.room.UserList) |
|
{ |
|
if (SubsId.Contains(item.Org.Id) |
|
&& (item.Role == Role.总队指挥 |
|
|| item.Role == Role.支队指挥 |
|
|| item.Role == Role.大队指挥 |
|
|| item.Role == Role.中队指挥)) |
|
{ |
|
isExistSub = true; |
|
break; |
|
} |
|
} |
|
|
|
if (!isExistSub) |
|
{ |
|
List<long> Uids = new List<long>(); |
|
foreach (UserData item in CurrentUserInfo.room.UserList) |
|
{ |
|
if ((item.Role == Role.总队指挥 |
|
|| item.Role == Role.支队指挥 |
|
|| item.Role == Role.大队指挥 |
|
|| item.Role == Role.中队指挥) |
|
&& item.UserInfo.Id != CurrentUserInfo.mySelf.Id) |
|
{//判断不为自己 |
|
|
|
Uids.Add(item.UserInfo.Id); |
|
} |
|
} |
|
|
|
if (Uids.Count == 0) |
|
{ |
|
CurrentUserInfo.generalCommanding = true; |
|
} |
|
else |
|
{ |
|
//是否存在组织机构已为总指挥 |
|
NetworkManager.Default.SendAsync("EXIST_OTHER_DEPT_ISCMD_SYNC", |
|
new KeyValuePair<long, List<long>>(CurrentUserInfo.mySelf.Id, Uids)); |
|
} |
|
|
|
} |
|
else |
|
{//既有上级也有下级 |
|
supOrgs.Clear(); |
|
|
|
foreach (UserData item in CurrentUserInfo.room.UserList) |
|
{ |
|
if (SupsId.Contains(item.Org.Id) |
|
&& (item.Role == Role.总队指挥 |
|
|| item.Role == Role.支队指挥 |
|
|| item.Role == Role.大队指挥 |
|
|| item.Role == Role.中队指挥)) |
|
{//找出当前登陆用户在房间内的上级 |
|
|
|
supOrgs.Add(item); |
|
} |
|
} |
|
|
|
NetworkManager.Default.SendAsync("GET_SUP_ISCOMMAND_SYNC", |
|
new KeyValuePair<long, List<UserData>>(CurrentUserInfo.mySelf.Id, supOrgs)); |
|
} |
|
} |
|
} |
|
|
|
} |
|
|
|
private void FindAllSupID(int supId) |
|
{ |
|
foreach (var item in GameSettings.othersSettings.orgs) |
|
{ |
|
//查看我是否存在上级 |
|
if (item.Id == supId && item.Level != 5) |
|
{ |
|
//保存上级的ID |
|
SupsId.Add(item.Id); |
|
//继续查找item的上级是否存在上级 |
|
FindAllSupID(item.ParentId); |
|
} |
|
} |
|
} |
|
|
|
private void FindAllSubID(int id) |
|
{ |
|
foreach (var item in GameSettings.othersSettings.orgs) |
|
{ |
|
//查看我是否存在下级 |
|
if (item.ParentId == id && item.Level != 5) |
|
{ |
|
//保存下级的ID |
|
SubsId.Add(item.Id); |
|
//继续查找item的下级是否存在下级 |
|
FindAllSubID(item.Id); |
|
} |
|
} |
|
} |
|
}
|
|
|