NewN_UAVPlane/Assets/Zion/Scripts/UI/Item/CheckPanelSeatItem.cs

74 lines
2.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DataModel.Model;
public class CheckPanelSeatItem : MonoBehaviour
{
public practiceseat practiceseat1;
CheckPanelSubjectItem checkPanelSubjectItem;
public Text SeatName,userName,userAccount;
public Toggle toggle;
public void Init(practiceseat practiceseat, CheckPanelSubjectItem subjectitem)
{
practiceseat1 = practiceseat;
checkPanelSubjectItem = subjectitem;
SeatName.text = practiceseat1.SeatName;
userName.text = practiceseat1.UserName;
userAccount.text = practiceseat1.UserAccount;
if (!string.IsNullOrEmpty(practiceseat1.UserAccount) && practiceseat1.UserAccount != "999")
{
//已被选择
toggle.interactable = false;
toggle.isOn = true;
if(practiceseat1.UserAccount==LoadManage.Instance.me.user.user_name)
{
//是自己
checkPanelSubjectItem.MyChose = this;
}
}
else
{
//未被选择
toggle.interactable = true;
toggle.isOn = false;
toggle.group = checkPanelSubjectItem.toggleGroup;
}
toggle.onValueChanged.AddListener(a =>
{
if(a)
{
//选中
checkPanelSubjectItem.items.ForEach(b =>
{
if (b.toggle.interactable)
{
b.userName.text = "虚兵";
b.userAccount.text = "999";
if (b != this)
{
b.toggle.isOn = false;
}
}
});
userName.text = LoadManage.Instance.me.user.nickName;
userAccount.text = LoadManage.Instance.me.user.user_name;
checkPanelSubjectItem.MyChose = this;
}
else
{
if(checkPanelSubjectItem.MyChose==this)
{
checkPanelSubjectItem.MyChose = null;
userName.text = "虚兵";
userAccount.text = "999";
}
}
});
}
}