广西桂平帝恒管道燃气投资有限公司多角色网上演练
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.
 
 
 
 
 

119 lines
4.3 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public enum SelectionInitType
{
, , , , ,
}
public class RolesInit : MonoBehaviour
{
private Transform PrefabParent;
private ToggleGroup Group;
public static SelectionInitType NowInitType;
public UI_Control_ScrollFlow _ScrollFlow;
public GameObject CanMouPrefab;
public GameObject DaDuiZhiHuiPrefab;
public GameObject DaoDiaoPrefab;
public GameObject GuanChaTuanPrefab;
public GameObject ZhanDouBanZhangPrefab;
public GameObject ZhiDuiZhiHuiPrefab;
public GameObject ZongDuiZhiHuiZhongXinPrefab;
public GameObject ZhiDuiZhiHuiZhongXinPrefab;
public GameObject ZhongDuiZhuiHuiPrefab;
public GameObject ZongDuiZhiHuiPrefab;
public void Awake()
{
PrefabParent = transform;
_ScrollFlow = GetComponent<UI_Control_ScrollFlow>();
//if (GameSettings.othersSettings.mode != Mode.manoeuvre)
// Init(SelectionInitType.所有);
}
/// <summary>
/// 重新加载角色选择项
/// </summary>
/// <param name="Type">需要加载的角色类型</param>
public void Init(SelectionInitType Type)
{
foreach (Transform t in PrefabParent)
{
Destroy(t.gameObject);
}
PrefabParent.GetComponent<UI_Control_ScrollFlow>().Items.Clear();
switch (Type)
{
case SelectionInitType.:
ClonePrefab(ZongDuiZhiHuiZhongXinPrefab);
ClonePrefab(DaoDiaoPrefab);
ClonePrefab(GuanChaTuanPrefab);
ClonePrefab(ZongDuiZhiHuiPrefab);
ClonePrefab(CanMouPrefab);
NowInitType = SelectionInitType.;
break;
case SelectionInitType.:
ClonePrefab(ZhiDuiZhiHuiZhongXinPrefab);
ClonePrefab(DaoDiaoPrefab);
ClonePrefab(GuanChaTuanPrefab);
ClonePrefab(ZhiDuiZhiHuiPrefab);
ClonePrefab(CanMouPrefab);
NowInitType = SelectionInitType.;
break;
case SelectionInitType.:
ClonePrefab(GuanChaTuanPrefab);
ClonePrefab(DaDuiZhiHuiPrefab);
ClonePrefab(CanMouPrefab);
ClonePrefab(GuanChaTuanPrefab);
ClonePrefab(DaDuiZhiHuiPrefab);
ClonePrefab(CanMouPrefab);
NowInitType = SelectionInitType.;
break;
case SelectionInitType.:
ClonePrefab(ZhongDuiZhuiHuiPrefab);
ClonePrefab(ZhongDuiZhuiHuiPrefab);
ClonePrefab(ZhongDuiZhuiHuiPrefab);
ClonePrefab(ZhongDuiZhuiHuiPrefab);
NowInitType = SelectionInitType.;
break;
case SelectionInitType.:
ClonePrefab(ZhanDouBanZhangPrefab);
ClonePrefab(ZhanDouBanZhangPrefab);
ClonePrefab(ZhanDouBanZhangPrefab);
ClonePrefab(ZhanDouBanZhangPrefab);
NowInitType = SelectionInitType.;
break;
default:
ClonePrefab(ZongDuiZhiHuiZhongXinPrefab);
ClonePrefab(ZhiDuiZhiHuiZhongXinPrefab);
ClonePrefab(DaoDiaoPrefab);
ClonePrefab(GuanChaTuanPrefab);
ClonePrefab(ZongDuiZhiHuiPrefab);
ClonePrefab(ZhiDuiZhiHuiPrefab);
ClonePrefab(DaDuiZhiHuiPrefab);
ClonePrefab(ZhongDuiZhuiHuiPrefab);
ClonePrefab(ZhanDouBanZhangPrefab);
ClonePrefab(CanMouPrefab);
NowInitType = SelectionInitType.;
break;
}
StartCoroutine(Wait());
}
private void ClonePrefab(GameObject Prefab)
{
GameObject g = Instantiate(Prefab, PrefabParent);
g.name = Prefab.name;
}
IEnumerator Wait()
{
yield return new WaitForSeconds(0.3f);
_ScrollFlow.Refresh();
for (int i = 0; i < PrefabParent.childCount; i++)//重新分组使角色选择只能选一个
{
PrefabParent.GetChild(i).GetComponentInChildren<Toggle>().group = PrefabParent.GetComponent<ToggleGroup>();
}
}
}