using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using AX.TrackRecord;
using AX.MessageSystem;
public class AutoBrowsing : MonoBehaviour {
///
/// 自动浏览脚本
///
private float time = 0f;
public Toggle toggle;
[HideInInspector]
public GameObject Game;
public bool Flag = false;//用于判断是否为浏览模式
public static AutoBrowsing instance = null;
private void Awake()
{
if (instance == null)
{
instance = this;
}
}
void Start ()
{
toggle.onValueChanged.AddListener(ClickToggle);
}
public void ClickToggle(bool flag)
{
Flag = flag;
if (!flag)
{
MessageDispatcher.SendMessage("CloseNodeTreeHints", (object)"");
Game = null;
}
}
void Update ()
{
//控制物体规定时间关闭
if (Flag && Game != null)
{
time -= Time.deltaTime;
if (time < 0)
{
ContinueSomthing(Game);
}
}
}
///
/// 关闭面板对应继续播放
///
public void ContinueSomthing(GameObject game)
{
Game = null;
switch (game.name)
{
case "NodeTreeHintsLoad":
game.SetActive(false);
StartPlayBack();
break;
case "TimeItem(Clone)":
TagCheck(game);
break;
case "RawImage":
game.SetActive(false);
ImageCheck(game);
break;
}
}
//刚开始的名称显示面板
public void StartPlayBack()
{
NodeSet.Instance.BecauseClickLoadNode();
}
//检测标签
public void TagCheck(GameObject obj)
{
if (obj.GetComponent().EventItem.objAttriList[0].modeadd != ModelADD.None)
{
if (obj.GetComponent().Picture.activeInHierarchy)
{
obj.GetComponent().ClickPicture(1);
}else
if (obj.GetComponent().Video.activeInHierarchy)
{
obj.GetComponent().ClickVideo(1);
}
}
else
{
TheBackView.instance.BoFang();
}
}
//检测标签图片
public void ImageCheck(GameObject obj)
{
GameObject Tag = obj.GetComponent().TagGame;
if (Tag != null)
{
if (Tag.GetComponent().Video.activeInHierarchy)
{
Tag.GetComponent().ClickVideo(1);
}
else
{
TheBackView.instance.BoFang();
}
}
GameObject.Find("Main Camera").GetComponent().enabled = true;
GameObject.Find("Main Camera").GetComponent().enabled = true;
}
///
/// 接受正在开启的面板
///
/// 传来的物体
/// 传来的时间
/// 是否为播放下个节点
public void GetMessage(GameObject game,float T,bool NextNode)
{
Game = game;
time = T;
CheckNext(NextNode);
}
///
/// 自动播放下一条节点
///
///
public void CheckNext(bool Next)
{
if (Next&& Flag)
{
if (TreeViewControl__.Instance.HasItemSelected() < 0)
{
MessageDispatcher.SendMessage("Operatinghints", (object)"未选中节点");
return;
}
else
{
NodeSet.Instance.KeyDownLoadNode2(1);
}
}
}
}