Compare commits

...
16 Commits
Author SHA1 Message Date
Jiaqi Liu 2b98a43ca2 Update settings 2023-08-07 23:33:50 -07:00
Jiaqi Liu 1c12b99056 v0.72 2023-08-07 23:22:03 -07:00
Jiaqi Liu 515f99d391 Supports Vulkan + SSAO on Android 2023-08-07 23:12:07 -07:00
Jiaqi Liu 5073f9ac49 Minor fix 2023-08-07 09:22:30 -07:00
Jiaqi Liu ee2128d5ca Add debug info on-off switch in settings menu 2023-08-07 08:35:02 -07:00
Jiaqi Liu d7c0a05165 Fix dialogue positioning issue when resizing the game window 2023-08-07 05:55:19 -07:00
Jiaqi Liu 0b27516bff Minor fixes 2023-08-07 04:27:02 -07:00
Jiaqi Liu b0eca97589 Tweaks and fixes 2023-08-06 09:44:45 -07:00
Jiaqi Liu 33f8f40399 v0.71 2023-08-06 07:57:36 -07:00
Jiaqi Liu ab24b6ab14 Tweak slide speed on SlidewayObject 2023-08-06 07:56:58 -07:00
Jiaqi Liu 55fc5504a5 v0.71 2023-08-06 07:47:28 -07:00
Jiaqi Liu a223a0ea1d Keep linear fog shader (used by PAL3A) 2023-08-06 07:12:44 -07:00
Jiaqi Liu d328f26c1f Implement mini map 2023-08-06 07:07:24 -07:00
Jiaqi Liu 0419a4bbd7 Update QualitySettings.asset 2023-08-06 00:53:50 -07:00
Jiaqi Liu 88a5db3420 Show game logo on launch 2023-08-05 23:48:58 -07:00
Jiaqi Liu 753c8baec5 UI and dialogue animation tweaks 2023-08-05 21:31:37 -07:00
34 changed files with 1703 additions and 203 deletions

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -333,7 +333,7 @@ MonoBehaviour:
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 18
m_fontSizeMax: 25
m_fontSizeMax: 24
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
@@ -7,6 +7,7 @@ Shader "Pal3/RoundedFrostedGlass"
Properties
{
_BlurAmount ("Blur", Range(0, 30)) = 1
_Transparency ("Transparency", Range(0, 1)) = 1
[HideInInspector] _MainTex ("Masking Texture", 2D) = "white" {}
_AdditiveColor ("Additive Tint color", Color) = (0, 0, 0, 0)
_MultiplyColor ("Multiply Tint color", Color) = (1, 1, 1, 1)
@@ -96,6 +97,7 @@ Shader "Pal3/RoundedFrostedGlass"
sampler2D _HBlur;
float4 _HBlur_TexelSize;
float _BlurAmount;
float _Transparency;
float4 _AdditiveColor;
float4 _MultiplyColor;
float4 _WidthHeightRadius;
@@ -125,6 +127,7 @@ Shader "Pal3/RoundedFrostedGlass"
sum.g * _MultiplyColor.g + _AdditiveColor.g,
sum.b * _MultiplyColor.b + _AdditiveColor.b,
tex2D(_MainTex, i.uvmain).a);
result.a *= _Transparency;
return result;
}
ENDCG
@@ -200,6 +203,7 @@ Shader "Pal3/RoundedFrostedGlass"
sampler2D _VBlur;
float4 _VBlur_TexelSize;
float _BlurAmount;
float _Transparency;
float4 _AdditiveColor;
float4 _MultiplyColor;
float4 _WidthHeightRadius;
@@ -224,12 +228,12 @@ Shader "Pal3/RoundedFrostedGlass"
sum += GRABPIXEL(0.09, +3.0);
sum += GRABPIXEL(0.05, +4.0);
half4 blurResult = half4(sum.r * _MultiplyColor.r + _AdditiveColor.r,
half4 result = half4(sum.r * _MultiplyColor.r + _AdditiveColor.r,
sum.g * _MultiplyColor.g + _AdditiveColor.g,
sum.b * _MultiplyColor.b + _AdditiveColor.b,
tex2D(_MainTex, i.uvmain).a);
return blurResult;
result.a *= _Transparency;
return result;
}
ENDCG
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

+140
View File
@@ -0,0 +1,140 @@
fileFormatVersion: 2
guid: c171273b4d327f14d8016fcbe864a769
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
+8 -1
View File
@@ -218,7 +218,14 @@ namespace Core.Utils
Debug.DrawLine(p4, p8, Color.cyan, duration);
}
public static bool IsAndroidDeviceAndSdkVersionLowerThanOrEqualTo(int sdkVersion)
public static bool IsLegacyMobileDevice()
{
if (IsAndroidDeviceAndSdkVersionLowerThanOrEqualTo(23)) return true;
// TODO: Add iOS legacy mobile device check etc
return false;
}
private static bool IsAndroidDeviceAndSdkVersionLowerThanOrEqualTo(int sdkVersion)
{
if (Application.platform != RuntimePlatform.Android) return false;
@@ -301,6 +301,21 @@ namespace Pal3.Data
});
}
public Sprite GetLogoSprite()
{
#if PAL3
const string mainLogoTextureFileName = "11.tga";
Rect mainLogoTextureRect = new Rect(0, 600, 375, 145);
#elif PAL3A
const string mainLogoTextureFileName = "12.tga";
Rect mainLogoTextureRect = new Rect(0, 770, 500, 253);
#endif
ITextureResourceProvider uiLibTextureProvider = CreateTextureResourceProvider(FileConstants.UILibFolderVirtualPath);
Texture2D logoTexture = uiLibTextureProvider.GetTexture(mainLogoTextureFileName);
return Sprite.Create(logoTexture, mainLogoTextureRect, new Vector2(0.5f, 0.5f));
}
private Texture2D GetActorAvatarTexture(string actorName, string avatarTextureName)
{
var roleAvatarTextureRelativePath = FileConstants.GetActorFolderVirtualPath(actorName);
+52 -30
View File
@@ -31,6 +31,7 @@ namespace Pal3.Dev
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.DualShock;
using UnityEngine.Rendering;
using UnityEngine.UI;
public sealed class MainMenu : MonoBehaviour,
@@ -192,6 +193,8 @@ namespace Pal3.Dev
}
_initViewCameraOrbitAnimationCts = new CancellationTokenSource();
StartCoroutine(StartCameraOrbitAnimationAsync(_initViewCameraOrbitAnimationCts.Token));
_gameStateManager.GoToState(GameState.Cutscene);
}
private IEnumerator StartCameraOrbitAnimationAsync(CancellationToken cancellationToken)
@@ -340,9 +343,9 @@ namespace Pal3.Dev
SelectFirstButtonForEventSystem();
UpdateRectTransformWidthAndHeight(_backgroundTransform,
_contentGridLayoutGroup.cellSize.x + 100f,
_contentGridLayoutGroup.cellSize.x,
(_contentGridLayoutGroup.cellSize.y + _contentGridLayoutGroup.spacing.y) * _menuItems.Count
- _contentGridLayoutGroup.spacing.y + 100f);
- _contentGridLayoutGroup.spacing.y);
}
private void SetupSettingButtons()
@@ -395,24 +398,27 @@ namespace Pal3.Dev
(_gameSettings.IsRealtimeLightingAndShadowsEnabled ? "开启(注意性能和耗电影响)" : "关闭") + ""));
});
#if !UNITY_ANDROID
string GetSSAOButtonText() => _gameSettings.IsAmbientOcclusionEnabled ? ssaoEnabledText : ssaoDisabledText;
CreateMenuButton(GetSSAOButtonText(), buttonTextUGUI => delegate
// SSAO is not available on Android OpenGLES3
if (!(Application.platform == RuntimePlatform.Android &&
SystemInfo.graphicsDeviceType != GraphicsDeviceType.Vulkan))
{
if (!_gameSettings.IsAmbientOcclusionEnabled && !_gameSettings.IsRealtimeLightingAndShadowsEnabled)
string GetSSAOButtonText() => _gameSettings.IsAmbientOcclusionEnabled ? ssaoEnabledText : ssaoDisabledText;
CreateMenuButton(GetSSAOButtonText(), buttonTextUGUI => delegate
{
CommandDispatcher<ICommand>.Instance.Dispatch(new UIDisplayNoteCommand("请先开启实时光影,再开启环境光遮蔽"));
return;
}
if (!_gameSettings.IsAmbientOcclusionEnabled && !_gameSettings.IsRealtimeLightingAndShadowsEnabled)
{
CommandDispatcher<ICommand>.Instance.Dispatch(new UIDisplayNoteCommand("请先开启实时光影,再开启环境光遮蔽"));
return;
}
_gameSettings.IsAmbientOcclusionEnabled = !_gameSettings.IsAmbientOcclusionEnabled;
_gameSettings.IsAmbientOcclusionEnabled = !_gameSettings.IsAmbientOcclusionEnabled;
buttonTextUGUI.text = GetSSAOButtonText();
buttonTextUGUI.text = GetSSAOButtonText();
CommandDispatcher<ICommand>.Instance.Dispatch(new UIDisplayNoteCommand("环境光遮蔽已" +
(_gameSettings.IsAmbientOcclusionEnabled ? "开启(注意性能和耗电影响)" : "关闭") + ""));
});
#endif
CommandDispatcher<ICommand>.Instance.Dispatch(new UIDisplayNoteCommand("环境光遮蔽已" +
(_gameSettings.IsAmbientOcclusionEnabled ? "开启(注意性能和耗电影响)" : "关闭") + ""));
});
}
}
#if UNITY_STANDALONE
@@ -433,17 +439,19 @@ namespace Pal3.Dev
#if UNITY_IOS || UNITY_ANDROID
const string fullResolutionScaleText = "渲染分辨率:100%";
const string halfResolutionScaleText = "渲染分辨率:75%";
string GetResolutionButtonText() => Math.Abs(_gameSettings.ResolutionScale - 1f) < 0.01f
? fullResolutionScaleText
: halfResolutionScaleText;
const string quarterResolutionScaleText = "渲染分辨率:50%";
string GetResolutionButtonText() => Math.Abs(_gameSettings.ResolutionScale - 1f) < 0.01f ? fullResolutionScaleText :
Math.Abs(_gameSettings.ResolutionScale - 0.75f) < 0.01f ? halfResolutionScaleText : quarterResolutionScaleText;
CreateMenuButton(GetResolutionButtonText(), buttonTextUGUI => delegate
{
_gameSettings.ResolutionScale = Math.Abs(_gameSettings.ResolutionScale - 1f) < 0.01f ? 0.75f : 1f;
_gameSettings.ResolutionScale = Math.Abs(_gameSettings.ResolutionScale - 1f) < 0.01f ? 0.75f :
Math.Abs(_gameSettings.ResolutionScale - 0.75f) < 0.01f ? 0.5f : 1f;
buttonTextUGUI.text = GetResolutionButtonText();
CommandDispatcher<ICommand>.Instance.Dispatch(new UIDisplayNoteCommand("渲染分辨率已" +
(Math.Abs(_gameSettings.ResolutionScale - 1f) < 0.01f ? "调整为100%" : "调整为75%") + ""));
(Math.Abs(_gameSettings.ResolutionScale - 1f) < 0.01f ? "调整为100%" :
(Math.Abs(_gameSettings.ResolutionScale - 0.75f) < 0.01f ? "调整为75%" : "调整为50%"))));
});
#endif
@@ -503,6 +511,19 @@ namespace Pal3.Dev
(_gameSettings.SfxVolume == 0f ? "关闭" : "开启") + ""));
});
const string debugInfoEnabledText = "调试信息:开启";
const string debugInfoDisabledText = "调试信息:关闭";
string GetDebugInfoButtonText() => _gameSettings.IsDebugInfoEnabled ? debugInfoEnabledText : debugInfoDisabledText;
CreateMenuButton(GetDebugInfoButtonText(), buttonTextUGUI => delegate
{
_gameSettings.IsDebugInfoEnabled = !_gameSettings.IsDebugInfoEnabled;
buttonTextUGUI.text = GetDebugInfoButtonText();
CommandDispatcher<ICommand>.Instance.Dispatch(new UIDisplayNoteCommand("调试信息已" +
(_gameSettings.IsDebugInfoEnabled ? "开启" : "关闭") + ""));
});
CreateMenuButton("返回", _ => delegate
{
_gameSettings.SaveSettings();
@@ -515,9 +536,9 @@ namespace Pal3.Dev
SelectFirstButtonForEventSystem();
UpdateRectTransformWidthAndHeight(_backgroundTransform,
_contentGridLayoutGroup.cellSize.x + 100f,
_contentGridLayoutGroup.cellSize.x,
(_contentGridLayoutGroup.cellSize.y + _contentGridLayoutGroup.spacing.y) * _menuItems.Count
- _contentGridLayoutGroup.spacing.y + 100f);
- _contentGridLayoutGroup.spacing.y);
}
private void SetupSaveMenuButtons()
@@ -558,9 +579,9 @@ namespace Pal3.Dev
SelectFirstButtonForEventSystem();
UpdateRectTransformWidthAndHeight(_backgroundTransform,
_contentGridLayoutGroup.cellSize.x + 100f,
_contentGridLayoutGroup.cellSize.x,
(_contentGridLayoutGroup.cellSize.y + _contentGridLayoutGroup.spacing.y) * _menuItems.Count
- _contentGridLayoutGroup.spacing.y + 100f);
- _contentGridLayoutGroup.spacing.y);
}
private void SetupLoadMenuButtons()
@@ -628,9 +649,9 @@ namespace Pal3.Dev
SelectFirstButtonForEventSystem();
UpdateRectTransformWidthAndHeight(_backgroundTransform,
_contentGridLayoutGroup.cellSize.x + 100f,
_contentGridLayoutGroup.cellSize.x,
(_contentGridLayoutGroup.cellSize.y + _contentGridLayoutGroup.spacing.y) * _menuItems.Count
- _contentGridLayoutGroup.spacing.y + 100f);
- _contentGridLayoutGroup.spacing.y);
}
private void SetupStorySelectionButtons()
@@ -661,14 +682,15 @@ namespace Pal3.Dev
UpdateRectTransformWidthAndHeight(_backgroundTransform,
(_contentGridLayoutGroup.cellSize.x + _contentGridLayoutGroup.spacing.x) * _menuItems.Count
- _contentGridLayoutGroup.spacing.x + 100f,
_contentGridLayoutGroup.cellSize.y + 100f);
- _contentGridLayoutGroup.spacing.x,
_contentGridLayoutGroup.cellSize.y);
}
private void UpdateRectTransformWidthAndHeight(RectTransform rectTransform, float width, float height)
{
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
const float padding = 60f;
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width + padding);
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height + padding);
rectTransform.ForceUpdateRectTransforms();
}
@@ -69,6 +69,8 @@ namespace Pal3.GamePlay
private Vector3? _lastKnownPosition;
private Vector2Int? _lastKnownTilePosition;
private int? _lastKnownLayerIndex;
private bool _tilePositionPendingNotify;
private string _lastKnownPlayerActorAction = string.Empty;
private int _jumpableAreaEnterCount;
#if PAL3
@@ -156,7 +158,6 @@ namespace Pal3.GamePlay
if (!(position == _lastKnownPosition && layerIndex == _lastKnownLayerIndex))
{
_lastKnownPosition = position;
Vector2Int tilePosition = _playerActorMovementController.GetTilePosition();
if (!(tilePosition == _lastKnownTilePosition && layerIndex == _lastKnownLayerIndex))
{
@@ -165,6 +166,12 @@ namespace Pal3.GamePlay
PlayerActorTilePositionChanged(layerIndex, tilePosition, !isPlayerInControl);
}
}
else if (_tilePositionPendingNotify)
{
Vector2Int tilePosition = _playerActorMovementController.GetTilePosition();
PlayerActorTilePositionChanged(layerIndex, tilePosition, !isPlayerInControl);
_tilePositionPendingNotify = false;
}
_lastKnownLayerIndex = layerIndex;
@@ -276,14 +283,15 @@ namespace Pal3.GamePlay
private void ReadInputAndMovePlayerIfNeeded()
{
var movement = _inputActions.Gameplay.Movement.ReadValue<Vector2>();
if (movement == Vector2.zero) return;
if (movement.magnitude <= 0.01f) return;
MovementMode movementMode = movement.magnitude < 0.7f ? MovementMode.Walk : MovementMode.Run;
ActorActionType movementAction = movementMode == MovementMode.Walk ? ActorActionType.Walk : ActorActionType.Run;
_playerActorMovementController.CancelMovement();
Transform cameraTransform = _camera.transform;
Vector3 inputDirection = cameraTransform.forward * movement.y +
cameraTransform.right * movement.x;
Vector2 normalizedDirection = movement.normalized;
Vector3 inputDirection = cameraTransform.forward * normalizedDirection.y +
cameraTransform.right * normalizedDirection.x;
MovementResult result = PlayerActorMoveTowards(inputDirection, movementMode);
_playerActorActionController.PerformAction(result == MovementResult.Blocked
? ActorActionType.Stand
@@ -1162,6 +1170,7 @@ namespace Pal3.GamePlay
_lastKnownPosition = currentScene.GetTilemap().GetWorldPosition(
new Vector2Int(command.TileXPosition,command.TileYPosition), currentLayerIndex);
_tilePositionPendingNotify = true;
}
}
@@ -1229,6 +1238,8 @@ namespace Pal3.GamePlay
#if PAL3
CommandDispatcher<ICommand>.Instance.Dispatch(new LongKuiSwitchModeCommand(_longKuiLastKnownMode));
#endif
_tilePositionPendingNotify = true;
}
private void DisposeGamePlayIndicators()
@@ -1261,6 +1272,7 @@ namespace Pal3.GamePlay
_lastKnownTilePosition = null;
_lastKnownLayerIndex = null;
_lastKnownPlayerActorAction = string.Empty;
_tilePositionPendingNotify = false;
#if PAL3
_longKuiLastKnownMode = 0;
@@ -219,11 +219,11 @@ namespace Pal3.GameSystem
}
float width = (_bigMapCanvasGridLayoutGroup.cellSize.x + _bigMapCanvasGridLayoutGroup.spacing.x) *
_selectionButtons.Count - _bigMapCanvasGridLayoutGroup.spacing.x + 80f;
float height = _bigMapCanvasGridLayoutGroup.cellSize.y + 100f;
_selectionButtons.Count - _bigMapCanvasGridLayoutGroup.spacing.x;
float height = _bigMapCanvasGridLayoutGroup.cellSize.y;
_bigMapBackgroundTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
_bigMapBackgroundTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
_bigMapBackgroundTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width + 50f);
_bigMapBackgroundTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height + 60f);
_bigMapBackgroundTransform.ForceUpdateRectTransforms();
_bigMapCanvas.alpha = 1f;
@@ -39,7 +39,7 @@ namespace Pal3.GameSystem
ICommandExecutor<ResetGameStateCommand>
{
private const float LIMIT_TIME_DIALOGUE_PLAYER_MAX_REACTION_TIME_IN_SECONDS = 4f;
private const float DIALOGUE_SHOW_HIDE_ANIMATION_DURATION = 0.1f;
private const float DIALOGUE_SHOW_HIDE_ANIMATION_DURATION = 0.12f;
private const float DIALOGUE_SHOW_HIDE_ANIMATION_Y_OFFSET = -30f;
private const float DIALOGUE_FLASHING_ANIMATION_DURATION = 0.5f;
@@ -56,6 +56,7 @@ namespace Pal3.GameSystem
private Canvas _dialogueSelectionButtonsCanvas;
private GameObject _dialogueSelectionButtonPrefab;
private Image _dialogueBackgroundImage;
private RoundedFrostedGlassImage _backgroundFrostedGlassImage;
private Image _avatarImageLeft;
private Image _avatarImageRight;
@@ -100,6 +101,8 @@ namespace Pal3.GameSystem
_dialogueCanvasGroup = Requires.IsNotNull(dialogueCanvasGroup, nameof(dialogueCanvasGroup));
_dialogueBackgroundImage = Requires.IsNotNull(dialogueBackgroundImage, nameof(dialogueBackgroundImage));
_backgroundFrostedGlassImage = Requires.IsNotNull(dialogueBackgroundImage.GetComponent<RoundedFrostedGlassImage>(),
nameof(dialogueBackgroundImage));
_avatarImageLeft = Requires.IsNotNull(avatarImageLeft, nameof(avatarImageLeft));
_avatarImageRight = Requires.IsNotNull(avatarImageRight, nameof(avatarImageRight));
@@ -330,35 +333,41 @@ namespace Pal3.GameSystem
private IEnumerator PlayDialogueBackgroundFlashingAnimationAsync(float duration, CancellationToken cancellationToken)
{
var startTime = Time.realtimeSinceStartup;
float startTime = Time.realtimeSinceStartup;
float initialBlurAmount = _backgroundFrostedGlassImage.blurAmount;
float initialTransparency = _backgroundFrostedGlassImage.transparency;
const float minThresholdPercentage = 0.65f;
while (!cancellationToken.IsCancellationRequested)
{
yield return CoreAnimation.EnumerateValueAsync(1f, 0.2f, DIALOGUE_FLASHING_ANIMATION_DURATION / 2f,
yield return CoreAnimation.EnumerateValueAsync(1f, minThresholdPercentage, DIALOGUE_FLASHING_ANIMATION_DURATION / 2f,
AnimationCurveType.Linear, value =>
{
_dialogueCanvasGroup.alpha = value;
_backgroundFrostedGlassImage.SetMaterialBlurAmount(initialBlurAmount * value);
_backgroundFrostedGlassImage.SetMaterialTransparency(initialTransparency * value);
}, cancellationToken);
if (Time.realtimeSinceStartup - startTime >= duration) break;
yield return CoreAnimation.EnumerateValueAsync(0.2f, 1f, DIALOGUE_FLASHING_ANIMATION_DURATION / 2f,
yield return CoreAnimation.EnumerateValueAsync(minThresholdPercentage, 1f, DIALOGUE_FLASHING_ANIMATION_DURATION / 2f,
AnimationCurveType.Linear, value =>
{
_dialogueCanvasGroup.alpha = value;
_backgroundFrostedGlassImage.SetMaterialBlurAmount(initialBlurAmount * value);
_backgroundFrostedGlassImage.SetMaterialTransparency(initialTransparency * value);
}, cancellationToken);
if (Time.realtimeSinceStartup - startTime >= duration) break;
}
_dialogueCanvasGroup.alpha = 1f;
_backgroundFrostedGlassImage.SetMaterialBlurAmount(initialBlurAmount);
_backgroundFrostedGlassImage.SetMaterialTransparency(initialTransparency);
}
private IEnumerator PlayDialogueBackgroundPopAnimationAsync(bool showDialogue)
{
const float yOffset = DIALOGUE_SHOW_HIDE_ANIMATION_Y_OFFSET;
Transform dialogueCanvasGroupTransform = _dialogueCanvasGroup.transform;
Vector3 finalPosition = dialogueCanvasGroupTransform.position;
Vector3 finalPosition = dialogueCanvasGroupTransform.localPosition;
Vector3 startPosition = finalPosition + new Vector3(0f, yOffset, 0);
float startValue = showDialogue ? 0f : 1f;
@@ -366,17 +375,23 @@ namespace Pal3.GameSystem
if (showDialogue)
{
dialogueCanvasGroupTransform.position = startPosition;
dialogueCanvasGroupTransform.localPosition = startPosition;
}
var initialBlurAmount = _backgroundFrostedGlassImage.blurAmount;
var initialTransparency = _backgroundFrostedGlassImage.transparency;
yield return CoreAnimation.EnumerateValueAsync(startValue, endValue, DIALOGUE_SHOW_HIDE_ANIMATION_DURATION,
AnimationCurveType.Linear, value =>
AnimationCurveType.EaseIn, value =>
{
_dialogueCanvasGroup.transform.position = finalPosition + new Vector3(0f, yOffset * (1 - value), 0);
_dialogueCanvasGroup.transform.localPosition = finalPosition + new Vector3(0f, yOffset * (1 - value), 0);
_dialogueCanvasGroup.alpha = value;
_backgroundFrostedGlassImage.SetMaterialBlurAmount(initialBlurAmount * value);
_backgroundFrostedGlassImage.SetMaterialTransparency(initialTransparency * value);
});
_backgroundFrostedGlassImage.SetMaterialBlurAmount(initialBlurAmount);
_backgroundFrostedGlassImage.SetMaterialTransparency(initialTransparency);
_dialogueCanvasGroup.transform.position = finalPosition; // Always set to final position
_dialogueCanvasGroup.transform.localPosition = finalPosition; // Always set to final position
_dialogueCanvasGroup.alpha = showDialogue ? 1f : 0f;
}
@@ -423,10 +438,10 @@ namespace Pal3.GameSystem
"另外,画面\\i左下角\\r那东西叫作\\i“司南”\\r,只要点一下,就能看到地图,认清方向了。"))
#endif
{
text = $"知道吗?您现在玩的{GameConstants.AppNameCNFull}是由\\i柒才\\r使用C#/Unity开发的复刻版,免费开源且支持全平台。" +
text = $"知道吗?您现在玩的{GameConstants.AppNameCNFull}是由\\i柒才\\r使用C#/Unity开发(完全重写)的复刻版,免费开源且支持全平台(Win/Mac/Linux/iOS/Android)。" +
"如果您是花钱得到的,那么恭喜您成为盗版游戏的受害者。" +
$"当前游戏还在开发中,包括战斗在内的很多功能尚未实现,请耐心等待,也欢迎加入本游戏QQ群与作者联系:\\i252315306\\r," +
"或者您也可以在B站关注Up主\\i@柒才\\r!";
$"当前游戏还在开发中,包括战斗在内的很多功能尚未实现,请耐心等待,也欢迎加入本游戏QQ群与作者联系或下载最新版:\\i252315306\\r," +
"您也可以在B站关注Up主\\i@柒才\\r获取最新开发信息!另外,全平台都支持手柄哦~";
}
var formattedText = text.Replace("\\n", "\n");
@@ -13,6 +13,8 @@ namespace Pal3.GameSystem
using Core.Animation;
using Core.Utils;
using MetaData;
using Settings;
using State;
using TMPro;
using UnityEngine;
@@ -20,11 +22,14 @@ namespace Pal3.GameSystem
public sealed class InformationManager : MonoBehaviour,
ICommandExecutor<UIDisplayNoteCommand>,
ICommandExecutor<UIShowDealerMenuCommand>,
ICommandExecutor<SceneLeavingCurrentSceneNotification>
ICommandExecutor<SceneLeavingCurrentSceneNotification>,
ICommandExecutor<SettingChangedNotification>,
ICommandExecutor<GameStateChangedNotification>
{
private const float NOTE_LAST_TIME_IN_SECONDS = 2f;
private const float NOTE_LAST_TIME_IN_SECONDS = 2.5f;
private const float NOTE_DISAPPEAR_ANIMATION_TIME_IN_SECONDS = 1f;
private GameSettings _gameSettings;
private CanvasGroup _noteCanvasGroup;
private TextMeshProUGUI _noteText;
private Coroutine _noteAnimation;
@@ -38,8 +43,14 @@ namespace Pal3.GameSystem
private bool _isNoteShowingEnabled = true;
public void Init(CanvasGroup noteCanvasGroup, TextMeshProUGUI noteText, TextMeshProUGUI debugInfo)
private string _defaultText;
public void Init(GameSettings gameSettings,
CanvasGroup noteCanvasGroup,
TextMeshProUGUI noteText,
TextMeshProUGUI debugInfo)
{
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
_noteCanvasGroup = Requires.IsNotNull(noteCanvasGroup, nameof(noteCanvasGroup));
_noteText = Requires.IsNotNull(noteText, nameof(noteText));
_debugInfo = Requires.IsNotNull(debugInfo, nameof(debugInfo));
@@ -47,10 +58,10 @@ namespace Pal3.GameSystem
_noteCanvasGroup.alpha = 0f;
_heapSize = GC.GetTotalMemory(false) / (1024f * 1024f);
_heapSizeLastQueryTime = Time.realtimeSinceStartupAsDouble;
}
private void OnEnable()
{
_defaultText = $"{GameConstants.ContactInfo} v{Application.version} {GameConstants.TestingType}\n";
_debugInfo.SetText(_defaultText);
#if UNITY_2022_1_OR_NEWER
var refreshRate = (int)Screen.currentResolution.refreshRateRatio.value;
#else
@@ -64,17 +75,20 @@ namespace Pal3.GameSystem
#endif
var deviceInfo =
$"Device: {SystemInfo.deviceModel.Trim()} OS: {SystemInfo.operatingSystem.Trim()}\n" +
$"CPU: {SystemInfo.processorType.Trim()} ({SystemInfo.processorCount} vCores)\n" +
$"GPU: {SystemInfo.graphicsDeviceName.Trim()} ({SystemInfo.graphicsDeviceType})\n" +
$"RAM: {SystemInfo.systemMemorySize / 1024f:0.0} GB VRAM: {SystemInfo.graphicsMemorySize / 1024f:0.0} GB\n" +
$"{GameConstants.ContactInfo}\n" +
$"Version: v{Application.version} Alpha (Unity {Application.unityVersion} {scriptingBackend})\n";
$"Device: {SystemInfo.deviceModel.Trim()} OS: {SystemInfo.operatingSystem.Trim()}\n" +
$"CPU: {SystemInfo.processorType.Trim()} ({SystemInfo.processorCount} vCores)\n" +
$"GPU: {SystemInfo.graphicsDeviceName.Trim()} ({SystemInfo.graphicsDeviceType})\n" +
$"RAM: {SystemInfo.systemMemorySize / 1024f:0.0} GB VRAM: {SystemInfo.graphicsMemorySize / 1024f:0.0} GB\n" +
$"Version: v{Application.version} {GameConstants.TestingType} (Unity {Application.unityVersion} {scriptingBackend})\n";
_debugInfoStringFormat = deviceInfo + "Heap size: {0:0.00} MB\n" + "{3:0.} fps ({1}x{2}, " + refreshRate + "Hz)";
_debugInfoStringFormat = _defaultText + deviceInfo +
"Heap size: {0:0.00} MB\n" + "{3:0.} fps ({1}x{2}, " + refreshRate + "Hz)";
_fpsCounter = GetComponent<FpsCounter>();
}
private void OnEnable()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
@@ -86,6 +100,8 @@ namespace Pal3.GameSystem
private void Update()
{
if (!_gameSettings.IsDebugInfoEnabled) return;
var currentTime = Time.realtimeSinceStartupAsDouble;
if (currentTime - _heapSizeLastQueryTime > 5f)
{
@@ -158,5 +174,28 @@ namespace Pal3.GameSystem
{
Execute(new UIDisplayNoteCommand("交易功能暂未开启"));
}
public void Execute(SettingChangedNotification command)
{
if (command.SettingName is nameof(GameSettings.IsDebugInfoEnabled))
{
if (!_gameSettings.IsDebugInfoEnabled)
{
_debugInfo.SetText(_defaultText);
}
}
}
public void Execute(GameStateChangedNotification command)
{
if (command.NewState == GameState.VideoPlaying)
{
_debugInfo.enabled = false;
}
else if (command.PreviousState == GameState.VideoPlaying)
{
_debugInfo.enabled = true;
}
}
}
}
@@ -0,0 +1,204 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.GameSystem
{
using System;
using Command;
using Command.InternalCommands;
using Core.DataReader.Nav;
using Core.DataReader.Scn;
using Core.Utils;
using Scene;
using State;
using UnityEngine;
using UnityEngine.UI;
public sealed class MiniMapManager : MonoBehaviour,
ICommandExecutor<PlayerActorTilePositionUpdatedNotification>,
ICommandExecutor<SceneLeavingCurrentSceneNotification>,
ICommandExecutor<ScenePostLoadingNotification>,
ICommandExecutor<GameStateChangedNotification>,
ICommandExecutor<ResetGameStateCommand>
{
private const float MINIMAP_SCALE = 2.5f;
private Camera _mainCamera;
private SceneManager _sceneManager;
private CanvasGroup _miniMapCanvasGroup;
private RectTransform _miniMapRectTransform;
private float _miniMapWidth;
private Image _miniMapImage;
private Texture2D[] _miniMapTextures;
private Sprite[] _miniMapSprites;
private Tilemap _currentTilemap;
private int _currentLayerIndex = -1;
private GameState _currentGameState = GameState.MenuShowing;
public void Init(Camera mainCamera,
SceneManager sceneManager,
CanvasGroup miniMapCanvasGroup,
Image miniMapImage)
{
_mainCamera = Requires.IsNotNull(mainCamera, nameof(mainCamera));
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
_miniMapCanvasGroup = Requires.IsNotNull(miniMapCanvasGroup, nameof(miniMapCanvasGroup));
_miniMapImage = Requires.IsNotNull(miniMapImage, nameof(miniMapImage));
_miniMapImage.preserveAspect = true;
_miniMapRectTransform = Requires.IsNotNull(_miniMapCanvasGroup.GetComponent<RectTransform>(), nameof(miniMapImage));
_miniMapWidth = _miniMapRectTransform.rect.width;
_miniMapCanvasGroup.alpha = 0f;
}
private void OnEnable()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private void OnDisable()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
Dispose();
}
private void Update()
{
_miniMapRectTransform.localRotation = Quaternion.Euler(0, 0, _mainCamera.transform.eulerAngles.y + 180f);
}
private Texture2D CreateMiniMapTexture(NavTileLayer layer)
{
Color[] colors = new Color[layer.Width * layer.Height];
for (var i = 0; i < layer.Width; i++)
{
for (int j = 0; j < layer.Height; j++)
{
var index = i + j * layer.Width;
NavTile tile = layer.Tiles[index];
// NOTE: the texture is flipped vertically compared to the tilemap space
var colorIndex = i + (layer.Height - j - 1) * layer.Width;
colors[colorIndex] = tile.DistanceToNearestObstacle switch
{
0 => new Color(0f, 0f, 0f, 0f),
1 => new Color(1f, 0.9f, 0.1f, 0.7f),
#if PAL3
_ => new Color(30f / 255f, 75f / 255f, 140f / 255f, 100f / 255f),
#elif PAL3A
_ => new Color(160f / 255f, 40f / 255f, 110f / 255f, 100f / 255f),
#endif
};
}
}
Texture2D texture = new Texture2D(layer.Width, layer.Height, TextureFormat.RGBA32, mipChain: false);
texture.SetPixels(colors);
texture.Apply(false);
return texture;
}
public void Execute(PlayerActorTilePositionUpdatedNotification command)
{
if (_currentTilemap == null) return;
NavTileLayer layer = _currentTilemap.GetLayer(command.LayerIndex);
// Swap the sprite if the player has moved to another layer
if (_currentLayerIndex != command.LayerIndex)
{
_currentLayerIndex = command.LayerIndex;
_miniMapImage.sprite = _miniMapSprites[_currentLayerIndex];
float scale = Mathf.Max(layer.Width, layer.Height) / _miniMapWidth * MINIMAP_SCALE;
_miniMapImage.rectTransform.localScale = new Vector3(scale, scale, 1f);
}
// NOTE: the texture is flipped vertically compared to the tilemap space
Vector2 playerPixelPosition = new Vector2(command.Position.x, layer.Height - command.Position.y - 1);
Vector2 textureCenter = new Vector2(layer.Width / 2f, layer.Height / 2f);
Vector2 offset = playerPixelPosition - textureCenter;
_miniMapImage.rectTransform.anchoredPosition = -offset * MINIMAP_SCALE;
if (_currentGameState == GameState.Gameplay &&
_miniMapCanvasGroup.alpha == 0f)
{
_miniMapCanvasGroup.alpha = 1f;
}
}
public void Execute(ResetGameStateCommand command)
{
_miniMapCanvasGroup.alpha = 0f;
}
public void Execute(ScenePostLoadingNotification command)
{
if (command.NewSceneInfo.SceneType == ScnSceneType.InDoor) return;
_currentTilemap = _sceneManager.GetCurrentScene().GetTilemap();
_miniMapTextures = new Texture2D[_currentTilemap.GetLayerCount()];
_miniMapSprites = new Sprite[_currentTilemap.GetLayerCount()];
for (var i = 0; i < _currentTilemap.GetLayerCount(); i++)
{
NavTileLayer tileLayer = _currentTilemap.GetLayer(i);
_miniMapTextures[i] = CreateMiniMapTexture(tileLayer);
_miniMapSprites[i] = Sprite.Create(_miniMapTextures[i],
new Rect(0, 0, tileLayer.Width, tileLayer.Height),
new Vector2(0.5f, 0.5f));
}
_currentLayerIndex = -1;
}
private void Dispose()
{
_miniMapCanvasGroup.alpha = 0f;
if (_miniMapSprites != null)
{
foreach (var sprite in _miniMapSprites)
{
Destroy(sprite);
}
_miniMapSprites = null;
}
if (_miniMapTextures != null)
{
foreach (var texture in _miniMapTextures)
{
Destroy(texture);
}
_miniMapTextures = null;
}
_currentTilemap = null;
_miniMapImage.sprite = null;
_currentLayerIndex = -1;
}
public void Execute(SceneLeavingCurrentSceneNotification command)
{
Dispose();
}
public void Execute(GameStateChangedNotification command)
{
_currentGameState = command.NewState;
_miniMapCanvasGroup.alpha = command.NewState == GameState.Gameplay && _miniMapImage.sprite != null
? 1f : 0f;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 038ba9e665d509e469be7db0de04a0b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -17,11 +17,13 @@ namespace Pal3.GameSystem
using Core.Utils;
using Data;
using MetaData;
using State;
using TMPro;
public sealed class TaskManager :
ICommandExecutor<TaskOpenCommand>,
ICommandExecutor<TaskCompleteCommand>,
ICommandExecutor<GameStateChangedNotification>,
ICommandExecutor<ResetGameStateCommand>
{
private const string TASK_DEFINITION_FILE_NAME = "task.txt";
@@ -89,6 +91,18 @@ namespace Pal3.GameSystem
_completedTasks.Add(command.TaskId);
}
public void Execute(GameStateChangedNotification command)
{
if (command.NewState == GameState.VideoPlaying)
{
_taskInfoText.enabled = false;
}
else if (command.PreviousState == GameState.VideoPlaying)
{
_taskInfoText.enabled = true;
}
}
public void Execute(ResetGameStateCommand command)
{
_openedTasks.Clear();
@@ -30,6 +30,7 @@ namespace Pal3.MetaData
private const string SCENE_FOLDER_NAME = "scene";
private const string EFFECT_FOLDER_NAME = "effect";
private const string UI_FOLDER_NAME = "ui";
private const string UI_LIBRARY_FOLDER_NAME = "UILib";
private const string BIG_MAP_FOLDER_NAME = "BigMap";
private const string OBJECT_FOLDER_NAME = "object";
private const string COMBAT_DATA_FOLDER_NAME = "cbdata";
@@ -128,9 +129,12 @@ namespace Pal3.MetaData
public static readonly string BigMapSceFileVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{UI_FOLDER_NAME}{DirSeparator}{BIG_MAP_FOLDER_NAME}{DirSeparator}BigMap.sce";
public static readonly string UISceneFolderVirtualPath =
public static readonly string UISceneFolderVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{UI_FOLDER_NAME}{DirSeparator}scene{DirSeparator}";
public static readonly string UILibFolderVirtualPath =
$"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{UI_FOLDER_NAME}{DirSeparator}{UI_LIBRARY_FOLDER_NAME}{DirSeparator}";
public static readonly string[] SkyBoxTexturePathFormat =
{
EffectScnFolderVirtualPath + "skybox" + DirSeparator + "{0:00}" + DirSeparator + "{0:00}_lf.tga",
@@ -23,7 +23,9 @@ namespace Pal3.MetaData
public const string AppIdentifier = AppIdentifierPrefix + "." + AppName;
public const string ContactInfo = AppNameCNShort + "复刻版讨论群:252315306 B站@柒才";
public const string ContactInfo = AppNameCNFull + "(复刻版) " + "讨论Q群:252315306 B站@柒才";
public const string TestingType = "Alpha";
public const string GithubRepoOwner = "0x7c13";
+85 -4
View File
@@ -14,6 +14,7 @@ namespace Pal3
using Camera;
using Command;
using Command.SceCommands;
using Core.DataLoader;
using Core.DataReader.Scn;
using Core.FileSystem;
using Core.Services;
@@ -34,6 +35,9 @@ namespace Pal3
using UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.UI;
using UnityEngine.Video;
@@ -64,6 +68,8 @@ namespace Pal3
[SerializeField] private CanvasGroup noteCanvasGroup;
[SerializeField] private TextMeshProUGUI noteText;
[SerializeField] private TextMeshProUGUI taskInfoText;
[SerializeField] private CanvasGroup miniMapCanvasGroup;
[SerializeField] private Image miniMapImage;
// Dialogue
[SerializeField] private CanvasGroup dialogueCanvasGroup;
@@ -107,6 +113,10 @@ namespace Pal3
[SerializeField] private PostProcessVolume postProcessVolume;
[SerializeField] private PostProcessLayer postProcessLayer;
// LOGO
[SerializeField] private GameObject logoCanvas;
[SerializeField] private Image logoImage;
// Global texture cache store
private readonly TextureCache _textureCache = new ();
@@ -131,6 +141,7 @@ namespace Pal3
private EffectManager _effectManager;
// Game components
private MiniMapManager _miniMapManager;
private TouchControlUIManager _touchControlUIManager;
private PlayerGamePlayController _playerGamePlayController;
private TeamManager _teamManager;
@@ -154,6 +165,9 @@ namespace Pal3
private TaskManager _taskManager;
#endif
// Utility components
private RenderingSettingsManager _renderingSettingsManager;
// Dev tools
private MazeSkipper _mazeSkipper;
private MainMenu _mainMenu;
@@ -255,9 +269,13 @@ namespace Pal3
ServiceLocator.Instance.Register(_audioManager);
_informationManager = gameObject.AddComponent<InformationManager>();
_informationManager.Init(noteCanvasGroup, noteText, debugInfo);
_informationManager.Init(_gameSettings, noteCanvasGroup, noteText, debugInfo);
ServiceLocator.Instance.Register(_informationManager);
_miniMapManager = gameObject.AddComponent<MiniMapManager>();
_miniMapManager.Init(mainCamera, _sceneManager, miniMapCanvasGroup, miniMapImage);
ServiceLocator.Instance.Register(_miniMapManager);
_dialogueManager = gameObject.AddComponent<DialogueManager>();
_dialogueManager.Init(_gameResourceProvider,
_gameStateManager,
@@ -344,6 +362,10 @@ namespace Pal3
mainCamera);
ServiceLocator.Instance.Register(_mainMenu);
_renderingSettingsManager = gameObject.AddComponent<RenderingSettingsManager>();
_renderingSettingsManager.Init(_gameSettings);
ServiceLocator.Instance.Register(_renderingSettingsManager);
DebugLogManager.Instance.OnLogWindowShown += OnDebugWindowShown;
DebugLogManager.Instance.OnLogWindowHidden += OnDebugWindowHidden;
@@ -362,15 +384,72 @@ namespace Pal3
Debug.Log($"[{nameof(Pal3)}] Game started.");
_mainMenu.ShowInitView();
_mainMenu.ShowMenu();
// Show logo image.
logoImage.sprite = _gameResourceProvider.GetLogoSprite();
logoImage.preserveAspect = true;
#if PAL3
logoImage.transform.localScale = new Vector3(0.85f, 0.85f, 1f);
#elif PAL3A
logoImage.transform.localScale = new Vector3(1.25f, 1.25f, 1f);
#endif
logoImage.enabled = true;
// Listen to input events to detect any key or touch press
// to hide the logo and show the main menu.
InputSystem.onEvent += OnInputEvent;
#if !UNITY_EDITOR
// Check latest version and notify if a newer version is found.
StartCoroutine(CheckLatestVersionAndNotify());
StartCoroutine(CheckLatestVersionAndNotifyAsync());
#endif
}
private IEnumerator CheckLatestVersionAndNotify()
private void OnInputEvent(InputEventPtr eventPtr, InputDevice device)
{
if (!eventPtr.IsA<StateEvent>() && !eventPtr.IsA<DeltaStateEvent>()) return;
var controls = device.allControls;
var buttonPressPoint = InputSystem.settings.defaultButtonPressPoint;
foreach (InputControl control in controls)
{
if (control.synthetic || control.noisy) continue;
switch (control)
{
case TouchControl:
OnAnyKeyOrTouchTriggered();
return;
case ButtonControl buttonControl when
buttonControl.ReadValueFromEvent(eventPtr, out var value) &&
value >= buttonPressPoint:
OnAnyKeyOrTouchTriggered();
return;
}
}
return;
void OnAnyKeyOrTouchTriggered()
{
InputSystem.onEvent -= OnInputEvent; // Only listen to the first touch event.
Destroy(logoImage.sprite);
Destroy(logoCanvas);
StartCoroutine(ShowMainMenuAfterLogoAsync());
}
}
private IEnumerator ShowMainMenuAfterLogoAsync()
{
// Wait one frame to make sure the logo image is destroyed.
// Also make sure InputManager captures the active input device, so
// that the main menu can auto-select the first button if necessary.
yield return null;
_mainMenu.ShowMenu();
}
private IEnumerator CheckLatestVersionAndNotifyAsync()
{
yield return new WaitForSeconds(1f);
yield return GithubReleaseVersionFetcher.GetLatestReleaseVersionAsync(GameConstants.GithubRepoOwner, GameConstants.GithubRepoName,
@@ -424,6 +503,7 @@ namespace Pal3
Destroy(_cameraManager);
Destroy(_audioManager);
Destroy(_informationManager);
Destroy(_miniMapManager);
Destroy(_dialogueManager);
Destroy(_hotelManager);
Destroy(_bigMapManager);
@@ -431,6 +511,7 @@ namespace Pal3
Destroy(_postProcessManager);
Destroy(_effectManager);
Destroy(_mainMenu);
Destroy(_renderingSettingsManager);
if (_cursorManager != null)
{
@@ -14,7 +14,7 @@ namespace Pal3.Scene.SceneObjects
[ScnSceneObject(ScnSceneObjectType.Collectable)]
public sealed class CollectableObject : SceneObject
{
private const float MAX_INTERACTION_DISTANCE = 3f;
private const float MAX_INTERACTION_DISTANCE = 3.5f;
public CollectableObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
: base(objectInfo, sceneInfo)
@@ -77,7 +77,7 @@ namespace Pal3.Scene.SceneObjects
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorActivateCommand(ActorConstants.PlayerActorVirtualID, 1));
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorSetTilePositionCommand(-1,
new ActorSetTilePositionCommand(ActorConstants.PlayerActorVirtualID,
ObjectInfo.Parameters[0],
ObjectInfo.Parameters[1]));
CommandDispatcher<ICommand>.Instance.Dispatch(
@@ -102,7 +102,7 @@ namespace Pal3.Scene.SceneObjects
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorActivateCommand(ActorConstants.PlayerActorVirtualID, 1));
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorSetWorldPositionCommand(-1, worldPosition.x, worldPosition.z));
new ActorSetWorldPositionCommand(ActorConstants.PlayerActorVirtualID, worldPosition.x, worldPosition.z));
CommandDispatcher<ICommand>.Instance.Dispatch(
new CameraFollowPlayerCommand(1));
#endif
@@ -16,7 +16,7 @@ namespace Pal3.Scene.SceneObjects
[ScnSceneObject(ScnSceneObjectType.SlideWay)]
public sealed class SlideWayObject : SceneObject
{
private const uint ACTOR_SLIDE_SPEED = 300;
private const uint ACTOR_SLIDE_SPEED = 500;
private TilemapTriggerController _triggerController;
private bool _isInteractionInProgress;
+5
View File
@@ -78,6 +78,11 @@ namespace Pal3.Scene
return currentLayer.Tiles[position.x + position.y * currentLayer.Width];
}
public NavTileLayer GetLayer(int layerIndex)
{
return _navFile.TileLayers[layerIndex];
}
public bool IsPositionInsidePortalArea(Vector3 position, int layerIndex)
{
Vector2Int tilePosition = GetTilePosition(position, layerIndex);
+27 -57
View File
@@ -17,25 +17,16 @@ namespace Pal3.Settings
using IngameDebugConsole;
using MetaData;
using UnityEngine;
using UnityEngine.Rendering;
public sealed class GameSettings : SettingsBase, IDisposable
{
private static Resolution _nativeResolution;
public bool IsOpenSourceVersion { get; }
public GameSettings(ITransactionalKeyValueStore settingsStore, bool isOpenSourceVersion) : base(settingsStore)
{
IsOpenSourceVersion = isOpenSourceVersion;
#if UNITY_STANDALONE
// Last resolution is the full native resolution on desktop platforms
_nativeResolution = Screen.resolutions[^1];
#else
// Current resolution is the full native resolution on other platforms
_nativeResolution = Screen.currentResolution;
#endif
InitDefaultSettings();
PropertyChanged += OnPropertyChanged;
@@ -54,6 +45,8 @@ namespace Pal3.Settings
"设置音效音量设定(0.0:静音,1.0:最大音量)", _ => SfxVolume = _);
DebugLogConsole.AddCommand<bool>("Settings.IsVoiceOverEnabled",
"设置角色配音设定(true:开启,false:关闭)", _ => IsVoiceOverEnabled = _);
DebugLogConsole.AddCommand<bool>("Settings.IsDebugInfoEnabled",
"设置调试信息显示设定(true:开启,false:关闭)", _ => IsDebugInfoEnabled = _);
DebugLogConsole.AddCommand<string>("Settings.GameDataFolderPath",
"设置自定义游戏数据文件夹路径", _ => GameDataFolderPath = _);
@@ -75,44 +68,8 @@ namespace Pal3.Settings
private void OnPropertyChanged(object sender, PropertyChangedEventArgs args)
{
string settingName = args.PropertyName;
if (settingName == nameof(VSyncCount))
{
QualitySettings.vSyncCount = VSyncCount;
}
else if (settingName == nameof(AntiAliasing))
{
QualitySettings.antiAliasing = AntiAliasing;
}
else if (settingName == nameof(TargetFrameRate))
{
Application.targetFrameRate = TargetFrameRate;
}
else if (settingName == nameof(ResolutionScale))
{
// Let OS to handle and persist the resolution change
// on Windows, macOS and Linux.
#if !UNITY_STANDALONE
Screen.SetResolution(
(int) (_nativeResolution.width * ResolutionScale),
(int) (_nativeResolution.height * ResolutionScale),
Screen.fullScreenMode);
#else
if (Screen.fullScreenMode
is FullScreenMode.ExclusiveFullScreen
or FullScreenMode.FullScreenWindow)
{
Screen.SetResolution(
(int) (_nativeResolution.width * ResolutionScale),
(int) (_nativeResolution.height * ResolutionScale),
Screen.fullScreenMode);
}
#endif
}
// Broadcast the setting change notification.
CommandDispatcher<ICommand>.Instance.Dispatch(new SettingChangedNotification(settingName));
CommandDispatcher<ICommand>.Instance.Dispatch(new SettingChangedNotification(args.PropertyName));
}
private void InitDefaultSettings()
@@ -135,8 +92,8 @@ namespace Pal3.Settings
}
else
{
// Disable v-sync on desktop devices by default
VSyncCount = Utility.IsDesktopDevice() ? 0 : 1;
// Disable v-sync by default
VSyncCount = 0;
}
if (SettingsStore.TryGet(nameof(AntiAliasing), out int antiAliasing))
@@ -171,9 +128,8 @@ namespace Pal3.Settings
}
else
{
// Full resolution by default unless on Android with SDK version lower than 23 (old devices)
// SDK version 23 is Android 6.0 Marshmallow
ResolutionScale = Utility.IsAndroidDeviceAndSdkVersionLowerThanOrEqualTo(23) ? 0.75f : 1.0f;
// Full resolution by default on legacy mobile devices
ResolutionScale = Utility.IsLegacyMobileDevice() ? 0.75f : 1.0f;
}
#if UNITY_STANDALONE
@@ -222,7 +178,8 @@ namespace Pal3.Settings
else
{
// Enable realtime lighting and shadows by default
IsRealtimeLightingAndShadowsEnabled = true;
// unless the device is a legacy mobile device
IsRealtimeLightingAndShadowsEnabled = !Utility.IsLegacyMobileDevice();
}
}
@@ -233,11 +190,15 @@ namespace Pal3.Settings
// thus AO will not work anyway
IsAmbientOcclusionEnabled = false;
}
else if (Application.platform == RuntimePlatform.Android &&
SystemInfo.graphicsDeviceType != GraphicsDeviceType.Vulkan)
{
// AO is only supported on Android with Vulkan
// Disable AO on Android with OpenGL ES by default
IsAmbientOcclusionEnabled = false;
}
else
{
#if UNITY_ANDROID // AO not working well with OpenGL on Android
IsAmbientOcclusionEnabled = false;
#else
if (SettingsStore.TryGet(nameof(IsAmbientOcclusionEnabled), out bool isAmbientOcclusionEnabled))
{
IsAmbientOcclusionEnabled = isAmbientOcclusionEnabled;
@@ -247,7 +208,6 @@ namespace Pal3.Settings
// Enable ambient occlusion by default on desktop devices
IsAmbientOcclusionEnabled = Utility.IsDesktopDevice();
}
#endif
}
if (SettingsStore.TryGet(nameof(IsVoiceOverEnabled), out bool isVoiceOverEnabled))
@@ -260,6 +220,16 @@ namespace Pal3.Settings
IsVoiceOverEnabled = true;
}
if (SettingsStore.TryGet(nameof(IsDebugInfoEnabled), out bool isDebugInfoEnabled))
{
IsDebugInfoEnabled = isDebugInfoEnabled;
}
else
{
// Enable debug info by default
IsDebugInfoEnabled = true;
}
if (SettingsStore.TryGet(nameof(GameDataFolderPath), out string gameDataFolderPath))
{
GameDataFolderPath = gameDataFolderPath;
@@ -0,0 +1,97 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Settings
{
using System;
using Command;
using Command.InternalCommands;
using Core.Utils;
using UnityEngine;
public sealed class RenderingSettingsManager : MonoBehaviour,
ICommandExecutor<SettingChangedNotification>
{
private int _mainDisplayWidth;
private int _mainDisplayHeight;
private GameSettings _gameSettings;
public void Init(GameSettings gameSettings)
{
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
_mainDisplayWidth = Display.main.systemWidth;
_mainDisplayHeight = Display.main.systemHeight;
ApplyCurrentSettings(_gameSettings);
}
private void ApplyCurrentSettings(GameSettings settings)
{
QualitySettings.vSyncCount = settings.VSyncCount;
QualitySettings.antiAliasing = settings.AntiAliasing;
Application.targetFrameRate = settings.TargetFrameRate;
ApplyResolutionScale(settings.ResolutionScale);
}
private void OnEnable()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private void OnDisable()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
private void Update()
{
// This could happen on Android foldable devices
if (_mainDisplayWidth != Display.main.systemWidth ||
_mainDisplayHeight != Display.main.systemHeight)
{
_mainDisplayWidth = Display.main.systemWidth;
_mainDisplayHeight = Display.main.systemHeight;
OnResolutionChanged();
}
}
private void OnResolutionChanged()
{
ApplyResolutionScale(_gameSettings.ResolutionScale);
}
private static void ApplyResolutionScale(float scale)
{
#if UNITY_IOS || UNITY_ANDROID
Screen.SetResolution(
(int) (Display.main.systemWidth * scale),
(int) (Display.main.systemHeight * scale),
true);
#endif
}
public void Execute(SettingChangedNotification command)
{
if (command.SettingName == nameof(_gameSettings.VSyncCount))
{
QualitySettings.vSyncCount = _gameSettings.VSyncCount;
}
else if (command.SettingName == nameof(_gameSettings.AntiAliasing))
{
QualitySettings.antiAliasing = _gameSettings.AntiAliasing;
}
else if (command.SettingName == nameof(_gameSettings.TargetFrameRate))
{
Application.targetFrameRate = _gameSettings.TargetFrameRate;
}
else if (command.SettingName == nameof(_gameSettings.ResolutionScale))
{
ApplyResolutionScale(_gameSettings.ResolutionScale);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 370f98e9693732241abb8f67373ec2b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -166,6 +166,21 @@ namespace Pal3.Settings
}
}
private bool _isDebugInfoEnabled = true; // Default to enable debug info
public bool IsDebugInfoEnabled
{
get => _isDebugInfoEnabled;
internal set
{
if (_isDebugInfoEnabled != value)
{
_isDebugInfoEnabled = value;
SettingsStore.Set(nameof(IsDebugInfoEnabled), value);
NotifyPropertyChanged();
}
}
}
private string _gameDataFolderPath = string.Empty;
public string GameDataFolderPath
{
@@ -9,33 +9,27 @@ namespace Pal3.UI
[ExecuteAlways]
[RequireComponent(typeof(RectTransform))]
public class RectTransformWidthResizer : MonoBehaviour
public class RectTransformMaxWidthLimiter : MonoBehaviour
{
public float maxThresholdRatio;
public float minThresholdRatio;
public float minWidth;
public float midWidth;
public float maxWidth;
[SerializeField] public float thresholdRatio;
[SerializeField] public float padding;
private RectTransform _transform;
private Canvas _canvas;
void OnEnable()
private void OnEnable()
{
_transform = GetComponent<RectTransform>();
}
void Update()
private void Update()
{
float currentRatio = (float) Screen.width / Screen.height;
bool useMaxWidth = currentRatio > maxThresholdRatio;
bool useMinWidth = currentRatio < minThresholdRatio;
_transform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, useMaxWidth ? maxWidth : useMinWidth ? minWidth : midWidth);
var currentRatio = (float) Screen.width / Screen.height;
_transform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, currentRatio > thresholdRatio
? _transform.rect.height * thresholdRatio - padding
: _transform.rect.height * currentRatio - padding);
}
void OnValidate() => OnEnable();
private void OnValidate() => OnEnable();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bdf09cb687ad7904c833af0fd80d4f63
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: e9d6f17a4e68481a9705f217be9b4156
timeCreated: 1688053110
@@ -12,13 +12,15 @@ namespace Pal3.UI
public class RoundedFrostedGlassImage : MonoBehaviour
{
private static readonly int BlurAmountPropertyId = Shader.PropertyToID("_BlurAmount");
private static readonly int TransparencyPropertyId = Shader.PropertyToID("_Transparency");
private static readonly int WidthHeightRadiusPropertyId = Shader.PropertyToID("_WidthHeightRadius");
private static readonly int AdditiveColorPropertyId = Shader.PropertyToID("_AdditiveColor");
private static readonly int MultiplyColorPropertyId = Shader.PropertyToID("_MultiplyColor");
private static Shader _shader;
[SerializeField] public float blurAmount = 1;
[SerializeField] public float blurAmount = 1f;
[SerializeField] public float transparency = 1f;
[SerializeField] public float cornerRadius;
[SerializeField] public Color additiveTintColor = Color.black;
[SerializeField] public Color multiplyTintColor = Color.white;
@@ -27,6 +29,18 @@ namespace Pal3.UI
[HideInInspector, SerializeField] private MaskableGraphic image;
public void SetMaterialBlurAmount(float newBlurAmount)
{
if (_material == null) return;
_material.SetFloat(BlurAmountPropertyId, newBlurAmount);
}
public void SetMaterialTransparency(float newAlpha)
{
if (_material == null) return;
_material.SetFloat(TransparencyPropertyId, newAlpha);
}
private void OnValidate()
{
Init();
@@ -94,6 +108,7 @@ namespace Pal3.UI
Rect rect = ((RectTransform)transform).rect;
_material.SetFloat(BlurAmountPropertyId, blurAmount);
_material.SetFloat(TransparencyPropertyId, transparency);
_material.SetColor(AdditiveColorPropertyId, additiveTintColor);
_material.SetColor(MultiplyColorPropertyId, multiplyTintColor);
_material.SetVector(WidthHeightRadiusPropertyId,
@@ -114,6 +114,7 @@ namespace Pal3.Video
}
catch (Exception ex)
{
CommandDispatcher<ICommand>.Instance.Dispatch(new UIDisplayNoteCommand("未找到过场动画文件,动画已跳过"));
Debug.LogError($"[{nameof(VideoManager)}] Exception: {ex}");
_videoPlayingWaiter.CancelWait();
_gameStateManager.GoToPreviousState();
+5 -3
View File
@@ -112,7 +112,7 @@ GraphicsSettings:
useDitherMaskForAlphaBlendedShadows: 0
m_Automatic: 0
m_LightmapStripping: 0
m_FogStripping: 0
m_FogStripping: 1
m_InstancingStripping: 0
m_BrgStripping: 0
m_LightmapKeepPlain: 1
@@ -122,8 +122,8 @@ GraphicsSettings:
m_LightmapKeepShadowMask: 1
m_LightmapKeepSubtractive: 1
m_FogKeepLinear: 1
m_FogKeepExp: 1
m_FogKeepExp2: 1
m_FogKeepExp: 0
m_FogKeepExp2: 0
m_AlbedoSwatchInfos: []
m_LightsUseLinearIntensity: 0
m_LightsUseColorTemperature: 0
@@ -131,3 +131,5 @@ GraphicsSettings:
m_LogWhenShaderIsCompiled: 0
m_SRPDefaultSettings: {}
m_LightProbeOutsideHullStrategy: 0
m_CameraRelativeLightCulling: 0
m_CameraRelativeShadowCulling: 0
+9 -8
View File
@@ -11,7 +11,7 @@ PlayerSettings:
defaultScreenOrientation: 4
targetDevice: 2
useOnDemandResources: 0
accelerometerFrequency: 60
accelerometerFrequency: 0
companyName: Jackil
productName: PAL3
defaultCursor: {fileID: 0}
@@ -49,7 +49,7 @@ PlayerSettings:
m_StereoRenderingPath: 0
m_ActiveColorSpace: 0
m_SpriteBatchVertexThreshold: 300
m_MTRendering: 1
m_MTRendering: 0
mipStripping: 0
numberOfMipsStripped: 0
numberOfMipsStrippedPerMipmapLimitGroup: {}
@@ -129,12 +129,13 @@ PlayerSettings:
stadiaTargetFramerate: 0
vulkanNumSwapchainBuffers: 3
vulkanEnableSetSRGBWrite: 0
vulkanEnablePreTransform: 1
vulkanEnablePreTransform: 0
vulkanEnableLateAcquireNextImage: 0
vulkanEnableCommandBufferRecycling: 1
loadStoreDebugModeEnabled: 0
bundleVersion: 0.70
preloadedAssets: []
bundleVersion: 0.72
preloadedAssets:
- {fileID: 11400000, guid: d36b5fde9d421c74cba9317a109723a2, type: 2}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1
@@ -624,8 +625,8 @@ PlayerSettings:
m_GraphicsJobMode: 0
m_BuildTargetGraphicsAPIs:
- m_BuildTarget: AndroidPlayer
m_APIs: 0b000000
m_Automatic: 0
m_APIs: 0b00000015000000
m_Automatic: 1
- m_BuildTarget: iOSSupport
m_APIs: 10000000
m_Automatic: 1
@@ -1064,7 +1065,7 @@ PlayerSettings:
activeInputHandler: 2
windowsGamepadBackendHint: 0
cloudProjectId:
framebufferDepthMemorylessMode: 0
framebufferDepthMemorylessMode: 2
qualitySettingsNames: []
projectName:
organizationId:
+7 -1
View File
@@ -29,6 +29,7 @@ QualitySettings:
billboardsFaceCameraPosition: 0
useLegacyDetailDistribution: 1
vSyncCount: 0
realtimeGICPUUsage: 25
lodBias: 0.3
maximumLODLevel: 0
enableLODCrossFade: 1
@@ -77,6 +78,7 @@ QualitySettings:
billboardsFaceCameraPosition: 0
useLegacyDetailDistribution: 1
vSyncCount: 0
realtimeGICPUUsage: 25
lodBias: 0.4
maximumLODLevel: 0
enableLODCrossFade: 1
@@ -125,6 +127,7 @@ QualitySettings:
billboardsFaceCameraPosition: 0
useLegacyDetailDistribution: 1
vSyncCount: 0
realtimeGICPUUsage: 25
lodBias: 0.7
maximumLODLevel: 0
enableLODCrossFade: 1
@@ -173,6 +176,7 @@ QualitySettings:
billboardsFaceCameraPosition: 1
useLegacyDetailDistribution: 1
vSyncCount: 0
realtimeGICPUUsage: 50
lodBias: 1
maximumLODLevel: 0
enableLODCrossFade: 1
@@ -221,6 +225,7 @@ QualitySettings:
billboardsFaceCameraPosition: 1
useLegacyDetailDistribution: 1
vSyncCount: 1
realtimeGICPUUsage: 50
lodBias: 1.5
maximumLODLevel: 0
enableLODCrossFade: 1
@@ -268,7 +273,8 @@ QualitySettings:
realtimeReflectionProbes: 1
billboardsFaceCameraPosition: 1
useLegacyDetailDistribution: 1
vSyncCount: 1
vSyncCount: 0
realtimeGICPUUsage: 100
lodBias: 2
maximumLODLevel: 0
enableLODCrossFade: 1