173 lines
4.8 KiB
C#
173 lines
4.8 KiB
C#
using AdamSync;
|
|
using Assets.Zion.Scripts.Adam;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Umawerse.FiniteStateMachines;
|
|
using UnityEngine;
|
|
using UnityTemplateProjects;
|
|
|
|
public class ToolsBootstrap : MonoSingleton<ToolsBootstrap>
|
|
{
|
|
private FiniteStateMachine _fsm;
|
|
public GameObject circlePointPrefab;
|
|
public GameObject linePointPrefab;
|
|
public GameObject ployPointPrefab;
|
|
public BackgroundLabel labelPrefab;
|
|
public Material solidLineMaterial;
|
|
public Material ployMaterial;
|
|
public TapGesture tapGesture;
|
|
|
|
public Camera mCamera;
|
|
public SimpleCameraController simpleCameraController;
|
|
public WRJManager wrjManager;
|
|
|
|
public GameObject buleInstruct;
|
|
public List<GameObject> instructs = new List<GameObject>();
|
|
|
|
public bool isDistance = true;
|
|
|
|
private void Awake()
|
|
{
|
|
_fsm = new FiniteStateMachine();
|
|
_fsm.AddState(new LineDrawingState(this));
|
|
_fsm.AddState(new CircleDrawingState(this));
|
|
_fsm.AddState(new PolygonDrawState(this));
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
recordPosition = mCamera.transform.position;
|
|
recordeulerAngles = mCamera.transform.eulerAngles;
|
|
}
|
|
|
|
public void SetCameraInfo(SyncPlayerTransform syncPlayer)
|
|
{
|
|
mCamera = syncPlayer.GetComponent<Camera>();
|
|
simpleCameraController = syncPlayer.GetComponent<SimpleCameraController>();
|
|
}
|
|
|
|
private Vector3 recordPosition = new Vector3();
|
|
private Vector3 recordeulerAngles = new Vector3();
|
|
|
|
/// <summary>
|
|
/// 1-3D 2-2D
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
public void SwitchSet2DMap(int state)
|
|
{
|
|
if (mCamera != null)
|
|
{
|
|
simpleCameraController.enabled = false;
|
|
if (state == 1)
|
|
{
|
|
buleInstruct.SetActive(false);
|
|
mCamera.transform.position = recordPosition;
|
|
mCamera.transform.eulerAngles = recordeulerAngles;
|
|
mCamera.orthographic = false;
|
|
simpleCameraController.enabled = true;
|
|
Switch2DModel(false);
|
|
UnmannedAerialVehicleUI.Instance.GetRouteSettings(false);
|
|
}
|
|
else if (state == 2)
|
|
{
|
|
//recordPosition = mCamera.transform.position;
|
|
//recordeulerAngles = mCamera.transform.eulerAngles;
|
|
buleInstruct.SetActive(true);
|
|
mCamera.transform.position = new Vector3(-480, 556f, 258f);
|
|
mCamera.transform.eulerAngles = new Vector3(90f, 0f, 0f);
|
|
mCamera.orthographic = true;
|
|
if (GlobalFlag.field_Char1=="学校")
|
|
{
|
|
mCamera.orthographicSize = 1000;
|
|
}
|
|
else if (GlobalFlag.field_Char1 == "山地")
|
|
{
|
|
mCamera.orthographicSize = 2500;
|
|
}
|
|
Switch2DModel(true);
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Switch2DModel(bool isActive)
|
|
{
|
|
if (instructs.Count == 0) return;
|
|
for (int i = 0; i < instructs.Count; i++)
|
|
{
|
|
if (instructs[i].gameObject)
|
|
instructs[i].gameObject.SetActive(isActive);
|
|
}
|
|
}
|
|
|
|
public void SetAttackTargetView()
|
|
{
|
|
if (mCamera != null)
|
|
{
|
|
simpleCameraController.enabled = false;
|
|
mCamera.transform.position = new Vector3(114.282f, 305.2f, -95.7f);
|
|
mCamera.transform.eulerAngles = new Vector3(45.8f, -13f, 0f);
|
|
mCamera.orthographic = false;
|
|
tapGesture.SetLayerMask(1 << 10);
|
|
|
|
wrjManager.wrjMenuSetPanel.gameObject.SetActive(false);
|
|
simpleCameraController.enabled = true;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
_fsm.Update();
|
|
}
|
|
|
|
public void SwitchState(int indexState)
|
|
{
|
|
switch (indexState)
|
|
{
|
|
case 0:
|
|
_fsm.SetState(StateName.none);
|
|
break;
|
|
case 1:
|
|
isDistance = true;
|
|
_fsm.SetState(StateName.line);
|
|
break;
|
|
case 2:
|
|
_fsm.SetState(StateName.polygon);
|
|
break;
|
|
case 3:
|
|
_fsm.SetState(StateName.circle);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void SetWRJWayPoint()
|
|
{
|
|
isDistance = false;
|
|
_fsm.SetState(StateName.line);
|
|
SwitchSet2DMap(2);
|
|
wrjManager.wrjMenuSetPanel.gameObject.SetActive(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始推演
|
|
/// </summary>
|
|
public void StartDeduction()
|
|
{
|
|
}
|
|
|
|
|
|
public void CloseMenu()
|
|
{
|
|
wrjManager.wrjMenuSetPanel.gameObject.SetActive(false);
|
|
}
|
|
|
|
private void OnApplicationQuit()
|
|
{
|
|
string _msg = "leaveroom ";
|
|
_ = AdamSync.SyncCreateRoom.SendMessageAsync(_msg);
|
|
}
|
|
}
|