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.
118 lines
5.0 KiB
118 lines
5.0 KiB
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using AX.Network.Protocols; |
|
using UnityEngine; |
|
using AX.Serialization; |
|
using UnityEngine.SceneManagement; |
|
using AX.NetworkSystem; |
|
using System.Linq; |
|
|
|
public class COMMANDCENTER_FIRENOTIFY_SYNC : NetworkMessageBehaviour |
|
{ |
|
protected override void Execute(BinaryMessage message) |
|
{ |
|
var info = message.Body.Deserialize<PoliceCallData>(); |
|
|
|
if (CurrentUserInfo.role == Role.总队指挥 || |
|
CurrentUserInfo.role == Role.大队指挥 || |
|
CurrentUserInfo.role == Role.支队指挥 |
|
) |
|
{ |
|
GameSettings.disasterSetting.policeCallData = info; |
|
foreach (UserData u in CurrentUserInfo.room.UserList) |
|
{ |
|
if (u.Org.Id == CurrentUserInfo.organization.Id && u.Role == Role.参谋) |
|
// 参谋随着对应总队、支队、大队跳转场景 |
|
{ |
|
//将通报指令转发给参谋同时添加参谋到场时间 |
|
int time = 0; |
|
foreach (var item in info.ArriveTimeList) |
|
{ |
|
if (item.Key == CurrentUserInfo.mySelf.Id) |
|
{ |
|
time = item.Value; |
|
} |
|
} |
|
info.ArriveTimeList.Add(new KeyValuePair<long, int>(u.UserInfo.Id, time)); |
|
NetworkManager.Default.SendAsync("COMMANDCENTER_FIRENOTIFY_SYNC", new KeyValuePair<long, PoliceCallData> |
|
(u.UserInfo.Id, info)); |
|
} |
|
} |
|
|
|
//SceneManager.LoadScene("Police"); |
|
//再再这里判断是不是有重复时间,有的话开携程等待 |
|
List<KeyValuePair<long, int>> zhiHArrivetimes = new List<KeyValuePair<long, int>>(); |
|
List<long> ZHID = new List<long>(); |
|
for (int i = 0; i < CurrentUserInfo.room.UserList.Count; i++) |
|
{//筛选房间里的总支大队ID |
|
if (CurrentUserInfo.room.UserList[i].Role==Role.总队指挥|| |
|
CurrentUserInfo.room.UserList[i].Role == Role.支队指挥 || |
|
CurrentUserInfo.room.UserList[i].Role == Role.大队指挥) |
|
{ |
|
ZHID.Add(CurrentUserInfo.room.UserList[i].UserInfo.Id); |
|
} |
|
} |
|
for (int i = 0; i < info.ArriveTimeList.Count; i++) |
|
{//根据房间里的总支大id筛选到达时间里的总支大 |
|
if (ZHID.Contains(info.ArriveTimeList[i].Key)) |
|
{ |
|
zhiHArrivetimes.Add(info.ArriveTimeList[i]); |
|
} |
|
} |
|
//根据到达时间分组 |
|
var q = from p in zhiHArrivetimes group p by p.Value; |
|
var timelist= q.ToList(); |
|
for (int i = 0; i < timelist.Count; i++) |
|
{ |
|
var pairlist = timelist[i].ToList(); |
|
if (pairlist.Count > 1) |
|
{//如果组里的个数大于一,也就是有两个及以上设置的时间是相同的 |
|
for (int j = 0; j < pairlist.Count; j++) |
|
{ |
|
if (CurrentUserInfo.mySelf.Id == pairlist[j].Key) |
|
{//加0.5是考虑第一组也就是i=0的情况,没有加整数是考虑计算出来的数可能设置时间相同最后导致进场时间还是一样 |
|
StartCoroutine(waitinto((i + 0.5f) * (j+0.5f))); |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
if (CurrentUserInfo.mySelf.Id == pairlist[0].Key) |
|
{ |
|
StartCoroutine(waitinto(0)); |
|
} |
|
} |
|
|
|
} |
|
} |
|
//else if (CurrentUserInfo.role == Role.中队指挥) |
|
//{ |
|
// GameSettings.disasterSetting.policeCallData = info; |
|
// foreach (UserData u in CurrentUserInfo.room.UserList) |
|
// { |
|
// if (u.Org.Id == CurrentUserInfo.organization.Id && u.Role == Role.战斗班长) |
|
// // 参谋随着对应战斗班跳转场景 |
|
// { |
|
// //将通报指令转发给战斗班 |
|
// NetworkManager.Default.SendAsync("COMMANDCENTER_FIRENOTIFY_SYNC", new KeyValuePair<long, PoliceCallData> |
|
// (u.UserInfo.Id, info)); |
|
// } |
|
// } |
|
// SceneManager.LoadScene("Police"); |
|
//} |
|
else |
|
{ |
|
GameSettings.disasterSetting.policeCallData = info; |
|
// SceneManager.LoadScene("Police"); |
|
transform.parent.Find("Police").gameObject.SetActive(true); |
|
UIManager.GetView<ChatPanel>().ShowPoliceSize(); |
|
} |
|
} |
|
IEnumerator waitinto(float time) |
|
{ |
|
yield return new WaitForSeconds(time*0.2f); |
|
transform.parent.Find("Police").gameObject.SetActive(true); |
|
UIManager.GetView<ChatPanel>().ShowPoliceSize(); |
|
} |
|
}
|
|
|