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.
198 lines
7.8 KiB
198 lines
7.8 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine.UI;
|
||
|
using UnityEngine.EventSystems;
|
||
|
using AX.MessageSystem;
|
||
|
public class StairUI : MonoBehaviour
|
||
|
{
|
||
|
|
||
|
/// <summary>
|
||
|
/// 电梯UI
|
||
|
/// </summary>
|
||
|
public GameObject Prefab;
|
||
|
private Button CloseBtn;
|
||
|
private Transform Fahter;
|
||
|
public static StairUI Instance;
|
||
|
|
||
|
void Awake()
|
||
|
{
|
||
|
if (Instance == null)
|
||
|
{
|
||
|
Instance = this;
|
||
|
}
|
||
|
|
||
|
CloseBtn = this.transform.Find("Close").GetComponent<Button>();
|
||
|
Fahter = this.transform.Find("Scroll View/Viewport/Content").transform;
|
||
|
CloseBtn.onClick.AddListener(CLOSE);
|
||
|
}
|
||
|
private void OnDisable()
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("clearTrigger", (object)"");
|
||
|
}
|
||
|
public int GetI;
|
||
|
private int TriggerMode;
|
||
|
public void GetRiseTop(int I,int triggerMode)
|
||
|
{
|
||
|
GetI = I;
|
||
|
TriggerMode = triggerMode;
|
||
|
if (MySceneManager.GetActiveScene().name.Equals("11"))
|
||
|
{
|
||
|
CanGo11();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
CanGo();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public void CanGo11()
|
||
|
{
|
||
|
int Num = 0;
|
||
|
foreach (Transform child in Fahter.transform)
|
||
|
{
|
||
|
Destroy(child.gameObject);
|
||
|
}
|
||
|
foreach (Transform child_ in StairCanGo.Instance.ShiNei)
|
||
|
{
|
||
|
if (child_.name.Contains("qian"))
|
||
|
{
|
||
|
foreach (Transform child in child_)
|
||
|
{
|
||
|
if (child.name.Contains("nei"))
|
||
|
{
|
||
|
foreach (Transform chlids in child.transform)
|
||
|
{
|
||
|
if (chlids.name.Contains("Floor"))
|
||
|
{
|
||
|
Num++;
|
||
|
if (Num < GetI)
|
||
|
{
|
||
|
string z = chlids.GetComponent<CengID>().NEI;
|
||
|
GameObject Game = Instantiate(Prefab) as GameObject;
|
||
|
Game.transform.parent = Fahter;
|
||
|
Game.transform.localScale = new Vector3(1, 1, 1);
|
||
|
Game.transform.Find("intro").GetComponent<Text>().text = z + "层";
|
||
|
Game.GetComponent<StairUIChild>().triggerMode = TriggerMode;
|
||
|
Game.GetComponent<Button>().interactable = false;
|
||
|
Game.name = child.name;
|
||
|
for (int i = 0; i < StairCanGo.Instance.CanGoFloor.Count; i++)
|
||
|
{
|
||
|
string name = StairCanGo.Instance.CanGoFloor[i].gameObject.name;
|
||
|
if (child.name.Equals(name))
|
||
|
{
|
||
|
Game.GetComponent<Button>().interactable = true;
|
||
|
}
|
||
|
}
|
||
|
if (z.Contains("M"))
|
||
|
{
|
||
|
Game.GetComponent<Button>().interactable = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if (child_.name.Contains("hou"))
|
||
|
{
|
||
|
foreach (Transform child in child_)
|
||
|
{
|
||
|
if (child.name.Contains("nei"))
|
||
|
{
|
||
|
foreach (Transform chlids in child.transform)
|
||
|
{
|
||
|
if (chlids.name.Contains("Floor"))
|
||
|
{
|
||
|
Num++;
|
||
|
if (Num < GetI)
|
||
|
{
|
||
|
string z = chlids.GetComponent<CengID>().NEI;
|
||
|
GameObject Game = Instantiate(Prefab) as GameObject;
|
||
|
Game.transform.parent = Fahter;
|
||
|
Game.transform.localScale = new Vector3(1, 1, 1);
|
||
|
Game.transform.Find("intro").GetComponent<Text>().text = z + "层";
|
||
|
Game.GetComponent<StairUIChild>().triggerMode = TriggerMode;
|
||
|
Game.GetComponent<Button>().interactable = false;
|
||
|
Game.name = child.name;
|
||
|
for (int i = 0; i < StairCanGo.Instance.CanGoFloor.Count; i++)
|
||
|
{
|
||
|
string name = StairCanGo.Instance.CanGoFloor[i].gameObject.name;
|
||
|
if (child.name.Equals(name))
|
||
|
{
|
||
|
Game.GetComponent<Button>().interactable = true;
|
||
|
}
|
||
|
}
|
||
|
if (z.Contains("M"))
|
||
|
{
|
||
|
Game.GetComponent<Button>().interactable = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
public void CanGo()
|
||
|
{
|
||
|
int Num = 0;
|
||
|
foreach (Transform child in Fahter.transform)
|
||
|
{
|
||
|
Destroy(child.gameObject);
|
||
|
}
|
||
|
foreach (Transform child in StairCanGo.Instance.ShiNei)
|
||
|
{
|
||
|
if (child.name.Contains("nei"))
|
||
|
{
|
||
|
foreach (Transform chlids in child.transform)
|
||
|
{
|
||
|
if (chlids.name.Contains("Floor"))
|
||
|
{
|
||
|
Num++;
|
||
|
if (Num < GetI)
|
||
|
{
|
||
|
string z = chlids.GetComponent<CengID>().NEI;
|
||
|
GameObject Game = Instantiate(Prefab) as GameObject;
|
||
|
Game.transform.parent = Fahter;
|
||
|
Game.transform.localScale = new Vector3(1, 1, 1);
|
||
|
Game.transform.Find("intro").GetComponent<Text>().text = z + "层";
|
||
|
Game.GetComponent<StairUIChild>().triggerMode = TriggerMode;
|
||
|
Game.GetComponent<Button>().interactable = false;
|
||
|
Game.name = child.name;
|
||
|
for (int i = 0; i < StairCanGo.Instance.CanGoFloor.Count; i++)
|
||
|
{
|
||
|
string name = StairCanGo.Instance.CanGoFloor[i].gameObject.name;
|
||
|
if (child.name.Equals(name))
|
||
|
{
|
||
|
Game.GetComponent<Button>().interactable = true;
|
||
|
}
|
||
|
}
|
||
|
if (z.Contains("M"))
|
||
|
{
|
||
|
Game.GetComponent<Button>().interactable = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//关闭UI
|
||
|
public void CLOSE()
|
||
|
{
|
||
|
this.gameObject.SetActive(false);
|
||
|
Time.timeScale = 1;
|
||
|
for (int i = 0; i < InputManager.Instance_.GetSelectedCharacters().Count; i++)
|
||
|
{
|
||
|
GameObject game = InputManager.Instance_.GetSelectedCharacters()[i] as GameObject;
|
||
|
game.GetComponent<UnityEngine.AI.NavMeshAgent>().enabled = false;
|
||
|
}
|
||
|
MessageDispatcher.SendMessage("clearTrigger", (object)"");
|
||
|
}
|
||
|
|
||
|
}
|