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.
99 lines
3.2 KiB
99 lines
3.2 KiB
4 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据房间人员列表生成需设置的列表
|
||
|
/// </summary>
|
||
|
public class ArriveTimeContent : MonoBehaviour
|
||
|
{
|
||
|
public List<KeyValuePair<long, int>> ArriveTimeList = new List<KeyValuePair<long, int>>();
|
||
|
public Transform ArriveTimeContentTransform;
|
||
|
public GameObject ArriveTimeItem;
|
||
|
List<UserData> udatalist = new List<UserData>();
|
||
|
private List<UserData> needSetting = new List<UserData>();
|
||
|
public bool Isset = true;
|
||
|
void Awake()
|
||
|
{
|
||
|
udatalist = CurrentUserInfo.room.UserList;
|
||
|
for (int i = 0; i < udatalist.Count; i++)
|
||
|
{
|
||
|
if (udatalist[i].Role == Role.导调组 ||
|
||
|
udatalist[i].Role == Role.战斗班长 ||
|
||
|
udatalist[i].Role == Role.总队指挥中心 ||
|
||
|
udatalist[i].Role == Role.支队指挥中心 ||
|
||
|
udatalist[i].Role == Role.参谋 ||
|
||
|
udatalist[i].Role == Role.观察团 ||
|
||
|
udatalist[i].Role == Role.None)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
needSetting.Add(udatalist[i]);
|
||
|
}
|
||
|
}
|
||
|
if (ArriveTimeItem == null)
|
||
|
{
|
||
|
ArriveTimeItem = Resources.Load("LeadGroup/ArriveTimeItem") as GameObject;
|
||
|
}
|
||
|
CreatArriveItem();
|
||
|
}
|
||
|
// Use this for initialization
|
||
|
void Start()
|
||
|
{
|
||
|
//把生成的Toggle加组
|
||
|
Toggle[] childtoggle = ArriveTimeContentTransform.GetComponentsInChildren<Toggle>();
|
||
|
for (int i = 0; i < childtoggle.Length; i++)
|
||
|
{
|
||
|
childtoggle[i].GetComponent<Toggle>().group = transform.GetComponent<ToggleGroup>();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CreatArriveItem()
|
||
|
{
|
||
|
for (int i = 0; i < needSetting.Count; i++)
|
||
|
{
|
||
|
GameObject Item = Instantiate(ArriveTimeItem, ArriveTimeContentTransform);
|
||
|
Item.name = needSetting[i].UserInfo.RealName;
|
||
|
Item.transform.Find("Toggle/OriText").GetComponent<Text>().text = needSetting[i].Org.DisplayName;
|
||
|
Item.GetComponent<ArriveTimeItem>().UserID = needSetting[i].UserInfo.Id;
|
||
|
}
|
||
|
}
|
||
|
public void GetArriveTime()
|
||
|
{
|
||
|
ArriveTimeItem[] allitem = ArriveTimeContentTransform.GetComponentsInChildren<ArriveTimeItem>(true);
|
||
|
for (int i = 0; i < allitem.Length; i++)
|
||
|
{
|
||
|
if ((allitem[i].MTime * 60 + allitem[i].STime) <= 0)
|
||
|
{
|
||
|
Isset = false;
|
||
|
break;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Isset = true;
|
||
|
KeyValuePair<long, int> ArriveItem = new KeyValuePair<long, int>(allitem[i].UserID, allitem[i].MTime * 60 + allitem[i].STime);
|
||
|
if (!CheckHasSetArriveTime(ArriveItem))
|
||
|
ArriveTimeList.Add(ArriveItem);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private bool CheckHasSetArriveTime(KeyValuePair<long, int> ArriveItem)
|
||
|
{
|
||
|
bool result = false;
|
||
|
for (int i = 0; i < ArriveTimeList.Count; i++)
|
||
|
{
|
||
|
if (ArriveTimeList[i].Key == ArriveItem.Key)
|
||
|
{
|
||
|
ArriveTimeList[i] = ArriveItem;
|
||
|
result = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
}
|