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.
143 lines
6.8 KiB
143 lines
6.8 KiB
using UnityEngine; |
|
using AX.MessageSystem; |
|
using AX.TrackRecord; |
|
/// <summary> |
|
/// 删除物体,可用于清空场景物体,挂载在所有p物体上 |
|
/// 使用举例:MessageDispatcher.SendMessage("parentName", "DestroyObj", (object)objName); |
|
/// </summary> |
|
public class DestroyObj : MessageBehaviour |
|
{ |
|
public GameObject messageBox; |
|
|
|
void Start() |
|
{ |
|
messageBox = GameObject.Find("Canvas").transform.Find("MessageBox").gameObject; |
|
} |
|
|
|
protected override void Execute(IMessage message) |
|
{ |
|
if ((string)message.Data == "All") |
|
{ |
|
InputManager.Instance_.ClearSelectedCharacters(); |
|
InputManager.Instance_.characters.Clear(); |
|
|
|
foreach (Transform child in transform) |
|
{ |
|
Destroy(child.gameObject); |
|
} |
|
foreach (Transform child in GameObject.Find("Canvas/PolyVerticeFather").transform) |
|
{ |
|
Destroy(child.gameObject); |
|
} |
|
if (UIController.instance.PolygonPlane != null) |
|
{ |
|
UIController.instance.PolygonPlane.SetActive(false); |
|
} |
|
//RecordManager.Instance.objCount = 0; |
|
} |
|
else |
|
{ |
|
|
|
|
|
|
|
if ((string)message.Sender == gameObject.name)//找到对应的父物体 |
|
{ |
|
if (gameObject.name.Contains("Polygon")) |
|
{ |
|
foreach (Transform child in GameObject.Find("Canvas/PolyVerticeFather").transform) |
|
{ |
|
Destroy(child.gameObject); |
|
} |
|
} |
|
|
|
|
|
if (gameObject.name == "pfire") |
|
{ |
|
//创建考题,备课中新建课件,自学 |
|
if (ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CreatQuestion |
|
|| ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.EditQuestion |
|
|| ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CopyQuestion |
|
|| ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.PrepareMode |
|
|| ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.EditCourceware |
|
|| ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.SelfStudyMode) |
|
{ |
|
//新建节点,既没有新建节点也没有加载节点两种情况下允许删除(加载节点不允许删除) |
|
if (RecordManager.Instance.IsRecording |
|
|| (!RecordManager.Instance.IsRecording && !LoadManager.Instance.IsPlayBacking)) |
|
{ |
|
foreach (Transform child in transform) |
|
{ |
|
if ((string)message.Data == child.name)//找到要删除的子物体 |
|
{ |
|
if (!child.GetComponent<FireSpreadCtrl>().isSpreading)//蔓延过程中不能删除 |
|
{ |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
MessageDispatcher.SendMessage(gameObject.name, "RecordDeleteEvent", (object)child.name); |
|
} |
|
//InputManager.Instance_.selectedCharacters.Remove(child.gameObject); |
|
|
|
Destroy(child.gameObject); |
|
//RecordManager.Instance.objCount--; |
|
|
|
//删除时,如果已经蔓延过一次,及存在蔓延出来的火,这是需要删除蔓延出来的火 |
|
foreach (Transform child1 in transform) |
|
{ |
|
if (child1.GetComponent<SpreadedFire>() && child1.GetComponent<SpreadedFire>().fireSourceName == child.name) |
|
{ |
|
Destroy(child1.gameObject); |
|
} |
|
} |
|
|
|
//删除时,如果已经设置了蔓延路径,需删除蔓延路径对象 |
|
if (GameObject.Find("pfirespreadline").transform.Find(child.name)) |
|
{ |
|
Destroy(GameObject.Find("pfirespreadline").transform.Find(child.name).gameObject); |
|
} |
|
} |
|
else |
|
{ |
|
messageBox.GetComponent<MessageTool>().showMessage(ShowMessageType.prompt, "提示信息", "蔓延过程中不能删除"); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
else |
|
{ |
|
foreach (Transform child in transform) |
|
{ |
|
if ((string)message.Data == child.name)//找到要删除的子物体 |
|
{ |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
if (child.name.Contains("zwd") || child.name.Contains("wxp")) |
|
{ |
|
MessageDispatcher.SendMessage(gameObject.name, "RecordDeleteEvent", (object)child.name, 1.5f); |
|
} |
|
else |
|
{ |
|
MessageDispatcher.SendMessage(gameObject.name, "RecordDeleteEvent", (object)child.name); |
|
} |
|
} |
|
//InputManager.Instance_.selectedCharacters.Remove(child.gameObject); |
|
if (InputManager.Instance_.characters.Contains(child.gameObject)) |
|
{ |
|
InputManager.Instance_.characters.Remove(child.gameObject); |
|
} |
|
if (InputManager.Instance_.GetSelectedCharacters().Contains(child.gameObject)) |
|
{ |
|
InputManager.Instance_.GetSelectedCharacters().Remove(child.gameObject); |
|
} |
|
Destroy(child.gameObject); |
|
//RecordManager.Instance.objCount--; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
}
|
|
|