157 lines
4.2 KiB
C#
157 lines
4.2 KiB
C#
using Assets.Zion.Scripts.Adam;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Umawerse.FiniteStateMachines;
|
|
using UnityEngine;
|
|
using UnityTemplateProjects;
|
|
|
|
public class ToolsBootstrap : MonoBehaviour
|
|
{
|
|
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));
|
|
//_fsm.SetState(StateName.line);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 1-3D 2-2D
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
public void SwitchSet2DMap(int state)
|
|
{
|
|
simpleCameraController.enabled = false;
|
|
if (state == 1)
|
|
{
|
|
buleInstruct.SetActive(false);
|
|
mCamera.transform.position = new Vector3(-118f, 163f, -409f);
|
|
mCamera.transform.eulerAngles = new Vector3(23f, 0f, 0f);
|
|
mCamera.orthographic = false;
|
|
simpleCameraController.enabled = true;
|
|
Switch2DModel(false);
|
|
}
|
|
else if (state == 2)
|
|
{
|
|
buleInstruct.SetActive(true);
|
|
mCamera.transform.position = new Vector3(0, 556f, -10f);
|
|
mCamera.transform.eulerAngles = new Vector3(90f, 0f, 0f);
|
|
mCamera.orthographic = true;
|
|
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()
|
|
{
|
|
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.currentWRJ.isAuto = false;
|
|
wrjManager.wrjMenuSetPanel.gameObject.SetActive(false);
|
|
simpleCameraController.enabled = true;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
_fsm.Update();
|
|
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
if (tapGesture.HitTest().collider != null)
|
|
{
|
|
if (tapGesture.HitTest().collider.gameObject.layer == 10)
|
|
{
|
|
|
|
wrjManager.currentWRJ.SetAttackTarget(tapGesture.HitTest().collider.gameObject.GetComponent<HuoPaoController>());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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.currentWRJ.isAuto = true;
|
|
wrjManager.wrjMenuSetPanel.gameObject.SetActive(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始推演
|
|
/// </summary>
|
|
public void StartDeduction()
|
|
{
|
|
//wrjManager.currentWRJ.isMove = true;
|
|
for (int i = 0; i < wrjManager.wRJControllers.Count; i++)
|
|
{
|
|
wrjManager.wRJControllers[i].SetMove();
|
|
}
|
|
}
|
|
|
|
|
|
public void CloseMenu()
|
|
{
|
|
wrjManager.wrjMenuSetPanel.gameObject.SetActive(false);
|
|
}
|
|
}
|