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.
76 lines
2.3 KiB
76 lines
2.3 KiB
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
using System.Linq; |
|
using AX.NetworkSystem; |
|
|
|
public class PoliceToController : MonoBehaviour |
|
{ |
|
public GameObject powerItem; |
|
public Transform powerParent; |
|
public ButtonRecordByAC SureBtn; |
|
public ButtonRecordByAC CancelBtn; |
|
private List<UserData> SelectedRoomUser; |
|
private bool HasCall; |
|
void Awake() |
|
{ |
|
SelectedRoomUser = new List<UserData>(); |
|
SureBtn.OutInterFaceButton = SureBtnClick; |
|
CancelBtn.OutInterFaceButton = CancelBtnClick; |
|
} |
|
|
|
private void CancelBtnClick() |
|
{ |
|
gameObject.SetActive(false); |
|
} |
|
|
|
private void SureBtnClick() |
|
{ |
|
if (powerParent.childCount == 0) |
|
return; |
|
|
|
foreach (Transform t in powerParent) |
|
{ |
|
if (t.GetComponent<Toggle>().isOn) |
|
{ |
|
UserData udata = t.GetComponent<NoticeItem>().UData; |
|
GameSettings.disasterSetting.policeCallData.UserId = CurrentUserInfo.mySelf.Id; |
|
//通报指令发送 |
|
NetworkManager.Default.SendAsync("COMMANDCENTER_FIRENOTIFY_SYNC", new KeyValuePair<long, PoliceCallData> |
|
(udata.UserInfo.Id, GameSettings.disasterSetting.policeCallData)); |
|
Destroy(t.gameObject); |
|
SelectedRoomUser.Remove(udata); |
|
HasCall = true; |
|
} |
|
} |
|
} |
|
void OnEnable() |
|
{ |
|
if (SelectedRoomUser != null && !HasCall) |
|
foreach (UserData data in CurrentUserInfo.room.UserList) |
|
{ |
|
if ((data.Role == Role.总队指挥) || (data.Role == Role.支队指挥) || (data.Role == Role.大队指挥)) |
|
{ |
|
if(!SelectedRoomUser.Contains(data)) |
|
SelectedRoomUser.Add(data); |
|
} |
|
} |
|
bindData(); |
|
} |
|
private void bindData() |
|
{ |
|
if (powerParent.childCount > 0) |
|
foreach (Transform t in powerParent) |
|
{ |
|
Destroy(t.gameObject); |
|
} |
|
if (SelectedRoomUser.Count > 0) |
|
foreach (UserData u in SelectedRoomUser) |
|
{ |
|
GameObject g = Instantiate(powerItem, powerParent); |
|
g.GetComponent<NoticeItem>().Bind(u); |
|
} |
|
} |
|
}
|
|
|