using UnityEngine;
using System.Collections;
using System;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using AX.MessageSystem;
using AX.TrackRecord;
using System.Collections.Generic;
///
/// 1、鼠标通过射线点击对应的UI,实现实例化工具栏物体
/// 2、挂载在Canvas下DomeView下ToolButtonPicture;
/// 3、核心方法:GetObj();
///
public class InstantiationTool : MonoBehaviour
{
public static InstantiationTool Instance;
//[HideInInspector]
public Vector3 placementPos2;//第二碰撞点
//[HideInInspector]
public Vector3 placementPos;//第一碰撞点
[HideInInspector]
public Vector3 Pos1_late = new Vector3(0, 0, 0);//第一碰撞点原来的位置
[HideInInspector]
public Vector3 Pos2_late = new Vector3(0, 0, 0);//第二碰撞点原来的位置
[HideInInspector]
public bool Pos2Controller = false;
GameObject prlineObj;
GameObject pPaiYanGuanObj;
private LayerMask ground_layerMask = -1;
private LayerMask Tr_layerMask = -1;
public string ToolName;
private RaycastHit hit;//射线
DateTime t1, t2;
private bool kongzhi = false;
private bool lol = false;
private int delta_millisecond = 400;
//public Toggle JGToggle; //进攻复选框
//public Toggle RSDToggle; //软水带复选框
//public Toggle CTToggle; //撤退复选框
[HideInInspector]
public bool lineFlag = false;
[HideInInspector]
public bool lineFiagchetui = false;
[HideInInspector]
public bool JG;
//public GameObject nullobject;
private GameObject ToolGrid;
private BaseClass JG_CT;
private BaseClass RSD;
private GameObject CTuiOBj;
private GameObject RSDObj;
private GameObject SSRSDObj;
private int RSDIndex = 0;
private GameObject PaiYanGuanObj;
private int PaiYanGuanIndex = 0;
private bool chetuilol = false;
private bool chetuikongzhi = false;
private GameObject JGongOBj;
private GameObject FGeOBJ;
private GameObject DJieOBJ;
[HideInInspector]
public bool CT;
[HideInInspector]
public bool SD_one;
[HideInInspector]
public bool SD_two;
[HideInInspector]
public bool shuidai_one = false;
[HideInInspector]
public bool shuidai_two = false;
private LayerMask RLinelayer = -1;
[HideInInspector]
public bool isRLineSelect = false;
[HideInInspector]
public LayerMask indoor_layerMask = -1;//室内层
public List LineSourceList = new List();
[HideInInspector]
public List LineRecrdList = new List();
GameObject FirstGame;
GameObject SecondGame;
private GameObject LineRenderGameObject;
private GameObject LineGameObject;
//[HideInInspector]
//public bool isToolSelect = false;
private void SetPlacePos(Vector3 hitPoint, out Vector3 placePos, RaycastHit hit)
{
//LineRecrdList.Add(hit.transform.gameObject);
if (hit.transform.gameObject.name.IndexOf("xiaofangyuan") >= 0)
{
placePos = hit.transform.position;
//LineSourceList.Add(hit.transform.gameObject);
placePos.y += 0.0f;//0.8f
}
else if (hit.transform.gameObject.name.IndexOf("xiaofangche") >= 0
|| hit.transform.gameObject.name.IndexOf("mb") >= 0)
{
placePos = hit.transform.gameObject.transform.position;
placePos = new Vector3(hit.transform.gameObject.transform.position.x, hit.transform.gameObject.transform.position.y + 0.5f, hit.point.z);
//if(hit.transform.gameObject)
//placePos = new Vector3
// (hit.transform.gameObject.transform.position.x,
// hit.transform.gameObject.transform.position.y,
// hit.transform.gameObject.transform.position.z);
//LineSourceList.Add(hit.transform.gameObject);
}
else
{
placePos = new Vector3(hit.point.x, hit.point.y + 0.3f, hit.point.z);
}
}
void Awake()
{
if (Instance == null)
{
Instance = this;
}
Tr_layerMask = 1 << 25 | 1 << 26;
RLinelayer = 1 << 25 | 1 << 26 | 1 << 27 | 1 << 30;
ground_layerMask = 1 << 25 | 1 << 26;
indoor_layerMask = 1 << 29 | 1 << 25 | 1 << 26;
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.SANDTABLE)
{
this.transform.Find("ScrollRect/ToolGrid/AnQuanShao").gameObject.SetActive(false);
}
#region
ToolGrid = GameObject.Find("DomeView/BroweMenu").transform.Find("ToolButtonPicture/ScrollRect/ToolGrid").gameObject;
MessageDispatcher.AddListener("ResettingButton", ResettingButton);
MessageDispatcher.AddListener("InstantiateButton", GetObj);
#endregion
}
void OnDestroy()
{
MessageDispatcher.RemoveListener("ResettingButton", ResettingButton);
MessageDispatcher.RemoveListener("InstantiateButton", GetObj);
WaterKnockoutTrap.waterIndex = 0;
StagingArea.stagingAreaIndex = 0;
AQS.aqsIndex = 0;
AttackArrow.arrowIndex = 0;
DuJieArrow.arrowIndex = 0;
SplitLine.SplitLineIndex = 0;
CommandPost.commandIndex = 0;
Ladder.ladderIndex = 0;
StagingArea.stagingAreaIndex = 0;
PoliceLine.lineIndex = 0;
BaseNameText.baseNameText = 0;
}
//重置方法
void ResettingButton(IMessage message)
{
foreach (Transform child in ToolGrid.transform)
{
if (child.gameObject.GetComponent