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.
75 lines
2.2 KiB
75 lines
2.2 KiB
using AX.MessageSystem; |
|
using AX.Network.Protocols; |
|
using AX.NetworkSystem; |
|
using AX.Serialization; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
public class ZDBOwnerScroll : MonoBehaviour { |
|
public GameObject itemPre; |
|
public Transform content; |
|
private List<UserData> users = new List<UserData>(); |
|
public ToggleGroup toggleGroup; |
|
// Use this for initialization |
|
void Awake () { |
|
if (itemPre == null) |
|
{ |
|
itemPre = Resources.Load("HandOver/OwnerItem") as GameObject; |
|
} |
|
if (content == null) |
|
{ |
|
content = transform.Find("Viewport/Content"); |
|
} |
|
toggleGroup = GetComponent<ToggleGroup>(); |
|
} |
|
void OnEnable() |
|
{ |
|
getMyUsers(); |
|
CreateItems(); |
|
NetworkMessageDispatcher.AddListener("HAND_OVER_SYNC", Reset); |
|
} |
|
void OnDisable() |
|
{ |
|
NetworkMessageDispatcher.RemoveListener("HAND_OVER_SYNC", Reset); |
|
} |
|
void getMyUsers() |
|
{ |
|
users = new List<UserData>(); |
|
foreach (UserData user in CurrentUserInfo.room.UserList) |
|
{ |
|
//找出与自己同一中队的战斗班和上级中队指挥 |
|
if (user.UserInfo.Id != CurrentUserInfo.mySelf.Id && (user.Org.ParentId == CurrentUserInfo.organization.ParentId || user.Org.Id==CurrentUserInfo.organization.ParentId)) |
|
{ |
|
users.Add(user); |
|
} |
|
} |
|
} |
|
void CreateItems() |
|
{ |
|
for (int i = 0; i < content.childCount; i++) |
|
{ |
|
Destroy(content.GetChild(i).gameObject); |
|
} |
|
foreach (UserData user in users) |
|
{ |
|
GameObject userItem = Instantiate(itemPre, content); |
|
userItem.transform.Find("OwnerToggle").GetComponent<OwnerToggle>().Set(user,toggleGroup); |
|
userItem.transform.Find("OwnerPanel").GetComponent<OwnerPanel>().GetOwnersPower(user); |
|
} |
|
} |
|
void Reset(BinaryMessage message) |
|
{ |
|
StartCoroutine(UpdateUsers()); |
|
} |
|
IEnumerator UpdateUsers() |
|
{ |
|
yield return new WaitForSeconds(0.1f); |
|
getMyUsers(); |
|
CreateItems(); |
|
} |
|
// Update is called once per frame |
|
void Update () { |
|
|
|
} |
|
}
|
|
|