105 lines
3.3 KiB
C#
105 lines
3.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SelectScenePanel : MonoBehaviour
|
|
{
|
|
public GameObject schoolPrefab;//滑动视图预制体
|
|
public Transform schoolList;//预制体列表
|
|
public ToggleGroup schooltoggleGroup;
|
|
public Toggle[] toggleList;
|
|
public GameObject scoolSelectBtn;//学校选择按钮
|
|
public GameObject schoolChoiceLable;//学校选择界面
|
|
public GameObject eventChoiceLable;//事件选择界面
|
|
public bool isOpen = false;
|
|
public List<SchoolInfo> schoolInfos = new List<SchoolInfo>();//学校信息
|
|
public List<EventInfo> eventInfos = new List<EventInfo>();//事件信息
|
|
public List<Toggle> difficultyList = new List<Toggle>();
|
|
|
|
//数据
|
|
public int schoolId;
|
|
public string schoolName;
|
|
public int eventId;
|
|
public string eventName;
|
|
public string difficulty;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
schoolChoiceLable.gameObject.SetActive(true);
|
|
eventChoiceLable.gameObject.SetActive(false);
|
|
//动态加载学校选择预制体
|
|
for (int i=0;i<6;i++)
|
|
{
|
|
GameObject slot = GameObject.Instantiate<GameObject>(schoolPrefab, schoolList);
|
|
//schoolPrefab.gameObject.GetComponent<Image>().sprite = Resources.Load("");
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
//学校选择,确定学校信息
|
|
public void SelectSchoolBtn()
|
|
{
|
|
SchoolInfo gameObject = GetComponentInChildren<SchoolInfo>();
|
|
foreach (SchoolInfo item in schoolInfos)
|
|
{
|
|
if(item.gameObject.transform.GetComponent<Toggle>().isOn)
|
|
{
|
|
this.schoolId = item.schoolId;
|
|
this.schoolName = item.schoolName;
|
|
}
|
|
}
|
|
//Debug.Log("###############1:"+ this.schoolId);
|
|
//Debug.Log("###############2:" + this.schoolName);
|
|
}
|
|
//事件及难度选择
|
|
public void SelectEvent()
|
|
{
|
|
EventInfo eventInfo = GetComponentInChildren<EventInfo>();
|
|
foreach(EventInfo item in eventInfos)
|
|
{
|
|
if (item.gameObject.transform.GetComponent<Toggle>().isOn)
|
|
{
|
|
this.eventId = item.eventId;
|
|
this.eventName = item.eventName;
|
|
}
|
|
}
|
|
//Debug.Log("%%%%%%%%%%%%%1:"+ this.eventId);
|
|
//Debug.Log("%%%%%%%%%%%%%2:" + this.eventName);
|
|
}
|
|
//游戏难度选择
|
|
public void SelsctDifficulty()
|
|
{
|
|
auth_createTemplate auth_CreateTemplate = new auth_createTemplate();
|
|
foreach(Toggle item in difficultyList)
|
|
{
|
|
if (item.isOn)
|
|
{
|
|
this.difficulty = item.transform.parent.GetComponentInChildren<Text>().text;
|
|
auth_CreateTemplate.mode = this.difficulty;//给结构体“难度”赋值
|
|
}
|
|
}
|
|
//Debug.Log("%%%%%%%%%%%%%3:" + this.difficulty);
|
|
}
|
|
//继续按钮,点击后上传数据
|
|
public void ContinueBtn()
|
|
{
|
|
SelectSchoolBtn();
|
|
schoolChoiceLable.gameObject.SetActive(false);
|
|
eventChoiceLable.gameObject.SetActive(true);
|
|
}
|
|
//提交按钮,点击上传数据和隐藏界面
|
|
public void SubmitBtn()
|
|
{
|
|
SelectEvent();
|
|
SelsctDifficulty();
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
}
|