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.
1056 lines
41 KiB
1056 lines
41 KiB
using UnityEngine; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using AX.MessageSystem; |
|
using AX.TrackRecord; |
|
using UnityEngine.EventSystems; |
|
using UnityEngine.UI; |
|
using System; |
|
|
|
public class InputManager : MonoBehaviour |
|
{ |
|
|
|
/** |
|
* 用于场景事件点击框选的事件发送 |
|
*/ |
|
public Color rectColor = Color.green; |
|
public LayerMask r_layerMask = 26; |
|
private Vector3 downPosition = Vector3.zero;//记录鼠标按下的位置 |
|
private float doubleClickCount = 0; |
|
private bool checkDoubleClick = false; |
|
private bool checkClick = false; |
|
private bool moved = false; |
|
private Material rectMat = null; |
|
|
|
public bool drawRectangle = false;//开始画线标识 |
|
private float farPlane = 100000; |
|
public static InputManager Instance_; |
|
public LayerMask Tm_layerMask = -1; |
|
public LayerMask Rm_layerMask = -1; |
|
private GameObject CarControlToggle; |
|
public List<InputField> inputFieldList = new List<InputField>(); |
|
LayerMask MultiselectLayer; |
|
public bool isMisoperation = false; |
|
private GameObject CarAttributeUI; |
|
private LayerMask indoor_layerMask = -1; |
|
public int MinCeng; |
|
public int MaxCeng; |
|
|
|
#region//移动指挥终端模块:战术克隆输入处理需要的变量 |
|
public TacticCloneType cloneType;//战术克隆类型 |
|
private Ray ray; |
|
private RaycastHit hit; |
|
|
|
private Vector3 preMousePos; |
|
private Vector3 curMousePos; |
|
#endregion |
|
|
|
void Awake() |
|
{ |
|
if (Instance_ == null) |
|
{ |
|
Instance_ = this; |
|
} |
|
} |
|
public Shader Shader; |
|
|
|
void Start() |
|
{ |
|
rectMat = new Material(Shader); |
|
Rm_layerMask = 1 << 25 | 1 << 26 | 1 << 29; |
|
Tm_layerMask = 1 << 25 | 1 << 29; |
|
indoor_layerMask = 1 << 29 | 1 << 25 | 1 << 26; |
|
//rectMat.hideFlags = HideFlags.HideAndDontSave; |
|
//rectMat.shader.hideFlags = HideFlags.HideAndDontSave; |
|
CarControlToggle = GameObject.Find("Canvas").transform.Find("控制举臂").gameObject; |
|
inputFieldList = ControlInputField.Instance.InputList; |
|
CarAttributeUI = GameObject.Find("Canvas").transform.Find("CarAttributeUI").gameObject; |
|
} |
|
private List<GameObject> selectedCharacters = new List<GameObject>(); |
|
public List<GameObject> characters = new List<GameObject>();//把可选择的对象保存在characters数组里 |
|
|
|
public List<GameObject> GetSelectedCharacters() |
|
{ |
|
return selectedCharacters; |
|
} |
|
|
|
public void SetChoseObj(GameObject obj) |
|
{ |
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING) |
|
{ |
|
ClearSelectedCharacters(); |
|
} |
|
addItem(obj); |
|
} |
|
public void ClearSelectedCharacters() |
|
{ |
|
|
|
for (int i = selectedCharacters.Count - 1; i >= 0; i--) |
|
{ |
|
removeItem(selectedCharacters[i]); |
|
} |
|
} |
|
public void addItem(GameObject obj) |
|
{ |
|
if (!selectedCharacters.Contains(obj)) |
|
{ |
|
//MessageDispatcher.SendMessage("CHOOSETHIS", (object)obj.name, "CUBE"); |
|
selectedCharacters.Add(obj); |
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING) |
|
{ |
|
obj.GetComponent<AgentControl>().enabled = true; |
|
} |
|
MessageDispatcher.SendMessage("SelectCharactersControl", (object)obj.name); |
|
} |
|
} |
|
void Update() |
|
{ |
|
for (int i = 0; i < inputFieldList.Count; i++) |
|
{ |
|
if (inputFieldList[i].isFocused) |
|
return; |
|
} |
|
if (Input.GetKeyDown(KeyCode.Space))//处理回放过程的暂停 |
|
{ |
|
MessageDispatcher.SendMessage("SpaceControl", (object)"NodeSet"); |
|
} |
|
if (Input.GetKeyDown(KeyCode.F2))//处理回放过程的暂停 |
|
{ |
|
MessageDispatcher.SendMessage("F2Control", (object)""); |
|
} |
|
if (Input.GetKeyDown(KeyCode.Tab)) |
|
{ |
|
MessageDispatcher.SendMessage("TabChangeView", (object)""); |
|
} |
|
if (Input.GetKeyDown(KeyCode.V)) |
|
{ |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"接受成功!"); |
|
} |
|
|
|
if (Input.GetKeyDown(KeyCode.LeftArrow))//控制左右键切换节点播放 |
|
{ |
|
|
|
if (!RecordManager.Instance.IsRecording) |
|
{ |
|
//第一套 |
|
var treeItems = TreeViewControl__.Instance.TreeItems; |
|
if (TreeViewControl__.Instance.HasItemSelected() < 0) |
|
{ |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"未选中节点"); |
|
return; |
|
} |
|
else |
|
{ |
|
NodeSet.Instance.KeyDownLoadNode2(-1); |
|
} |
|
//if (TempDataManager.Instance.CurNodeID == -1) |
|
//{ |
|
// MessageDispatcher.SendMessage("Operatinghints", (object)"未选中节点"); |
|
// return; |
|
//} |
|
//else |
|
//{ |
|
// if (NodeSecondLevelControl.Instance.curNodeItem_SL == null) |
|
// { |
|
// MessageDispatcher.SendMessage("Operatinghints", (object)"未选中子节点"); |
|
// return; |
|
// } |
|
// NodeSet.Instance.KeyDownLoadNode2(-1); |
|
//} |
|
} |
|
} |
|
if (Input.GetKeyDown(KeyCode.RightArrow)) |
|
{ |
|
if (!RecordManager.Instance.IsRecording) |
|
{ |
|
if (TreeViewControl__.Instance.HasItemSelected() < 0) |
|
{ |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"未选中节点"); |
|
return; |
|
} |
|
else |
|
{ |
|
NodeSet.Instance.KeyDownLoadNode2(1); |
|
} |
|
//if (TempDataManager.Instance.CurNodeID == -1) |
|
//{ |
|
// MessageDispatcher.SendMessage("Operatinghints", (object)"未选中节点"); |
|
// return; |
|
//} |
|
//else |
|
//{ |
|
// if (NodeSecondLevelControl.Instance.curNodeItem_SL == null) |
|
// { |
|
// MessageDispatcher.SendMessage("Operatinghints", (object)"未选中子节点"); |
|
// return; |
|
// } |
|
// NodeSet.Instance.KeyDownLoadNode2(1); |
|
//} |
|
} |
|
} |
|
if (CarAttributeUI.activeInHierarchy) |
|
return; |
|
if (!TrackRecordHelpClass.CheckIfCanControl()) |
|
return; |
|
|
|
|
|
#region//移动指挥终端模块输入处理 |
|
|
|
if (ModeHelper.Mode == Mode.MobileCommunication) |
|
{ |
|
if (cloneType != TacticCloneType.None) |
|
{ |
|
CloneTacticObj(); |
|
} |
|
CancelTacticCloneBtnSelected(); |
|
|
|
if (cloneType == TacticCloneType.None) |
|
{ |
|
RadioSelect(); |
|
} |
|
CancelObjSelected(); |
|
} |
|
|
|
#endregion |
|
|
|
|
|
if (Input.GetMouseButtonDown(0)) |
|
{ |
|
downPosition = Input.mousePosition; |
|
moved = false; |
|
return; |
|
} |
|
else if (Input.GetMouseButtonUp(0)) |
|
{ |
|
if (!moved) |
|
{ |
|
Ray ray = GetComponent<Camera>().ScreenPointToRay(Input.mousePosition); |
|
RaycastHit hit; |
|
bool hited = Physics.Raycast(ray, out hit, farPlane); |
|
if ((hited && !characters.Contains(hit.transform.root.gameObject)) || !hited) |
|
{ |
|
|
|
} |
|
} |
|
moved = false; |
|
|
|
downPosition = Vector3.zero; |
|
drawRectangle = false; |
|
|
|
|
|
|
|
} |
|
else if (Input.GetMouseButton(0)) |
|
{ |
|
if ((Input.GetAxis("Mouse X") == 0 && Input.GetAxis("Mouse Y") == 0) || downPosition == Vector3.zero) |
|
return; |
|
moved = true; |
|
drawRectangle = true; |
|
return; |
|
} |
|
//else if (Input.GetMouseButtonUp(1)) |
|
//{ |
|
// if (doubleClickCount <= 0.5 && checkDoubleClick) |
|
// { |
|
// if (selectedCharacters.Count == 0) |
|
// return; |
|
|
|
// Ray ray = GetComponent<Camera>().ScreenPointToRay(Input.mousePosition); |
|
// RaycastHit hit; |
|
// if (Physics.Raycast(ray, out hit, Mathf.Infinity, r_layerMask) && (selectedCharacters.Count > 0)) |
|
// { |
|
// foreach (GameObject obj in selectedCharacters) |
|
// { |
|
// if (hit.collider.gameObject.layer == 8 && obj.name.IndexOf("xiaofangche") >= 0) |
|
// { |
|
// return; |
|
// } |
|
// } |
|
// } |
|
// doubleClickCount = 0; |
|
// checkDoubleClick = false; |
|
// } |
|
// else |
|
// { |
|
// doubleClickCount = 0; |
|
// checkDoubleClick = true; |
|
// } |
|
//} |
|
|
|
//else if (Input.GetMouseButton(1)) |
|
//{ |
|
// if (Input.GetAxis("Mouse X") == 0 && Input.GetAxis("Mouse Y") == 0) |
|
// return; |
|
// moved = true; |
|
//} |
|
|
|
//事件发送 |
|
if (Input.GetKey(KeyCode.Delete) && !LoadManager.Instance.IsPlayBacking && ExamInfoHelpClass.loadSceneMode != ExamInfoHelpClass.LoadSceneMode.CoursewareMode && ExamInfoHelpClass.loadSceneMode != ExamInfoHelpClass.LoadSceneMode.CourseBaseMode) |
|
{ |
|
//创建考题,编辑考题,复制考题,备课模式,自学考试模式下可以进行删除灾情 |
|
if (LineamentEvent.gameobj != null) |
|
{ |
|
if (LineamentEvent.gameobj.name.Contains("XF_SPZ")) |
|
return; |
|
|
|
if (LineamentEvent.gameobj.name.Contains("shangyuan") |
|
|| LineamentEvent.gameobj.name.Contains("zhiqingren") |
|
|| LineamentEvent.gameobj.name.Contains("fire") |
|
|| LineamentEvent.gameobj.name.Contains("zwd") |
|
|| LineamentEvent.gameobj.name.Contains("wxp") |
|
|| LineamentEvent.gameobj.name.Contains("pcd")) |
|
{ |
|
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)) |
|
{ |
|
if ((LineamentEvent.gameobj.name.Contains("xiaofangche") || LineamentEvent.gameobj.name.Contains("xiaofangyuan")) && |
|
ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING && |
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.ExamineMode) |
|
{ |
|
return; |
|
} |
|
else |
|
{ |
|
string Str = "PromptWindow"; |
|
MessageDispatcher.SendMessage("OPEN", (object)Str, "CUBE"); |
|
return; |
|
} |
|
|
|
} |
|
} |
|
} |
|
else |
|
{ |
|
if ((LineamentEvent.gameobj.name.Contains("xiaofangche") || LineamentEvent.gameobj.name.Contains("xiaofangyuan")) && |
|
ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING && |
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.ExamineMode |
|
) |
|
{ |
|
string Str = "PromptWindow"; |
|
MessageDispatcher.SendMessage("OPEN", (object)Str, "CUBE"); |
|
return; |
|
} |
|
else |
|
{ |
|
if (ModeHelper.Mode == Mode.MobileCommunication) |
|
{//实时指挥及移动终端通信模块,车辆不能删除 |
|
return; |
|
} |
|
|
|
string Str = "PromptWindow"; |
|
MessageDispatcher.SendMessage("OPEN", (object)Str, "CUBE"); |
|
return; |
|
} |
|
} |
|
} |
|
|
|
} |
|
if (!LoadManager.Instance.IsPlayBacking /*&& ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING*/) |
|
{ |
|
//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 |
|
// || ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.ExamineMode) |
|
// { |
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.PageUp)) |
|
{ |
|
if (MySceneManager.GetActiveScene().name.Equals("5")) |
|
{//没有楼牌的场景 |
|
return; |
|
} |
|
if (FloorSelect.PageNum < MaxCeng) |
|
{ |
|
FloorSelect.PageNum++; |
|
if (FloorSelect.PageNum == 0) |
|
{ |
|
FloorSelect.PageNum++; |
|
} |
|
|
|
EndBuildingFloor.Instance.Louceng = FloorSelect.PageNum; |
|
if (MySceneManager.GetActiveScene().name.Equals("2")) |
|
{ |
|
if (FloorSelect.PageNum == 1) |
|
{ |
|
EndBuildingFloor.Instance.Louceng = 0; |
|
EndBuildingFloor.Instance.Control = true; |
|
} |
|
} |
|
MessageDispatcher.SendMessage(FloorSelect.PageType, "SELECTFLOOR_EVENT", (object)FloorSelect.PageNum); |
|
|
|
if (MySceneManager.GetActiveScene().name.Equals("1"))//处理城市综合体 |
|
{ |
|
if (GameObject.Find("YueTanShangSha")) |
|
{ |
|
if (GameObject.Find("YueTanShangSha/BrandAll/Cube" + FloorSelect.PageNum)) |
|
{ |
|
Transform Trager = GameObject.Find("target").transform; |
|
GameObject Cube = GameObject.Find("YueTanShangSha/BrandAll/Cube" + FloorSelect.PageNum).gameObject; |
|
Trager.transform.localPosition = new Vector3(Cube.transform.localPosition.x, Cube.transform.localPosition.y, Cube.transform.localPosition.z); |
|
MouseFollowRotation.Instance.distance = 120; |
|
MouseFollowRotation.Instance.y = 13f; |
|
MouseFollowRotation.Instance.x = 358f; |
|
} |
|
} |
|
|
|
} |
|
if (MySceneManager.GetActiveScene().name.Equals("3"))//处理超高层 |
|
{ |
|
if (GameObject.Find("JinMaoScenes/CubeAll/Cube" + FloorSelect.PageNum)) |
|
{ |
|
Transform Trager = GameObject.Find("target").transform; |
|
GameObject Cube = GameObject.Find("JinMaoScenes/CubeAll/Cube" + FloorSelect.PageNum).gameObject; |
|
Trager.transform.localPosition = new Vector3(Cube.transform.localPosition.x, Cube.transform.localPosition.y, Cube.transform.localPosition.z); |
|
MouseFollowRotation.Instance.distance = 29; |
|
MouseFollowRotation.Instance.y = 28.6f; |
|
MouseFollowRotation.Instance.x = 182f; |
|
} |
|
|
|
} |
|
if (MySceneManager.GetActiveScene().name.Equals("9"))//处理超高层 |
|
{ |
|
|
|
if (GameObject.Find("SceneAll/CubeAll/Cube" + FloorSelect.PageNum)) |
|
{ |
|
Transform Trager = GameObject.Find("target").transform; |
|
GameObject Cube = GameObject.Find("SceneAll/CubeAll/Cube" + FloorSelect.PageNum).gameObject; |
|
if (Trager.transform.parent == null) |
|
{ |
|
Trager.transform.localPosition = new Vector3(Trager.transform.localPosition.x, Cube.transform.localPosition.y, Trager.transform.localPosition.z); |
|
} |
|
|
|
} |
|
|
|
} |
|
if (MySceneManager.GetActiveScene().name.Equals("11"))//处理超高层 |
|
{ |
|
|
|
if (GameObject.Find("SceneAll/CubeAll/Cube" + FloorSelect.PageNum)) |
|
{ |
|
Transform Trager = GameObject.Find("target").transform; |
|
GameObject Cube = GameObject.Find("SceneAll/CubeAll/Cube" + FloorSelect.PageNum).gameObject; |
|
if (Trager.transform.parent == null) |
|
{ |
|
Trager.transform.localPosition = new Vector3(Trager.transform.position.x, Cube.transform.position.y, Trager.transform.position.z); |
|
} |
|
} |
|
|
|
} |
|
|
|
if (RecordManager.Instance.IsRecording)//记录切换楼层事件 |
|
{ |
|
EventRecordItem_two EventAttribute = new EventRecordItem_two(); |
|
|
|
CameraAttribute camAttribute = MouseFollowRotation.Instance.CameraAttri; |
|
Transform Trager = GameObject.Find("target").transform; |
|
camAttribute.CameraTargetPos = Trager.transform.localPosition; |
|
EventAttribute.camAttributeList.Add(camAttribute); |
|
|
|
|
|
EventAttribute.eventType = eventTypeRecord.SwitchingFloor; |
|
RecordManager.Instance.RecordBasicEventAttri(ref EventAttribute); |
|
EventAttribute.TheFloor = FloorSelect.PageNum; |
|
EventAttribute.BuildTYPE = FloorSelect.PageType; |
|
RecordManager.Instance.AddToRecordEventList(EventAttribute); |
|
|
|
} |
|
} |
|
if (FloorSelect.PageNum >= MaxCeng) |
|
{ |
|
EndBuildingFloor.Instance.Louceng = MaxCeng; |
|
EndBuildingFloor.Instance.Control = true; |
|
} |
|
|
|
} |
|
if (Input.GetKeyDown(KeyCode.PageDown)) |
|
{ |
|
if (MySceneManager.GetActiveScene().name.Equals("5")) |
|
{//没有楼牌的场景 |
|
return; |
|
} |
|
if (FloorSelect.PageNum > MinCeng) |
|
{ |
|
FloorSelect.PageNum--; |
|
|
|
if (FloorSelect.PageNum == 0) |
|
{ |
|
FloorSelect.PageNum--; |
|
} |
|
|
|
EndBuildingFloor.Instance.Louceng = FloorSelect.PageNum; |
|
MessageDispatcher.SendMessage(FloorSelect.PageType, "SELECTFLOOR_EVENT", (object)FloorSelect.PageNum); |
|
|
|
if (MySceneManager.GetActiveScene().name.Equals("1"))//处理城市综合体 |
|
{ |
|
if (GameObject.Find("YueTanShangSha")) |
|
{ |
|
if (GameObject.Find("YueTanShangSha/BrandAll/Cube" + FloorSelect.PageNum)) |
|
{ |
|
Transform Trager = GameObject.Find("target").transform; |
|
GameObject Cube = GameObject.Find("YueTanShangSha/BrandAll/Cube" + FloorSelect.PageNum).gameObject; |
|
Trager.transform.localPosition = new Vector3(Cube.transform.localPosition.x, Cube.transform.localPosition.y, Cube.transform.localPosition.z); |
|
MouseFollowRotation.Instance.distance = 120; |
|
MouseFollowRotation.Instance.y = 13f; |
|
MouseFollowRotation.Instance.x = 358f; |
|
} |
|
} |
|
|
|
} |
|
if (MySceneManager.GetActiveScene().name.Equals("3"))//处理超高层 |
|
{ |
|
|
|
if (GameObject.Find("JinMaoScenes/CubeAll/Cube" + FloorSelect.PageNum)) |
|
{ |
|
Transform Trager = GameObject.Find("target").transform; |
|
GameObject Cube = GameObject.Find("JinMaoScenes/CubeAll/Cube" + FloorSelect.PageNum).gameObject; |
|
Trager.transform.localPosition = new Vector3(Cube.transform.localPosition.x, Cube.transform.localPosition.y, Cube.transform.localPosition.z); |
|
MouseFollowRotation.Instance.distance = 29; |
|
MouseFollowRotation.Instance.y = 28.6f; |
|
MouseFollowRotation.Instance.x = 182f; |
|
} |
|
|
|
} |
|
if (MySceneManager.GetActiveScene().name.Equals("9"))//处理超高层 |
|
{ |
|
|
|
if (GameObject.Find("SceneAll/CubeAll/Cube" + FloorSelect.PageNum)) |
|
{ |
|
Transform Trager = GameObject.Find("target").transform; |
|
GameObject Cube = GameObject.Find("SceneAll/CubeAll/Cube" + FloorSelect.PageNum).gameObject; |
|
if (Trager.transform.parent == null) |
|
{ |
|
Trager.transform.localPosition = new Vector3(Trager.transform.localPosition.x, Cube.transform.localPosition.y, Trager.transform.localPosition.z); |
|
} |
|
} |
|
|
|
} |
|
if (MySceneManager.GetActiveScene().name.Equals("11"))//处理超高层 |
|
{ |
|
|
|
if (GameObject.Find("SceneAll/CubeAll/Cube" + FloorSelect.PageNum)) |
|
{ |
|
Transform Trager = GameObject.Find("target").transform; |
|
GameObject Cube = GameObject.Find("SceneAll/CubeAll/Cube" + FloorSelect.PageNum).gameObject; |
|
if (Trager.transform.parent == null) |
|
{ |
|
Trager.transform.localPosition = new Vector3(Trager.transform.position.x, Cube.transform.position.y, Trager.transform.position.z); |
|
} |
|
} |
|
|
|
} |
|
if (RecordManager.Instance.IsRecording)//记录切换楼层事件 |
|
{ |
|
EventRecordItem_two EventAttribute = new EventRecordItem_two(); |
|
CameraAttribute camAttribute = MouseFollowRotation.Instance.CameraAttri; |
|
Transform Trager = GameObject.Find("target").transform; |
|
camAttribute.CameraTargetPos = Trager.transform.localPosition; |
|
EventAttribute.camAttributeList.Add(camAttribute); |
|
|
|
EventAttribute.eventType = eventTypeRecord.SwitchingFloor; |
|
RecordManager.Instance.RecordBasicEventAttri(ref EventAttribute); |
|
EventAttribute.TheFloor = FloorSelect.PageNum; |
|
EventAttribute.BuildTYPE = FloorSelect.PageType; |
|
RecordManager.Instance.AddToRecordEventList(EventAttribute); |
|
|
|
} |
|
} |
|
//} |
|
} |
|
} |
|
|
|
//} |
|
//传送物体 |
|
if (Input.GetMouseButtonUp(1) && LineamentEvent.gameobj != null && LineamentEvent.gameobj.transform.Find("info") && !LoadManager.Instance.IsPlayBacking && ExamInfoHelpClass.loadSceneMode != ExamInfoHelpClass.LoadSceneMode.CoursewareMode && ExamInfoHelpClass.loadSceneMode != ExamInfoHelpClass.LoadSceneMode.CourseBaseMode) |
|
{ |
|
//寻路模式取消双击传送 |
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING) |
|
return; |
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); |
|
RaycastHit hit; |
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity, indoor_layerMask)) |
|
{ |
|
Debug.Log("层" + hit.collider.name); |
|
if (hit.collider.name.Equals("VoidWall")) |
|
{ |
|
return; |
|
} |
|
} |
|
if (doubleClickCount <= 0.9 && checkDoubleClick) |
|
{ |
|
if (LineamentEvent.gameobj.name.Contains("xiaofangyuan")) |
|
{ |
|
MultiselectLayer = Rm_layerMask; |
|
} |
|
else |
|
{ |
|
MultiselectLayer = Tm_layerMask; |
|
} |
|
//传送单个物体,到指定层 |
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity, MultiselectLayer) && !EventSystem.current.IsPointerOverGameObject() && LineamentEvent.gameobj.name.Contains("xiaofang")) |
|
{ |
|
Debug.Log("层" + hit.collider.name); |
|
if (hit.collider.gameObject.layer == 29) |
|
{ |
|
return; |
|
} |
|
|
|
if (LineamentEvent.gameobj.GetComponent<LineamentEvent>().ControlJuBi) |
|
{ |
|
return; |
|
} |
|
GameObject tubiao = Instantiate(Resources.Load<GameObject>("Prefabs/Targeted/TuBiao"), transform.localPosition, Quaternion.identity) as GameObject; |
|
tubiao.transform.localPosition = new Vector3(hit.point.x, hit.point.y, hit.point.z); |
|
tubiao.transform.localEulerAngles = new Vector3(0, 0, -90); |
|
Vector3 CoordinatePoint = new Vector3(hit.point.x, hit.point.y, hit.point.z); |
|
|
|
LineamentEvent.gameobj.gameObject.transform.localPosition = CoordinatePoint; |
|
BuildItem build = new BuildItem(); |
|
build.floor = hit.collider.GetComponent<CengID>().cengID; |
|
build.buildType = hit.collider.GetComponent<CengID>().CengIDBuildType; |
|
MessageDispatcher.SendMessage(LineamentEvent.gameobj.name, "SetCengID", build); |
|
|
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
MessageDispatcher.SendMessage(LineamentEvent.gameobj.name, "RecordPathFindingEvent", CoordinatePoint); |
|
} |
|
|
|
|
|
|
|
} |
|
|
|
doubleClickCount = 0; |
|
checkDoubleClick = false; |
|
} |
|
else |
|
{ |
|
doubleClickCount = 0; |
|
checkDoubleClick = true; |
|
} |
|
} |
|
else if (checkDoubleClick) |
|
{ |
|
doubleClickCount += Time.deltaTime; |
|
if (doubleClickCount > 0.5) |
|
{ |
|
doubleClickCount = 0; |
|
checkDoubleClick = false; |
|
} |
|
} |
|
|
|
|
|
#region//键盘事件 |
|
if (LineamentEvent.gameobj != null && !LoadManager.Instance.IsPlayBacking) |
|
{ |
|
if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.W)) |
|
{ |
|
MessageDispatcher.SendMessage("LeftShift_W", (object)LineamentEvent.gameobj.name); |
|
} |
|
if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.S)) |
|
{ |
|
MessageDispatcher.SendMessage("LeftShift_S", (object)LineamentEvent.gameobj.name); |
|
} |
|
if ((!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.W)) |
|
{ |
|
MessageDispatcher.SendMessage("W", (object)LineamentEvent.gameobj.name); |
|
} |
|
if ((!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.S)) |
|
{ |
|
MessageDispatcher.SendMessage("S", (object)LineamentEvent.gameobj.name); |
|
} |
|
if ((!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.A)) |
|
{ |
|
MessageDispatcher.SendMessage("A", (object)LineamentEvent.gameobj.name); |
|
} |
|
if ((!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.D)) |
|
{ |
|
MessageDispatcher.SendMessage("D", (object)LineamentEvent.gameobj.name); |
|
} |
|
if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.U)) |
|
{ |
|
MessageDispatcher.SendMessage("LeftShift_U", (object)LineamentEvent.gameobj.name); |
|
} |
|
if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.J)) |
|
{ |
|
MessageDispatcher.SendMessage("LeftShift_J", (object)LineamentEvent.gameobj.name); |
|
} |
|
if ((!Input.GetKey(KeyCode.LeftShift) || !Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.H)) |
|
{ |
|
MessageDispatcher.SendMessage("H", (object)LineamentEvent.gameobj.name); |
|
} |
|
if ((!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.K)) |
|
{ |
|
MessageDispatcher.SendMessage("K", (object)LineamentEvent.gameobj.name); |
|
} |
|
if ((!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.U)) |
|
{ |
|
MessageDispatcher.SendMessage("U", (object)LineamentEvent.gameobj.name); |
|
} |
|
else if ((!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftControl)) && Input.GetKey(KeyCode.J)) |
|
{ |
|
MessageDispatcher.SendMessage("J", (object)LineamentEvent.gameobj.name); |
|
|
|
} |
|
|
|
|
|
if (Input.GetKey(KeyCode.Equals)) |
|
{ |
|
MessageDispatcher.SendMessage("Equals", (object)LineamentEvent.gameobj.name); |
|
} |
|
if (Input.GetKey(KeyCode.Minus)) |
|
{ |
|
MessageDispatcher.SendMessage("Minus", (object)LineamentEvent.gameobj.name); |
|
} |
|
|
|
|
|
} |
|
if (Input.GetKey(KeyCode.B)) |
|
{ |
|
MessageDispatcher.SendMessage("B"); |
|
} |
|
if (Input.GetKey(KeyCode.P)) |
|
{ |
|
MessageDispatcher.SendMessage("P"); |
|
} |
|
|
|
if (Input.GetKey(KeyCode.O)) |
|
{ |
|
MessageDispatcher.SendMessage("O"); |
|
} |
|
if (Input.GetKeyDown(KeyCode.Y))//烟雾显示按钮 |
|
{ |
|
if (MySceneManager.GetActiveScene().name.Equals("2")) |
|
{ |
|
MessageDispatcher.SendMessage("Y"); |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
EventRecordItem_two EventAttribute = new EventRecordItem_two(); |
|
|
|
EventAttribute.eventType = eventTypeRecord.Y; |
|
EventAttribute.TheFloor = EndBuildingFloor.Instance.Louceng; |
|
RecordManager.Instance.RecordBasicEventAttri(ref EventAttribute); |
|
RecordManager.Instance.AddToRecordEventList(EventAttribute); |
|
} |
|
} |
|
} |
|
|
|
#endregion |
|
} |
|
|
|
#region//移动指挥终端模块输入处理方法 |
|
/// <summary> |
|
/// 克隆战术的输入处理 |
|
/// </summary> |
|
private void CloneTacticObj() |
|
{ |
|
if (cloneType != TacticCloneType.None && !EventSystem.current.IsPointerOverGameObject()) |
|
{ |
|
ray = Camera.main.ScreenPointToRay(Input.mousePosition); |
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity, Rm_layerMask))//只能在dimian,shineiFloor两个层克隆 |
|
{ |
|
if (Input.GetButtonDown("LeftMouse")) |
|
{ |
|
preMousePos = Input.mousePosition; |
|
} |
|
|
|
if (Input.GetButtonUp("LeftMouse")) |
|
{ |
|
curMousePos = Input.mousePosition; |
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击克隆操作与左键框选的冲突 |
|
{ |
|
MessageDispatcher.SendMessage(hit.transform, "TACTIC_CLONE", |
|
new KeyValuePair<TacticCloneType, Vector3>(cloneType, hit.point)); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 取消战术克隆按钮的选中 的输入处理 |
|
/// </summary> |
|
private void CancelTacticCloneBtnSelected() |
|
{ |
|
if (Input.GetButtonDown("RightMouse")) |
|
{ |
|
preMousePos = Input.mousePosition; |
|
} |
|
|
|
if (Input.GetButtonUp("RightMouse")) |
|
{ |
|
curMousePos = Input.mousePosition; |
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:右键单击取消克隆按钮的选中操作与右键旋转的冲突 |
|
{ |
|
MessageDispatcher.SendMessage("CANCEL_CLONEBTN_SELECTED", false); |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 单选输入处理 |
|
/// </summary> |
|
private void RadioSelect() |
|
{ |
|
if (Input.GetButtonDown("LeftMouse")) |
|
{ |
|
preMousePos = Input.mousePosition; |
|
} |
|
|
|
if (Input.GetButtonUp("LeftMouse")) |
|
{ |
|
curMousePos = Input.mousePosition; |
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击选中操作与左键框选的冲突 |
|
{ |
|
ray = Camera.main.ScreenPointToRay(Input.mousePosition); |
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity)) |
|
{ |
|
if (SelectedObjs.gameObjs.Contains(hit.transform.parent.gameObject)) |
|
{ |
|
if (SelectedObjs.selectedObj != hit.transform.parent.gameObject) |
|
{ |
|
if (SelectedObjs.selectedObj != null) |
|
{ |
|
MessageDispatcher.SendMessage("CANCEL_RADIOSELECT", SelectedObjs.selectedObj); |
|
} |
|
|
|
MessageDispatcher.SendMessage("RADIOSELECT", hit.transform.gameObject); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 取消游戏对象的选中 的输入处理 |
|
/// </summary> |
|
private void CancelObjSelected() |
|
{ |
|
if (!EventSystem.current.IsPointerOverGameObject()) |
|
{ |
|
ray = Camera.main.ScreenPointToRay(Input.mousePosition); |
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity, Rm_layerMask)) |
|
{ |
|
if (Input.GetButtonDown("LeftMouse")) |
|
{ |
|
if (SelectedObjs.selectedObj != null) |
|
{ |
|
MessageDispatcher.SendMessage("CANCEL_RADIOSELECT", SelectedObjs.selectedObj); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
#endregion |
|
|
|
|
|
private int numDown; |
|
void OnGUI() |
|
{ |
|
// Render boxes if numeric key 1-9 is pressed. |
|
// 处理键盘事件 |
|
//if (Input.GetKey(KeyCode.LeftShift)) |
|
//{ |
|
// if (GetNumKeyDown()) |
|
// { |
|
// //同时按住Ctrl键和数字键,打组 |
|
// MessageDispatcher.SendMessage("MakeGroup", (object)numDown); |
|
// numDown = 0; |
|
// } |
|
//} |
|
//else |
|
//{ |
|
// if (GetNumKeyDown()) |
|
// { |
|
// //只按下数字键,选择打组 |
|
// ClearSelectedCharacters(); |
|
// MessageDispatcher.SendMessage("SelectGroup", (object)numDown); |
|
// numDown = 0; |
|
// } |
|
//} |
|
} |
|
|
|
private bool GetNumKeyDown() |
|
{ |
|
int num; |
|
if (Event.current.type == EventType.KeyDown) |
|
{ |
|
// 为了方便,转换到数值 |
|
num = Event.current.keyCode - KeyCode.Alpha1 + 1; |
|
|
|
// 避免多个数字键同时按下 |
|
if (numDown == 0 && num >= 1 && num <= 9) |
|
{ |
|
numDown = num; |
|
Event.current.Use(); |
|
} |
|
} |
|
else if (Event.current.type == EventType.KeyUp) |
|
{ |
|
num = Event.current.keyCode - KeyCode.Alpha1 + 1; |
|
if (numDown == num) |
|
{ |
|
numDown = 0; |
|
Event.current.Use(); |
|
} |
|
} |
|
if (numDown > 0) |
|
{ |
|
return true; |
|
} |
|
return false; |
|
} |
|
|
|
|
|
public void drawSelectionRectangle(Vector3 start, Vector3 end) |
|
{ |
|
|
|
GL.PushMatrix();//保存摄像机变换矩阵 |
|
|
|
if (!rectMat) |
|
return; |
|
|
|
rectMat.SetPass(0); |
|
GL.LoadPixelMatrix();//设置用屏幕坐标绘图 |
|
GL.Begin(GL.QUADS); |
|
GL.Color(new Color(rectColor.r, rectColor.g, rectColor.b, 0.1f)); |
|
GL.Vertex3(start.x, start.y, 0); |
|
GL.Vertex3(end.x, start.y, 0); |
|
GL.Vertex3(end.x, end.y, 0); |
|
GL.Vertex3(start.x, end.y, 0); |
|
GL.End(); |
|
GL.Begin(GL.LINES); |
|
GL.Color(rectColor);//设置方框的边框颜色 边框不透明 |
|
GL.Vertex3(start.x, start.y, 0); |
|
GL.Vertex3(end.x, start.y, 0); |
|
GL.Vertex3(end.x, start.y, 0); |
|
GL.Vertex3(end.x, end.y, 0); |
|
GL.Vertex3(end.x, end.y, 0); |
|
GL.Vertex3(start.x, end.y, 0); |
|
GL.Vertex3(start.x, end.y, 0); |
|
GL.Vertex3(start.x, start.y, 0); |
|
GL.End(); |
|
GL.PopMatrix();//恢复摄像机矩阵 |
|
} |
|
public void OnPostRender() |
|
{ |
|
//if (StairUI.Instance.gameObject.activeInHierarchy) |
|
//{ |
|
// return; |
|
//} |
|
if (!TrackRecordHelpClass.CheckIfCanControl()) |
|
return; |
|
if (LineamentEvent.gameobj == null) //防止单选中后可以框选 |
|
{ |
|
if (drawRectangle) |
|
{ |
|
Vector3 end = Input.mousePosition;//鼠标当前位置 |
|
drawSelectionRectangle(downPosition, end); |
|
checkSelection(downPosition, end); |
|
|
|
if (Vector3.Distance(downPosition, end) > 40) |
|
{ |
|
MessageDispatcher.SendMessage("ResettingButton", (object)this.name); |
|
} |
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
float OffestDistance = 0; |
|
public void checkSelection(Vector3 start, Vector3 end) |
|
{ |
|
Vector3 p1 = Vector3.zero; |
|
Vector3 p2 = Vector3.zero; |
|
if (start.x > end.x)//这些判断是用来确保p1的xy坐标小于p2的xy坐标,因为画的框不见得就是左下到右上或者左上到右下这个方向 |
|
{ |
|
p1.x = end.x; |
|
p2.x = start.x; |
|
} |
|
else |
|
{ |
|
p1.x = start.x; |
|
p2.x = end.x; |
|
} |
|
if (start.y > end.y) |
|
{ |
|
p1.y = end.y; |
|
p2.y = start.y; |
|
} |
|
else |
|
{ |
|
p1.y = start.y; |
|
p2.y = end.y; |
|
} |
|
|
|
for (int i = characters.Count - 1; i >= 0; i--) |
|
{ |
|
GameObject obj = characters[i]; |
|
if (!obj) |
|
{ |
|
characters.Remove(obj); |
|
continue; |
|
} |
|
Vector3 location = GetComponent<Camera>().WorldToScreenPoint(obj.transform.position); |
|
if (location.x < p1.x || location.x > p2.x || location.y < p1.y || location.y > p2.y |
|
|| location.z < 0 || location.z > farPlane) |
|
{//z方向就用摄像机的设定值,看不见的也不需要选择了 |
|
removeItem(obj);//上面的条件是筛选 不在选择范围内的对象,然后进行取消选择操作,比如把物体放到default层,就不显示轮廓线了 |
|
} |
|
else |
|
{ |
|
addItem(obj);//否则就进行选中操作,比如把物体放到画轮廓线的层去 |
|
} |
|
|
|
} |
|
} |
|
public void removeItem(GameObject obj) |
|
{ |
|
if (obj == null) |
|
{ |
|
return; |
|
} |
|
if (selectedCharacters.Contains(obj)) |
|
{ |
|
selectedCharacters.Remove(obj); |
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING) |
|
{ |
|
if (obj.GetComponent<AgentControl>()) |
|
{ |
|
obj.GetComponent<AgentControl>().enabled = false; |
|
} |
|
} |
|
|
|
MessageDispatcher.SendMessage("RemoveCharactersControl", (object)obj.name); |
|
} |
|
} |
|
|
|
void OnDestroy() |
|
{ |
|
foreach (GameObject obj in characters) |
|
{ |
|
DestroyImmediate(obj); |
|
} |
|
if (rectMat) |
|
{ |
|
DestroyImmediate(rectMat); |
|
} |
|
} |
|
}
|
|
|