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.
354 lines
13 KiB
354 lines
13 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using UnityEngine.UI;
|
||
|
using AX.MessageSystem;
|
||
|
public class NodeRecordController : MonoBehaviour
|
||
|
{
|
||
|
public static NodeRecordController Instance;
|
||
|
public Text ButtonName;
|
||
|
bool IsRecord = false;
|
||
|
bool IsLoad = false;
|
||
|
string NodeName = "", NodeIntro = "";
|
||
|
public InputField NodeNameInput;
|
||
|
public InputField NodeIntroInput;
|
||
|
public GameObject EditWin;
|
||
|
public Transform camera_;
|
||
|
string cjid = "1";
|
||
|
int zqid = 1;
|
||
|
int jdid = 0;
|
||
|
int count = 0;
|
||
|
[HideInInspector]
|
||
|
public int selected_jdid = 0, last_id = 0;
|
||
|
[HideInInspector]
|
||
|
public string filename = "";
|
||
|
[HideInInspector]
|
||
|
public ArrayList PosList, RotList, LouNumList;
|
||
|
[HideInInspector]
|
||
|
public Vector3 targetPos;
|
||
|
public InputField NameInputShow;
|
||
|
public InputField IntroInputShow;
|
||
|
string name_, intro;
|
||
|
public GameObject NodeIntroShowWin;
|
||
|
[HideInInspector]
|
||
|
public bool IsShowEditWin = false;
|
||
|
public GameObject TheTime;
|
||
|
GameObject ThePfire;
|
||
|
|
||
|
public GameObject TheEditNodePalne;//停止记录后弹出面板
|
||
|
void Awake()
|
||
|
{
|
||
|
if (Instance == null)
|
||
|
{
|
||
|
Instance = this;
|
||
|
}
|
||
|
}
|
||
|
void Start()
|
||
|
{
|
||
|
|
||
|
//EventDelegate.Add(this.popList.onChange, this.popChange);1111
|
||
|
//NodeIntroShowWin.SetActive(false);
|
||
|
//Selected.selectChangJing = Selected.ChangJing.金钰大都会;
|
||
|
//Selected.selectChangJing = Selected.ChangJing.云南石油;
|
||
|
//ButtonName.text = "添加记录";
|
||
|
//TheYesOrNo = GameObject.Find("UI Root/ToolbarObject/NodeRecord").transform.FindChild("是否放弃记录").gameObject;
|
||
|
//xList = new ArrayList();
|
||
|
//yList = new ArrayList();
|
||
|
//PosList = new ArrayList();
|
||
|
//RotList = new ArrayList();
|
||
|
//LouNumList = new ArrayList();
|
||
|
//NodeNameInput = this.transform.FindChild("NodeIntroShowWin").FindChild("NameInputShow").GetComponent<UIInput>();
|
||
|
//NodeIntroInput = this.transform.FindChild("NodeIntroShowWin").FindChild("IntroInputShow").GetComponent<UIInput>();
|
||
|
GenerateNode();
|
||
|
//ThePfire = GameObject.Find("pdrawline").gameObject;
|
||
|
//camera_ = GameObject.Find("Main Camera").transform;
|
||
|
}
|
||
|
|
||
|
|
||
|
void FixedUpdate()
|
||
|
{
|
||
|
/*if (IsRecord)1111111111
|
||
|
{
|
||
|
//float x = MouseFR.x;
|
||
|
//xList.Add(x);
|
||
|
//float y = MouseFR.y;
|
||
|
//yList.Add(y);
|
||
|
Vector3 pos = camera_.position;
|
||
|
PosList.Add(pos);
|
||
|
Vector3 rot = camera_.localEulerAngles;
|
||
|
RotList.Add(rot);
|
||
|
int cn = louceng.cengnum;
|
||
|
LouNumList.Add(cn);
|
||
|
}
|
||
|
if (IsLoad)
|
||
|
{
|
||
|
if (count >= PosList.Count - 1)
|
||
|
{
|
||
|
IsLoad = false;
|
||
|
|
||
|
GameObject.Find("Main Camera").GetComponent<MouseFollowRotation>().enabled = true;
|
||
|
//MouseFR.x = (float)xList[count - 1];
|
||
|
//MouseFR.y = (float)yList[count - 1];
|
||
|
xmlManager.Instance.SetCameraFromNodeData("Node/NodeRecord.xml", cjid, zqid, selected_jdid);
|
||
|
return;
|
||
|
}
|
||
|
//MouseFR.x = (float)xList[count];
|
||
|
//MouseFR.y = (float)yList[count];
|
||
|
camera_.position = (Vector3)PosList[count];
|
||
|
camera_.localEulerAngles = (Vector3)RotList[count];
|
||
|
louceng.cengnum = (int)LouNumList[count];
|
||
|
count++;
|
||
|
//count = count + 4;
|
||
|
}*/
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
|
||
|
if (last_id != selected_jdid)
|
||
|
{
|
||
|
last_id = selected_jdid;
|
||
|
//IsShowEditWin = true;
|
||
|
//NodeIntroShowWin.SetActive(true);
|
||
|
UpdateNameIntro(selected_jdid);
|
||
|
}
|
||
|
if (IsDelete)
|
||
|
{
|
||
|
IsDelete = false;
|
||
|
//UIManager.Instance.ShowWin(new UIClass(TipWin, this.gameObject, "closeCancelDelete"), UIManager.WinShowType.CloseOthers, true);
|
||
|
UpdateNameIntro(0);
|
||
|
MessageDispatcher.SendMessage("OPEN", (object)TipWin.name, "CUBE");
|
||
|
//TipWin.SetActive(true);
|
||
|
//NodeIntroShowWin.SetActive(false);
|
||
|
}
|
||
|
if (IsShowEditWin)
|
||
|
{
|
||
|
IsShowEditWin = false;
|
||
|
MessageDispatcher.SendMessage("OPEN", (object)NodeIntroShowWin.name, "CUBE");
|
||
|
//NodeIntroShowWin.SetActive(true);
|
||
|
//UIManager.Instance.ShowWin(new UIClass(NodeIntroShowWin, this.gameObject, "closeCancelDelete"), UIManager.WinShowType.CloseOthers, true);
|
||
|
|
||
|
// GameObject.Find("UI Root").transform.FindChild("BJ").gameObject.SetActive(false);
|
||
|
//GameObject.Find("UI Root/ToolbarObject/DomeMenu/JieDian_shezhi").GetComponent<UISprite>().spriteName = "SavaGreen";
|
||
|
UpdateNameIntro(selected_jdid);
|
||
|
}
|
||
|
}
|
||
|
public GameObject AddTagGame;
|
||
|
public void AddNodeButton_Click()
|
||
|
{
|
||
|
|
||
|
//Stopwatch.seconds = 0;
|
||
|
//Stopwatch.minutes = 0;
|
||
|
//Stopwatch.hours = 0;
|
||
|
//GameObject.Find("KaiShi").gameObject.transform.FindChild("Label").gameObject.GetComponent<UILabel>().text = "开始演练";
|
||
|
//GameObject.Find("KaiShi").gameObject.GetComponent<UISprite>().spriteName = "StartGreen";
|
||
|
//GameObject.Find("KaiShi").gameObject.GetComponent<UIButton>().tweenTarget = null;
|
||
|
if (ButtonName.text == "新建记录")
|
||
|
{
|
||
|
ButtonName.text = "停止记录";
|
||
|
PosList.Clear();
|
||
|
RotList.Clear();
|
||
|
LouNumList.Clear();
|
||
|
//TheShowUI.SetActive(true);
|
||
|
//TheShowUI.GetComponent<SaveSuccess>().GetIt("开始记录");
|
||
|
//AddTagGame.SetActive(true);
|
||
|
//GameObject.Find("Main Camera").GetComponent<Stopwatch>().Reset(false);//避免点击添加记录就开始演练
|
||
|
//RecordManager.Instance.StartRecord();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ButtonName.text = "添加记录";
|
||
|
MessageDispatcher.SendMessage("OPEN", (object)TheEditNodePalne.name, "CUBE");
|
||
|
//TheShowUI.SetActive(true);
|
||
|
//TheShowUI.GetComponent<SaveSuccess>().GetIt("停止记录");
|
||
|
//AddTagGame.SetActive(false);
|
||
|
//GameObject.Find("Main Camera").GetComponent<Stopwatch>().Stop();
|
||
|
//if (LouCengControllor.ToggleValue && RecordManager.Instance.IsRecording)
|
||
|
//{
|
||
|
// RecordManager.Instance.RecordOneEvent(GameObject.Find(ChooseObject.ObjectName), eventTypeRecord.ControlJuBi, "", Vector3.zero, GameObject.Find(ChooseObject.ObjectName).transform, 0);
|
||
|
//}
|
||
|
|
||
|
//RecordManager.Instance.Endrecord();
|
||
|
//RecordManager.Instance.RecordOneEvent(this.gameObject, eventTypeRecord.None, "", Vector3.zero, this.transform, 0);
|
||
|
}
|
||
|
//TheTime.SetActive(false);
|
||
|
}
|
||
|
|
||
|
|
||
|
public void SaveEdit()
|
||
|
{
|
||
|
string name1 = NameInputShow.text;
|
||
|
string intro1 = IntroInputShow.text;
|
||
|
xmlManager.Instance.EditJieDian("NodeRecord.xml", cjid, zqid, selected_jdid, name1, intro1);
|
||
|
GenerateNode();
|
||
|
MessageDispatcher.SendMessage("CLOSE", (object)NodeIntroShowWin.name, "CUBE");
|
||
|
closeCancelDelete();
|
||
|
}
|
||
|
|
||
|
public void SaveNode()
|
||
|
{
|
||
|
NodeName = NodeNameInput.text;
|
||
|
NodeIntro = NodeIntroInput.text;
|
||
|
if (xmlManager.Instance.FindTheName("NodeRecord.xml", NodeName, cjid, zqid))
|
||
|
{
|
||
|
NodeNameInput.text = "已经有此名字";
|
||
|
return;
|
||
|
}
|
||
|
jdid = xmlManager.Instance.GetJieDianCount("NodeRecord.xml", cjid, zqid);
|
||
|
jdid++;
|
||
|
xmlManager.Instance.CreatJieDian("Node/NodeRecord.xml", cjid, zqid, jdid, NodeName, NodeIntro, jdid + ".xml", jdid);
|
||
|
//xmlController.RecordCameraWithMemoryDate("Node/NodeRecordCamera.xml", cjid, zqid, jdid, 0, LouNumList, PosList, RotList);
|
||
|
//UIManager.Instance.CloseWin(new UIClass(EditWin, this.gameObject, "closeCancelDeleteA"));
|
||
|
GenerateNode();
|
||
|
closeCancelDelete();
|
||
|
//RecordManager.Instance.SaveRecord_SerializeRecordToXML(zqid + "/" + jdid + ".xml");
|
||
|
}
|
||
|
//public RecordManager recordManager;*/
|
||
|
public GameObject TheShowUI;
|
||
|
/* public void LoadNode()
|
||
|
{
|
||
|
//MouseFR.enabled = false;
|
||
|
TheTime.SetActive(false);
|
||
|
Stopwatch.seconds = 0;
|
||
|
Stopwatch.minutes = 0;
|
||
|
Stopwatch.hours = 0;
|
||
|
xmlManager.Instance.LoadJieDian("NodeRecord.xml", cjid, zqid, selected_jdid);
|
||
|
//xmlController.LoadCameraFromMemoryDate("Node/NodeRecordCamera.xml", cjid, zqid, selected_jdid, 0);
|
||
|
//IsLoad = true;
|
||
|
//count = 1;
|
||
|
foreach (Transform child in ThePfire.transform)
|
||
|
{
|
||
|
if (child != null)
|
||
|
{
|
||
|
Destroy(child.gameObject);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
GameObject.Find("ToolbarObject/DomeMenu/KaiShi").gameObject.transform.FindChild("Label").gameObject.GetComponent<UILabel>().text = "开始演练";
|
||
|
GameObject.Find("ToolbarObject/DomeMenu").transform.FindChild("KaiShi").gameObject.GetComponent<UISprite>().spriteName = "StartGreen";
|
||
|
GameObject.Find("ToolbarObject/DomeMenu").transform.FindChild("KaiShi").gameObject.GetComponent<UIButton>().tweenTarget = null;
|
||
|
if (filename != "")
|
||
|
{
|
||
|
|
||
|
TheShowUI.SetActive(true);
|
||
|
string str = xmlManager.Instance.GetJieDianName("NodeRecord.xml", cjid, zqid, selected_jdid);
|
||
|
TheShowUI.GetComponent<SaveSuccess>().GetIt(str + "--" + "开始回放");
|
||
|
RecordManager.Instance.StartPlayBack(zqid + "/" + filename);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
public void closeCancelDeleteA()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
public void closeCancelDeleteB()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
//public void TheYesButton()
|
||
|
//{
|
||
|
// //EditWin.SetActive(false);
|
||
|
|
||
|
// RecordManager.Instance.IsRecording = false;
|
||
|
// closeCancelDelete();
|
||
|
//}
|
||
|
public void TheNoButton()
|
||
|
{
|
||
|
|
||
|
closeCancelDelete();
|
||
|
}
|
||
|
*/
|
||
|
public GameObject TheYesOrNo;//询问是否放弃记录面板
|
||
|
public void Cancel()
|
||
|
{
|
||
|
closeCancelDelete();
|
||
|
}
|
||
|
public GameObject NodePrefab;
|
||
|
public static ArrayList NodeList = new ArrayList();
|
||
|
public Text TheName;
|
||
|
public GameObject ParentUIGrid;
|
||
|
public void GenerateNode()
|
||
|
{
|
||
|
int NodeCount = 0;
|
||
|
NodeCount = xmlManager.Instance.GetJieDianCount("NodeRecord.xml", cjid, zqid);
|
||
|
TheName.text = xmlManager.Instance.GetZaiQingName(cjid, zqid);
|
||
|
foreach (Transform obj in ParentUIGrid.transform)
|
||
|
{
|
||
|
Destroy(obj.gameObject);
|
||
|
}
|
||
|
NodeList.Clear();
|
||
|
for (int i = 1; i <= NodeCount; i++)
|
||
|
{
|
||
|
GameObject checkBox = Instantiate(NodePrefab) as GameObject;
|
||
|
checkBox.transform.SetParent(ParentUIGrid.transform);
|
||
|
checkBox.name = "item" + i;
|
||
|
checkBox.GetComponent<NodePrefabController>().id = i;
|
||
|
checkBox.GetComponent<NodePrefabController>().FatherID = zqid;
|
||
|
checkBox.GetComponent<NodePrefabController>().filename = xmlManager.Instance.GetJieDianFilename("NodeRecord.xml", cjid, zqid, i);
|
||
|
checkBox.GetComponentInChildren<Text>().text =
|
||
|
xmlManager.Instance.GetJieDianName("NodeRecord.xml", cjid, zqid, i);
|
||
|
NodeList.Add(checkBox);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Text IntroShow;
|
||
|
public Text NameShow;
|
||
|
public void UpdateNameIntro(int id)
|
||
|
{
|
||
|
string name;
|
||
|
string intro;
|
||
|
if (id == 0)
|
||
|
{
|
||
|
name = "请输入名称";
|
||
|
intro = "请输入简介";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
name = xmlManager.Instance.GetJieDianName("NodeRecord.xml", cjid, zqid, id);
|
||
|
intro = xmlManager.Instance.GetJieDianIntro("NodeRecord.xml", cjid, zqid, id);
|
||
|
}
|
||
|
if (NameInputShow.gameObject.activeInHierarchy)
|
||
|
{
|
||
|
NameInputShow.gameObject.GetComponentInChildren<Text>().text = name;
|
||
|
NameInputShow.text = name;
|
||
|
IntroInputShow.gameObject.GetComponentInChildren<Text>().text = intro;
|
||
|
IntroInputShow.text = intro;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
public GameObject TipWin;
|
||
|
[HideInInspector]
|
||
|
public bool IsDelete = false;
|
||
|
[HideInInspector]
|
||
|
public bool IsEdit = false;
|
||
|
public void OKDelete()
|
||
|
{
|
||
|
|
||
|
MessageDispatcher.SendMessage("CLOSE", (object)TipWin.name, "CUBE");
|
||
|
xmlManager.Instance.DeleteJieDian("NodeRecord.xml", cjid, zqid, selected_jdid);
|
||
|
xmlManager.Instance.DeleteJieDian("NodeRecordCamera.xml", cjid, zqid, selected_jdid);
|
||
|
GenerateNode();
|
||
|
closeCancelDelete();
|
||
|
}
|
||
|
public void closeCancelDelete()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
public void CancelDelete()
|
||
|
{
|
||
|
|
||
|
MessageDispatcher.SendMessage("CLOSE", (object)TipWin.name, "CUBE");
|
||
|
closeCancelDelete();
|
||
|
}
|
||
|
|
||
|
public void GetZaiQingMess(int id, string Cj)
|
||
|
{
|
||
|
zqid = id;
|
||
|
cjid = Cj.ToString();
|
||
|
TheName.text = xmlManager.Instance.GetZaiQingName(cjid, zqid);
|
||
|
GenerateNode();
|
||
|
}
|
||
|
}
|