删除了一些废弃代码
This commit is contained in:
@@ -11,55 +11,32 @@ using UnityEngine.SceneManagement;
|
||||
using System.Numerics;
|
||||
public class EyeTransitionManager : MonoBehaviour
|
||||
{
|
||||
|
||||
// 视图过渡的持续时间
|
||||
private float zoomDuration = 1.5f;
|
||||
|
||||
// 黑屏图片
|
||||
public Image blackScreenImage;
|
||||
|
||||
// MemoryProcess 组件的引用
|
||||
public MemoryProcess memoryProcess;
|
||||
|
||||
public LineManager lineManager; // LineManager的引用
|
||||
public EyeManager eyeManager; // LineManager的引用
|
||||
// 视图配置类
|
||||
[System.Serializable]
|
||||
public class ViewConfig
|
||||
{
|
||||
public ViewState viewState;
|
||||
public MonoBehaviour manager;
|
||||
[HideInInspector]
|
||||
public IViewLifecycle viewLifecycle; // 引用视图的生命周期接口
|
||||
public GameObject viewPanel; // 视图的面板
|
||||
public GameObject fixPanel;
|
||||
//public Button activateButton; // 视图的激活按钮(MainView除外)
|
||||
//public Button returnToMainViewButton; // 视图的返回MainView按钮
|
||||
public Socket socket;
|
||||
//public InteractiveLineSegment lineSegment; // 线段
|
||||
public ViewState viewState;
|
||||
public List<GameObject> Visuals; // 用于保存视图的图片列表
|
||||
public int currentVisualIndex = 0;
|
||||
public CrowBarSocket crowBarSocket;
|
||||
// public UnityEngine.Vector2 viewPosition;
|
||||
public float cameraSize;
|
||||
public UnityEngine.Vector2 cameraPos;
|
||||
|
||||
private bool _isAvailable = false; // 视图是否可用的私有字段
|
||||
//private bool _isAvailable = false; // 视图是否可用的私有字段
|
||||
public Socket socket;
|
||||
//public CrowBarSocket crowBarSocket;
|
||||
|
||||
// 视图是否可用的公有属性
|
||||
public bool IsAvailable
|
||||
{
|
||||
get { return _isAvailable; }
|
||||
set
|
||||
{
|
||||
_isAvailable = value;
|
||||
// 当视图的可用性改变时,更新按钮的状态
|
||||
// if (activateButton != null)
|
||||
// {
|
||||
// activateButton.interactable = value;
|
||||
// //activateButton.gameObject.SetActive(value);
|
||||
// }
|
||||
}
|
||||
}
|
||||
// public bool IsAvailable
|
||||
// {
|
||||
// get { return _isAvailable; }
|
||||
// set
|
||||
// {
|
||||
// _isAvailable = value;
|
||||
// }
|
||||
// }
|
||||
public string audioName="amb_remove";
|
||||
public string soundName="remove_in_1";
|
||||
}
|
||||
@@ -74,7 +51,6 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
// 是否正在进行视图过渡
|
||||
private bool isTransitioning = false;
|
||||
|
||||
public Transform faceTransform;
|
||||
public Transform projector;
|
||||
// 视图状态枚举
|
||||
public enum ViewState
|
||||
@@ -102,22 +78,14 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
public event ViewChangeRequestedHandler OnViewChangeRequested;
|
||||
|
||||
public event Action OnGetMainView;
|
||||
public event Action OnGetDeepView;
|
||||
|
||||
|
||||
public event Action OnGetDeepView;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
//LoadState();
|
||||
|
||||
//DontDestroyOnLoad(this.gameObject);
|
||||
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
||||
Application.quitting += ClearState;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
SceneManager.sceneUnloaded -= OnSceneUnloaded;
|
||||
@@ -131,53 +99,9 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveState()
|
||||
{
|
||||
PlayerPrefs.SetString("CurrentViewState", currentViewState.ToString());
|
||||
|
||||
foreach (var config in viewConfigs)
|
||||
{
|
||||
PlayerPrefs.SetInt(config.viewState.ToString() + "IsAvailable", config.IsAvailable ? 1 : 0);
|
||||
}
|
||||
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
private void LoadState()
|
||||
{
|
||||
string savedViewState = PlayerPrefs.GetString("CurrentViewState", "");
|
||||
|
||||
if (!string.IsNullOrEmpty(savedViewState))
|
||||
{
|
||||
currentViewState = (ViewState)Enum.Parse(typeof(ViewState), savedViewState);
|
||||
}
|
||||
|
||||
foreach (var config in viewConfigs)
|
||||
{
|
||||
int isAvailable = PlayerPrefs.GetInt(config.viewState.ToString() + "IsAvailable", -1);
|
||||
|
||||
if (isAvailable != -1)
|
||||
{
|
||||
config.IsAvailable = isAvailable == 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ClearState()
|
||||
{
|
||||
PlayerPrefs.DeleteKey("CurrentViewState");
|
||||
|
||||
foreach (var config in viewConfigs)
|
||||
{
|
||||
PlayerPrefs.DeleteKey(config.viewState.ToString() + "IsAvailable");
|
||||
}
|
||||
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 首先注册命令
|
||||
DialogController.Instance.RegisterOptionCommand("activate_socket_choice", ActivateSocketChoice);
|
||||
|
||||
|
||||
// 初始化视图
|
||||
InitializeView();
|
||||
@@ -193,54 +117,10 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
// 查找视图的 IViewLifecycle 组件
|
||||
config.viewLifecycle = lifecycle;
|
||||
}
|
||||
if(config.Visuals.Count!=0)
|
||||
{
|
||||
//SetVisualState(config.viewState.ToString(),config.currentVisualIndex);
|
||||
}
|
||||
}
|
||||
//LoadState();
|
||||
}
|
||||
|
||||
public void ActivateSocketChoice(YarnOption[] options)
|
||||
{
|
||||
var optionDic = options.ToDictionary(item => item.Text, item => item);
|
||||
Debug.Log("Option dictionary keys: " + string.Join(", ", optionDic.Keys));
|
||||
|
||||
foreach (var viewConfig in viewConfigs)
|
||||
{
|
||||
if (optionDic.ContainsKey(viewConfig.viewState.ToString()))
|
||||
{
|
||||
// 为Socket添加方法
|
||||
viewConfig.socket.Option = optionDic[viewConfig.viewState.ToString()];
|
||||
}
|
||||
if (optionDic.ContainsKey(viewConfig.viewState + "Activate"))
|
||||
{
|
||||
//viewConfig.activateButton.onClick.RemoveAllListeners();
|
||||
// 为激活添加方法
|
||||
// viewConfig.activateButton.onClick.AddListener(() =>
|
||||
// {
|
||||
// optionDic[viewConfig.viewState+ "Activate"].SelectOption();
|
||||
// });
|
||||
}
|
||||
if (optionDic.ContainsKey(viewConfig.viewState + "CrowBar")&&viewConfig.crowBarSocket!=null)
|
||||
{
|
||||
// 为Socket添加方法
|
||||
viewConfig.crowBarSocket.Option = optionDic[viewConfig.viewState+"CrowBar"];
|
||||
}
|
||||
foreach (var lineSegmentName in lineManager.GetLineSegmentNames())
|
||||
{
|
||||
var recognizedName = lineManager.GetLineSegmentName(lineSegmentName);
|
||||
if (recognizedName != null && optionDic.ContainsKey(recognizedName + "Scissor"))
|
||||
{
|
||||
// 为线段的option赋值
|
||||
lineManager.BindOptionToLineSegment(lineSegmentName, optionDic[recognizedName + "Scissor"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[YarnCommand("SetExternalError")]
|
||||
public void SetExternalError(string targetViewStateName,bool hasExternalError)
|
||||
{
|
||||
@@ -315,13 +195,6 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
{
|
||||
config.viewLifecycle?.OnExit(); // 初始化视图
|
||||
}
|
||||
|
||||
// foreach (var viewConfig in viewConfigs)
|
||||
// {
|
||||
// if(viewConfig.viewPanel!=null)
|
||||
|
||||
// viewConfig.viewPanel.SetActive(viewConfig.viewState == viewState);
|
||||
// }
|
||||
}
|
||||
|
||||
[YarnCommand("BackToMainView")]
|
||||
@@ -350,7 +223,6 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
yield return null;
|
||||
}
|
||||
yield break;
|
||||
|
||||
}
|
||||
if (!viewConfigDictionary.TryGetValue(targetViewState, out ViewConfig targetConfig))
|
||||
{
|
||||
@@ -358,13 +230,6 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
yield break;
|
||||
}
|
||||
|
||||
if(targetConfig.IsAvailable==false)
|
||||
{
|
||||
Debug.LogError(targetViewStateName+"is not avilable");
|
||||
yield break;
|
||||
|
||||
}
|
||||
|
||||
StartTransition(targetViewState);
|
||||
while (isTransitioning)
|
||||
{
|
||||
@@ -372,36 +237,14 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
}
|
||||
//SaveState();
|
||||
}
|
||||
// Yarn 命令,设置视图的可用性
|
||||
[YarnCommand("set_view_availability")]
|
||||
public void SetViewAvailability(string viewStateName, bool isAvailable)
|
||||
{
|
||||
Debug.Log("Setting availability for view state: " + viewStateName + " to " + isAvailable);
|
||||
|
||||
ViewState viewState;
|
||||
if (!Enum.TryParse(viewStateName, out viewState))
|
||||
{
|
||||
Debug.LogError("Invalid ViewState name: " + viewStateName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!viewConfigDictionary.TryGetValue(viewState, out ViewConfig config)) return;
|
||||
|
||||
// 更新视图的可用性和激活按钮的可用性
|
||||
config.IsAvailable = isAvailable;
|
||||
|
||||
SaveState();
|
||||
}
|
||||
// Yarn 命令,设置线段的可剪断性
|
||||
|
||||
|
||||
|
||||
// 开始视图过渡
|
||||
private void StartTransition(ViewState targetViewState)
|
||||
{
|
||||
AudioManager.PauseMemoryAudio();
|
||||
// 如果正在进行视图过渡,或者目标视图是当前视图,或者 MemoryProcess 正在处理,就不进行视图过渡
|
||||
if (isTransitioning || currentViewState == targetViewState || (memoryProcess != null && memoryProcess.IsProcessing()))
|
||||
//if (isTransitioning || currentViewState == targetViewState || (memoryProcess != null && memoryProcess.IsProcessing()))
|
||||
if (isTransitioning || currentViewState == targetViewState)
|
||||
{
|
||||
Debug.LogWarning("Transition is currently not allowed. Please wait until the current process is finished.");
|
||||
return;
|
||||
@@ -430,10 +273,6 @@ public void SetViewAvailability(string viewStateName, bool isAvailable)
|
||||
|
||||
// 开始淡出黑屏
|
||||
zoomOutSequence.Append(blackScreenImage.DOFade(0f, zoomDuration).OnComplete(() => blackScreenImage.gameObject.SetActive(false)));
|
||||
|
||||
// 在淡出黑屏到一半时开始 Zoom Out
|
||||
// zoomOutSequence.Insert(zoomDuration / 2, faceTransform.DOLocalMove(UnityEngine.Vector2.zero, zoomDuration).SetEase(Ease.OutCubic));
|
||||
// zoomOutSequence.Insert(zoomDuration / 2, faceTransform.DOScale(UnityEngine.Vector2.one, zoomDuration).SetEase(Ease.OutCubic));
|
||||
zoomOutSequence.Insert(zoomDuration / 2,Camera.main.DOOrthoSize(5f, zoomDuration).SetEase(Ease.OutCubic));
|
||||
zoomOutSequence.Insert(zoomDuration / 2, Camera.main.transform.DOMove(new UnityEngine.Vector3(0,0,-10) , zoomDuration).SetEase(Ease.OutCubic));
|
||||
|
||||
@@ -441,8 +280,6 @@ public void SetViewAvailability(string viewStateName, bool isAvailable)
|
||||
{
|
||||
zoomOutSequence.Append(projector.DOLocalMoveY(-1, zoomDuration).SetEase(Ease.OutCubic));
|
||||
}
|
||||
|
||||
|
||||
// 在整个动画完成后更新视图状态
|
||||
zoomOutSequence.OnComplete(() =>
|
||||
{
|
||||
@@ -450,10 +287,9 @@ public void SetViewAvailability(string viewStateName, bool isAvailable)
|
||||
isTransitioning = false;
|
||||
AudioManager.PlayAmb1Audio("amb_main");
|
||||
AudioManager.PlayAmb2Audio("amb_general");
|
||||
//MouseCursorManager.Instance.isInDeepView=false;
|
||||
OnGetMainView.Invoke();
|
||||
//MouseCursorManager.Instance.isInDeepView=false;
|
||||
DialogController.Instance.StartDialogNode("主维修界面游戏状态检查");
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -462,18 +298,11 @@ public void SetViewAvailability(string viewStateName, bool isAvailable)
|
||||
|
||||
if (!viewConfigDictionary.TryGetValue(targetViewState, out ViewConfig targetConfig)) return;
|
||||
|
||||
// if (!targetConfig.IsAvailable)
|
||||
// {
|
||||
// Debug.LogWarning("Target view is not available.");
|
||||
// isTransitioning = false;
|
||||
// return;
|
||||
// }
|
||||
AudioManager.RandomPlayInteraction(targetConfig.soundName);
|
||||
// Zoom In 的时候,开始 Zoom
|
||||
Sequence zoomInSequence = DOTween.Sequence();
|
||||
Sequence roateSequence = DOTween.Sequence();
|
||||
// zoomInSequence.Append(faceTransform.DOLocalMove(targetConfig.viewPosition, zoomDuration).SetEase(Ease.OutCubic));
|
||||
// zoomInSequence.Join(faceTransform.DOScale(UnityEngine.Vector2.one*1.5f, zoomDuration).SetEase(Ease.OutCubic));
|
||||
|
||||
float FadeTiming=zoomDuration/4;
|
||||
if (targetViewState == ViewState.MemoryView)
|
||||
{
|
||||
@@ -482,15 +311,7 @@ public void SetViewAvailability(string viewStateName, bool isAvailable)
|
||||
zoomInSequence.Append(projector.DOLocalMoveY(-5, zoomDuration).SetEase(Ease.OutElastic,0.5f));
|
||||
zoomInSequence.AppendCallback(() =>
|
||||
{
|
||||
|
||||
// 创建并启动循环旋转动画
|
||||
// roateSequence.Append(projector.GetChild(0).transform.DOLocalRotate(new UnityEngine.Vector3(0, 0, -360), 1f, RotateMode.FastBeyond360).SetEase(Ease.Linear)
|
||||
// .SetLoops(3, LoopType.Incremental));
|
||||
// roateSequence.Play();
|
||||
});
|
||||
|
||||
//zoomInSequence.AppendInterval(0.5f);
|
||||
|
||||
}
|
||||
zoomInSequence.Append(Camera.main.DOOrthoSize(targetConfig.cameraSize, zoomDuration).SetEase(Ease.OutCubic));
|
||||
zoomInSequence.Join( Camera.main.transform.DOMove(new UnityEngine.Vector3(targetConfig.cameraPos.x,targetConfig.cameraPos.y,-10), zoomDuration).SetEase(Ease.OutCubic));
|
||||
@@ -514,7 +335,7 @@ public void SetViewAvailability(string viewStateName, bool isAvailable)
|
||||
currentViewState = targetViewState;
|
||||
isTransitioning = false;
|
||||
OnGetDeepView.Invoke();
|
||||
if(targetConfig.audioName!=null)
|
||||
if(targetConfig.audioName!=null)
|
||||
{
|
||||
AudioManager.PlayAmb1Audio(targetConfig.audioName);
|
||||
}
|
||||
@@ -526,60 +347,6 @@ public void SetViewAvailability(string viewStateName, bool isAvailable)
|
||||
});
|
||||
}
|
||||
}
|
||||
[YarnCommand("Set_ViewVisualState")]
|
||||
public void SetVisualState(string viewStateName, int visualIndex)
|
||||
{
|
||||
ViewState viewState;
|
||||
if (!Enum.TryParse(viewStateName, out viewState))
|
||||
{
|
||||
Debug.LogError("Invalid ViewState name: " + viewStateName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!viewConfigDictionary.TryGetValue(viewState, out ViewConfig config))
|
||||
{
|
||||
Debug.LogError("ViewState " + viewState + " not found in viewConfigDictionary");
|
||||
return;
|
||||
}
|
||||
|
||||
if (visualIndex < 0 || visualIndex >= config.Visuals.Count)
|
||||
{
|
||||
Debug.LogError("Invalid visual index for " + viewStateName);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < config.Visuals.Count; i++)
|
||||
{
|
||||
config.Visuals[i].SetActive(i == visualIndex);
|
||||
}
|
||||
|
||||
config.currentVisualIndex = visualIndex;
|
||||
|
||||
|
||||
}
|
||||
|
||||
[YarnCommand("Set_VeiwCrowSocketAvailable")]
|
||||
public void SetCrowSocketAvailable(string viewStateName,bool isActive)
|
||||
{
|
||||
ViewState viewState;
|
||||
if (!Enum.TryParse(viewStateName, out viewState))
|
||||
{
|
||||
Debug.LogError("Invalid ViewState name: " + viewStateName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!viewConfigDictionary.TryGetValue(viewState, out ViewConfig config)) return;
|
||||
|
||||
// 加载新的图片
|
||||
if (config.crowBarSocket != null)
|
||||
{
|
||||
bool activeStatus = isActive;
|
||||
config.crowBarSocket.IsAvailable=activeStatus;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 从黑屏淡出
|
||||
private void FadeFromBlack(TweenCallback onComplete)
|
||||
{
|
||||
blackScreenImage.DOFade(0f, 1f).OnComplete(() =>
|
||||
@@ -589,7 +356,6 @@ public void SetVisualState(string viewStateName, int visualIndex)
|
||||
});
|
||||
}
|
||||
|
||||
// 请求更改视图
|
||||
public void RequestViewChange(ViewState targetViewState)
|
||||
{
|
||||
StartTransition(targetViewState);
|
||||
|
||||
Binary file not shown.
@@ -186,7 +186,7 @@ public class OscilloscopeController : MonoBehaviour
|
||||
}
|
||||
else if(currentSocket.targetData.HasExternalError())
|
||||
{
|
||||
transitionManager.SetViewAvailability(trimmedString, true);
|
||||
//transitionManager.SetViewAvailability(trimmedString, true);
|
||||
DeepInButton.interactable=false;
|
||||
HandleDeepIn();
|
||||
}
|
||||
@@ -301,7 +301,7 @@ private void DeepInexecution()
|
||||
//Debug.Log("找到错误,可以开始深入");
|
||||
//screenText.text="找到错误,可以开始深入";
|
||||
yield return new WaitForSeconds(1f);
|
||||
transitionManager.SetViewAvailability(trimmedString, true);
|
||||
// transitionManager.SetViewAvailability(trimmedString, true);
|
||||
DeepInButton.interactable = false;
|
||||
HandleDeepIn();
|
||||
break;
|
||||
@@ -315,7 +315,7 @@ private void DeepInexecution()
|
||||
{
|
||||
Debug.Log("未找到错误,无法深入");
|
||||
screenText.text = "未找到错误,无法深入";
|
||||
transitionManager.SetViewAvailability(trimmedString, false);
|
||||
//transitionManager.SetViewAvailability(trimmedString, false);
|
||||
}
|
||||
|
||||
// 扫描完成,停留片刻后隐藏扫描线
|
||||
|
||||
@@ -61,7 +61,6 @@ public class Module : MonoBehaviour, IPointerClickHandler
|
||||
originalCanvasPosition=Vector3.zero;
|
||||
}
|
||||
|
||||
//socketToEnable.raycastTarget=false;
|
||||
if(socketToEnable!=null)
|
||||
{
|
||||
socketToEnable.IsAvailable=false;
|
||||
@@ -72,10 +71,7 @@ public class Module : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
screw.GetComponent<Screw>().enabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
public void SetReapirState(bool state)
|
||||
{
|
||||
@@ -99,11 +95,6 @@ public class Module : MonoBehaviour, IPointerClickHandler
|
||||
ObejctToInstall.SetActive(false);
|
||||
}
|
||||
}
|
||||
// public void StartRepairIfToolIsScrewdriver(Tool tool)
|
||||
// {
|
||||
// EnterRepairMode();
|
||||
// }
|
||||
|
||||
|
||||
public void RemoveAllPlugsFromSockets()
|
||||
{
|
||||
@@ -116,46 +107,6 @@ public class Module : MonoBehaviour, IPointerClickHandler
|
||||
plug.enabled=false;
|
||||
}
|
||||
|
||||
// public void EnterRepairMode()
|
||||
// {
|
||||
|
||||
// DialogController.Instance.StartDialogNode("EnterRepairMode");
|
||||
// isRepairMode = true;
|
||||
// RemoveAllPlugsFromSockets();
|
||||
// // 使用 DOTween 对 Canvas 的位置和缩放进行平滑过渡
|
||||
// faceCanvas.DOMove(repairCanvasPosition, animationDuration)
|
||||
// .SetEase(Ease.OutQuad) // 移动面板
|
||||
// .OnComplete(() => EnableScrewsInteraction(true)); // 动画完成后才启用交互
|
||||
|
||||
// faceCanvas.DOScale(repairCanvasScale, animationDuration)
|
||||
// .SetEase(Ease.OutQuad); // 缩放面板
|
||||
// }
|
||||
|
||||
// public void ExitRepairMode()
|
||||
// {
|
||||
// isRepairMode = false;
|
||||
|
||||
// // 使用 DOTween 对 Canvas 的位置和缩放进行平滑过渡
|
||||
// faceCanvas.DOMove(originalCanvasPosition, animationDuration)
|
||||
// .SetEase(Ease.InQuad)
|
||||
// .OnComplete(() => EnableScrewsInteraction(false)); // 动画完成后禁用交互
|
||||
|
||||
// faceCanvas.DOScale(1f, animationDuration)
|
||||
// .SetEase(Ease.InQuad); // 恢复面板缩放
|
||||
// ResetModulePosition();
|
||||
// ToolManager.Instance.ShowToolBoxAfterTask();
|
||||
// //socketToEnable.raycastTarget=true;
|
||||
// socketToEnable.IsAvailable=true;
|
||||
|
||||
// foreach (Transform screw in screwsContainer.transform)
|
||||
// {
|
||||
// if(screw!=null)
|
||||
// {
|
||||
// screw.GetComponent<Screw>().enabled = false;
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
public void Install()
|
||||
{
|
||||
Debug.Log(gameObject.name+"InStalled");
|
||||
|
||||
Reference in New Issue
Block a user