|
|
|
using UnityEngine;
|
|
|
|
using System.Collections;
|
|
|
|
using System;
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
using AX.InputSystem;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine.AI;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 处理输入的类
|
|
|
|
/// </summary>
|
|
|
|
public class InputManager : MonoBehaviour
|
|
|
|
{
|
|
|
|
private static InputManager instance;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取 InputManager Singleton 实例。
|
|
|
|
/// </summary>
|
|
|
|
public static InputManager Instance { get { return instance; } }
|
|
|
|
|
|
|
|
private const long gameObjID = 0;
|
|
|
|
|
|
|
|
private RaycastHit hit;
|
|
|
|
public static int frameCount = 0;//进入场景后累加的帧数
|
|
|
|
public static SceneType sceneType;//记录进入场景的类型(这里测试暂时在Start里初始化,做项目时进入场景时赋值)
|
|
|
|
public static CloneObjType cloneObjType = CloneObjType.None;//克隆对象的类型
|
|
|
|
public static ForcibleType ForcibleType = ForcibleType.None;//破拆门类型
|
|
|
|
public static bool skill;
|
|
|
|
//public static bool AutoArm;
|
|
|
|
private float mouseScroll = 0.0f;//鼠标中键滚动值
|
|
|
|
//控制鼠标中键没有滚动时及mouseScroll为0时只分发一次命令,避免中键没有滚动情况下战斗回放历史记录一直记录没有改变的信息
|
|
|
|
private bool mouseScrollIsZero = true;
|
|
|
|
|
|
|
|
private float mouseX = 0.0f;//鼠标在屏幕坐标系下X方向的变化值
|
|
|
|
private float mouseY = 0.0f;//鼠标在屏幕坐标系下Y方向的变化值
|
|
|
|
private bool rotateStart = false;//旋转是否开始
|
|
|
|
private bool flag;//控制 鼠标右键按下状态时,如果鼠标停止移动,只发一次旋转中命令,避免鼠标停止后,还会有旋转效果
|
|
|
|
|
|
|
|
|
|
|
|
private bool dragStart = false;//拖拽是否开始
|
|
|
|
|
|
|
|
private bool CamdragStart = false;//相机拖拽是否开始
|
|
|
|
private bool FireDeployCmdragStart = false;//作战部署相机拖拽是否开始
|
|
|
|
private bool notDragUI = false;//拖拽的不是UI面板(ScrollRect)----为了处理拖拽ScrollRect时,当鼠标处于ScrollRect范围之外,摄像机跟着移动
|
|
|
|
|
|
|
|
private CameraManager cameraManager;
|
|
|
|
private FireDeployCameraManager fireDeployCameraManager;
|
|
|
|
private Transform target;
|
|
|
|
private float yMax;
|
|
|
|
private float initialTargetPosY;
|
|
|
|
|
|
|
|
private Vector3 preMousePos;
|
|
|
|
private Vector3 curMousePos;
|
|
|
|
|
|
|
|
private GameObject gameObjectCloneable;
|
|
|
|
private bool cloneable;
|
|
|
|
|
|
|
|
private bool drawRectStart;//框选画框是否开始
|
|
|
|
|
|
|
|
private int pathFindingLayer;
|
|
|
|
|
|
|
|
public static bool isRectSelect;//是否处于框选状态
|
|
|
|
public static bool isCameraDrag;//是否处于相机(场景)拖动状态
|
|
|
|
public static bool OccupyKeyboard;//是否占用键盘输入(比如正在输入字符)
|
|
|
|
public static bool isDargUI = false;//是否正在拖拽UI
|
|
|
|
|
|
|
|
public static bool IsGuidance;//时否开始引导
|
|
|
|
public static List<Vector3> GuidanceList=new List<Vector3>();//引导路径点
|
|
|
|
|
|
|
|
private GameObject hitObjToDrag;
|
|
|
|
private GameObject hitObjToDragCamera;
|
|
|
|
|
|
|
|
//全液面火设置参数
|
|
|
|
private float minScale = 0.2f;
|
|
|
|
private float maxScale = 2.0f;
|
|
|
|
private float scaleSpeed = 2.0f;
|
|
|
|
|
|
|
|
public static Organization org;//作战部署克隆力量图标(车,消防员)需要绑定的组织机构
|
|
|
|
public static FireCarEngine fireCarEngine; //作战部署克隆力量图标(车)需要绑定的车辆数据
|
|
|
|
public static Color color;//作战部署克隆力量图标(车,消防员)需要绑定的颜色数据
|
|
|
|
|
|
|
|
public static long selectedFireDeployObjId;
|
|
|
|
|
|
|
|
public static FireDeployPrivateToolType fireDeployPrivateToolType = FireDeployPrivateToolType.None;
|
|
|
|
|
|
|
|
private NavMeshQueryFilter filter;
|
|
|
|
private NavMeshHit nhit;
|
|
|
|
private Transform p_trappedman;
|
|
|
|
private GameObject pointer;
|
|
|
|
private Transform p_Hitpoint;
|
|
|
|
|
|
|
|
public static bool isTagSearchRoom;//是否正在使用侦察技能
|
|
|
|
public static Vector3 tagSearchRoomPoint = Vector3.zero;//侦察点位
|
|
|
|
private bool LeftShift;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
|
|
|
|
|
|
|
fireDeployCameraManager = GameObject.Find("FireDeployCamera").GetComponent<FireDeployCameraManager>();
|
|
|
|
}
|
|
|
|
public static void ResertInputmanage()
|
|
|
|
{
|
|
|
|
sceneType = SceneType.None;
|
|
|
|
frameCount = 0;
|
|
|
|
skill =false;
|
|
|
|
//AutoArm=false;
|
|
|
|
cloneObjType = CloneObjType.None;
|
|
|
|
selectedFireDeployObjId = -1;
|
|
|
|
IsGuidance = false;
|
|
|
|
GuidanceList.Clear();
|
|
|
|
isTagSearchRoom = false;
|
|
|
|
tagSearchRoomPoint = Vector3.zero;
|
|
|
|
fireDeployPrivateToolType = FireDeployPrivateToolType.None;
|
|
|
|
fireCarEngine = null;
|
|
|
|
org = null;
|
|
|
|
//instance = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
sceneType = SceneType.化工建筑;
|
|
|
|
|
|
|
|
cameraManager = GameObject.Find("Main Camera").GetComponent<CameraManager>();
|
|
|
|
if (cameraManager)
|
|
|
|
{
|
|
|
|
target = cameraManager.target;
|
|
|
|
|
|
|
|
yMax = cameraManager.yMax;
|
|
|
|
initialTargetPosY = cameraManager.initialTargetPosY;
|
|
|
|
}
|
|
|
|
|
|
|
|
gameObjectCloneable = GameObject.Find("GameObjectCloneable");
|
|
|
|
if (gameObjectCloneable == null)
|
|
|
|
{
|
|
|
|
gameObjectCloneable = new GameObject("GameObjectCloneable");
|
|
|
|
gameObjectCloneable.AddComponent<Cloneable>();
|
|
|
|
}
|
|
|
|
pathFindingLayer = LayerMask.NameToLayer("PathFinding");
|
|
|
|
|
|
|
|
p_trappedman = GameObject.Find("P_AllParent/P_Disasters/P_TrappedPerson").transform;
|
|
|
|
p_Hitpoint = GameObject.Find("P_AllParent/P_Hitpoint").transform;
|
|
|
|
filter.agentTypeID = p_trappedman.GetComponent<CloneSingleDisasterObj>().clonePrefab.GetComponent<NavMeshAgent>().agentTypeID;
|
|
|
|
filter.areaMask = p_trappedman.GetComponent<CloneSingleDisasterObj>().clonePrefab.GetComponent<NavMeshAgent>().areaMask;
|
|
|
|
if (pointer==null)
|
|
|
|
{
|
|
|
|
pointer = Resources.Load<GameObject>("Particle");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
//if (!GameSettings.othersSettings.isReplayMode)
|
|
|
|
//{
|
|
|
|
// InputHandle();
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// if (GameSettings.othersSettings.isReplayPause || GameSettings.othersSettings.isReplayOver)
|
|
|
|
// {
|
|
|
|
// InputHandle();
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
if (GameSettings.othersSettings.playState != PlayState.Playing)
|
|
|
|
{
|
|
|
|
InputHandle();
|
|
|
|
// KeyboardHandle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FixedUpdate()
|
|
|
|
{
|
|
|
|
++frameCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
private bool getRayCastAll(Ray ray)
|
|
|
|
{
|
|
|
|
bool rayCast = false;
|
|
|
|
//Ray ray = Camera.main.ScreenPointToRay(point);
|
|
|
|
RaycastHit[] hits;
|
|
|
|
//int notRendering = LayerMask.NameToLayer("NotRendering");
|
|
|
|
int ignoreRaycast = LayerMask.NameToLayer("Ignore Raycast");
|
|
|
|
hits = Physics.RaycastAll(ray, Mathf.Infinity, ~(1 << ignoreRaycast));
|
|
|
|
//List<RaycastHit> hitList= hits.
|
|
|
|
Array.Sort(hits, (r1, r2) => r1.distance.CompareTo(r2.distance));
|
|
|
|
for (var i = 0; i < hits.Length; i++)
|
|
|
|
{
|
|
|
|
var hitpoint = hits[i];
|
|
|
|
var renderer = hitpoint.collider.GetComponent<Renderer>();
|
|
|
|
if (renderer)
|
|
|
|
{
|
|
|
|
if (renderer.enabled)
|
|
|
|
{
|
|
|
|
rayCast = true;
|
|
|
|
hit = hitpoint;
|
|
|
|
//Debug.Log("----->"+hit.collider.name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var renderers = hitpoint.transform.GetComponentsInChildren<Renderer>();
|
|
|
|
for (int k = 0; k < renderers.Length; k++)
|
|
|
|
{
|
|
|
|
if (renderers[k].enabled)
|
|
|
|
{
|
|
|
|
rayCast = true;
|
|
|
|
hit = hitpoint;
|
|
|
|
//Debug.Log("----->"+hit.collider.name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rayCast)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
string a = "";
|
|
|
|
for (var i = 0; i < hits.Length; i++)
|
|
|
|
{
|
|
|
|
a += "|" + hits[i].collider.name;
|
|
|
|
}
|
|
|
|
Debug.Log(a);
|
|
|
|
*/
|
|
|
|
return rayCast;
|
|
|
|
}
|
|
|
|
private void InputHandle()
|
|
|
|
{
|
|
|
|
if (GameObject.Find("Main Camera").GetComponent<CameraManager>().viewType != CameraViewState.ThirdPersonView)
|
|
|
|
{
|
|
|
|
//相机横向移动的输入操作处理
|
|
|
|
CameraHorizontalMoveInputHandle();
|
|
|
|
//相机竖向移动的输入操作处理
|
|
|
|
CameraVerticalMoveInputHandle();
|
|
|
|
}
|
|
|
|
//相机旋转的输入操作处理
|
|
|
|
CameraRotationInputHandle();
|
|
|
|
|
|
|
|
//作战部署相机横向移动的输入操作处理
|
|
|
|
FireDeployCameraHMoveInputHandle();
|
|
|
|
//作战部署相机缩放的输入操作处理
|
|
|
|
FireDeplyCameraScaleInputHandle();
|
|
|
|
|
|
|
|
//框选画框输入处理
|
|
|
|
DrawSelectionRectangle();
|
|
|
|
//对象拖动输入处理
|
|
|
|
ObjDrag();
|
|
|
|
//取消克隆按钮选中的输入处理
|
|
|
|
CancelCloneBtnSelected();
|
|
|
|
//取消游戏对象的选中的输入处理
|
|
|
|
CancelObjSelected();
|
|
|
|
//对象删除输入处理
|
|
|
|
ObjDelete();
|
|
|
|
|
|
|
|
//作战部署对象删除
|
|
|
|
FireDeployObjDelete();
|
|
|
|
|
|
|
|
//对象旋转输入处理
|
|
|
|
ObjRotate();
|
|
|
|
SetFireLiquidLevelScale();
|
|
|
|
if (!EventSystem.current.IsPointerOverGameObject())
|
|
|
|
{
|
|
|
|
//相机缩放的输入操作处理
|
|
|
|
CameraScaleInputHandle();
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
|
|
var rayCast = getRayCastAll(ray);
|
|
|
|
//Debug.Log("------>"+ rayCast);
|
|
|
|
if (rayCast)
|
|
|
|
{
|
|
|
|
if (skill)
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("LeftShift"))
|
|
|
|
{
|
|
|
|
LeftShift = true;
|
|
|
|
}
|
|
|
|
if (Input.GetButtonUp("LeftShift"))
|
|
|
|
{
|
|
|
|
LeftShift = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
// //破拆输入处理
|
|
|
|
ForcibleEntry();
|
|
|
|
// //营救输入处理
|
|
|
|
// SaveMan();
|
|
|
|
// //询问知情人输入处理
|
|
|
|
AskPeople();
|
|
|
|
//清理危险品输入处理
|
|
|
|
ClearDangerous();
|
|
|
|
// //清理杂物堆输入处理
|
|
|
|
// ClearSundries();
|
|
|
|
GuidanceMan();
|
|
|
|
MoveMan();
|
|
|
|
FristAidMan();
|
|
|
|
// ClearSundries();
|
|
|
|
|
|
|
|
|
|
|
|
//蔓延火
|
|
|
|
cloneable = gameObjectCloneable.GetComponent<Cloneable>().GetCloneAble(hit.point, hit.transform.gameObject, cloneObjType);
|
|
|
|
if (cloneable)
|
|
|
|
{
|
|
|
|
//克隆火蔓延路径的输入处理
|
|
|
|
CloneObj();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SelectedObjs.selectedObj && SelectedObjs.selectedObj.GetComponent<ControlTruckArm>())
|
|
|
|
{
|
|
|
|
var cmdargs = new WeightCmdArgs();
|
|
|
|
cmdargs.Weight += Time.deltaTime * 10f;
|
|
|
|
long gameObjID = SelectedObjs.selectedObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
//cmdargs.Weight += GlobalVariable.TruckArmSpeed;
|
|
|
|
//cmdargs.Weight *= 0.1f;
|
|
|
|
if (Input.GetButton("W"))
|
|
|
|
{
|
|
|
|
if (LeftShift)
|
|
|
|
{
|
|
|
|
LeftShiftWCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (Input.GetButton("S"))
|
|
|
|
{
|
|
|
|
if (LeftShift)
|
|
|
|
{
|
|
|
|
LeftShiftSCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Input.GetButton("A"))
|
|
|
|
{
|
|
|
|
ACommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (Input.GetButton("D"))
|
|
|
|
{
|
|
|
|
DCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
else if (Input.GetButton("U"))
|
|
|
|
{
|
|
|
|
if (LeftShift)
|
|
|
|
{
|
|
|
|
LeftShiftUCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (Input.GetButton("J"))
|
|
|
|
{
|
|
|
|
if (LeftShift)
|
|
|
|
{
|
|
|
|
LeftShiftJCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// //设置寻路点
|
|
|
|
// SetPathPoint();
|
|
|
|
//自动举臂
|
|
|
|
//if (AutoArm)
|
|
|
|
//{
|
|
|
|
// AutoLiftArm();
|
|
|
|
//}
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// //寻路输入处理 PathFinding();
|
|
|
|
// }
|
|
|
|
if (IsGuidance)//引导状态设置引导点
|
|
|
|
{
|
|
|
|
SetGuidancePoint();
|
|
|
|
}
|
|
|
|
else if (isTagSearchRoom)
|
|
|
|
{//设置侦察技能侦察点位
|
|
|
|
SetTagSearchRoomPoint();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PathFinding();
|
|
|
|
}
|
|
|
|
TakeOrPickWaterHose();
|
|
|
|
}
|
|
|
|
//克隆按钮没有被选中
|
|
|
|
else if (cloneObjType == CloneObjType.None)
|
|
|
|
{
|
|
|
|
|
|
|
|
//if (AutoArm)
|
|
|
|
//{
|
|
|
|
// AutoLiftArm();
|
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
//单选输入处理
|
|
|
|
RadioSelect();
|
|
|
|
//寻路输入处理
|
|
|
|
|
|
|
|
PathFinding();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{//克隆按钮被选中
|
|
|
|
cloneable = gameObjectCloneable.GetComponent<Cloneable>().GetCloneAble(hit.point, hit.transform.gameObject, cloneObjType);
|
|
|
|
//克隆状态下,如果点击到能被选中或者既不能被选中也不能在其上面克隆对象时,不分发克隆指令
|
|
|
|
//(即只有点击到能克隆的对象上才发生克隆行为)
|
|
|
|
if (!cloneable)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//克隆的输入处理
|
|
|
|
CloneObj();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else//如果鼠标在UI上 相关操作没有结束
|
|
|
|
{
|
|
|
|
// if (AutoArm)
|
|
|
|
// {
|
|
|
|
// CursorManager.GetInstance.SetNormal();
|
|
|
|
// }
|
|
|
|
if (SelectedObjs.selectedObj && SelectedObjs.selectedObj.GetComponent<ControlTruckArm>())
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("LeftShift"))
|
|
|
|
{
|
|
|
|
LeftShift = true;
|
|
|
|
}
|
|
|
|
if (Input.GetButtonUp("LeftShift"))
|
|
|
|
{
|
|
|
|
LeftShift = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
var cmdargs = new WeightCmdArgs();
|
|
|
|
cmdargs.Weight += Time.deltaTime * 10f;
|
|
|
|
long gameObjID = SelectedObjs.selectedObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
//cmdargs.Weight += GlobalVariable.TruckArmSpeed;
|
|
|
|
//cmdargs.Weight *= 0.1f;
|
|
|
|
if (Input.GetButton("W"))
|
|
|
|
{
|
|
|
|
if (LeftShift)
|
|
|
|
{
|
|
|
|
LeftShiftWCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (Input.GetButton("S"))
|
|
|
|
{
|
|
|
|
if (LeftShift)
|
|
|
|
{
|
|
|
|
LeftShiftSCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Input.GetButton("A"))
|
|
|
|
{
|
|
|
|
ACommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (Input.GetButton("D"))
|
|
|
|
{
|
|
|
|
DCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
else if (Input.GetButton("U"))
|
|
|
|
{
|
|
|
|
if (LeftShift)
|
|
|
|
{
|
|
|
|
LeftShiftUCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (Input.GetButton("J"))
|
|
|
|
{
|
|
|
|
if (LeftShift)
|
|
|
|
{
|
|
|
|
LeftShiftJCommand.Instance.Execute(gameObjID, cmdargs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//作战部署工具克隆逻辑
|
|
|
|
PointerEventData eventDataCurrentPosition = new PointerEventData(EventSystem.current);
|
|
|
|
eventDataCurrentPosition.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
|
|
|
|
|
|
|
|
List<RaycastResult> results = new List<RaycastResult>();
|
|
|
|
EventSystem.current.RaycastAll(eventDataCurrentPosition, results);
|
|
|
|
|
|
|
|
var point = new Vector3(eventDataCurrentPosition.position.x, eventDataCurrentPosition.position.y,0f);
|
|
|
|
|
|
|
|
if (results.Count > 0)
|
|
|
|
{
|
|
|
|
if (cloneObjType != CloneObjType.None)
|
|
|
|
{
|
|
|
|
cloneable = gameObjectCloneable.GetComponent<Cloneable>().GetCloneAble(point, results[0].gameObject, cloneObjType);
|
|
|
|
|
|
|
|
if (!cloneable)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CloneFireDeployObj();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#region 原来代码
|
|
|
|
// if (!EventSystem.current.IsPointerOverGameObject())
|
|
|
|
// {
|
|
|
|
// //相机缩放的输入操作处理
|
|
|
|
// CameraScaleInputHandle();
|
|
|
|
// //相机旋转的输入操作处理
|
|
|
|
// CameraRotationInputHandle();
|
|
|
|
// //相机横向移动的输入操作处理
|
|
|
|
// CameraHorizontalMoveInputHandle();
|
|
|
|
// //相机竖向移动的输入操作处理
|
|
|
|
// CameraVerticalMoveInputHandle();
|
|
|
|
// //取消克隆按钮选中的输入处理
|
|
|
|
// CancelCloneBtnSelected();
|
|
|
|
// //取消游戏对象的选中 的输入处理
|
|
|
|
// CancelObjSelected();
|
|
|
|
// //框选画框输入处理
|
|
|
|
// DrawSelectionRectangle();
|
|
|
|
// //对象删除输入处理
|
|
|
|
// ObjDelete();
|
|
|
|
// //对象旋转输入处理
|
|
|
|
// ObjRotate();
|
|
|
|
// //对象拖动输入处理
|
|
|
|
// ObjDrag();
|
|
|
|
|
|
|
|
// Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
|
|
|
|
|
|
// if (Physics.Raycast(ray, out hit, Mathf.Infinity))
|
|
|
|
// {
|
|
|
|
// //克隆按钮没有被选中
|
|
|
|
// if (cloneObjType == CloneObjType.None)
|
|
|
|
// {
|
|
|
|
// //单选输入处理
|
|
|
|
// RadioSelect();
|
|
|
|
// //寻路输入处理
|
|
|
|
// PathFinding();
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {//克隆按钮被选中
|
|
|
|
// cloneable = gameObjectCloneable.GetComponent<Cloneable>().GetCloneAble(hit.transform.gameObject, cloneObjType);
|
|
|
|
// //克隆状态下,如果点击到能被选中或者既不能被选中也不能在其上面克隆对象时,不分发克隆指令
|
|
|
|
// //(即只有点击到能克隆的对象上才发生克隆行为)
|
|
|
|
// if (!cloneable)
|
|
|
|
// {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// //克隆的输入处理
|
|
|
|
// CloneObj();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 自动举臂
|
|
|
|
/// </summary>
|
|
|
|
private void AutoLiftArm()
|
|
|
|
{
|
|
|
|
CursorManager.GetInstance.SetAutoLiftArm();
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击选中操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedObj)
|
|
|
|
{
|
|
|
|
//施放举臂技能
|
|
|
|
SkillManager.Instance.LiftArm(SelectedObjs.selectedObj, hit.point);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 相机缩放的输入操作处理
|
|
|
|
/// </summary>
|
|
|
|
private void CameraScaleInputHandle()
|
|
|
|
{
|
|
|
|
//控制摄像头以Target为参照物缩放
|
|
|
|
mouseScroll = Input.GetAxis("Mouse ScrollWheel");
|
|
|
|
if (mouseScroll != 0)
|
|
|
|
{
|
|
|
|
if (!mouseScrollIsZero)
|
|
|
|
{
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mouseScroll = mouseScroll;
|
|
|
|
|
|
|
|
MiddleMouseScrollCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
|
|
|
|
mouseScrollIsZero = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (mouseScrollIsZero)
|
|
|
|
{
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mouseScroll = mouseScroll;
|
|
|
|
|
|
|
|
arg.distance = cameraManager.distance;
|
|
|
|
|
|
|
|
MiddleMouseScrollCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
|
|
|
|
mouseScrollIsZero = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 作战部署相机缩放的输入操作处理
|
|
|
|
/// </summary>
|
|
|
|
private void FireDeplyCameraScaleInputHandle()
|
|
|
|
{
|
|
|
|
//控制摄像头以Target为参照物缩放
|
|
|
|
mouseScroll = Input.GetAxis("Mouse ScrollWheel");
|
|
|
|
if (mouseScroll != 0)
|
|
|
|
{
|
|
|
|
if (!mouseScrollIsZero)
|
|
|
|
{
|
|
|
|
if (EventSystem.current.IsPointerOverGameObject()
|
|
|
|
&& (OnePointColliderObject() && OnePointColliderObject().GetComponent<CloneableEnums>())
|
|
|
|
&& (OnePointColliderObject() && OnePointColliderObject().GetComponent<RawImage>())
|
|
|
|
)
|
|
|
|
{
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mouseScroll = mouseScroll;
|
|
|
|
|
|
|
|
FireDeployMiddleMouseScrollCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
|
|
|
|
mouseScrollIsZero = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (mouseScrollIsZero)
|
|
|
|
{
|
|
|
|
if (EventSystem.current.IsPointerOverGameObject()
|
|
|
|
&& (OnePointColliderObject() && OnePointColliderObject().GetComponent<CloneableEnums>())
|
|
|
|
&& (OnePointColliderObject() && OnePointColliderObject().GetComponent<RawImage>())
|
|
|
|
)
|
|
|
|
{
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mouseScroll = mouseScroll;
|
|
|
|
|
|
|
|
arg.distance = fireDeployCameraManager.distance;
|
|
|
|
|
|
|
|
FireDeployMiddleMouseScrollCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
|
|
|
|
mouseScrollIsZero = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 点击对象
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>点击对象</returns>
|
|
|
|
public GameObject OnePointColliderObject()
|
|
|
|
{
|
|
|
|
PointerEventData eventDataCurrentPosition = new PointerEventData(EventSystem.current);
|
|
|
|
eventDataCurrentPosition.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
|
|
|
|
|
|
|
|
List<RaycastResult> results = new List<RaycastResult>();
|
|
|
|
EventSystem.current.RaycastAll(eventDataCurrentPosition, results);
|
|
|
|
|
|
|
|
if (results.Count > 0)
|
|
|
|
{
|
|
|
|
return results[0].gameObject;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 相机旋转的输入操作处理
|
|
|
|
/// </summary>
|
|
|
|
private void CameraRotationInputHandle()
|
|
|
|
{
|
|
|
|
if (!EventSystem.current.IsPointerOverGameObject() && Input.GetButtonDown("Fire2"))
|
|
|
|
{
|
|
|
|
//preMousePos = Input.mousePosition;
|
|
|
|
rotateStart = true;
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mouseX = mouseX;
|
|
|
|
arg.mouseY = mouseY;
|
|
|
|
arg.rotateStart = rotateStart;
|
|
|
|
|
|
|
|
//旋转开始
|
|
|
|
RotateEnterCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButton("Fire2"))
|
|
|
|
{
|
|
|
|
//curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
mouseX = Input.GetAxis("Mouse X");
|
|
|
|
mouseY = Input.GetAxis("Mouse Y");
|
|
|
|
|
|
|
|
//var thresholdValue = Vector3.Distance(preMousePos, curMousePos);//旋转开始阈值为2两个像素单位长度
|
|
|
|
|
|
|
|
if (rotateStart)
|
|
|
|
{
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mouseX = mouseX;
|
|
|
|
arg.mouseY = mouseY;
|
|
|
|
|
|
|
|
arg.rotateStart = rotateStart;
|
|
|
|
|
|
|
|
if (mouseX == 0 && mouseY == 0)
|
|
|
|
{//控制右键按下状态但没有移动鼠标,不分发指令,避免历史记录记录很多无用指令
|
|
|
|
|
|
|
|
if (!flag)
|
|
|
|
{
|
|
|
|
RotatingCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
flag = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flag = false;
|
|
|
|
}
|
|
|
|
//旋转中
|
|
|
|
RotatingCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire2"))
|
|
|
|
{
|
|
|
|
if (rotateStart)
|
|
|
|
{
|
|
|
|
mouseX = Input.GetAxis("Mouse X");
|
|
|
|
mouseY = Input.GetAxis("Mouse Y");
|
|
|
|
|
|
|
|
rotateStart = false;
|
|
|
|
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mouseX = mouseX;
|
|
|
|
arg.mouseY = mouseY;
|
|
|
|
|
|
|
|
arg.rotateStart = rotateStart;
|
|
|
|
|
|
|
|
arg.x = cameraManager.x;
|
|
|
|
arg.y = cameraManager.y;
|
|
|
|
|
|
|
|
//旋转结束
|
|
|
|
RotateExitCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 相机横向移动的输入操作处理
|
|
|
|
/// </summary>
|
|
|
|
///
|
|
|
|
private void CameraHorizontalMoveInputHandle()
|
|
|
|
{
|
|
|
|
if (isDargUI) return;//防止跟UI拖拽冲突
|
|
|
|
|
|
|
|
//区分相机(场景)横向拖动与游戏对象的拖动
|
|
|
|
//if (isDragEditorMode)
|
|
|
|
//{
|
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//区分相机(场景)横向拖动与框选操作
|
|
|
|
if (isRectSelect)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!EventSystem.current.IsPointerOverGameObject() && Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
//preMousePos = Input.mousePosition;
|
|
|
|
notDragUI = true;
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
|
|
var rayCast = getRayCastAll(ray);
|
|
|
|
if (rayCast)
|
|
|
|
{
|
|
|
|
hitObjToDragCamera = hit.transform.gameObject;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hitObjToDragCamera = null;
|
|
|
|
}
|
|
|
|
if (hitObjToDragCamera != null && hitObjToDragCamera == SelectedObjs.selectedObj)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//if (hitObjToDragCamera)
|
|
|
|
//{
|
|
|
|
//var thresholdValue = Vector3.Distance(preMousePos, curMousePos);//拖动开始阈值为2个像素单位长度
|
|
|
|
|
|
|
|
if (!CamdragStart)
|
|
|
|
{
|
|
|
|
CamdragStart = true;
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mousePosition = Input.mousePosition;
|
|
|
|
//拖拽开始
|
|
|
|
CameraDragEnterCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
|
|
|
|
isCameraDrag = true;
|
|
|
|
//Debug.Log("相机拖动开始");
|
|
|
|
}
|
|
|
|
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButton("Fire1") && notDragUI)
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
mouseX = Input.GetAxis("Mouse X");
|
|
|
|
mouseY = Input.GetAxis("Mouse Y");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (hitObjToDragCamera)
|
|
|
|
//{
|
|
|
|
if (CamdragStart)
|
|
|
|
{
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mousePosition = Input.mousePosition;
|
|
|
|
arg.dragStart = CamdragStart;
|
|
|
|
|
|
|
|
if (mouseX == 0 && mouseY == 0)
|
|
|
|
{//控制中键按下状态但没有移动鼠标,不分发指令
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//Debug.Log("相机拖动中...");
|
|
|
|
//拖拽中
|
|
|
|
CameraDragingCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
// if (hitObjToDragCamera)
|
|
|
|
// {
|
|
|
|
if (CamdragStart)
|
|
|
|
{
|
|
|
|
CamdragStart = false;
|
|
|
|
notDragUI = false;
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mousePosition = Vector3.zero;
|
|
|
|
arg.dragStart = CamdragStart;
|
|
|
|
//Debug.Log("相机拖动结束");
|
|
|
|
//拖拽结束
|
|
|
|
CameraDragExitCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
isCameraDrag = false;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 作战部署顶视图相机横向移动的输入操作处理
|
|
|
|
/// </summary>
|
|
|
|
///
|
|
|
|
private void FireDeployCameraHMoveInputHandle()
|
|
|
|
{
|
|
|
|
if (isDargUI) return;//防止跟UI拖拽冲突
|
|
|
|
|
|
|
|
//区分相机(场景)横向拖动与框选操作
|
|
|
|
if (isRectSelect)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EventSystem.current.IsPointerOverGameObject()
|
|
|
|
&& (OnePointColliderObject() && OnePointColliderObject().GetComponent<CloneableEnums>())
|
|
|
|
&& (OnePointColliderObject() && OnePointColliderObject().GetComponent<RawImage>())
|
|
|
|
&& Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
notDragUI = true;
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
|
|
var rayCast = getRayCastAll(ray);
|
|
|
|
if (rayCast)
|
|
|
|
{
|
|
|
|
hitObjToDragCamera = hit.transform.gameObject;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hitObjToDragCamera = null;
|
|
|
|
}
|
|
|
|
if (hitObjToDragCamera != null && hitObjToDragCamera == SelectedObjs.selectedObj)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!FireDeployCmdragStart)
|
|
|
|
{
|
|
|
|
FireDeployCmdragStart = true;
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mousePosition = Input.mousePosition;
|
|
|
|
//拖拽开始
|
|
|
|
FireDeployCameraDragEnterCmd.Instance.Execute(gameObjID, arg);
|
|
|
|
|
|
|
|
isCameraDrag = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButton("Fire1") && notDragUI)
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
mouseX = Input.GetAxis("Mouse X");
|
|
|
|
mouseY = Input.GetAxis("Mouse Y");
|
|
|
|
|
|
|
|
if (FireDeployCmdragStart)
|
|
|
|
{
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mousePosition = Input.mousePosition;
|
|
|
|
arg.dragStart = FireDeployCmdragStart;
|
|
|
|
|
|
|
|
if (mouseX == 0 && mouseY == 0)
|
|
|
|
{//控制中键按下状态但没有移动鼠标,不分发指令
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//拖拽中
|
|
|
|
FireDeployCameraDragingCmd.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
if (FireDeployCmdragStart)
|
|
|
|
{
|
|
|
|
FireDeployCmdragStart = false;
|
|
|
|
notDragUI = false;
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.mousePosition = Vector3.zero;
|
|
|
|
arg.dragStart = FireDeployCmdragStart;
|
|
|
|
//Debug.Log("相机拖动结束");
|
|
|
|
//拖拽结束
|
|
|
|
FireDeployCameraDragExitCmd.Instance.Execute(gameObjID, arg);
|
|
|
|
isCameraDrag = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 相机竖向移动的输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void CameraVerticalMoveInputHandle()
|
|
|
|
{
|
|
|
|
if (isDargUI) return;//防止跟UI拖拽冲突
|
|
|
|
if (Input.GetButtonDown("VerticalDU"))
|
|
|
|
{
|
|
|
|
notDragUI = true;
|
|
|
|
}
|
|
|
|
if (Input.GetButton("VerticalDU") && notDragUI)
|
|
|
|
{
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.keyX = Input.GetAxis("VerticalDU");
|
|
|
|
arg.targetMoveing = true;
|
|
|
|
|
|
|
|
if (arg.keyX < 0)
|
|
|
|
{
|
|
|
|
if (target.position.y > initialTargetPosY)
|
|
|
|
{
|
|
|
|
//控制摄像头跟随Target垂直移动
|
|
|
|
CameraVerticalMoveCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg.keyX > 0)
|
|
|
|
{
|
|
|
|
if (target.position.y < yMax)
|
|
|
|
{
|
|
|
|
//控制摄像头跟随Target垂直移动
|
|
|
|
CameraVerticalMoveCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("VerticalDU"))
|
|
|
|
{
|
|
|
|
notDragUI = false;
|
|
|
|
var arg = new CameraCmdArgs();
|
|
|
|
arg.keyX = Input.GetAxis("VerticalDU");
|
|
|
|
arg.targetMoveing = false;
|
|
|
|
|
|
|
|
if (arg.keyX < 0)
|
|
|
|
{
|
|
|
|
if (target.position.y >= initialTargetPosY)
|
|
|
|
{
|
|
|
|
//控制摄像头跟随Target垂直移动
|
|
|
|
CameraVerticalMoveCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg.keyX > 0)
|
|
|
|
{
|
|
|
|
if (target.position.y <= yMax)
|
|
|
|
{
|
|
|
|
//控制摄像头跟随Target垂直移动
|
|
|
|
CameraVerticalMoveCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 取消克隆按钮选中的输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void CancelCloneBtnSelected()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire2"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire2"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:右键单击取消克隆按钮的选中操作与右键旋转的冲突
|
|
|
|
{
|
|
|
|
var arg = new CloneCmdArgs();
|
|
|
|
arg.selected = false;
|
|
|
|
|
|
|
|
if (cloneObjType != CloneObjType.None)
|
|
|
|
{
|
|
|
|
CancelCloneBtnSelectedCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 取消游戏对象的选中 的输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void CancelObjSelected()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonUp("Cancel"))
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedObj || SelectedObjs.selectedCharacters.Count != 0)
|
|
|
|
{
|
|
|
|
CancelSelectedCommand.Instance.Execute(gameObjID, new CmdArgs());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 单选输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void RadioSelect()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击选中操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
if (SelectedObjs.gameObjs.Contains(hit.transform.gameObject))
|
|
|
|
{
|
|
|
|
if (hit.transform.gameObject!=null&& hit.transform.GetComponent<BaseGameObjInfo>()
|
|
|
|
&& SelectedObjs.selectedObj != hit.transform.gameObject)
|
|
|
|
{
|
|
|
|
if (CurrentUserInfo.generalCommanding &&
|
|
|
|
GameObject.Find("Main Camera").GetComponent<CameraManager>().viewType == CameraViewState.ThirdPersonView)
|
|
|
|
{//处理总,支,大第三人称情况下,选中安全区等的操作时,取消角色的选中来解决选中同时角色寻路过去的冲突
|
|
|
|
//在取消安全区等的选中时,回复角色的选中,以便能寻路
|
|
|
|
SelectedObjs.selectedRolePlay = null;
|
|
|
|
//除消防员外,其他可单选物体的单选处理
|
|
|
|
RadioSelectedCommand.Instance.Execute(hit.transform.GetComponent<BaseGameObjInfo>().GameObjID, new CmdArgs());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//除消防员外,其他可单选物体的单选处理
|
|
|
|
RadioSelectedCommand.Instance.Execute(hit.transform.GetComponent<BaseGameObjInfo>().GameObjID, new CmdArgs());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hit.transform.gameObject!=null&&SelectedObjs.characters.Contains(hit.transform.gameObject))
|
|
|
|
{
|
|
|
|
if (!SelectedObjs.selectedCharacters.Contains(hit.transform.gameObject))
|
|
|
|
{
|
|
|
|
//消防员的单选处理
|
|
|
|
RadioSelectedCommand.Instance.Execute(hit.transform.GetComponent<BaseGameObjInfo>().GameObjID, new CmdArgs());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 框选画框输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void DrawSelectionRectangle()
|
|
|
|
{
|
|
|
|
//区分框选与游戏对象的拖动
|
|
|
|
//if (isDragEditorMode)
|
|
|
|
//{
|
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//区分框选与相机的拖动
|
|
|
|
if (isCameraDrag)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isRectSelect && Input.GetButton("LeftShift"))
|
|
|
|
{
|
|
|
|
isRectSelect = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isRectSelect && Input.GetButtonUp("LeftShift"))
|
|
|
|
{
|
|
|
|
isRectSelect = false;
|
|
|
|
|
|
|
|
if (drawRectStart)
|
|
|
|
{
|
|
|
|
drawRectStart = false;
|
|
|
|
|
|
|
|
var arg = new DrawRectSelectRangeCmdArgs();
|
|
|
|
arg.mousePosition = Vector3.zero;
|
|
|
|
arg.drawRectStart = drawRectStart;
|
|
|
|
|
|
|
|
//拖拽结束
|
|
|
|
RectDrawExitCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isRectSelect)
|
|
|
|
{
|
|
|
|
if (!EventSystem.current.IsPointerOverGameObject() && Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
//preMousePos = Input.mousePosition;
|
|
|
|
drawRectStart = true;
|
|
|
|
var arg = new DrawRectSelectRangeCmdArgs();
|
|
|
|
arg.mousePosition = Input.mousePosition;
|
|
|
|
|
|
|
|
//框选画框开始
|
|
|
|
RectDrawEnterCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButton("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
mouseX = Input.GetAxis("Mouse X");
|
|
|
|
mouseY = Input.GetAxis("Mouse Y");
|
|
|
|
|
|
|
|
var arg = new DrawRectSelectRangeCmdArgs();
|
|
|
|
|
|
|
|
//var thresholdValue = Vector3.Distance(preMousePos, curMousePos);//框选画框开始阈值为2个像素单位长度
|
|
|
|
|
|
|
|
if (drawRectStart)
|
|
|
|
{
|
|
|
|
arg.mousePosition = Input.mousePosition;
|
|
|
|
arg.drawRectStart = drawRectStart;
|
|
|
|
|
|
|
|
if (mouseX == 0 && mouseY == 0)
|
|
|
|
{//控制左键按下状态但没有移动鼠标,不分发指令
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//框选画框中
|
|
|
|
RectDrawingCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
if (drawRectStart)
|
|
|
|
{
|
|
|
|
drawRectStart = false;
|
|
|
|
|
|
|
|
var arg = new DrawRectSelectRangeCmdArgs();
|
|
|
|
arg.mousePosition = Vector3.zero;
|
|
|
|
arg.drawRectStart = drawRectStart;
|
|
|
|
|
|
|
|
//拖拽结束
|
|
|
|
RectDrawExitCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
|
|
|
|
isRectSelect = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 克隆的输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void CloneObj()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击克隆操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
var arg = new CloneCmdArgs();
|
|
|
|
|
|
|
|
arg.cloneObjType = cloneObjType;
|
|
|
|
arg.ForcibleType = ForcibleType;
|
|
|
|
arg.hitPos = hit.point;
|
|
|
|
arg.mousePosition = Input.mousePosition;
|
|
|
|
if (hit.transform.GetComponent<BaseGameObjInfo>())
|
|
|
|
{
|
|
|
|
arg.gameObjID = hit.transform.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
}
|
|
|
|
CloneCommand.Instance.Execute(EntitiesManager.Instance.CreateObjID(CurrentUserInfo.mySelf.Id), arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 作战部署消防力量,公用工具,私有分类工具 克隆的输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void CloneFireDeployObj()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击克隆操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
var arg = new CloneCmdArgs();
|
|
|
|
|
|
|
|
arg.cloneObjType = cloneObjType;
|
|
|
|
arg.hitPos = hit.point;
|
|
|
|
arg.mousePosition = Input.mousePosition;
|
|
|
|
arg.org = org;
|
|
|
|
arg.fireCarEngine = fireCarEngine;
|
|
|
|
arg.color = color;
|
|
|
|
arg.fireDeployPrivateToolType = fireDeployPrivateToolType;
|
|
|
|
if (hit.transform.GetComponent<BaseGameObjInfo>())
|
|
|
|
{
|
|
|
|
arg.gameObjID = hit.transform.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
}
|
|
|
|
CloneCommand.Instance.Execute(EntitiesManager.Instance.CreateObjID(CurrentUserInfo.mySelf.Id), arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 寻路输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void PathFinding()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击寻路操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedCharacters.Count != 0 //消防员
|
|
|
|
|| (SelectedObjs.selectedObj != null && SelectedObjs.selectedObj.GetComponent<NavMeshAgent>())// 车
|
|
|
|
|| (SelectedObjs.selectedRolePlay != null && SelectedObjs.selectedRolePlay.GetComponent<NavMeshAgent>()) //角色
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (hit.transform.GetComponent<BaseGameObjInfo>() && hit.transform.GetComponent<PathFindingClick>())
|
|
|
|
{
|
|
|
|
var arg = new PathFindingCmdArgs();
|
|
|
|
arg.hitPoint = hit.point;
|
|
|
|
arg.gameObjID = hit.transform.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
PathFindingCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 对象删除输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void ObjDelete()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonUp("Delete"))
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedObj && SelectedObjs.selectedObj.GetComponent<ObjDelete>())
|
|
|
|
{
|
|
|
|
DeleteCommand.Instance.Execute(gameObjID, new CmdArgs());
|
|
|
|
}
|
|
|
|
if (SelectedObjs.selectedCharacters.Count > 0)
|
|
|
|
{
|
|
|
|
DeleteCommand.Instance.Execute(gameObjID, new CmdArgs());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 作战部署对象删除输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void FireDeployObjDelete()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonUp("Delete"))
|
|
|
|
{
|
|
|
|
if (selectedFireDeployObjId != -1)
|
|
|
|
{
|
|
|
|
var arg = new FireDeployObjDeleteCmdArgs();
|
|
|
|
arg.gameObjId = selectedFireDeployObjId;
|
|
|
|
|
|
|
|
DeleteCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 对象旋转输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void ObjRotate()
|
|
|
|
{
|
|
|
|
//if (isRotateEditorMode)
|
|
|
|
//{
|
|
|
|
if ((SelectedObjs.selectedObj && SelectedObjs.selectedObj.GetComponent<ObjRotate>()) || SelectedObjs.selectedCharacters.Count != 0)
|
|
|
|
{
|
|
|
|
if (Input.GetButton("Q"))
|
|
|
|
{
|
|
|
|
LeftRotateCommand.Instance.Execute(gameObjID, new CmdArgs());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButton("E"))
|
|
|
|
{
|
|
|
|
RightRotateCommand.Instance.Execute(gameObjID, new CmdArgs());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 对象拖动输入处理
|
|
|
|
/// </summary>
|
|
|
|
private void ObjDrag()
|
|
|
|
{
|
|
|
|
//if (!isDragEditorMode)
|
|
|
|
//{
|
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
if (isRectSelect)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!EventSystem.current.IsPointerOverGameObject() && Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
//preMousePos = Input.mousePosition;
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
|
|
var rayCast = getRayCastAll(ray);
|
|
|
|
if (rayCast)
|
|
|
|
{
|
|
|
|
hitObjToDrag = hit.transform.gameObject;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hitObjToDrag = null;
|
|
|
|
}
|
|
|
|
//var msg = hitObjToDrag.GetComponent<BaseGameObjInfo>();
|
|
|
|
//var gameObjID = SelectedObjs.selectedObj.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
if (hitObjToDrag != SelectedObjs.selectedObj)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (hitObjToDrag && hitObjToDrag.GetComponent<ObjDrag>())
|
|
|
|
{
|
|
|
|
//var thresholdValue = Vector3.Distance(preMousePos, curMousePos);//拖动开始阈值为2个像素单位长度
|
|
|
|
|
|
|
|
if (!dragStart)
|
|
|
|
{
|
|
|
|
dragStart = true;
|
|
|
|
var arg = new ObjDragCmdArgs();
|
|
|
|
arg.mousePosition = Input.mousePosition;
|
|
|
|
//Debug.Log("物体拖动开始");
|
|
|
|
//拖拽开始
|
|
|
|
ObjDragEnterCommand.Instance.Execute(hitObjToDrag.GetComponent<BaseGameObjInfo>().GameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButton("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
mouseX = Input.GetAxis("Mouse X");
|
|
|
|
mouseY = Input.GetAxis("Mouse Y");
|
|
|
|
|
|
|
|
if (hitObjToDrag && hitObjToDrag.GetComponent<ObjDrag>())
|
|
|
|
{
|
|
|
|
if (dragStart)
|
|
|
|
{
|
|
|
|
var arg = new ObjDragCmdArgs();
|
|
|
|
arg.mousePosition = Input.mousePosition;
|
|
|
|
arg.dragStart = dragStart;
|
|
|
|
|
|
|
|
if (mouseX == 0 && mouseY == 0)
|
|
|
|
{//控制中键按下状态但没有移动鼠标,不分发指令
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//Debug.Log("物体拖动中...");
|
|
|
|
//拖拽中
|
|
|
|
ObjDragingCommand.Instance.Execute(hitObjToDrag.GetComponent<BaseGameObjInfo>().GameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
if (hitObjToDrag && hitObjToDrag.GetComponent<ObjDrag>())
|
|
|
|
{
|
|
|
|
if (dragStart)
|
|
|
|
{
|
|
|
|
dragStart = false;
|
|
|
|
var arg = new ObjDragCmdArgs();
|
|
|
|
arg.mousePosition = Vector3.zero;
|
|
|
|
arg.dragStart = dragStart;
|
|
|
|
|
|
|
|
//Debug.Log("物体拖动结束");
|
|
|
|
//拖拽结束
|
|
|
|
ObjDragExitcommand.Instance.Execute(hitObjToDrag.GetComponent<BaseGameObjInfo>().GameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 移动技能
|
|
|
|
/// </summary>
|
|
|
|
private void MoveMan()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击寻路操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedCharacters.Count != 0)
|
|
|
|
{
|
|
|
|
var msg = SelectedObjs.selectedCharacters[0].GetComponent<FireManControl>();
|
|
|
|
if (msg && msg.workType == FireManSkills.Move)
|
|
|
|
{
|
|
|
|
var hitMsg = hit.transform.GetComponent<BaseGameObjInfo>();
|
|
|
|
if (hitMsg && (hitMsg.gameObjType == CloneObjType.wounded || hitMsg.gameObjType == CloneObjType.trappedPerson))
|
|
|
|
{
|
|
|
|
var arg = new ForcibleEntryCmdArgs();
|
|
|
|
arg.currentCursorPos = Input.mousePosition;
|
|
|
|
arg.fireManID = SelectedObjs.selectedCharacters[0].GetComponent<BaseGameObjInfo>().gameObjID;//当前消防员ID
|
|
|
|
arg.gameObjID = hit.transform.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
MoveManCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 安抚
|
|
|
|
/// </summary>
|
|
|
|
private void PacifyMan()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击寻路操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedCharacters.Count != 0)
|
|
|
|
{
|
|
|
|
var msg = SelectedObjs.selectedCharacters[0].GetComponent<FireManControl>();
|
|
|
|
if (msg && msg.workType == FireManSkills.Pacify)
|
|
|
|
{
|
|
|
|
var hitMsg = hit.transform.GetComponent<BaseGameObjInfo>();
|
|
|
|
if (hitMsg && (hitMsg.gameObjType == CloneObjType.wounded || hitMsg.gameObjType == CloneObjType.trappedPerson))
|
|
|
|
{
|
|
|
|
var arg = new ForcibleEntryCmdArgs();
|
|
|
|
arg.currentCursorPos = Input.mousePosition;
|
|
|
|
arg.fireManID = SelectedObjs.selectedCharacters[0].GetComponent<BaseGameObjInfo>().gameObjID;//当前消防员ID
|
|
|
|
arg.gameObjID = hit.transform.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
PacifyManCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 急救
|
|
|
|
/// </summary>
|
|
|
|
private void FristAidMan()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击寻路操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedCharacters.Count != 0)
|
|
|
|
{
|
|
|
|
var msg = SelectedObjs.selectedCharacters[0].GetComponent<FireManControl>();
|
|
|
|
if (msg && msg.workType == FireManSkills.FristAid)
|
|
|
|
{
|
|
|
|
var hitMsg = hit.transform.GetComponent<BaseGameObjInfo>();
|
|
|
|
if (hitMsg && (hitMsg.gameObjType == CloneObjType.wounded || hitMsg.gameObjType == CloneObjType.trappedPerson))
|
|
|
|
{
|
|
|
|
var arg = new ForcibleEntryCmdArgs();
|
|
|
|
arg.currentCursorPos = Input.mousePosition;
|
|
|
|
arg.fireManID = SelectedObjs.selectedCharacters[0].GetComponent<BaseGameObjInfo>().gameObjID;//当前消防员ID
|
|
|
|
arg.gameObjID = hit.transform.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
FristAidManCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 引导被困人员
|
|
|
|
/// </summary>
|
|
|
|
private void GuidanceMan()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击寻路操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedCharacters.Count != 0)
|
|
|
|
{
|
|
|
|
var msg = SelectedObjs.selectedCharacters[0].GetComponent<FireManControl>();
|
|
|
|
if (msg && msg.workType == FireManSkills.Guidance)
|
|
|
|
{
|
|
|
|
var hitMsg = hit.transform.GetComponent<BaseGameObjInfo>();
|
|
|
|
if (hitMsg && (hitMsg.gameObjType == CloneObjType.wounded || hitMsg.gameObjType == CloneObjType.trappedPerson))
|
|
|
|
{
|
|
|
|
var arg = new ForcibleEntryCmdArgs();
|
|
|
|
arg.currentCursorPos = Input.mousePosition;
|
|
|
|
arg.fireManID = SelectedObjs.selectedCharacters[0].GetComponent<BaseGameObjInfo>().gameObjID;//当前消防员ID
|
|
|
|
arg.gameObjID = hit.transform.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
GuidanceManCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SetGuidancePoint()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击寻路操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
|
|
|
|
if (SelectedObjs.selectedCharacters.Count != 0
|
|
|
|
|| (SelectedObjs.selectedObj != null && SelectedObjs.selectedObj.GetComponent<NavMeshAgent>()))
|
|
|
|
{
|
|
|
|
if (hit.transform.GetComponent<BaseGameObjInfo>() && hit.transform.GetComponent<PathFindingClick>())
|
|
|
|
{
|
|
|
|
Ray ray= Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
|
|
RaycastHit hitpoint;
|
|
|
|
if (Physics.Raycast(ray, out hitpoint))
|
|
|
|
{//点击的寻路点在可寻路网格内,加进集合
|
|
|
|
if (NavMesh.SamplePosition(hitpoint.point, out nhit, 0.5f, filter))
|
|
|
|
{
|
|
|
|
if (Vector3.Distance(hitpoint.point, nhit.position) > 0.2f)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!GuidanceList.Contains(hit.point))
|
|
|
|
{
|
|
|
|
GuidanceList.Add(hit.point);
|
|
|
|
GameObject hitpart = Instantiate(pointer,hit.point,Quaternion.identity);
|
|
|
|
hitpart.transform.parent = p_Hitpoint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 设置侦察技能侦察点位
|
|
|
|
/// </summary>
|
|
|
|
private void SetTagSearchRoomPoint()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击设置侦察点位操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
|
|
|
|
if (SelectedObjs.selectedCharacters.Count != 0
|
|
|
|
|| (SelectedObjs.selectedObj != null && SelectedObjs.selectedObj.GetComponent<NavMeshAgent>()))
|
|
|
|
{
|
|
|
|
if (hit.transform.GetComponent<BaseGameObjInfo>() && hit.transform.GetComponent<PathFindingClick>())
|
|
|
|
{
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
|
|
RaycastHit hitpoint;
|
|
|
|
if (Physics.Raycast(ray, out hitpoint))
|
|
|
|
{//点击的寻路点在可寻路网格内,加进集合
|
|
|
|
if (NavMesh.SamplePosition(hitpoint.point, out nhit, 0.5f, filter))
|
|
|
|
{
|
|
|
|
if (Vector3.Distance(hitpoint.point, nhit.position) <= 0.2f)
|
|
|
|
{
|
|
|
|
tagSearchRoomPoint = hit.point;
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("侦察点位设置成功", 1f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 拿起/收起管线
|
|
|
|
/// </summary>
|
|
|
|
private void TakeOrPickWaterHose()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击寻路操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedCharacters.Count != 0)
|
|
|
|
{
|
|
|
|
var msg = SelectedObjs.selectedCharacters[0].GetComponent<FireManControl>();
|
|
|
|
if (!hit.transform.GetComponent<FireManControl>())
|
|
|
|
{
|
|
|
|
if (msg.workType==FireManSkills.PackUpLine||msg.workType==FireManSkills.TakeUpWaterLine)
|
|
|
|
{
|
|
|
|
if (hit.transform.parent.GetComponent<ParentLayWaterHoseMsg>())
|
|
|
|
{
|
|
|
|
var hitMsg = hit.transform.parent.GetComponent<BaseGameObjInfo>();
|
|
|
|
if ((hitMsg.gameObjType == CloneObjType.OrdinaryHose))
|
|
|
|
{
|
|
|
|
if (hitMsg.GetComponent<ParentLayWaterHoseMsg>())
|
|
|
|
{
|
|
|
|
var arg = new PackOrTakeHoseCmdArgs();
|
|
|
|
arg.currentCursorPos = Input.mousePosition;
|
|
|
|
arg.HitPoint = hit.point;
|
|
|
|
arg.fireManID = SelectedObjs.selectedCharacters[0].GetComponent<BaseGameObjInfo>().gameObjID;//当前消防员ID
|
|
|
|
arg.gameObj = hit.transform.parent.gameObject;//GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
PackOrTackHoseCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 询问知情人
|
|
|
|
/// </summary>
|
|
|
|
private void AskPeople()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击寻路操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedCharacters.Count != 0)
|
|
|
|
{
|
|
|
|
var msg = SelectedObjs.selectedCharacters[0].GetComponent<FireManControl>();
|
|
|
|
if (msg && msg.workType == FireManSkills.AskPeople)
|
|
|
|
{
|
|
|
|
var hitMsg = hit.transform.GetComponent<BaseGameObjInfo>();
|
|
|
|
if (hitMsg && hitMsg.gameObjType == CloneObjType.insider)
|
|
|
|
{
|
|
|
|
var arg = new ForcibleEntryCmdArgs();
|
|
|
|
arg.currentCursorPos = Input.mousePosition;
|
|
|
|
arg.fireManID = SelectedObjs.selectedCharacters[0].GetComponent<BaseGameObjInfo>().gameObjID;//当前消防员ID
|
|
|
|
arg.gameObjID = hit.transform.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
AskPeopleCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 清理危险品
|
|
|
|
/// </summary>
|
|
|
|
private void ClearDangerous()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击寻路操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedCharacters.Count != 0)
|
|
|
|
{
|
|
|
|
var msg = SelectedObjs.selectedCharacters[0].GetComponent<FireManControl>();
|
|
|
|
if (msg && msg.workType == FireManSkills.ClearDangerous)
|
|
|
|
{
|
|
|
|
var hitMsg = hit.transform.GetComponent<BaseGameObjInfo>();
|
|
|
|
if (hitMsg && hitMsg.gameObjType == CloneObjType.dangerousGoods)
|
|
|
|
{
|
|
|
|
var arg = new ForcibleEntryCmdArgs();
|
|
|
|
arg.currentCursorPos = Input.mousePosition;
|
|
|
|
arg.fireManID = SelectedObjs.selectedCharacters[0].GetComponent<BaseGameObjInfo>().gameObjID;//当前消防员ID
|
|
|
|
arg.gameObjID = hit.transform.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
ClearDangerousCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void ForcibleEntry()
|
|
|
|
{
|
|
|
|
if (Input.GetButtonDown("Fire1"))
|
|
|
|
{
|
|
|
|
preMousePos = Input.mousePosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetButtonUp("Fire1"))
|
|
|
|
{
|
|
|
|
curMousePos = Input.mousePosition;
|
|
|
|
|
|
|
|
if (Vector3.Distance(preMousePos, curMousePos) < 2)//解决:左键单击寻路操作与左键框选的冲突
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedCharacters.Count != 0)
|
|
|
|
{
|
|
|
|
var msg = SelectedObjs.selectedCharacters[0].GetComponent<FireManControl>();
|
|
|
|
if (msg && msg.workType == FireManSkills.ForcibleEntry)
|
|
|
|
{
|
|
|
|
var hitMsg = hit.transform.GetComponent<BaseGameObjInfo>();
|
|
|
|
if (hitMsg && hitMsg.gameObjType == CloneObjType.forcibleEntryPoint)
|
|
|
|
{
|
|
|
|
var arg = new ForcibleEntryCmdArgs();
|
|
|
|
arg.currentCursorPos = Input.mousePosition;
|
|
|
|
arg.fireManID = SelectedObjs.selectedCharacters[0].GetComponent<BaseGameObjInfo>().gameObjID;//当前消防员ID
|
|
|
|
arg.gameObjID = hit.transform.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
ForcibleEntryCommand.Instance.Execute(gameObjID, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void SetFireLiquidLevelScale()
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedObj && SelectedObjs.selectedObj.GetComponent<FireLiquidLevelCtrl>())
|
|
|
|
{
|
|
|
|
float firescale = SelectedObjs.selectedObj.GetComponent<FireLiquidLevelCtrl>().fireScale;
|
|
|
|
if (Input.GetButton("Plus"))
|
|
|
|
{
|
|
|
|
firescale = Mathf.Clamp(firescale+Time.deltaTime * scaleSpeed,minScale,maxScale);
|
|
|
|
}
|
|
|
|
if (Input.GetButton("Minus"))
|
|
|
|
{
|
|
|
|
firescale = Mathf.Clamp(firescale -Time.deltaTime * scaleSpeed, minScale, maxScale);
|
|
|
|
}
|
|
|
|
var arg = new FireLiquidLevelCmdArgs();
|
|
|
|
arg.FireScale = firescale;
|
|
|
|
arg.SelectgameObjID = SelectedObjs.selectedObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
FireLiquidLevelScaleCommand.Instance.Execute(gameObjID,arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|