存档功能
This commit is contained in:
@@ -9,49 +9,41 @@ using DG.Tweening;
|
||||
using Yarn.Unity;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Numerics;
|
||||
|
||||
public class EyeTransitionManager : MonoBehaviour
|
||||
{
|
||||
private float zoomDuration = 1.5f;
|
||||
|
||||
public Image blackScreenImage;
|
||||
|
||||
// 视图配置类
|
||||
[System.Serializable]
|
||||
public class ViewConfig
|
||||
{
|
||||
public ViewState viewState;
|
||||
public MonoBehaviour manager;
|
||||
[HideInInspector]
|
||||
public IViewLifecycle viewLifecycle; // 引用视图的生命周期接口
|
||||
[HideInInspector] public IViewLifecycle viewLifecycle; // 引用视图的生命周期接口
|
||||
public GameObject viewPanel; // 视图的面板
|
||||
public float cameraSize;
|
||||
public UnityEngine.Vector2 cameraPos;
|
||||
//private bool _isAvailable = false; // 视图是否可用的私有字段
|
||||
public Socket socket;
|
||||
//public CrowBarSocket crowBarSocket;
|
||||
|
||||
// 视图是否可用的公有属性
|
||||
// public bool IsAvailable
|
||||
// {
|
||||
// get { return _isAvailable; }
|
||||
// set
|
||||
// {
|
||||
// _isAvailable = value;
|
||||
// }
|
||||
// }
|
||||
public string audioName="amb_remove";
|
||||
public string soundName="remove_in_1";
|
||||
public UnityEngine.Vector2 cameraPos;
|
||||
|
||||
public Socket socket;
|
||||
public string audioName = "amb_remove";
|
||||
public string soundName = "remove_in_1";
|
||||
}
|
||||
|
||||
// 在 Unity 编辑器中配置视图(不包括MainView)
|
||||
[SerializeField]
|
||||
private List<ViewConfig> viewConfigs;
|
||||
[SerializeField] private List<ViewConfig> viewConfigs;
|
||||
|
||||
// 视图状态和视图配置的映射
|
||||
private Dictionary<ViewState, ViewConfig> viewConfigDictionary;
|
||||
|
||||
|
||||
// 是否正在进行视图过渡
|
||||
private bool isTransitioning = false;
|
||||
|
||||
public Transform projector;
|
||||
|
||||
// 视图状态枚举
|
||||
public enum ViewState
|
||||
{
|
||||
@@ -59,14 +51,6 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
EyeView,
|
||||
UFView,
|
||||
MemoryView,
|
||||
LogicView,
|
||||
EmoView,
|
||||
ColorView,
|
||||
SpeakView,
|
||||
UFViewBroken,
|
||||
//ColorView
|
||||
|
||||
|
||||
// 为未来的视图添加更多状态
|
||||
}
|
||||
|
||||
@@ -75,16 +59,16 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
|
||||
// 视图更改请求的事件
|
||||
public delegate void ViewChangeRequestedHandler(ViewState targetViewState);
|
||||
|
||||
public event ViewChangeRequestedHandler OnViewChangeRequested;
|
||||
|
||||
public event Action OnGetMainView;
|
||||
public event Action OnGetDeepView;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
@@ -101,8 +85,6 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
|
||||
// 初始化视图
|
||||
InitializeView();
|
||||
|
||||
@@ -112,8 +94,8 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
{
|
||||
viewConfigDictionary[config.viewState] = config;
|
||||
|
||||
if(config.manager != null&&(config.manager is IViewLifecycle lifecycle))
|
||||
{
|
||||
if (config.manager != null && (config.manager is IViewLifecycle lifecycle))
|
||||
{
|
||||
// 查找视图的 IViewLifecycle 组件
|
||||
config.viewLifecycle = lifecycle;
|
||||
}
|
||||
@@ -122,7 +104,7 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
|
||||
|
||||
[YarnCommand("SetExternalError")]
|
||||
public void SetExternalError(string targetViewStateName,bool hasExternalError)
|
||||
public void SetExternalError(string targetViewStateName, bool hasExternalError)
|
||||
{
|
||||
ViewState targetViewState;
|
||||
if (!Enum.TryParse(targetViewStateName, out targetViewState))
|
||||
@@ -130,14 +112,15 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
Debug.LogError("Invalid ViewState name: " + targetViewStateName);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!viewConfigDictionary.TryGetValue(targetViewState, out ViewConfig config)) return;
|
||||
|
||||
config.socket.targetData.isExternalError=hasExternalError;
|
||||
config.socket.targetData.isExternalError = hasExternalError;
|
||||
}
|
||||
|
||||
[YarnCommand("SetIsRunning")]
|
||||
public void SetIsRunning(string targetViewStateName,bool isRunning)
|
||||
public void SetIsRunning(string targetViewStateName, bool isRunning)
|
||||
{
|
||||
ViewState targetViewState;
|
||||
if (!Enum.TryParse(targetViewStateName, out targetViewState))
|
||||
@@ -145,17 +128,17 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
Debug.LogError("Invalid ViewState name: " + targetViewStateName);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!viewConfigDictionary.TryGetValue(targetViewState, out ViewConfig config)) return;
|
||||
|
||||
config.socket.targetData.isRunning=isRunning;
|
||||
config.socket.targetData.isRunning = isRunning;
|
||||
}
|
||||
|
||||
private void InitializeView()
|
||||
{
|
||||
// 默认激活 MainView
|
||||
SetView(ViewState.MainView);
|
||||
SetView(ViewState.MainView);
|
||||
}
|
||||
|
||||
private void SetView(ViewState viewState)
|
||||
@@ -165,70 +148,77 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
{
|
||||
foreach (var viewConfig in viewConfigs)
|
||||
{
|
||||
if(viewConfig.viewPanel!=null)
|
||||
viewConfig.viewPanel.SetActive(false);
|
||||
if (viewConfig.viewPanel != null)
|
||||
viewConfig.viewPanel.SetActive(false);
|
||||
//viewConfig.viewLifecycle?.OnExit(); // 初始化视图
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!viewConfigDictionary.TryGetValue(viewState, out ViewConfig config)) return;
|
||||
|
||||
if(config.viewPanel!=null)
|
||||
if (config.viewPanel != null)
|
||||
{
|
||||
config.viewPanel.SetActive(true);
|
||||
}
|
||||
if(config.viewLifecycle!=null)
|
||||
|
||||
if (config.viewLifecycle != null)
|
||||
{
|
||||
config.viewLifecycle?.OnEnter(); // 初始化视图
|
||||
}
|
||||
}
|
||||
private void ExitView(ViewState viewState)
|
||||
|
||||
private void ExitView(ViewState viewState)
|
||||
{
|
||||
if (!viewConfigDictionary.TryGetValue(viewState, out ViewConfig config)) return;
|
||||
|
||||
if(config.viewPanel!=null)
|
||||
if (config.viewPanel != null)
|
||||
{
|
||||
config.viewPanel.SetActive(false);
|
||||
}
|
||||
if(config.viewLifecycle!=null)
|
||||
|
||||
if (config.viewLifecycle != null)
|
||||
{
|
||||
config.viewLifecycle?.OnExit(); // 初始化视图
|
||||
}
|
||||
}
|
||||
|
||||
[YarnCommand("BackToMainView")]
|
||||
|
||||
[YarnCommand("BackToMainView")]
|
||||
public void BackToFace()
|
||||
{
|
||||
StartCoroutine(StartTransitionCoroutine("MainView"));
|
||||
}
|
||||
|
||||
// Yarn 命令,开始视图过渡
|
||||
[YarnCommand("start_transition")]
|
||||
public IEnumerator StartTransitionCoroutine(string targetViewStateName)
|
||||
{
|
||||
Debug.Log("start_transition To "+targetViewStateName);
|
||||
Debug.Log("start_transition To " + targetViewStateName);
|
||||
//eyeManager.EyeEffectInit();
|
||||
//memoryProcess.Init();
|
||||
ViewState targetViewState;
|
||||
if (!Enum.TryParse(targetViewStateName, out targetViewState))
|
||||
{
|
||||
Debug.LogError("Invalid ViewState name: " + targetViewStateName);
|
||||
|
||||
}
|
||||
if(targetViewStateName=="MainView")
|
||||
|
||||
if (targetViewStateName == "MainView")
|
||||
{
|
||||
StartTransition(targetViewState);
|
||||
while (isTransitioning)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
if (!viewConfigDictionary.TryGetValue(targetViewState, out ViewConfig targetConfig))
|
||||
{
|
||||
Debug.LogError("Invalid Viewconfig name: " + targetViewStateName);
|
||||
|
||||
if (!viewConfigDictionary.TryGetValue(targetViewState, out ViewConfig targetConfig))
|
||||
{
|
||||
Debug.LogError("Invalid Viewconfig name: " + targetViewStateName);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
StartTransition(targetViewState);
|
||||
while (isTransitioning)
|
||||
@@ -241,7 +231,7 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
// 开始视图过渡
|
||||
private void StartTransition(ViewState targetViewState)
|
||||
{
|
||||
AudioManager.PauseMemoryAudio();
|
||||
AudioManager.PauseMemoryAudio();
|
||||
// 如果正在进行视图过渡,或者目标视图是当前视图,或者 MemoryProcess 正在处理,就不进行视图过渡
|
||||
//if (isTransitioning || currentViewState == targetViewState || (memoryProcess != null && memoryProcess.IsProcessing()))
|
||||
if (isTransitioning || currentViewState == targetViewState)
|
||||
@@ -252,9 +242,9 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
|
||||
// 开始视图过渡
|
||||
isTransitioning = true;
|
||||
|
||||
|
||||
if (targetViewState == ViewState.MainView)
|
||||
{
|
||||
{
|
||||
Debug.Log("into mainview");
|
||||
// Zoom Out 的时候,先黑屏淡入
|
||||
blackScreenImage.gameObject.SetActive(true);
|
||||
@@ -262,24 +252,20 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
zoomOutSequence.Append(blackScreenImage.DOFade(1f, zoomDuration / 2));
|
||||
|
||||
// 在黑屏淡入完成后关闭 Panel
|
||||
zoomOutSequence.AppendCallback(() =>
|
||||
{
|
||||
ExitView(currentViewState);
|
||||
// foreach (var viewConfig in viewConfigs)
|
||||
// {
|
||||
// viewConfig.viewPanel.SetActive(false);
|
||||
// }
|
||||
});
|
||||
zoomOutSequence.AppendCallback(() => { ExitView(currentViewState); });
|
||||
|
||||
// 开始淡出黑屏
|
||||
zoomOutSequence.Append(blackScreenImage.DOFade(0f, zoomDuration).OnComplete(() => blackScreenImage.gameObject.SetActive(false)));
|
||||
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));
|
||||
|
||||
if(projector.localPosition.y<=-1)
|
||||
zoomOutSequence.Append(blackScreenImage.DOFade(0f, zoomDuration)
|
||||
.OnComplete(() => blackScreenImage.gameObject.SetActive(false)));
|
||||
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));
|
||||
|
||||
if (projector.localPosition.y <= -1)
|
||||
{
|
||||
zoomOutSequence.Append(projector.DOLocalMoveY(-1, zoomDuration).SetEase(Ease.OutCubic));
|
||||
zoomOutSequence.Append(projector.DOLocalMoveY(-1, zoomDuration).SetEase(Ease.OutCubic));
|
||||
}
|
||||
|
||||
// 在整个动画完成后更新视图状态
|
||||
zoomOutSequence.OnComplete(() =>
|
||||
{
|
||||
@@ -295,7 +281,6 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
if (!viewConfigDictionary.TryGetValue(targetViewState, out ViewConfig targetConfig)) return;
|
||||
|
||||
AudioManager.RandomPlayInteraction(targetConfig.soundName);
|
||||
@@ -303,30 +288,35 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
Sequence zoomInSequence = DOTween.Sequence();
|
||||
Sequence roateSequence = DOTween.Sequence();
|
||||
|
||||
float FadeTiming=zoomDuration/4;
|
||||
float FadeTiming = zoomDuration / 4;
|
||||
if (targetViewState == ViewState.MemoryView)
|
||||
{
|
||||
FadeTiming*=5f;
|
||||
|
||||
zoomInSequence.Append(projector.DOLocalMoveY(-5, zoomDuration).SetEase(Ease.OutElastic,0.5f));
|
||||
zoomInSequence.AppendCallback(() =>
|
||||
{
|
||||
});
|
||||
FadeTiming *= 5f;
|
||||
|
||||
zoomInSequence.Append(projector.DOLocalMoveY(-5, zoomDuration).SetEase(Ease.OutElastic, 0.5f));
|
||||
zoomInSequence.AppendCallback(() => { });
|
||||
}
|
||||
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));
|
||||
|
||||
|
||||
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));
|
||||
|
||||
// 在 Zoom 到一半时开始黑屏过渡
|
||||
zoomInSequence.Insert(FadeTiming, blackScreenImage.DOFade(1f, zoomDuration / 2).OnStart(() => blackScreenImage.gameObject.SetActive(true)));
|
||||
zoomInSequence.Insert(FadeTiming,
|
||||
blackScreenImage.DOFade(1f, zoomDuration / 2)
|
||||
.OnStart(() => blackScreenImage.gameObject.SetActive(true)));
|
||||
|
||||
|
||||
// 在整个 Zoom 完成后激活 Eye View
|
||||
zoomInSequence.OnComplete(() =>
|
||||
{
|
||||
if(zoomInSequence!=null)
|
||||
if (zoomInSequence != null)
|
||||
{
|
||||
zoomInSequence.Kill();
|
||||
}
|
||||
|
||||
ExitView(currentViewState);
|
||||
SetView(targetViewState);
|
||||
FadeFromBlack(() =>
|
||||
@@ -335,11 +325,12 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
currentViewState = targetViewState;
|
||||
isTransitioning = false;
|
||||
OnGetDeepView.Invoke();
|
||||
if(targetConfig.audioName!=null)
|
||||
if (targetConfig.audioName != null)
|
||||
{
|
||||
AudioManager.PlayAmb1Audio(targetConfig.audioName);
|
||||
}
|
||||
if(targetConfig.viewLifecycle!=null)
|
||||
|
||||
if (targetConfig.viewLifecycle != null)
|
||||
{
|
||||
targetConfig.viewLifecycle?.OnShow(); // 初始化视图
|
||||
}
|
||||
@@ -347,6 +338,7 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void FadeFromBlack(TweenCallback onComplete)
|
||||
{
|
||||
blackScreenImage.DOFade(0f, 1f).OnComplete(() =>
|
||||
@@ -360,4 +352,4 @@ public class EyeTransitionManager : MonoBehaviour
|
||||
{
|
||||
StartTransition(targetViewState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,17 @@ using TMPro;
|
||||
public class ManualManager : MonoBehaviour
|
||||
{
|
||||
public List<Page> pages;
|
||||
public EyeTransitionManager eyeTransitionManager;
|
||||
public GameObject manualGameObject;
|
||||
public Button manualButton;
|
||||
public GameObject executeWindow;
|
||||
public TextMeshProUGUI executeWindowText;
|
||||
public Button executeWindowButton;
|
||||
public Button nextPageButton;
|
||||
public Button previousPageButton;
|
||||
public EyeTransitionManager eyeTransitionManager;
|
||||
public GameObject manualGameObject;
|
||||
public Button manualButton;
|
||||
public GameObject executeWindow;
|
||||
public TextMeshProUGUI executeWindowText;
|
||||
public Button executeWindowButton;
|
||||
public Button nextPageButton;
|
||||
public Button previousPageButton;
|
||||
|
||||
private bool isManualVisible = false;
|
||||
private int currentIndex = 0;
|
||||
private int currentIndex = 0;
|
||||
private Entry currentEntry; // 添加一个变量来保存当前选中的条目
|
||||
|
||||
private void Start()
|
||||
@@ -25,12 +25,12 @@ public class ManualManager : MonoBehaviour
|
||||
foreach (var page in pages)
|
||||
{
|
||||
page.SetupPage(this, eyeTransitionManager);
|
||||
page.gameObject.SetActive(false); // 初始化时隐藏所有页面
|
||||
page.gameObject.SetActive(false); // 初始化时隐藏所有页面
|
||||
}
|
||||
|
||||
manualButton.onClick.AddListener(ToggleManual);
|
||||
nextPageButton.onClick.AddListener(NextPage);
|
||||
previousPageButton.onClick.AddListener(PreviousPage);
|
||||
nextPageButton.onClick.AddListener(NextPage);
|
||||
previousPageButton.onClick.AddListener(PreviousPage);
|
||||
}
|
||||
|
||||
private void ToggleManual()
|
||||
@@ -39,13 +39,13 @@ public class ManualManager : MonoBehaviour
|
||||
manualGameObject.SetActive(isManualVisible);
|
||||
if (isManualVisible)
|
||||
{
|
||||
pages[currentIndex].gameObject.SetActive(true); // 显示当前页面
|
||||
pages[currentIndex].gameObject.SetActive(true); // 显示当前页面
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var page in pages)
|
||||
{
|
||||
page.gameObject.SetActive(false); // 隐藏所有页面
|
||||
page.gameObject.SetActive(false); // 隐藏所有页面
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class ManualManager : MonoBehaviour
|
||||
executeWindowButton.onClick.AddListener(() =>
|
||||
{
|
||||
executeWindow.SetActive(false);
|
||||
ExecuteCode(); // 在这里添加执行代码的逻辑
|
||||
ExecuteCode(); // 在这里添加执行代码的逻辑
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ public class ManualManager : MonoBehaviour
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
executeWindowButton.onClick.RemoveAllListeners(); // 执行完操作后,移除监听器
|
||||
}
|
||||
|
||||
@@ -90,9 +91,9 @@ public class ManualManager : MonoBehaviour
|
||||
{
|
||||
if (currentIndex < pages.Count - 1)
|
||||
{
|
||||
pages[currentIndex].gameObject.SetActive(false); // 隐藏当前页面
|
||||
pages[currentIndex].gameObject.SetActive(false); // 隐藏当前页面
|
||||
currentIndex++;
|
||||
pages[currentIndex].gameObject.SetActive(true); // 显示新页面
|
||||
pages[currentIndex].gameObject.SetActive(true); // 显示新页面
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,10 +101,9 @@ public class ManualManager : MonoBehaviour
|
||||
{
|
||||
if (currentIndex > 0)
|
||||
{
|
||||
pages[currentIndex].gameObject.SetActive(false); // 隐藏当前页面
|
||||
pages[currentIndex].gameObject.SetActive(false); // 隐藏当前页面
|
||||
currentIndex--;
|
||||
pages[currentIndex].gameObject.SetActive(true); // 显示新页面
|
||||
pages[currentIndex].gameObject.SetActive(true); // 显示新页面
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class MemoryProcess : MonoBehaviour
|
||||
|
||||
private bool isProcessing = false; // 新增变量来追踪是否正在处理记忆
|
||||
|
||||
private bool isColorful = false; //
|
||||
private bool isColorful = false; //
|
||||
private bool isFrequencyFound = false; // 追踪是否找到目标频率
|
||||
private bool isClarityFound = false; // 追踪是否找到目标清晰度
|
||||
|
||||
@@ -45,49 +45,40 @@ public class MemoryProcess : MonoBehaviour
|
||||
public Material fadeMaterial;
|
||||
|
||||
private Dictionary<PunchTape, bool> processedPunchTapes = new Dictionary<PunchTape, bool>();
|
||||
|
||||
|
||||
public void OpenMemoryView()
|
||||
{
|
||||
memoryView.gameObject.SetActive(true);
|
||||
// coverOpen.SetActive(true);
|
||||
// coverClose.SetActive(false);
|
||||
}
|
||||
|
||||
public IEnumerator DropMemoryProjector()
|
||||
{
|
||||
Sequence zoomInSequence = DOTween.Sequence();
|
||||
zoomInSequence.Append(projector.transform.DOLocalMoveY(-5, 2f).SetEase(Ease.OutElastic,0.5f));
|
||||
zoomInSequence.Append(projector.transform.DOLocalMoveY(-5, 2f).SetEase(Ease.OutElastic, 0.5f));
|
||||
yield return zoomInSequence.WaitForCompletion();
|
||||
}
|
||||
|
||||
public IEnumerator PullMemoryProjector()
|
||||
{
|
||||
Sequence zoomInSequence = DOTween.Sequence();
|
||||
zoomInSequence.Append(projector.transform.DOLocalMoveY(0, 2f).SetEase(Ease.OutElastic,0.5f));
|
||||
zoomInSequence.Append(projector.transform.DOLocalMoveY(0, 2f).SetEase(Ease.OutElastic, 0.5f));
|
||||
yield return zoomInSequence.WaitForCompletion();
|
||||
}
|
||||
|
||||
public void CloseMemoryView()
|
||||
{
|
||||
memoryView.gameObject.SetActive(false);
|
||||
}
|
||||
public void Initialize()
|
||||
{
|
||||
// 初始化逻辑
|
||||
Debug.Log("MemoryView initialized.");
|
||||
}
|
||||
|
||||
public void OnEnter()
|
||||
public void OnShow()
|
||||
{
|
||||
Debug.Log("memoryView entered.");
|
||||
}
|
||||
public void OnShow()
|
||||
{
|
||||
Debug.Log("memoryView showed.");
|
||||
clueSlot=FindObjectOfType<MemoryClueSlot>();
|
||||
clueSlot = FindObjectOfType<MemoryClueSlot>();
|
||||
FavoritesManager.Instance.OpenFavorites();
|
||||
Color color = playBackground.color;
|
||||
color.a = 0f;
|
||||
playBackground.color = color;
|
||||
playBackground.gameObject.SetActive(false);
|
||||
//DialogController.Instance.StartDialogNode("OnMemoryViewShow");
|
||||
Color color = playBackground.color;
|
||||
color.a = 0f;
|
||||
playBackground.color = color;
|
||||
playBackground.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void OnExit()
|
||||
@@ -95,15 +86,16 @@ public class MemoryProcess : MonoBehaviour
|
||||
FavoritesManager.Instance.CloseFavorites();
|
||||
// 离开视图时的逻辑
|
||||
Debug.Log("MemoryView exited.");
|
||||
|
||||
}
|
||||
private void Awake()
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitSystem();
|
||||
}
|
||||
private void InitSystem()
|
||||
|
||||
private void InitSystem()
|
||||
{
|
||||
FixSystemCenter.SystemDic.Register(this);
|
||||
FixSystemCenter.SystemDic.Register(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -113,45 +105,50 @@ public class MemoryProcess : MonoBehaviour
|
||||
//searchMemoryButton.onClick.AddListener(SearchMemory);
|
||||
|
||||
// 初始化UI状态
|
||||
Init();
|
||||
Init();
|
||||
}
|
||||
|
||||
float GetRandomNumber()
|
||||
{
|
||||
// 随机决定选择哪个区间
|
||||
if (Random.value < 0.5f) // 50% 概率选择第一个区间
|
||||
{
|
||||
return Random.Range(0.5f, 2f);
|
||||
// 随机决定选择哪个区间
|
||||
if (Random.value < 0.5f) // 50% 概率选择第一个区间
|
||||
{
|
||||
return Random.Range(0.5f, 2f);
|
||||
}
|
||||
else // 50% 概率选择第二个区间
|
||||
{
|
||||
return Random.Range(4f, 5.5f);
|
||||
}
|
||||
}
|
||||
else // 50% 概率选择第二个区间
|
||||
{
|
||||
return Random.Range(4f, 5.5f);
|
||||
}
|
||||
}
|
||||
|
||||
void OnFrequencyChanged(float value)
|
||||
{
|
||||
float distance = Mathf.Abs(value - targetFrequency);
|
||||
UpdateShaderParameters(distance);
|
||||
CheckIfFound(distance, ref isFrequencyFound); // 这里更新 isFrequencyFound
|
||||
}
|
||||
void OnClarityChanged(float value)
|
||||
{
|
||||
float distance = Mathf.Abs(value - targetClarity);
|
||||
float maxDistance = Mathf.Max(
|
||||
Mathf.Abs(claritySlider.maxValue - targetClarity),
|
||||
Mathf.Abs(claritySlider.minValue - targetClarity)
|
||||
);
|
||||
float t = Mathf.Clamp01(distance / maxDistance);
|
||||
|
||||
UpdateClarityShaderParameters(t);
|
||||
CheckIfFound(t, ref isClarityFound); // 这里更新 isClarityFound
|
||||
}
|
||||
void OnSearchComplete()
|
||||
|
||||
void OnClarityChanged(float value)
|
||||
{
|
||||
float distance = Mathf.Abs(value - targetClarity);
|
||||
float maxDistance = Mathf.Max(
|
||||
Mathf.Abs(claritySlider.maxValue - targetClarity),
|
||||
Mathf.Abs(claritySlider.minValue - targetClarity)
|
||||
);
|
||||
float t = Mathf.Clamp01(distance / maxDistance);
|
||||
|
||||
UpdateClarityShaderParameters(t);
|
||||
CheckIfFound(t, ref isClarityFound); // 这里更新 isClarityFound
|
||||
}
|
||||
|
||||
void OnSearchComplete()
|
||||
{
|
||||
Debug.Log("Memory search completed.");
|
||||
frequencySlider.interactable = false;
|
||||
claritySlider.interactable = false;
|
||||
StartCoroutine(PlayMemory());
|
||||
}
|
||||
|
||||
void CheckIfFound(float distance, ref bool isFound)
|
||||
{
|
||||
if (distance < lockThreshold)
|
||||
@@ -179,72 +176,74 @@ void OnClarityChanged(float value)
|
||||
processMaterial.SetFloat("_FullAlphaDissolveFade", alpha);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void UpdateClarityShaderParameters(float t)
|
||||
{
|
||||
if (memoryMaterial != null)
|
||||
{
|
||||
float smoothT = Mathf.SmoothStep(0, 1, t);
|
||||
float pixelateSize;
|
||||
// 根据 t 的值线性插值材质参数,实现平滑过渡
|
||||
//float pixelateSize = Mathf.Lerp(512, 20, smoothT);
|
||||
float offsetUvX = Mathf.Lerp(0, 0.12f, smoothT);
|
||||
float offsetUvY = Mathf.Lerp(0, 0.18f, smoothT);
|
||||
float distortAmount = Mathf.Lerp(0, 1.735f, smoothT);
|
||||
|
||||
if (t >= 0.7f && t <= 1)
|
||||
{
|
||||
// 在 t 值为 0.7 到 1 时,PixelateSize 在 15 到 30 之间变化
|
||||
pixelateSize = Mathf.Lerp(30, 15, Mathf.InverseLerp(0.7f, 1f, t));
|
||||
}
|
||||
else if (t > 0.35f && t < 0.7f)
|
||||
{
|
||||
// 在 t 值为 0.35 到 0.7 时,PixelateSize 在 30 到 50 之间变化
|
||||
pixelateSize = Mathf.Lerp(80, 30, Mathf.InverseLerp(0.35f, 0.7f, t));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 在 t 值小于 0.35 时,PixelateSize 在 50 到 512 之间变化
|
||||
pixelateSize = Mathf.Lerp(512, 80, Mathf.InverseLerp(0f, 0.35f, t));
|
||||
}
|
||||
|
||||
void UpdateClarityShaderParameters(float t)
|
||||
{
|
||||
if (memoryMaterial != null)
|
||||
{
|
||||
float smoothT = Mathf.SmoothStep(0, 1, t);
|
||||
float pixelateSize;
|
||||
// 根据 t 的值线性插值材质参数,实现平滑过渡
|
||||
//float pixelateSize = Mathf.Lerp(512, 20, smoothT);
|
||||
float offsetUvX = Mathf.Lerp(0, 0.12f, smoothT);
|
||||
float offsetUvY = Mathf.Lerp(0, 0.18f, smoothT);
|
||||
float distortAmount = Mathf.Lerp(0, 1.735f, smoothT);
|
||||
|
||||
memoryMaterial.SetFloat("_PixelateSize", pixelateSize);
|
||||
memoryMaterial.SetFloat("_OffsetUvX", offsetUvX);
|
||||
memoryMaterial.SetFloat("_OffsetUvY", offsetUvY);
|
||||
memoryMaterial.SetFloat("_DistortAmount", distortAmount);
|
||||
if (t >= 0.7f && t <= 1)
|
||||
{
|
||||
// 在 t 值为 0.7 到 1 时,PixelateSize 在 15 到 30 之间变化
|
||||
pixelateSize = Mathf.Lerp(30, 15, Mathf.InverseLerp(0.7f, 1f, t));
|
||||
}
|
||||
else if (t > 0.35f && t < 0.7f)
|
||||
{
|
||||
// 在 t 值为 0.35 到 0.7 时,PixelateSize 在 30 到 50 之间变化
|
||||
pixelateSize = Mathf.Lerp(80, 30, Mathf.InverseLerp(0.35f, 0.7f, t));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 在 t 值小于 0.35 时,PixelateSize 在 50 到 512 之间变化
|
||||
pixelateSize = Mathf.Lerp(512, 80, Mathf.InverseLerp(0f, 0.35f, t));
|
||||
}
|
||||
|
||||
|
||||
memoryMaterial.SetFloat("_PixelateSize", pixelateSize);
|
||||
memoryMaterial.SetFloat("_OffsetUvX", offsetUvX);
|
||||
memoryMaterial.SetFloat("_OffsetUvY", offsetUvY);
|
||||
memoryMaterial.SetFloat("_DistortAmount", distortAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
isFrequencyFound=false;
|
||||
isClarityFound=false;
|
||||
isProcessing=false;
|
||||
isFrequencyFound = false;
|
||||
isClarityFound = false;
|
||||
isProcessing = false;
|
||||
if (frequencySlider != null)
|
||||
{
|
||||
frequencySlider.onValueChanged.AddListener(OnFrequencyChanged);
|
||||
frequencySlider.gameObject.SetActive(false);
|
||||
frequencySlider.value=3;
|
||||
frequencySlider.value = 3;
|
||||
frequencySlider.interactable = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (claritySlider != null)
|
||||
{
|
||||
claritySlider.onValueChanged.AddListener(OnClarityChanged);
|
||||
claritySlider.gameObject.SetActive(false);
|
||||
claritySlider.value=3;
|
||||
claritySlider.value = 3;
|
||||
claritySlider.interactable = true;
|
||||
}
|
||||
memoryProcessImage.gameObject.SetActive(true);
|
||||
processMaterial=memoryProcessImage.material;
|
||||
memoryMaterial=memoryFinishedImage.material;
|
||||
}
|
||||
|
||||
memoryProcessImage.gameObject.SetActive(true);
|
||||
processMaterial = memoryProcessImage.material;
|
||||
memoryMaterial = memoryFinishedImage.material;
|
||||
//memoryFinishedImage.gameObject.SetActive(false);
|
||||
memoryFinishedImageNoColor.gameObject.SetActive(false);
|
||||
processMaterial.SetFloat("_FullAlphaDissolveFade", 1);
|
||||
processMaterial.SetFloat("_GlitchFade", 0);
|
||||
processMaterial.SetFloat("_StrongTintFade", 1);
|
||||
float distance = Mathf.Abs(3 - targetClarity);
|
||||
float distance = Mathf.Abs(3 - targetClarity);
|
||||
// 计算滑块值与目标清晰度之间的最大可能距离
|
||||
float maxDistance = Mathf.Max(
|
||||
Mathf.Abs(claritySlider.maxValue - targetClarity),
|
||||
@@ -252,15 +251,15 @@ void OnClarityChanged(float value)
|
||||
);
|
||||
// 归一化距离,确保 t 在 0 到 1 之间,且当滑块值等于目标清晰度时,t 等于 1
|
||||
float t = Mathf.Clamp01(distance / maxDistance);
|
||||
UpdateClarityShaderParameters(t);
|
||||
PunchTape=null;
|
||||
Color color = playBackground.color;
|
||||
color.a = 0f;
|
||||
playBackground.color = color;
|
||||
UpdateClarityShaderParameters(t);
|
||||
PunchTape = null;
|
||||
Color color = playBackground.color;
|
||||
color.a = 0f;
|
||||
playBackground.color = color;
|
||||
playBackground.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
[YarnCommand("MemoryFinished")]
|
||||
[YarnCommand("MemoryFinished")]
|
||||
public IEnumerator MemoryFinished()
|
||||
{
|
||||
AudioManager.PauseMemoryAudio();
|
||||
@@ -274,30 +273,31 @@ void OnClarityChanged(float value)
|
||||
|
||||
// Initialize and release slot
|
||||
Init();
|
||||
clueSlot.punchTape.used=true;
|
||||
clueSlot.punchTape.used = true;
|
||||
clueSlot.ReleaseSlot();
|
||||
|
||||
}
|
||||
[YarnCommand("ColorFadeOut")]
|
||||
public IEnumerator ColorFadeOut()
|
||||
{
|
||||
memoryFinishedImageForFade.sprite=memoryFinishedImage.sprite;
|
||||
memoryFinishedImageNoColor.sprite=memoryFinishedImage.sprite;
|
||||
memoryFinishedImageForFade.gameObject.SetActive(true);
|
||||
memoryFinishedImageNoColor.gameObject.SetActive(true);
|
||||
memoryFinishedImage.gameObject.SetActive(false);
|
||||
|
||||
AudioManager.RandomPlayInteraction("colorerase");
|
||||
AudioManager.PauseMemoryAudio();
|
||||
Tween tween = fadeMaterial.DOFloat(-3, "_DirectionalDistortionFade", 3);
|
||||
yield return tween.WaitForCompletion();
|
||||
}
|
||||
[YarnCommand("PlayMemory")]
|
||||
public IEnumerator PlayMemory(bool useYarn=false,string memName="")
|
||||
|
||||
[YarnCommand("ColorFadeOut")]
|
||||
public IEnumerator ColorFadeOut()
|
||||
{
|
||||
if(useYarn)
|
||||
memoryFinishedImageForFade.sprite = memoryFinishedImage.sprite;
|
||||
memoryFinishedImageNoColor.sprite = memoryFinishedImage.sprite;
|
||||
memoryFinishedImageForFade.gameObject.SetActive(true);
|
||||
memoryFinishedImageNoColor.gameObject.SetActive(true);
|
||||
memoryFinishedImage.gameObject.SetActive(false);
|
||||
|
||||
AudioManager.RandomPlayInteraction("colorerase");
|
||||
AudioManager.PauseMemoryAudio();
|
||||
Tween tween = fadeMaterial.DOFloat(-3, "_DirectionalDistortionFade", 3);
|
||||
yield return tween.WaitForCompletion();
|
||||
}
|
||||
|
||||
[YarnCommand("PlayMemory")]
|
||||
public IEnumerator PlayMemory(bool useYarn = false, string memName = "")
|
||||
{
|
||||
if (useYarn)
|
||||
{
|
||||
fadeMaterial.SetFloat("_DirectionalDistortionFade",-15);
|
||||
fadeMaterial.SetFloat("_DirectionalDistortionFade", -15);
|
||||
memoryFinishedImage.gameObject.SetActive(true);
|
||||
FavoritesManager.Instance.CloseFavorites();
|
||||
Sprite memSprite = Resources.Load<Sprite>("Art/Memory/" + memName);
|
||||
@@ -307,29 +307,12 @@ public IEnumerator PlayMemory(bool useYarn=false,string memName="")
|
||||
{
|
||||
Debug.LogError("Memory not found: " + memName);
|
||||
}
|
||||
AudioManager.PlayMemoryAudio("mem_"+memName);
|
||||
|
||||
AudioManager.PlayMemoryAudio("mem_" + memName);
|
||||
playBackground.gameObject.SetActive(true);
|
||||
//FavoritesManager.Instance.CloseFavorites();
|
||||
playBackground.color = new Color(playBackground.color.r, playBackground.color.g, playBackground.color.b, 0);
|
||||
|
||||
yield return playBackground.DOFade(1f, 1f).WaitForCompletion(); // Fade to fully opaque over 1 second
|
||||
|
||||
// Set material properties
|
||||
processMaterial.SetFloat("_FullAlphaDissolveFade", 0);
|
||||
memoryMaterial.SetFloat("_PixelateSize", 512);
|
||||
memoryMaterial.SetFloat("_OffsetUvX", 0);
|
||||
memoryMaterial.SetFloat("_OffsetUvY", 0);
|
||||
memoryMaterial.SetFloat("_DistortAmount", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
FavoritesManager.Instance.CloseFavorites();
|
||||
// Activate playBackground and fade in alpha from 0 to 1
|
||||
AudioManager.PlayMemoryAudio("mem_"+clueSlot.punchTape.MemoryIndex);
|
||||
playBackground.gameObject.SetActive(true);
|
||||
//FavoritesManager.Instance.CloseFavorites();
|
||||
playBackground.color = new Color(playBackground.color.r, playBackground.color.g, playBackground.color.b, 0);
|
||||
|
||||
yield return playBackground.DOFade(1f, 1f).WaitForCompletion(); // Fade to fully opaque over 1 second
|
||||
|
||||
// Set material properties
|
||||
@@ -338,82 +321,71 @@ public IEnumerator PlayMemory(bool useYarn=false,string memName="")
|
||||
memoryMaterial.SetFloat("_OffsetUvX", 0);
|
||||
memoryMaterial.SetFloat("_OffsetUvY", 0);
|
||||
memoryMaterial.SetFloat("_DistortAmount", 0);
|
||||
DialogController.Instance.StartDialogNode(clueSlot.punchTape.ClueName);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
FavoritesManager.Instance.CloseFavorites();
|
||||
// Activate playBackground and fade in alpha from 0 to 1
|
||||
AudioManager.PlayMemoryAudio("mem_" + clueSlot.punchTape.MemoryIndex);
|
||||
playBackground.gameObject.SetActive(true);
|
||||
//FavoritesManager.Instance.CloseFavorites();
|
||||
playBackground.color = new Color(playBackground.color.r, playBackground.color.g, playBackground.color.b, 0);
|
||||
|
||||
yield return playBackground.DOFade(1f, 1f).WaitForCompletion(); // Fade to fully opaque over 1 second
|
||||
|
||||
// Set material properties
|
||||
processMaterial.SetFloat("_FullAlphaDissolveFade", 0);
|
||||
memoryMaterial.SetFloat("_PixelateSize", 512);
|
||||
memoryMaterial.SetFloat("_OffsetUvX", 0);
|
||||
memoryMaterial.SetFloat("_OffsetUvY", 0);
|
||||
memoryMaterial.SetFloat("_DistortAmount", 0);
|
||||
DialogController.Instance.StartDialogNode(clueSlot.punchTape.ClueName);
|
||||
}
|
||||
}
|
||||
[YarnCommand("search_memory")]
|
||||
public IEnumerator SearchMemory(PunchTape punchTape, bool isSkipDialogue=false)
|
||||
|
||||
[YarnCommand("search_memory")]
|
||||
public IEnumerator SearchMemory(PunchTape punchTape, bool isSkipDialogue = false)
|
||||
{
|
||||
targetClarity=GetRandomNumber();
|
||||
targetFrequency=GetRandomNumber();
|
||||
targetClarity = GetRandomNumber();
|
||||
targetFrequency = GetRandomNumber();
|
||||
FavoritesManager.Instance.CloseFavorites();
|
||||
//FavoritesManager.Instance.CloseFavorites();
|
||||
if(punchTape==null)
|
||||
if (punchTape == null)
|
||||
{
|
||||
Debug.Log("no punchTape");
|
||||
yield break;
|
||||
}
|
||||
PunchTape=punchTape;
|
||||
// if (isSearchedBefore)
|
||||
// {
|
||||
// if(isSkipDialogue)
|
||||
// {
|
||||
// PlayMemory(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// PlayMemory();
|
||||
// }
|
||||
|
||||
// yield break;
|
||||
// }
|
||||
|
||||
// if (processedPunchTapes.TryGetValue(punchTape, out bool isProcessed) && isProcessed)
|
||||
// {
|
||||
// Sprite memorySprite1 = Resources.Load<Sprite>("Art/Memory/" + PunchTape.MemoryIndex);
|
||||
// memoryFinishedImage.sprite = memorySprite1;
|
||||
// memoryFinishedImageNoColor.sprite = memorySprite1;
|
||||
// PlayMemory();
|
||||
// yield break;
|
||||
// }
|
||||
PunchTape = punchTape;
|
||||
|
||||
AudioManager.PauseMemoryAudio();
|
||||
if (isProcessing)
|
||||
{
|
||||
Debug.LogWarning("Already processing a memory. Please wait until the process is finished.");
|
||||
yield break;
|
||||
AudioManager.PauseMemoryAudio();
|
||||
if (isProcessing)
|
||||
{
|
||||
Debug.LogWarning("Already processing a memory. Please wait until the process is finished.");
|
||||
yield break;
|
||||
}
|
||||
|
||||
Sprite memorySprite = Resources.Load<Sprite>("Art/Memory/" + PunchTape.MemoryIndex);
|
||||
memoryFinishedImage.sprite = memorySprite;
|
||||
memoryFinishedImageNoColor.sprite = memorySprite;
|
||||
if (memorySprite == null)
|
||||
{
|
||||
Debug.LogError("Memory not found: " + PunchTape.MemoryIndex);
|
||||
}
|
||||
|
||||
processMaterial.SetFloat("_StrongTintFade", 0);
|
||||
processMaterial.SetFloat("_GlitchFade", 1);
|
||||
|
||||
isProcessing = true; // 开始处理,设置为true
|
||||
frequencySlider.gameObject.SetActive(true);
|
||||
claritySlider.gameObject.SetActive(true);
|
||||
Sequence memorySequence = DOTween.Sequence();
|
||||
|
||||
yield return memorySequence.WaitForCompletion();
|
||||
}
|
||||
//processedPunchTapes.Add(punchTape,true);
|
||||
Sprite memorySprite = Resources.Load<Sprite>("Art/Memory/" + PunchTape.MemoryIndex);
|
||||
memoryFinishedImage.sprite = memorySprite;
|
||||
memoryFinishedImageNoColor.sprite = memorySprite;
|
||||
if (memorySprite == null)
|
||||
{
|
||||
Debug.LogError("Memory not found: " + PunchTape.MemoryIndex);
|
||||
}
|
||||
// if (isColorful)
|
||||
// {
|
||||
// memoryFinishedImage.material.SetFloat("_DirectionalDistortionFade", -2);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// memoryFinishedImage.material.SetFloat("_DirectionalDistortionFade", -14);
|
||||
// }
|
||||
//AudioManager.PlayLoopAudio("tv_noise");
|
||||
processMaterial.SetFloat("_StrongTintFade", 0);
|
||||
processMaterial.SetFloat("_GlitchFade", 1);
|
||||
|
||||
isProcessing = true; // 开始处理,设置为true
|
||||
frequencySlider.gameObject.SetActive(true);
|
||||
claritySlider.gameObject.SetActive(true);
|
||||
DG.Tweening.Sequence memorySequence = DOTween.Sequence();
|
||||
|
||||
yield return memorySequence.WaitForCompletion();
|
||||
}
|
||||
public bool IsProcessing()
|
||||
{
|
||||
return isProcessing;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
using Yarn.Unity;
|
||||
using AibisDream;
|
||||
|
||||
public class UFProcess : MonoBehaviour,IViewLifecycle
|
||||
{
|
||||
public Image memoryProcessImage; // 用于显示调取记忆的表现
|
||||
public Image memoryFinishedImage; // 用于显示记忆处理结束的表现
|
||||
public Image memoryFinishedImageColorWrong; // 用于显示记忆处理结束的表现
|
||||
public Image UFImage; // 用于显示糅合后的广告图
|
||||
public Button drawButton; // 绘图按钮
|
||||
|
||||
public Sprite defaultSprite; // 默认图片
|
||||
|
||||
private int currentMemoryIndex = 0; // 当前记忆索引
|
||||
|
||||
private bool isProcessing = false; // 新增变量来追踪是否正在处理记忆
|
||||
private void Start()
|
||||
{
|
||||
// 绑定绘图按钮事件
|
||||
//drawButton.onClick.AddListener(ProcessMemory);
|
||||
|
||||
// 初始化UI状态
|
||||
// memoryProcessImage.gameObject.SetActive(true);
|
||||
// memoryFinishedImage.gameObject.SetActive(false);
|
||||
// memoryFinishedImageColorWrong.gameObject.SetActive(false);
|
||||
// UFImage.gameObject.SetActive(false);
|
||||
// memoryProcessImage.material.SetFloat("_StrongTintFade", 1);
|
||||
// memoryProcessImage.material.SetFloat("_GlitchFade", 0);
|
||||
}
|
||||
public void Initialize()
|
||||
{
|
||||
// 初始化逻辑
|
||||
|
||||
}
|
||||
|
||||
public void OnEnter()
|
||||
{
|
||||
|
||||
}
|
||||
public void OnShow()
|
||||
{
|
||||
// Debug.Log("UFview Show");
|
||||
//StartCoroutine(ProcessMemory("liuying1-2"));
|
||||
DialogController.Instance.StartDialogNode("OnUFViewShow");
|
||||
}
|
||||
|
||||
public void OnExit()
|
||||
{
|
||||
|
||||
Debug.Log("EyeView exited.");
|
||||
|
||||
}
|
||||
|
||||
[YarnCommand("UFprocess")]
|
||||
public IEnumerator ProcessMemory(string memoryFinishedImageName)
|
||||
{
|
||||
AudioManager.PlayLoopAudio("UFlearning");
|
||||
if (isProcessing)
|
||||
{
|
||||
Debug.LogWarning("Already processing a memory. Please wait until the process is finished.");
|
||||
yield break;
|
||||
}
|
||||
isProcessing = true; // 开始处理,设置为true
|
||||
yield return new WaitForSeconds(3f);
|
||||
AudioManager.PauseLoopAudio();
|
||||
isProcessing = false;
|
||||
//DialogController.Instance.StartDialogNode("UF进程播放完毕");
|
||||
|
||||
|
||||
// Sprite memoryFinishedSprite = Resources.Load<Sprite>("Art/Memory/" + memoryFinishedImageName);
|
||||
// Sprite UFMemorySprite = Resources.Load<Sprite>("Art/Photos/" + memoryFinishedImageName+"Error");
|
||||
// if (memoryFinishedSprite == null)
|
||||
// {
|
||||
// Debug.LogError("Memory finished image not found: " + memoryFinishedImageName);
|
||||
// yield break;
|
||||
// }
|
||||
|
||||
// // if (UFMemorySprite == null)
|
||||
// // {
|
||||
// // Debug.LogError("UF image not found: " + UFImageName);
|
||||
// // yield break;
|
||||
// // }
|
||||
// memoryFinishedImage.material.SetFloat("_TwistUvAmount", 0); // 设置 Pixel_Fade 为0
|
||||
|
||||
|
||||
// // 开始处理记忆的表现
|
||||
// memoryProcessImage.gameObject.SetActive(true);
|
||||
// //memoryProcessImage.sprite = defaultSprite; // 设置默认图片
|
||||
// memoryProcessImage.color = Color.white; // 设置初始颜色
|
||||
|
||||
// Sequence memorySequence = DOTween.Sequence();
|
||||
|
||||
// // 修改memoryprocess的参数
|
||||
// memorySequence.Append(memoryProcessImage.material.DOFloat(0, "_StrongTintFade", 1));
|
||||
// memorySequence.Join(memoryProcessImage.material.DOFloat(1, "_GlitchFade", 1));
|
||||
|
||||
// memorySequence.AppendInterval(2f);
|
||||
|
||||
// // 记忆处理结束,激活memoryFinishedImage
|
||||
// memorySequence.AppendCallback(() =>
|
||||
// {
|
||||
// memoryFinishedImage.color= Color.white;
|
||||
// memoryProcessImage.gameObject.SetActive(false);
|
||||
|
||||
// memoryFinishedImage.gameObject.SetActive(true);
|
||||
// memoryFinishedImage.sprite = memoryFinishedSprite; // 设置记忆处理结束的图片
|
||||
// memoryFinishedImage.material.SetFloat("_TwistUvAmount", 0); // 设置 Pixel_Fade 为0
|
||||
// });
|
||||
|
||||
// memorySequence.AppendInterval(0f); // 添加4秒的延时
|
||||
|
||||
// memorySequence.Append(memoryFinishedImage.material.DOFloat(1, "_TwistUvAmount", 3f));
|
||||
// memorySequence.Join(memoryFinishedImage.material.DOFloat(0, "_Alpha", 3f));
|
||||
// memorySequence.AppendInterval(1f); // 添加1.5秒的延时
|
||||
|
||||
// // 激活UFImage,并开始像素淡入效果
|
||||
// memorySequence.AppendCallback(() =>
|
||||
// {
|
||||
// memoryFinishedImage.gameObject.SetActive(false);
|
||||
// UFImage.gameObject.SetActive(true);
|
||||
// UFImage.color= Color.white;
|
||||
// UFImage.sprite = UFMemorySprite; // 设置糅合后的广告图
|
||||
// UFImage.material.SetFloat("Pixel_Fade", 1); // 设置 Pixel_Fade 为1
|
||||
// UFImage.rectTransform.anchoredPosition = new Vector2(0, -111f); // 重置位置
|
||||
// });
|
||||
|
||||
// // Pixel_Fade 从1变为0,持续1.5秒
|
||||
// memorySequence.Append(DOTween.To(() => UFImage.material.GetFloat("Pixel_Fade"), x => UFImage.material.SetFloat("Pixel_Fade", x), 0, 3f));
|
||||
|
||||
// memorySequence.AppendInterval(1f); // 添加2秒的延时
|
||||
|
||||
// // UFImage向右移动
|
||||
// memorySequence.Append(UFImage.rectTransform.DOAnchorPosX(1000, 1f)); // 假设向右移动1000单位
|
||||
|
||||
// // 序列完成时更新索引
|
||||
// memorySequence.OnComplete(() =>
|
||||
// {
|
||||
// UFImage.gameObject.SetActive(false);
|
||||
// isProcessing = false; // 处理完成,设置为false
|
||||
// AudioManager.PauseLoopAudio();
|
||||
// });
|
||||
}
|
||||
public bool IsProcessing()
|
||||
{
|
||||
return isProcessing;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d90b606a3de9db4b8ba9429b71a430c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,18 +3,16 @@ using DG.Tweening;
|
||||
|
||||
public class ViewCameraManager : MonoBehaviour
|
||||
{
|
||||
//public Transform targetTransform; // 目标位置
|
||||
public Vector2 minBounds; // 相机允许移动的最小边界
|
||||
public Vector2 maxBounds; // 相机允许移动的最大边界
|
||||
|
||||
private Camera cam;
|
||||
private Vector3 smoothVelocity = Vector3.zero;
|
||||
public float smoothTime = 0.3f; // 相机移动的平滑时间
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
cam = GetComponent<Camera>();
|
||||
}
|
||||
|
||||
public void MoveCameraTo(Transform newTarget, float duration)
|
||||
{
|
||||
Vector3 targetPosition = newTarget.position;
|
||||
@@ -30,6 +28,7 @@ public class ViewCameraManager : MonoBehaviour
|
||||
// 使用 DOTween 平滑地移动相机
|
||||
cam.transform.DOMove(targetPosition, duration).SetEase(Ease.InOutSine);
|
||||
}
|
||||
|
||||
public void SetCameraPosition(Transform newTarget)
|
||||
{
|
||||
Vector3 targetPosition = newTarget.position;
|
||||
@@ -46,26 +45,6 @@ public class ViewCameraManager : MonoBehaviour
|
||||
cam.transform.position = targetPosition;
|
||||
}
|
||||
|
||||
/*private void LateUpdate()
|
||||
{
|
||||
if (targetTransform != null)
|
||||
{
|
||||
Vector3 targetPosition = targetTransform.position;
|
||||
Vector3 cameraPosition = cam.transform.position;
|
||||
|
||||
float camHeight = cam.orthographicSize * 2;
|
||||
float camWidth = camHeight * cam.aspect;
|
||||
|
||||
// 限制相机位置不超过边界,同时考虑到相机的大小
|
||||
targetPosition.x = Mathf.Clamp(targetPosition.x, minBounds.x + camWidth / 2, maxBounds.x - camWidth / 2);
|
||||
targetPosition.y = Mathf.Clamp(targetPosition.y, minBounds.y + camHeight / 2, maxBounds.y - camHeight / 2);
|
||||
targetPosition.z = cameraPosition.z; // 保持相机的Z轴位置不变
|
||||
|
||||
// 使用平滑阻尼来移动相机
|
||||
cam.transform.position = Vector3.SmoothDamp(cameraPosition, targetPosition, ref smoothVelocity, smoothTime);
|
||||
}
|
||||
}*/
|
||||
|
||||
// 在编辑器中绘制相机边界
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
@@ -75,4 +54,4 @@ public class ViewCameraManager : MonoBehaviour
|
||||
Gizmos.DrawLine(new Vector2(maxBounds.x, maxBounds.y), new Vector2(minBounds.x, maxBounds.y));
|
||||
Gizmos.DrawLine(new Vector2(minBounds.x, maxBounds.y), new Vector2(minBounds.x, minBounds.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user