diff --git a/Assets/Scripts/Pal3/Actor/LongKuiController.cs b/Assets/Scripts/Pal3/Actor/LongKuiController.cs index d182d990..4bb02358 100644 --- a/Assets/Scripts/Pal3/Actor/LongKuiController.cs +++ b/Assets/Scripts/Pal3/Actor/LongKuiController.cs @@ -12,7 +12,7 @@ namespace Pal3.Actor using MetaData; using UnityEngine; - public class LongKuiController : MonoBehaviour, + public sealed class LongKuiController : MonoBehaviour, ICommandExecutor { private Actor _actor; diff --git a/Assets/Scripts/Pal3/Audio/AudioManager.cs b/Assets/Scripts/Pal3/Audio/AudioManager.cs index bbb388ac..9df9d2d4 100644 --- a/Assets/Scripts/Pal3/Audio/AudioManager.cs +++ b/Assets/Scripts/Pal3/Audio/AudioManager.cs @@ -22,7 +22,7 @@ namespace Pal3.Audio using State; using UnityEngine; - public class AudioManager : MonoBehaviour, + public sealed class AudioManager : MonoBehaviour, ICommandExecutor, ICommandExecutor, ICommandExecutor, diff --git a/Assets/Scripts/Pal3/Camera/CameraManager.cs b/Assets/Scripts/Pal3/Camera/CameraManager.cs index 9f91b008..5b5b3f89 100644 --- a/Assets/Scripts/Pal3/Camera/CameraManager.cs +++ b/Assets/Scripts/Pal3/Camera/CameraManager.cs @@ -24,7 +24,7 @@ namespace Pal3.Camera using UnityEngine.InputSystem.OnScreen; using UnityEngine.UI; - public class CameraManager : MonoBehaviour, + public sealed class CameraManager : MonoBehaviour, ICommandExecutor, ICommandExecutor, ICommandExecutor, @@ -78,6 +78,8 @@ namespace Pal3.Camera private GameObject _lookAtGameObject; + private int _currentAppliedDefaultTransformOption = 0; + private RectTransform _joyStickRect; private float _joyStickMovementRange; private bool _isTouchEnabled; @@ -361,6 +363,11 @@ namespace Pal3.Camera waiter?.CancelWait(); } + public int GetCurrentAppliedDefaultTransformOption() + { + return _currentAppliedDefaultTransformOption; + } + public void ApplySceneSettings(ScnSceneInfo sceneInfo) { switch (sceneInfo.SceneType) @@ -444,6 +451,7 @@ namespace Pal3.Camera _lastLookAtPoint = _gamePlayController.GetPlayerActorLastKnownPosition(); ApplyDefaultSettings(command.Option); + _currentAppliedDefaultTransformOption = command.Option; _free = true; } @@ -689,6 +697,7 @@ namespace Pal3.Camera public void Execute(ScenePreLoadingNotification notification) { + _currentAppliedDefaultTransformOption = 0; ApplySceneSettings(notification.NewSceneInfo); } diff --git a/Assets/Scripts/Pal3/Command/CommandExtensions.cs b/Assets/Scripts/Pal3/Command/CommandExtensions.cs new file mode 100644 index 00000000..de4f4699 --- /dev/null +++ b/Assets/Scripts/Pal3/Command/CommandExtensions.cs @@ -0,0 +1,33 @@ +// --------------------------------------------------------------------------------------------- +// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved. +// See LICENSE file in the project root for license information. +// --------------------------------------------------------------------------------------------- + +namespace Pal3.Command +{ + using System; + using System.Reflection; + using System.Text; + + public static class CommandExtensions + { + public static string ToString(ICommand command) + { + var builder = new StringBuilder(); + Type type = command.GetType(); + + builder.Append(type.Name[..^"Command".Length]); + builder.Append(' '); + + foreach (PropertyInfo propertyInfo in type.GetProperties()) + { + builder.Append(propertyInfo.GetValue(command)); + builder.Append(' '); + } + + var commandStr = builder.ToString(); + if (commandStr.EndsWith(' ')) commandStr = commandStr[..^1]; + return commandStr; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Pal3/Command/CommandExtensions.cs.meta b/Assets/Scripts/Pal3/Command/CommandExtensions.cs.meta new file mode 100644 index 00000000..c92a2c1b --- /dev/null +++ b/Assets/Scripts/Pal3/Command/CommandExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c053d9f1ea1a49569557705e30028a3c +timeCreated: 1664709809 \ No newline at end of file diff --git a/Assets/Scripts/Pal3/Dev/MazeSkipper.cs b/Assets/Scripts/Pal3/Dev/MazeSkipper.cs index 023767ab..45c36650 100644 --- a/Assets/Scripts/Pal3/Dev/MazeSkipper.cs +++ b/Assets/Scripts/Pal3/Dev/MazeSkipper.cs @@ -20,7 +20,7 @@ namespace Pal3.Dev using UnityEngine; using UnityEngine.UI; - public class MazeSkipper : + public sealed class MazeSkipper : ICommandExecutor, ICommandExecutor { diff --git a/Assets/Scripts/Pal3/Dev/StorySelector.cs b/Assets/Scripts/Pal3/Dev/StorySelector.cs index 63207bd5..3f41f604 100644 --- a/Assets/Scripts/Pal3/Dev/StorySelector.cs +++ b/Assets/Scripts/Pal3/Dev/StorySelector.cs @@ -20,9 +20,10 @@ namespace Pal3.Dev using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; + using UnityEngine.InputSystem.DualShock; using UnityEngine.UI; - public class StorySelector : MonoBehaviour, + public sealed class StorySelector : MonoBehaviour, ICommandExecutor, ICommandExecutor { @@ -32,6 +33,7 @@ namespace Pal3.Dev private ScriptManager _scriptManager; private GameStateManager _gameStateManager; private SceneManager _sceneManager; + private SaveManager _saveManager; private CanvasGroup _storySelectorCanvas; private GameObject _storySelectorButtonPrefab; @@ -40,6 +42,8 @@ namespace Pal3.Dev private readonly Dictionary _storySelections = new() { {"关闭", ""}, + {"继续游戏", ""}, + {"保存当前游戏进度", ""}, {"新的游戏", ""}, #if PAL3 {"永安当-去客房找赵文昌", @" @@ -1262,24 +1266,6 @@ namespace Pal3.Dev BigMapEnableRegion 8 2 BigMapEnableRegion 9 1 CameraFadeIn"}, - {"血濡回魂-石村", @" - ScriptVarSetValue -32768 71700 - SceneLoad Q07 Q07y - ActorActivate -1 1 - ActorEnablePlayerControl -1 - PlayerEnableInput 1 - ActorSetNavLayer -1 0 - ActorSetTilePosition -1 142 169 - BigMapEnableRegion 0 2 - BigMapEnableRegion 1 2 - BigMapEnableRegion 2 2 - BigMapEnableRegion 4 2 - BigMapEnableRegion 5 2 - BigMapEnableRegion 6 1 - BigMapEnableRegion 7 2 - BigMapEnableRegion 8 2 - BigMapEnableRegion 9 1 - CameraFadeIn"}, {"血濡回魂-梦醒", @" ScriptVarSetValue -32768 72001 SceneLoad m07 3 @@ -1447,6 +1433,7 @@ namespace Pal3.Dev BigMapEnableRegion 9 1 BigMapEnableRegion 10 2 BigMapEnableRegion 11 1 + CameraSetDefaultTransform 2 CameraFadeIn"}, {"新安当", @" ScriptVarSetValue -32768 101500 @@ -1895,6 +1882,7 @@ namespace Pal3.Dev SceneManager sceneManager, GameStateManager gameStateManager, ScriptManager scriptManager, + SaveManager saveManager, CanvasGroup storySelectorCanvas, GameObject storySelectorButtonPrefab) { @@ -1904,6 +1892,7 @@ namespace Pal3.Dev _gameStateManager = gameStateManager; _playerInputActions = inputManager.GetPlayerInputActions(); _scriptManager = scriptManager; + _saveManager = saveManager; _storySelectorCanvas = storySelectorCanvas; _storySelectorButtonPrefab = storySelectorButtonPrefab; @@ -1954,13 +1943,14 @@ namespace Pal3.Dev foreach (var story in _storySelections) { - if (hideCloseButton && story.Key == "关闭") continue; - + if (hideCloseButton && story.Key is "关闭" or "保存当前游戏进度") continue; + GameObject selectionButton = Instantiate(_storySelectorButtonPrefab, _storySelectorCanvas.transform); + var buttonTextUI = selectionButton.GetComponentInChildren(); buttonTextUI.text = story.Key; - selectionButton.GetComponent