123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class StationaryAreaStep : AbstractSafetyAreaStep<SafetyAreaMono>
- {
- public StationaryAreaStep(SafetyAreaMono safetyAreaMono) : base(safetyAreaMono)
- {
- }
- public override void OnEnterStep(object data)
- {
- //reference.safetyGreyCameraUI.gameObject.SetActive(true);
- reference.stationaryAreaUI.gameObject.SetActive(true);
- reference.stationaryAreaUI.Init();
- reference.stationaryAreaUI.OnSwitchToPlayAreaClick += OnSwitchPlayAreaClick;
- reference.stationaryAreaUI.OnCancelClick += OnStationaryAreaCancelClick;
- reference.stationaryAreaUI.OnConfirmClick += OnStationaryAreaConfirmClick;
- SafetyAreaManager.Instance.CreateStationarySafetyArea();
- UnFreezeStationarySafetyArea();
- HidePlane();
- SafetyAreaManager.Instance.stationaryAreaMono.SetMaterial(reference.areaConfirmMat);
- }
- public override void OnExitStep()
- {
- reference.stationaryAreaUI.OnSwitchToPlayAreaClick -= OnSwitchPlayAreaClick;
- reference.stationaryAreaUI.OnCancelClick -= OnStationaryAreaCancelClick;
- reference.stationaryAreaUI.OnConfirmClick -= OnStationaryAreaConfirmClick;
- reference.stationaryAreaUI.Release();
- reference.stationaryAreaUI.gameObject.SetActive(false);
- //reference.safetyGreyCameraUI.gameObject.SetActive(false);
- }
- public override SafetyAreaStepEnum GetStepEnum()
- {
- return SafetyAreaStepEnum.StationaryArea;
- }
- //暂时隐藏平面
- public void HidePlane()
- {
- reference.safetyPlaneMono.gameObject.SetActive(false);
- }
- public void OnSwitchPlayAreaClick()
- {
- SafetyAreaManager.Instance.DestroyStationaryArea();
- SafetyAreaManager.Instance.ChangeStep(SafetyAreaStepEnum.PlayArea);
- SafetyAreaManager.Instance.GetStep<PlayAreaStep>(SafetyAreaStepEnum.PlayArea).ChangePlanePosition();
- }
- private void OnStationaryAreaCancelClick()
- {
- SafetyAreaManager.Instance.DestroyStationaryArea();
- reference.DestroySafetyPlane();
- SafetyAreaManager.Instance.ExitSafeAreaStep();
- }
- private void OnStationaryAreaConfirmClick()
- {
- SafetyAreaManager.Instance.stationaryAreaMono.SetMaterial(reference.areaNormalMat);
- FreezeStationarySafetyArea();
- reference.DestroySafetyPlane();
- SafetyAreaManager.Instance.ExitSafeAreaStep();
- }
- public void FreezeStationarySafetyArea()
- {
- if (SafetyAreaManager.Instance.stationaryAreaMono == null)
- {
- Debug.LogError("stationaryAreaMono is Null FreezeStationarySafetyArea");
- }
- SafetyAreaManager.Instance.stationaryAreaMono.FreezeStationaryAreaPosition();
- }
- public void UnFreezeStationarySafetyArea()
- {
- if (SafetyAreaManager.Instance.stationaryAreaMono == null)
- {
- Debug.LogError("stationaryAreaMono is Null UnFreezeStationarySafetyArea");
- }
- SafetyAreaManager.Instance.stationaryAreaMono.UnFreezeStationaryAreaPosition();
- }
- private Vector2 circleCenter = new Vector2(0, 0);
- public void SetCircleCenter(Vector3 headPosition)
- {
- circleCenter = new Vector2(headPosition.x, headPosition.z);
- }
- public Vector2 GetCircleCenter()
- {
- return circleCenter;
- }
- public override void OnUserCancel()
- {
- OnStationaryAreaConfirmClick();
- }
- }
|