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.

88 lines
2.7 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
namespace BuildSystem
{
public class UIManager : MonoSingleton<UIManager>
{
[Header("道路部署阶段")]
public GameObject roadPlacePanel;
public GameObject tip;
public GameObject level1Target;
[Header("红绿灯放置阶段")]
public GameObject placeLight;
public GameObject traficWnd;
public GameObject lightTip;
public GameObject level2Target;
[Header("通车阶段")]
public Button carRun;
public GameObject render;
public Transform renderGrid;
public GameObject rawImagePre;
public GameObject carTip;
public GameObject carNumber;
public Slider carSlider;
protected override void Awake()
{
base.Awake();
carRun.onClick.AddListener(()=> {
CarController.Instance.StartCreateCar();
carRun.gameObject.SetActive(false);
StartCoroutine(Wait(()=> {
EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true);
},30f));
});
carSlider.onValueChanged.AddListener(CarController.Instance.CarNumberChange);
}
/// <summary>
/// 道路部署阶段完成的ui更改
/// </summary>
public void OneStageEnd() {
roadPlacePanel.SetActive(false);
tip.SetActive(false);
level1Target.SetActive(false);
placeLight.SetActive(true);
traficWnd.SetActive(true);
level2Target.SetActive(true);
lightTip.SetActive(true);
}
/// <summary>
/// 红绿灯部署阶段完成
/// </summary>
public void TwoStageEnd() {
level2Target.SetActive(false);
carRun.gameObject.SetActive(true);
render.SetActive(true);
carTip.SetActive(true);
carNumber.SetActive(true);
foreach (GridInfo info in BuildSystemManager.Instance.grid) {
GameObject obj = Instantiate(rawImagePre,renderGrid);
RenderTexture renderTexture = new RenderTexture(300,200,0);
obj.GetComponent<RawImage>().texture = renderTexture;
info.placeObject.GetComponent<RoadInfo>().camera.gameObject.SetActive(true);
info.placeObject.GetComponent<RoadInfo>().camera.targetTexture = renderTexture;
obj.GetComponent<RenderRawImg>().renderGrid = renderGrid;
}
}
IEnumerator Wait(Action action, float t)
{
yield return new WaitForSeconds(t);
action();
}
}
}