mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57d1da275f | ||
|
|
07bf42ee04 | ||
|
|
2fe8e61032 | ||
|
|
10d9cc9eca | ||
|
|
86a698d66d | ||
|
|
efba3b899b | ||
|
|
c369b1cf14 | ||
|
|
8e7f6bdbe0 | ||
|
|
d37348e503 | ||
|
|
79435a7edb | ||
|
|
68026452c5 | ||
|
|
bd3243213c | ||
|
|
bae12e066d | ||
|
|
c57b4aaf78 | ||
|
|
e5449c0f06 | ||
|
|
54344ead7f | ||
|
|
f26636ca8c | ||
|
|
7ea58826cf | ||
|
|
c957519b50 | ||
|
|
95208f5328 | ||
|
|
74a1cd88e2 | ||
|
|
ddc1e7565b | ||
|
|
255103b36a | ||
|
|
6155eca8ce | ||
|
|
a0d6b9c725 | ||
|
|
5276462b8e | ||
|
|
5081dfd0d1 | ||
|
|
c2c69497d2 | ||
|
|
d05637763b | ||
|
|
3e8c0b2979 | ||
|
|
f1bd8a57db | ||
|
|
94c8e824d2 | ||
|
|
b49a24caf7 | ||
|
|
fba2ff7481 | ||
|
|
f621ab34b4 |
No files matched your search
@@ -0,0 +1,9 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
# default location of `.github/workflows`
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
commit-message:
|
||||
prefix: 'action-deps: '
|
||||
@@ -0,0 +1,35 @@
|
||||
name: Builds - PAL3 - Mono - Android
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_pal3_mono_android:
|
||||
name: Build PAL3 for ${{ matrix.targetPlatform }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
targetPlatform:
|
||||
- Android # Build an Android .apk standalone app.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
with:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
@@ -0,0 +1,31 @@
|
||||
name: Builds - PAL3 - Mono - iOS
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_pal3_mono_ios:
|
||||
name: Build PAL3 for ${{ matrix.targetPlatform }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
targetPlatform:
|
||||
- iOS # Build an iOS player.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
with:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
# do not upload artifacts for iOS builds
|
||||
@@ -0,0 +1,35 @@
|
||||
name: Builds - PAL3 - Mono - Linux
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_pal3_mono_linux:
|
||||
name: Build PAL3 for ${{ matrix.targetPlatform }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
targetPlatform:
|
||||
- StandaloneLinux64 # Build a Linux 64-bit standalone.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
with:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
@@ -0,0 +1,35 @@
|
||||
name: Builds - PAL3 - Mono - MacOS
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_pal3_mono_macos:
|
||||
name: Build PAL3 for ${{ matrix.targetPlatform }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
targetPlatform:
|
||||
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
with:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
@@ -0,0 +1,36 @@
|
||||
name: Builds - PAL3 - Mono - Windows
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_pal3_mono_windows:
|
||||
name: Build PAL3 for ${{ matrix.targetPlatform }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
targetPlatform:
|
||||
- StandaloneWindows # Build a Windows standalone.
|
||||
- StandaloneWindows64 # Build a Windows 64-bit standalone.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
with:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
@@ -0,0 +1,48 @@
|
||||
name: Builds - PAL3A - Mono - Android
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_pal3a_mono_android:
|
||||
name: Build PAL3A for ${{ matrix.targetPlatform }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
targetPlatform:
|
||||
- Android # Build an Android .apk standalone app.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- name: Switch define symbol from PAL3 to PAL3A
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "PAL3"
|
||||
replace: "PAL3A"
|
||||
include: "**ProjectSettings.asset"
|
||||
- name: Replace PAL3 game icon with PAL3A one
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
with:
|
||||
allowDirtyBuild: true
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: PAL3A-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
@@ -0,0 +1,44 @@
|
||||
name: Builds - PAL3A - Mono - iOS
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_pal3a_mono_ios:
|
||||
name: Build PAL3A for ${{ matrix.targetPlatform }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
targetPlatform:
|
||||
- iOS # Build an iOS player.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- name: Switch define symbol from PAL3 to PAL3A
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "PAL3"
|
||||
replace: "PAL3A"
|
||||
include: "**ProjectSettings.asset"
|
||||
- name: Replace PAL3 game icon with PAL3A one
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
with:
|
||||
allowDirtyBuild: true
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
# do not upload artifacts for iOS builds
|
||||
@@ -0,0 +1,48 @@
|
||||
name: Builds - PAL3A - Mono - Linux
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_pal3a_mono_linux:
|
||||
name: Build PAL3A for ${{ matrix.targetPlatform }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
targetPlatform:
|
||||
- StandaloneLinux64 # Build a Linux 64-bit standalone.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- name: Switch define symbol from PAL3 to PAL3A
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "PAL3"
|
||||
replace: "PAL3A"
|
||||
include: "**ProjectSettings.asset"
|
||||
- name: Replace PAL3 game icon with PAL3A one
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
with:
|
||||
allowDirtyBuild: true
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: PAL3A-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
@@ -0,0 +1,48 @@
|
||||
name: Builds - PAL3A - Mono - MacOS
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_pal3a_mono_macos:
|
||||
name: Build PAL3A for ${{ matrix.targetPlatform }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
targetPlatform:
|
||||
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- name: Switch define symbol from PAL3 to PAL3A
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "PAL3"
|
||||
replace: "PAL3A"
|
||||
include: "**ProjectSettings.asset"
|
||||
- name: Replace PAL3 game icon with PAL3A one
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
with:
|
||||
allowDirtyBuild: true
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: PAL3A-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
@@ -0,0 +1,49 @@
|
||||
name: Builds - PAL3A - Mono - Windows
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_pal3a_mono_windows:
|
||||
name: Build PAL3A for ${{ matrix.targetPlatform }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
targetPlatform:
|
||||
- StandaloneWindows # Build a Windows standalone.
|
||||
- StandaloneWindows64 # Build a Windows 64-bit standalone.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- name: Switch define symbol from PAL3 to PAL3A
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "PAL3"
|
||||
replace: "PAL3A"
|
||||
include: "**ProjectSettings.asset"
|
||||
- name: Replace PAL3 game icon with PAL3A one
|
||||
uses: jacobtomlinson/gha-find-replace@v3
|
||||
with:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
with:
|
||||
allowDirtyBuild: true
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: PAL3A-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
retention-days: 14
|
||||
@@ -536,7 +536,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Cancel
|
||||
m_Text: "\u53D6\u6D88"
|
||||
--- !u!1 &1000010571070120
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1806,7 +1806,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Search...
|
||||
m_Text: "\u641C\u7D22..."
|
||||
--- !u!1 &1000011474259412
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -5094,7 +5094,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Show hidden files
|
||||
m_Text: "\u663E\u793A\u9690\u85CF\u6587\u4EF6"
|
||||
--- !u!1 &1017798384541682
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -6640,7 +6640,7 @@ MonoBehaviour:
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Highlighted
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_Interactable: 0
|
||||
m_TargetGraphic: {fileID: 114938008637452676}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
|
||||
@@ -301,7 +301,7 @@ namespace SimpleFileBrowser
|
||||
}
|
||||
}
|
||||
|
||||
private static string m_foldersFilterText = "Folders";
|
||||
private static string m_foldersFilterText = "文件夹";
|
||||
public static string FoldersFilterText
|
||||
{
|
||||
get { return m_foldersFilterText; }
|
||||
@@ -1027,7 +1027,7 @@ namespace SimpleFileBrowser
|
||||
if( FileBrowserHelpers.ShouldUseSAF )
|
||||
{
|
||||
AddQuickLink( m_skin.DriveIcon, PickFolderQuickLinkText, SAF_PICK_FOLDER_QUICK_LINK_PATH );
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
FetchPersistedSAFQuickLinks();
|
||||
@@ -1145,7 +1145,7 @@ namespace SimpleFileBrowser
|
||||
// {
|
||||
// driveName = "Drive " + driveIndex++;
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
|
||||
string driveName;
|
||||
if( !defaultPathInitialized )
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Build.Editor
|
||||
[PostProcessBuild]
|
||||
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
|
||||
{
|
||||
if (buildTarget != BuildTarget.iOS) return;
|
||||
if (buildTarget != BuildTarget.iOS) return; // Only for iOS
|
||||
|
||||
// Get plist
|
||||
string plistPath = pathToBuiltProject + "/Info.plist";
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
#if UNITY_EDITOR_OSX
|
||||
#if UNITY_EDITOR_OSX && UNITY_STANDALONE_OSX
|
||||
|
||||
namespace Build.Editor
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using UnityEngine;
|
||||
@@ -23,11 +26,13 @@ namespace Build.Editor
|
||||
{
|
||||
if (buildTarget != BuildTarget.StandaloneOSX) return;
|
||||
|
||||
bool isBuiltProjectXCodeProject = !pathToBuiltProject.EndsWith(".app", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// Get plist
|
||||
#if PAL3
|
||||
string plistPath = pathToBuiltProject + "/PAL3/Info.plist";
|
||||
string plistPath = pathToBuiltProject + (isBuiltProjectXCodeProject ? "/PAL3" : "/Contents") + "/Info.plist";
|
||||
#elif PAL3A
|
||||
string plistPath = pathToBuiltProject + "/PAL3A/Info.plist";
|
||||
string plistPath = pathToBuiltProject + (isBuiltProjectXCodeProject ? "/PAL3A" : "/Contents") + "/Info.plist";
|
||||
#endif
|
||||
|
||||
PlistDocument plist = new PlistDocument();
|
||||
@@ -44,6 +49,20 @@ namespace Build.Editor
|
||||
Debug.Log("NSPrefersDisplaySafeAreaCompatibilityMode set to NO.");
|
||||
}
|
||||
}
|
||||
|
||||
public class MyPostprocessor : IPostprocessBuildWithReport
|
||||
{
|
||||
public int callbackOrder => int.MaxValue;
|
||||
|
||||
public void OnPostprocessBuild(BuildReport report)
|
||||
{
|
||||
if (report.summary.platform != BuildTarget.StandaloneOSX) return;
|
||||
if (!report.summary.outputPath.EndsWith(".app", StringComparison.OrdinalIgnoreCase)) return;
|
||||
|
||||
UnityEditor.OSXStandalone.MacOSCodeSigning.CodeSignAppBundle(report.summary.outputPath);
|
||||
Debug.Log($"Code re-signed for macOS app: {report.summary.outputPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -41,7 +41,7 @@ namespace Core.DataReader.Cpk
|
||||
{
|
||||
if (!File.Exists(cpkFilePath))
|
||||
{
|
||||
throw new ArgumentException($"File does not exists: {cpkFilePath}");
|
||||
throw new ArgumentException($"游戏数据加载失败,游戏原CPK压缩包不存在: {cpkFilePath}");
|
||||
}
|
||||
|
||||
_filePath = cpkFilePath;
|
||||
|
||||
@@ -251,9 +251,14 @@ namespace Core.DataReader.Scn
|
||||
public string InitAction;
|
||||
|
||||
// uint[3] 怪物种类ID
|
||||
public uint[] MonsterId;
|
||||
public ushort MonsterNumber;
|
||||
public ushort MonsterRepeat;
|
||||
public uint[] MonsterIds;
|
||||
public byte NumberOfMonsters;
|
||||
public byte MonsterCanRespawn;
|
||||
|
||||
// Empty byte between the memory addresses to align the data in memory.
|
||||
// NumberOfMonsters and MonsterCanRespawn take 2 bytes in memory, thus we need to
|
||||
// add 2 more bytes here to align the data in memory (4 bytes).
|
||||
internal byte[] PaddingBytes;
|
||||
|
||||
public ScnPath Path;
|
||||
|
||||
|
||||
@@ -78,9 +78,10 @@ namespace Core.DataReader.Scn
|
||||
ScriptId = reader.ReadUInt32(),
|
||||
GameBoxYPosition = reader.ReadSingle(),
|
||||
InitAction = reader.ReadString(16, codepage),
|
||||
MonsterId = reader.ReadUInt32Array(3),
|
||||
MonsterNumber = reader.ReadUInt16(),
|
||||
MonsterRepeat = reader.ReadUInt16(),
|
||||
MonsterIds = reader.ReadUInt32Array(3),
|
||||
NumberOfMonsters = reader.ReadByte(),
|
||||
MonsterCanRespawn = reader.ReadByte(),
|
||||
PaddingBytes = reader.ReadBytes(2), // Empty padding bytes to complete 4-byte alignment
|
||||
Path = new ScnPath()
|
||||
{
|
||||
NumberOfWaypoints = reader.ReadInt32(),
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Core.FileSystem
|
||||
using System.Threading.Tasks;
|
||||
using DataReader.Cpk;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
/// <summary>
|
||||
/// File system wrapper for CPack archives
|
||||
@@ -27,8 +28,8 @@ namespace Core.FileSystem
|
||||
|
||||
public CpkFileSystem(string rootPath, CrcHash crcHash)
|
||||
{
|
||||
rootPath = !string.IsNullOrEmpty(rootPath) ? rootPath : throw new ArgumentNullException(nameof(rootPath));
|
||||
crcHash = crcHash ?? throw new ArgumentNullException(nameof(crcHash));
|
||||
rootPath = Requires.IsNotNullOrEmpty(rootPath, nameof(rootPath));
|
||||
crcHash = Requires.IsNotNull(crcHash, nameof(crcHash));
|
||||
|
||||
if (!rootPath.EndsWith(Path.DirectorySeparatorChar))
|
||||
{
|
||||
@@ -37,8 +38,7 @@ namespace Core.FileSystem
|
||||
|
||||
if (!Directory.Exists(rootPath))
|
||||
{
|
||||
var error = "Failed to initialize CpkFileSystem" +
|
||||
$" since application's root directory does not exists: {rootPath}";
|
||||
var error = $"游戏数据加载失败,原始游戏数据根目录不存在: {rootPath}";
|
||||
Debug.LogError(error);
|
||||
throw new ArgumentException(error);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Core.Services
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the service to lookup</typeparam>
|
||||
/// <returns>The service instance</returns>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the service is not registered.</exception>
|
||||
public T Get<T>()
|
||||
{
|
||||
if (!_services.ContainsKey(typeof(T)))
|
||||
@@ -41,11 +42,14 @@ namespace Core.Services
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Service typ.</typeparam>
|
||||
/// <param name="service">Service instance</param>
|
||||
/// <exception cref="ArgumentNullException">Thrown if the service is null.</exception>
|
||||
public void Register<T>(T service)
|
||||
{
|
||||
if (service == null) throw new ArgumentNullException(nameof(service));
|
||||
|
||||
if (_services.ContainsKey(typeof(T)))
|
||||
{
|
||||
Debug.LogError($"{typeof(T)} already registered.");
|
||||
Debug.LogWarning($"{typeof(T)} already registered.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,7 +64,7 @@ namespace Core.Services
|
||||
{
|
||||
if (!_services.ContainsKey(typeof(T)))
|
||||
{
|
||||
Debug.LogError($"Failed to unregister since {typeof(T)} is not registered yet.");
|
||||
Debug.LogWarning($"Failed to unregister since {typeof(T)} is not registered yet.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.Utils
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
||||
/// <summary>
|
||||
/// Checks method arguments for both dotnet objects and Unity objects.
|
||||
/// </summary>
|
||||
public static class Requires
|
||||
{
|
||||
public static T IsNotNull<T>([NotNull] T instance, string paramName)
|
||||
where T : class
|
||||
{
|
||||
if (typeof(T) == typeof(UnityEngine.Object) ||
|
||||
typeof(T).IsSubclassOf(typeof(UnityEngine.Object)))
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
throw new ArgumentNullException(paramName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
if (System.Object.ReferenceEquals(null, instance))
|
||||
{
|
||||
throw new ArgumentNullException(paramName);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static string IsNotNullOrEmpty([NotNull] string value, string paramName)
|
||||
{
|
||||
IsNotNull(value, paramName);
|
||||
|
||||
if (value == string.Empty)
|
||||
{
|
||||
throw new ArgumentException(paramName);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ICollection<T> IsNotNullOrEmpty<T>([NotNull] ICollection<T> value, string paramName)
|
||||
{
|
||||
IsNotNull(value, paramName);
|
||||
|
||||
if (!value.Any())
|
||||
{
|
||||
throw new ArgumentException("Collection is empty", paramName);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static T[] IsNotNullOrEmpty<T>([NotNull] T[] instances, string paramName)
|
||||
{
|
||||
IsNotNull(instances, paramName);
|
||||
|
||||
if (instances.Length == 0)
|
||||
{
|
||||
throw new ArgumentException("Array is empty", paramName);
|
||||
}
|
||||
|
||||
return instances;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20ce7c5ef43049b8bd382b29499840a0
|
||||
timeCreated: 1679519446
|
||||
@@ -29,6 +29,7 @@ namespace Core.Utils
|
||||
{
|
||||
name = typeof(T).ToString()
|
||||
};
|
||||
|
||||
_instance = singletonObj.AddComponent<T>();
|
||||
|
||||
return _instance;
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace Editor
|
||||
SymbolsHelper.AddSymbol("PAL3");
|
||||
ApplyPlayerSettingsForVariant("PAL3");
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
Debug.Log("Switched to PAL3");
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
@@ -38,9 +40,9 @@ namespace Editor
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
[MenuItem("PAL3/Switch Variant/PAL3A", priority = 2)]
|
||||
[MenuItem("PAL3/Switch Variant/PAL3A", priority = 1)]
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Switch Variant/PAL3A", priority = 2)]
|
||||
[MenuItem("PAL3A/Switch Variant/PAL3A", priority = 1)]
|
||||
#endif
|
||||
public static void SwitchToPal3A()
|
||||
{
|
||||
@@ -48,6 +50,8 @@ namespace Editor
|
||||
SymbolsHelper.AddSymbol("PAL3A");
|
||||
ApplyPlayerSettingsForVariant("PAL3A");
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
Debug.Log("Switched to PAL3A");
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Editor
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using Pal3.MetaData;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2020_2_OR_NEWER && UNITY_STANDALONE_OSX
|
||||
using UnityEditor.OSXStandalone;
|
||||
#endif
|
||||
|
||||
[Flags]
|
||||
public enum Pal3BuildTarget
|
||||
{
|
||||
Windows_x86 = 1 << 0,
|
||||
Windows_x64 = 1 << 1,
|
||||
Linux_x86_x64 = 1 << 2,
|
||||
MacOS_arm64_x64 = 1 << 3,
|
||||
Android = 1 << 4,
|
||||
iOS = 1 << 5,
|
||||
}
|
||||
|
||||
public static class ReleaseBuildPipeline
|
||||
{
|
||||
private static readonly string[] BuildLevels = { "Assets/Scenes/Game.unity" };
|
||||
|
||||
private static readonly char PathSeparator = Path.DirectorySeparatorChar;
|
||||
|
||||
#if PAL3
|
||||
[MenuItem("PAL3/Build Pipelines/Build [Windows_x86] IL2CPP Release Executable")]
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Build Pipelines/Build [Windows_x86] IL2CPP Release Executable")]
|
||||
#endif
|
||||
public static void Build_Windows_x86()
|
||||
{
|
||||
BuildGame(Pal3BuildTarget.Windows_x86);
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
[MenuItem("PAL3/Build Pipelines/Build [Windows_x64] IL2CPP Release Executable")]
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Build Pipelines/Build [Windows_x64] IL2CPP Release Executable")]
|
||||
#endif
|
||||
public static void Build_Windows_x64()
|
||||
{
|
||||
BuildGame(Pal3BuildTarget.Windows_x64);
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
[MenuItem("PAL3/Build Pipelines/Build [Linux_x86_x64] IL2CPP Release Executable")]
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Build Pipelines/Build [Linux_x86_x64] IL2CPP Release Executable")]
|
||||
#endif
|
||||
public static void Build_Linux_x86_x64()
|
||||
{
|
||||
BuildGame(Pal3BuildTarget.Linux_x86_x64);
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
[MenuItem("PAL3/Build Pipelines/Build [MacOS_arm64_x64] IL2CPP XCode Project")]
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Build Pipelines/Build [MacOS_arm64_x64] IL2CPP XCode Project")]
|
||||
#endif
|
||||
public static void Build_MacOS_arm64_x64()
|
||||
{
|
||||
BuildGame(Pal3BuildTarget.MacOS_arm64_x64);
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
[MenuItem("PAL3/Build Pipelines/Build [Android] IL2CPP Release APK")]
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Build Pipelines/Build [Android] IL2CPP Release APK")]
|
||||
#endif
|
||||
public static void Build_Android()
|
||||
{
|
||||
BuildGame(Pal3BuildTarget.Android);
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
[MenuItem("PAL3/Build Pipelines/Build [iOS] IL2CPP XCode Project")]
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Build Pipelines/Build [iOS] IL2CPP XCode Project")]
|
||||
#endif
|
||||
public static void Build_iOS()
|
||||
{
|
||||
BuildGame(Pal3BuildTarget.iOS);
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
[MenuItem("PAL3/Build Pipelines/Build All [Windows, Linux, MacOS, Android, iOS]")]
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Build Pipelines/Build All [Windows, Linux, MacOS, Android, iOS]")]
|
||||
#endif
|
||||
public static void BuildAll()
|
||||
{
|
||||
BuildGame(Pal3BuildTarget.Windows_x86 |
|
||||
Pal3BuildTarget.Windows_x64 |
|
||||
Pal3BuildTarget.Linux_x86_x64 |
|
||||
Pal3BuildTarget.MacOS_arm64_x64 |
|
||||
Pal3BuildTarget.Android |
|
||||
Pal3BuildTarget.iOS);
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
[MenuItem("PAL3/Build Pipelines/Zip Release files [Windows, Linux, Android]")]
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Build Pipelines/Zip Release files [Windows, Linux, Android]")]
|
||||
#endif
|
||||
public static void ZipAll()
|
||||
{
|
||||
ZipReleaseFiles();
|
||||
}
|
||||
|
||||
private static void BuildGame(Pal3BuildTarget buildTarget)
|
||||
{
|
||||
BuildTargetGroup targetGroupBeforeBuild = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
BuildTarget targetBeforeBuild = EditorUserBuildSettings.activeBuildTarget;
|
||||
|
||||
string buildOutputPath = EditorUtility.SaveFolderPanel("Choose Location of Built Game", "", "");
|
||||
|
||||
if (string.IsNullOrEmpty(buildOutputPath)) return;
|
||||
|
||||
buildOutputPath += $"{PathSeparator}{PlayerSettings.bundleVersion}{PathSeparator}";
|
||||
|
||||
var buildConfigurations = new[]
|
||||
{
|
||||
new { Platform = Pal3BuildTarget.Windows_x86, Extension = ".exe", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneWindows },
|
||||
new { Platform = Pal3BuildTarget.Windows_x64, Extension = ".exe", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneWindows64 },
|
||||
new { Platform = Pal3BuildTarget.Linux_x86_x64, Extension = "", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneLinux64 },
|
||||
new { Platform = Pal3BuildTarget.MacOS_arm64_x64, Extension = "", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneOSX },
|
||||
new { Platform = Pal3BuildTarget.Android, Extension = ".apk", Group = BuildTargetGroup.Android, Target = BuildTarget.Android },
|
||||
new { Platform = Pal3BuildTarget.iOS, Extension = "", Group = BuildTargetGroup.iOS, Target = BuildTarget.iOS },
|
||||
};
|
||||
|
||||
List<Action> logActions = new List<Action>();
|
||||
|
||||
foreach (var config in buildConfigurations)
|
||||
{
|
||||
if (buildTarget.HasFlag(config.Platform))
|
||||
{
|
||||
Build(config.Platform.ToString(),
|
||||
config.Extension,
|
||||
config.Group,
|
||||
config.Target,
|
||||
buildOutputPath,
|
||||
logActions);
|
||||
}
|
||||
}
|
||||
|
||||
// Restore build target settings
|
||||
EditorUserBuildSettings.SwitchActiveBuildTarget(targetGroupBeforeBuild, targetBeforeBuild);
|
||||
|
||||
// Execute report log actions
|
||||
logActions.ForEach(action => action.Invoke());
|
||||
|
||||
Debug.Log($"Build for version {PlayerSettings.bundleVersion} complete! Output path: " +
|
||||
$"{buildOutputPath}{GameConstants.AppName}");
|
||||
}
|
||||
|
||||
private static void Build(string folderName,
|
||||
string extension,
|
||||
BuildTargetGroup buildTargetGroup,
|
||||
BuildTarget buildTarget,
|
||||
string buildOutputPath,
|
||||
List<Action> logActions,
|
||||
bool deletePdbFiles = true)
|
||||
{
|
||||
string outputFolder = buildOutputPath + $"{GameConstants.AppName}{PathSeparator}" +
|
||||
$"{folderName}{PathSeparator}";
|
||||
|
||||
if (buildTarget is BuildTarget.StandaloneWindows
|
||||
or BuildTarget.StandaloneWindows64
|
||||
or BuildTarget.StandaloneLinux64)
|
||||
{
|
||||
outputFolder += $"{GameConstants.AppName}{PathSeparator}";
|
||||
}
|
||||
else if (buildTarget is BuildTarget.StandaloneOSX)
|
||||
{
|
||||
#if UNITY_2020_2_OR_NEWER && UNITY_STANDALONE_OSX
|
||||
UserBuildSettings.architecture = OSArchitecture.x64ARM64;
|
||||
UserBuildSettings.createXcodeProject = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
string outputPath = outputFolder + $"{GameConstants.AppName}{extension}";
|
||||
|
||||
PlayerSettings.SetScriptingBackend(buildTargetGroup, ScriptingImplementation.IL2CPP);
|
||||
|
||||
BuildReport report = BuildPipeline.BuildPlayer(BuildLevels, outputPath, buildTarget, BuildOptions.None);
|
||||
|
||||
if (deletePdbFiles)
|
||||
{
|
||||
FileUtil.DeleteFileOrDirectory(outputFolder +
|
||||
$"{GameConstants.AppName}_BackUpThisFolder_ButDontShipItWithYourGame");
|
||||
}
|
||||
|
||||
WriteBuildReport(report, logActions);
|
||||
}
|
||||
|
||||
private static void WriteBuildReport(BuildReport report, List<Action> logActions)
|
||||
{
|
||||
switch (report.summary.result)
|
||||
{
|
||||
case BuildResult.Succeeded:
|
||||
string successReport = $"Build [{report.summary.platform}] succeeded. " +
|
||||
$"Finished in {report.summary.totalTime.TotalMinutes:F2} minutes. " +
|
||||
$"Build size: {(report.summary.totalSize / 1024f / 1024f):F2} MB";
|
||||
logActions.Add(() => Debug.Log(successReport));
|
||||
break;
|
||||
case BuildResult.Failed:
|
||||
string errorReport = $"Build [{report.summary.platform}] failed.";
|
||||
logActions.Add(() => Debug.LogError(errorReport));
|
||||
break;
|
||||
case BuildResult.Cancelled:
|
||||
string cancelReport = $"Build [{report.summary.platform}] cancelled.";
|
||||
logActions.Add(() => Debug.LogWarning(cancelReport));
|
||||
break;
|
||||
case BuildResult.Unknown:
|
||||
string unknownReport = $"Build [{report.summary.platform}] skipped or not completed.";
|
||||
logActions.Add(() => Debug.LogWarning(unknownReport));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ZipReleaseFiles()
|
||||
{
|
||||
string buildOutputPath = EditorUtility.SaveFolderPanel("Choose Location of Built Game",
|
||||
$"{PlayerSettings.bundleVersion}", $"{PlayerSettings.bundleVersion}");
|
||||
|
||||
if (string.IsNullOrEmpty(buildOutputPath)) return;
|
||||
|
||||
if (!buildOutputPath.EndsWith($"{PlayerSettings.bundleVersion}"))
|
||||
{
|
||||
Debug.LogError($"Invalid build output path: {buildOutputPath}. " +
|
||||
$"Please choose the current release build folder \"{PlayerSettings.bundleVersion}\"");
|
||||
return;
|
||||
}
|
||||
|
||||
string releaseDirPath = $"{buildOutputPath}{PathSeparator}Release";
|
||||
Directory.CreateDirectory(releaseDirPath);
|
||||
|
||||
List<(string FolderPath, Pal3BuildTarget Target)> buildTargets = new()
|
||||
{
|
||||
($"{GameConstants.AppName}{PathSeparator}{Pal3BuildTarget.Android.ToString()}{PathSeparator}{GameConstants.AppName}.apk", Pal3BuildTarget.Android),
|
||||
($"{GameConstants.AppName}{PathSeparator}{Pal3BuildTarget.Windows_x86.ToString()}", Pal3BuildTarget.Windows_x86),
|
||||
($"{GameConstants.AppName}{PathSeparator}{Pal3BuildTarget.Windows_x64.ToString()}", Pal3BuildTarget.Windows_x64),
|
||||
($"{GameConstants.AppName}{PathSeparator}{Pal3BuildTarget.Linux_x86_x64.ToString()}", Pal3BuildTarget.Linux_x86_x64)
|
||||
};
|
||||
|
||||
foreach ((string folderPath, Pal3BuildTarget target) in buildTargets)
|
||||
{
|
||||
string fullPath = $"{buildOutputPath}{PathSeparator}{folderPath}";
|
||||
string zipFileName = $"{GameConstants.AppName}_v{PlayerSettings.bundleVersion}_{target.ToString()}.zip";
|
||||
string zipFilePath = $"{releaseDirPath}{PathSeparator}{zipFileName}";
|
||||
|
||||
if (File.Exists(fullPath) || Directory.Exists(fullPath))
|
||||
{
|
||||
File.Delete(zipFilePath);
|
||||
|
||||
if (target == Pal3BuildTarget.Android)
|
||||
{
|
||||
using FileStream fileStream = new(zipFilePath, FileMode.Create);
|
||||
using ZipArchive archive = new(fileStream, ZipArchiveMode.Create);
|
||||
archive.CreateEntryFromFile(fullPath, $"{GameConstants.AppName}.apk");
|
||||
}
|
||||
else
|
||||
{
|
||||
ZipFile.CreateFromDirectory(fullPath, zipFilePath);
|
||||
}
|
||||
|
||||
Debug.Log($"{target.ToString()} build zipped to {zipFilePath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"{target.ToString()} release folder not found at {fullPath}. Skipped.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d744af8977c74774b6027a7c6c1c5f3e
|
||||
timeCreated: 1679528190
|
||||
@@ -24,9 +24,9 @@ namespace Editor
|
||||
#endif
|
||||
|
||||
#if PAL3
|
||||
[MenuItem("PAL3/Source Generator/Generate ConsoleCommands.PAL3.generated.cs")]
|
||||
[MenuItem("PAL3/Source Generator/Generate ConsoleCommands.PAL3.generated.cs", priority = 2)]
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Source Generator/Generate ConsoleCommands.PAL3A.generated.cs")]
|
||||
[MenuItem("PAL3A/Source Generator/Generate ConsoleCommands.PAL3A.generated.cs", priority = 2)]
|
||||
#endif
|
||||
public static void GenerateConsoleCommands()
|
||||
{
|
||||
@@ -69,6 +69,7 @@ namespace Editor
|
||||
|
||||
Debug.Log($"{fileName}.cs generated.");
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ namespace Pal3.Actor
|
||||
using Input;
|
||||
using MetaData;
|
||||
using Player;
|
||||
using Scene;
|
||||
using Script.Waiter;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -167,9 +166,7 @@ namespace Pal3.Actor
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
if (_actor.Info.Kind == ScnActorKind.CombatNpc &&
|
||||
ServiceLocator.Instance.Get<SceneManager>()
|
||||
.GetCurrentScene()
|
||||
.GetSceneInfo().SceneType == ScnSceneType.Maze &&
|
||||
(_actor.Info.MonsterIds[0] != 0 || _actor.Info.MonsterIds[1] != 0 || _actor.Info.MonsterIds[2] != 0) &&
|
||||
collision.gameObject.GetComponent<ActorController>() is {} actorController &&
|
||||
(byte) ServiceLocator.Instance.Get<PlayerManager>()
|
||||
.GetPlayerActor() == actorController.GetActor().Info.Id)
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Pal3.Audio
|
||||
using Core.DataReader.Cpk;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.Extensions;
|
||||
using Core.Utils;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using Scene;
|
||||
@@ -62,11 +63,11 @@ namespace Pal3.Audio
|
||||
AudioSource musicSource,
|
||||
GameSettings gameSettings)
|
||||
{
|
||||
_mainCamera = mainCamera != null ? mainCamera : throw new ArgumentNullException(nameof(mainCamera));
|
||||
_resourceProvider = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_musicPlayer = musicSource != null ? musicSource : throw new ArgumentNullException(nameof(musicSource));
|
||||
_gameSettings = gameSettings ?? throw new ArgumentNullException(nameof(gameSettings));
|
||||
_mainCamera = Requires.IsNotNull(mainCamera, nameof(mainCamera));
|
||||
_resourceProvider = Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
|
||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||
_musicPlayer = Requires.IsNotNull(musicSource, nameof(musicSource));
|
||||
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
|
||||
|
||||
_musicVolume = _gameSettings.MusicVolume;
|
||||
_sfxVolume = _gameSettings.SfxVolume;
|
||||
|
||||
@@ -110,10 +110,10 @@ namespace Pal3.Camera
|
||||
Canvas touchControlUI,
|
||||
Image curtainImage)
|
||||
{
|
||||
_inputActions = inputActions ?? throw new ArgumentNullException(nameof(inputActions));
|
||||
_gamePlayController = gamePlayController != null ? gamePlayController : throw new ArgumentNullException(nameof(gamePlayController));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_gameStateManager = gameStateManager ?? throw new ArgumentNullException(nameof(gameStateManager));
|
||||
_inputActions = Requires.IsNotNull(inputActions, nameof(inputActions));
|
||||
_gamePlayController = Requires.IsNotNull(gamePlayController, nameof(gamePlayController));
|
||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||
_gameStateManager = Requires.IsNotNull(gameStateManager, nameof(gameStateManager));
|
||||
|
||||
_camera = mainCamera;
|
||||
_camera!.fieldOfView = HorizontalToVerticalFov(24.05f, 4f/3f);
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Pal3.Data
|
||||
using Command.InternalCommands;
|
||||
using Core.DataReader.Cpk;
|
||||
using Core.FileSystem;
|
||||
using Core.Utils;
|
||||
|
||||
/// <summary>
|
||||
/// Cache/dispose Cpk archive into memory based on scenarios.
|
||||
@@ -23,7 +24,7 @@ namespace Pal3.Data
|
||||
|
||||
public FileSystemCacheManager(ICpkFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
|
||||
_fileSystem = Requires.IsNotNull(fileSystem, nameof(fileSystem));
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,11 +93,11 @@ namespace Pal3.Data
|
||||
GameSettings gameSettings,
|
||||
int codepage)
|
||||
{
|
||||
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
|
||||
_textureLoaderFactory = textureLoaderFactory ?? throw new ArgumentNullException(nameof(textureLoaderFactory));
|
||||
_unlitMaterialFactory = unlitMaterialFactory ?? throw new ArgumentNullException(nameof(unlitMaterialFactory));
|
||||
_litMaterialFactory = litMaterialFactory ?? throw new ArgumentNullException(nameof(litMaterialFactory));
|
||||
_gameSettings = gameSettings ?? throw new ArgumentNullException(nameof(gameSettings));
|
||||
_fileSystem = Requires.IsNotNull(fileSystem, nameof(fileSystem));
|
||||
_textureLoaderFactory = Requires.IsNotNull(textureLoaderFactory, nameof(textureLoaderFactory));
|
||||
_unlitMaterialFactory = Requires.IsNotNull(unlitMaterialFactory, nameof(unlitMaterialFactory));
|
||||
_litMaterialFactory = litMaterialFactory; // Lit materials are not required
|
||||
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
|
||||
_codepage = codepage;
|
||||
|
||||
var gdbFilePath =
|
||||
@@ -137,7 +137,7 @@ namespace Pal3.Data
|
||||
|
||||
public IMaterialFactory GetMaterialFactory()
|
||||
{
|
||||
return _gameSettings.IsRealtimeLightingAndShadowsEnabled ?
|
||||
return !_gameSettings.IsOpenSourceVersion && _gameSettings.IsRealtimeLightingAndShadowsEnabled ?
|
||||
_litMaterialFactory :
|
||||
_unlitMaterialFactory;
|
||||
}
|
||||
|
||||
@@ -16,40 +16,36 @@ namespace Pal3.Data
|
||||
{
|
||||
private readonly Dictionary<string, (Texture2D texutre, bool hasAlphaChannel)> _textureCache = new ();
|
||||
|
||||
public void Add(string textureFullPath, Texture2D texture, bool hasAlphaChannel)
|
||||
public void Add(string key, Texture2D texture, bool hasAlphaChannel)
|
||||
{
|
||||
if (texture == null) return;
|
||||
|
||||
textureFullPath = textureFullPath.ToLower();
|
||||
key = key.ToLowerInvariant();
|
||||
|
||||
if (Contains(textureFullPath))
|
||||
if (_textureCache.ContainsKey(key))
|
||||
{
|
||||
Debug.LogError($"Texture {textureFullPath} already existed in cache.");
|
||||
Debug.LogError($"Texture {key} already existed in cache.");
|
||||
}
|
||||
else
|
||||
{
|
||||
texture.hideFlags = HideFlags.HideAndDontSave;
|
||||
_textureCache[textureFullPath] = new (texture, hasAlphaChannel);
|
||||
_textureCache[key] = new (texture, hasAlphaChannel);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Contains(string textureFullPath)
|
||||
public bool TryGetTextureFromCache(string key,
|
||||
out (Texture2D texture, bool hasAlphaChannel) texture)
|
||||
{
|
||||
textureFullPath = textureFullPath.ToLower();
|
||||
return _textureCache.ContainsKey(textureFullPath);
|
||||
}
|
||||
key = key.ToLowerInvariant();
|
||||
|
||||
public (Texture2D texture, bool hasAlphaChannel) GetTextureFromCache(string textureFullPath)
|
||||
{
|
||||
textureFullPath = textureFullPath.ToLower();
|
||||
if (Contains(textureFullPath))
|
||||
if (_textureCache.ContainsKey(key))
|
||||
{
|
||||
return _textureCache[textureFullPath];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException($"Texture {textureFullPath} does not exist in cache.");
|
||||
texture = _textureCache[key];
|
||||
return true;
|
||||
}
|
||||
|
||||
texture = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void DisposeAll()
|
||||
|
||||
@@ -35,17 +35,16 @@ namespace Pal3.Data
|
||||
_textureCache = textureCache;
|
||||
}
|
||||
|
||||
private Texture2D GetTextureInCache(string textureFullPath, out bool hasAlphaChannel)
|
||||
private bool TryGetTextureFromCache(string textureFullPath,
|
||||
out (Texture2D texture, bool hasAlphaChannel) texture)
|
||||
{
|
||||
if (_textureCache != null && _textureCache.Contains(textureFullPath))
|
||||
if (_textureCache != null)
|
||||
{
|
||||
(Texture2D texture, bool hasAlpha) = _textureCache.GetTextureFromCache(textureFullPath);
|
||||
hasAlphaChannel = hasAlpha;
|
||||
return texture;
|
||||
return _textureCache.TryGetTextureFromCache(textureFullPath, out texture);
|
||||
}
|
||||
|
||||
hasAlphaChannel = false;
|
||||
return null;
|
||||
texture = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
public string GetTexturePath(string name)
|
||||
@@ -87,15 +86,19 @@ namespace Pal3.Data
|
||||
if (_textureCache != null)
|
||||
{
|
||||
// Check if dds texture exists in cache
|
||||
if (GetTextureInCache(ddsTexturePath, out hasAlphaChannel) is { } ddsTextureInCache)
|
||||
if (TryGetTextureFromCache(ddsTexturePath,
|
||||
out (Texture2D texture, bool hasAlphaChannel) ddsTextureInCache))
|
||||
{
|
||||
return ddsTextureInCache;
|
||||
hasAlphaChannel = ddsTextureInCache.hasAlphaChannel;
|
||||
return ddsTextureInCache.texture;
|
||||
}
|
||||
|
||||
// Check if texture exists in cache
|
||||
if (GetTextureInCache(texturePath, out hasAlphaChannel) is { } textureInCache)
|
||||
if (TryGetTextureFromCache(texturePath,
|
||||
out (Texture2D texture, bool hasAlphaChannel) textureInCache))
|
||||
{
|
||||
return textureInCache;
|
||||
hasAlphaChannel = textureInCache.hasAlphaChannel;
|
||||
return textureInCache.texture;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Pal3.Dev
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.Utils;
|
||||
using IngameDebugConsole;
|
||||
using Input;
|
||||
using MetaData;
|
||||
@@ -29,7 +30,7 @@ namespace Pal3.Dev
|
||||
using UnityEngine.InputSystem.DualShock;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public sealed class StorySelector : MonoBehaviour,
|
||||
public sealed class MainMenu : MonoBehaviour,
|
||||
ICommandExecutor<ToggleStorySelectorRequest>,
|
||||
ICommandExecutor<GameSwitchToMainMenuCommand>,
|
||||
ICommandExecutor<ScenePostLoadingNotification>
|
||||
@@ -2044,18 +2045,19 @@ namespace Pal3.Dev
|
||||
CanvasGroup storySelectorCanvas,
|
||||
GameObject storySelectorButtonPrefab)
|
||||
{
|
||||
_gameSettings = gameSettings ?? throw new ArgumentNullException(nameof(gameSettings));
|
||||
_inputManager = inputManager ?? throw new ArgumentNullException(nameof(inputManager));
|
||||
_eventSystem = eventSystem != null ? eventSystem : throw new ArgumentNullException(nameof(eventSystem));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_gameStateManager = gameStateManager ?? throw new ArgumentNullException(nameof(gameStateManager));
|
||||
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
|
||||
_inputManager = Requires.IsNotNull(inputManager, nameof(inputManager));
|
||||
_eventSystem = Requires.IsNotNull(eventSystem, nameof(eventSystem));
|
||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||
_gameStateManager = Requires.IsNotNull(gameStateManager, nameof(gameStateManager));
|
||||
_scriptManager = Requires.IsNotNull(scriptManager, nameof(scriptManager));
|
||||
_teamManager = Requires.IsNotNull(teamManager, nameof(teamManager));
|
||||
_saveManager = Requires.IsNotNull(saveManager, nameof(saveManager));
|
||||
_informationManager = Requires.IsNotNull(informationManager, nameof(informationManager));
|
||||
_storySelectorCanvas = Requires.IsNotNull(storySelectorCanvas, nameof(storySelectorCanvas));
|
||||
_storySelectorButtonPrefab = Requires.IsNotNull(storySelectorButtonPrefab, nameof(storySelectorButtonPrefab));
|
||||
|
||||
_playerInputActions = inputManager.GetPlayerInputActions();
|
||||
_scriptManager = scriptManager ?? throw new ArgumentNullException(nameof(scriptManager));
|
||||
_teamManager = teamManager ?? throw new ArgumentNullException(nameof(teamManager));
|
||||
_saveManager = saveManager ?? throw new ArgumentNullException(nameof(saveManager));
|
||||
_informationManager = informationManager != null ? informationManager : throw new ArgumentNullException(nameof(informationManager));
|
||||
_storySelectorCanvas = storySelectorCanvas != null ? storySelectorCanvas : throw new ArgumentNullException(nameof(storySelectorCanvas));
|
||||
_storySelectorButtonPrefab = storySelectorButtonPrefab != null ? storySelectorButtonPrefab : throw new ArgumentNullException(nameof(storySelectorButtonPrefab));
|
||||
|
||||
_storySelectorCanvas.alpha = 0f;
|
||||
_storySelectorCanvas.interactable = false;
|
||||
@@ -2063,6 +2065,13 @@ namespace Pal3.Dev
|
||||
_playerInputActions.Gameplay.ToggleStorySelector.performed += ToggleStorySelectorOnPerformed;
|
||||
_playerInputActions.Cutscene.ToggleStorySelector.performed += ToggleStorySelectorOnPerformed;
|
||||
_playerInputActions.Cutscene.ExitCurrentShowingMenu.performed += HideStorySelectorOnPerformed;
|
||||
|
||||
// Toon materials are not available in open source build.
|
||||
// so lighting and shadow will not work, thus we remove the option.
|
||||
if (_gameSettings.IsOpenSourceVersion)
|
||||
{
|
||||
_storySelections.Remove("开启/关闭实时光影");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
File renamed without changes.
@@ -13,6 +13,7 @@ namespace Pal3.Dev
|
||||
using Command.SceCommands;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.Services;
|
||||
using Core.Utils;
|
||||
using MetaData;
|
||||
using Scene;
|
||||
using Script;
|
||||
@@ -900,11 +901,11 @@ namespace Pal3.Dev
|
||||
Button mazeEntranceButton,
|
||||
Button mazeExitButton)
|
||||
{
|
||||
_gameStateManager = gameStateManager ?? throw new ArgumentNullException(nameof(gameStateManager));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_mazeSkipperCanvasGroup = mazeSkipperCanvasGroup != null ? mazeSkipperCanvasGroup : throw new ArgumentNullException(nameof(mazeSkipperCanvasGroup));
|
||||
_mazeEntranceButton = mazeEntranceButton != null ? mazeEntranceButton : throw new ArgumentNullException(nameof(mazeEntranceButton));
|
||||
_mazeExitButton = mazeExitButton != null ? mazeExitButton : throw new ArgumentNullException(nameof(mazeExitButton));
|
||||
_gameStateManager = Requires.IsNotNull(gameStateManager, nameof(gameStateManager));
|
||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||
_mazeSkipperCanvasGroup = Requires.IsNotNull(mazeSkipperCanvasGroup, nameof(mazeSkipperCanvasGroup));
|
||||
_mazeEntranceButton = Requires.IsNotNull(mazeEntranceButton, nameof(mazeEntranceButton));
|
||||
_mazeExitButton = Requires.IsNotNull(mazeExitButton, nameof(mazeExitButton));
|
||||
|
||||
_mazeSkipperCanvasGroup.alpha = 0f;
|
||||
_mazeSkipperCanvasGroup.interactable = false;
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Pal3.Effect
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.GameBox;
|
||||
using Core.Utils;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using Scene;
|
||||
@@ -32,8 +33,8 @@ namespace Pal3.Effect
|
||||
public void Init(GameResourceProvider resourceProvider,
|
||||
SceneManager sceneManager)
|
||||
{
|
||||
_resourceProvider = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_resourceProvider = Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
|
||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace Pal3.Effect.PostProcessing
|
||||
PostProcessLayer postProcessLayer,
|
||||
GameSettings gameSettings)
|
||||
{
|
||||
_postProcessVolume = volume != null ? volume : throw new ArgumentNullException(nameof(volume));
|
||||
_postProcessLayer = postProcessLayer != null ? postProcessLayer : throw new ArgumentNullException(nameof(postProcessLayer));
|
||||
_gameSettings = gameSettings ?? throw new ArgumentNullException(nameof(gameSettings));
|
||||
_postProcessVolume = Requires.IsNotNull(volume, nameof(volume));
|
||||
_postProcessLayer = Requires.IsNotNull(postProcessLayer, nameof(postProcessLayer));
|
||||
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
|
||||
|
||||
_bloom = _postProcessVolume.profile.GetSetting<Bloom>();
|
||||
ToggleBloomBasedOnSetting();
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Pal3.Feature
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.Animation;
|
||||
using Core.Utils;
|
||||
using Data;
|
||||
using Input;
|
||||
using Script.Waiter;
|
||||
@@ -37,9 +38,9 @@ namespace Pal3.Feature
|
||||
PlayerInputActions playerInputActions,
|
||||
Image captionImage)
|
||||
{
|
||||
_gameResourceProvider = gameResourceProvider ?? throw new ArgumentNullException(nameof(gameResourceProvider));
|
||||
_playerInputActions = playerInputActions ?? throw new ArgumentNullException(nameof(playerInputActions));
|
||||
_captionImage = captionImage != null ? captionImage : throw new ArgumentNullException(nameof(captionImage));
|
||||
_gameResourceProvider = Requires.IsNotNull(gameResourceProvider, nameof(gameResourceProvider));
|
||||
_playerInputActions = Requires.IsNotNull(playerInputActions, nameof(playerInputActions));
|
||||
_captionImage = Requires.IsNotNull(captionImage, nameof(captionImage));
|
||||
|
||||
_captionImage.preserveAspect = true;
|
||||
_playerInputActions.Cutscene.Continue.performed += CutsceneContinueOnPerformed;
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Pal3.Feature
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.Utils;
|
||||
using MetaData;
|
||||
using Scene;
|
||||
using Script;
|
||||
@@ -23,8 +24,8 @@ namespace Pal3.Feature
|
||||
|
||||
public void Init(ScriptManager scriptManager, SceneManager sceneManager)
|
||||
{
|
||||
_scriptManager = scriptManager ?? throw new ArgumentNullException(nameof(scriptManager));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_scriptManager = Requires.IsNotNull(scriptManager, nameof(scriptManager));
|
||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
|
||||
@@ -19,11 +19,8 @@ namespace Pal3
|
||||
using MetaData;
|
||||
using Renderer;
|
||||
using Settings;
|
||||
#if UNITY_EDITOR || UNITY_STANDALONE
|
||||
using SimpleFileBrowser;
|
||||
#endif
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Debug = UnityEngine.Debug;
|
||||
@@ -42,10 +39,18 @@ namespace Pal3
|
||||
private const int DEFAULT_CODE_PAGE = 936; // GBK Encoding's code page
|
||||
// change it to 950 to supports Traditional Chinese (Big5)
|
||||
|
||||
// Optional materials that are used in the game but not open sourced
|
||||
private Material _toonDefaultMaterial;
|
||||
private Material _toonTransparentMaterial;
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
loadingText.text = "Loading game assets...";
|
||||
loadingText.text = "正在加载游戏数据...";
|
||||
yield return null; // Wait for next frame to make sure the text is updated
|
||||
|
||||
_toonDefaultMaterial = Resources.Load<Material>("Materials/ToonDefault");
|
||||
_toonTransparentMaterial = Resources.Load<Material>("Materials/ToonTransparent");
|
||||
|
||||
yield return InitResourceAsync();
|
||||
}
|
||||
|
||||
@@ -59,68 +64,72 @@ namespace Pal3
|
||||
crcHash.Init();
|
||||
ServiceLocator.Instance.Register<CrcHash>(crcHash);
|
||||
|
||||
// If toon materials are not present, it's an open source build
|
||||
bool isOpenSourceVersion = _toonDefaultMaterial == null || _toonTransparentMaterial == null;
|
||||
|
||||
// Init settings store
|
||||
ITransactionalKeyValueStore settingsStore = new PlayerPrefsStore();
|
||||
|
||||
// Init settings
|
||||
GameSettings gameSettings = new (settingsStore);
|
||||
GameSettings gameSettings = new (settingsStore, isOpenSourceVersion);
|
||||
gameSettings.InitOrLoadSettings();
|
||||
ServiceLocator.Instance.Register<GameSettings>(gameSettings);
|
||||
|
||||
// Init file system
|
||||
string gameDataFolderPath = gameSettings.GameDataFolderPath;
|
||||
Queue<string> gameDataFolderSearchLocations = new(gameSettings.GetGameDataFolderSearchLocations());
|
||||
ICpkFileSystem cpkFileSystem = null;
|
||||
|
||||
while (cpkFileSystem == null)
|
||||
if (gameDataFolderSearchLocations.Count == 0)
|
||||
{
|
||||
Debug.LogError("No game data folder search locations found.");
|
||||
yield break;
|
||||
}
|
||||
|
||||
while (gameDataFolderSearchLocations.Count > 0)
|
||||
{
|
||||
string gameDataFolderPath = gameDataFolderSearchLocations.Dequeue();
|
||||
Exception exception = null;
|
||||
|
||||
yield return InitFileSystemAsync(gameDataFolderPath,
|
||||
crcHash, codepage, fileSystem =>
|
||||
crcHash, codepage, (fileSystem, ex) =>
|
||||
{
|
||||
cpkFileSystem = fileSystem;
|
||||
exception = ex;
|
||||
});
|
||||
|
||||
if (cpkFileSystem == null)
|
||||
if (cpkFileSystem != null) // Init file system successfully
|
||||
{
|
||||
string userPickedGameDataFolderPath = null;
|
||||
ServiceLocator.Instance.Register<ICpkFileSystem>(cpkFileSystem);
|
||||
|
||||
#if UNITY_EDITOR || UNITY_STANDALONE
|
||||
yield return FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.Folders,
|
||||
allowMultiSelection: false,
|
||||
initialPath: null,
|
||||
initialFilename: GameConstants.AppName,
|
||||
title: $"请选择<<{GameConstants.AppNameCNFull}>>原始游戏文件夹根目录",
|
||||
loadButtonText: "选择");
|
||||
if (FileBrowser.Success && FileBrowser.Result.Length == 1)
|
||||
{
|
||||
userPickedGameDataFolderPath = FileBrowser.Result[0];
|
||||
}
|
||||
#endif
|
||||
// Save game data folder path when file system initialized successfully,
|
||||
// since it's possible that user changed the game data folder path
|
||||
// during the file system initialization
|
||||
gameSettings.GameDataFolderPath = gameDataFolderPath;
|
||||
|
||||
if (!string.IsNullOrEmpty(userPickedGameDataFolderPath))
|
||||
{
|
||||
gameDataFolderPath = userPickedGameDataFolderPath;
|
||||
loadingText.text = "Loading game assets...";
|
||||
yield return null; // Wait for next frame to make sure the text is updated
|
||||
continue; // Retry when new root path is picked
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EditorApplication.ExitPlaymode();
|
||||
#elif UNITY_STANDALONE
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
|
||||
yield break; // Stop initialization if failed to init file system
|
||||
break; // Stop searching when file system is initialized successfully
|
||||
}
|
||||
|
||||
ServiceLocator.Instance.Register<ICpkFileSystem>(cpkFileSystem);
|
||||
// If file system is not initialized successfully, retry with next search
|
||||
// location when there is any
|
||||
if (gameDataFolderSearchLocations.Count > 0) continue;
|
||||
|
||||
// Save game data folder path when file system initialized successfully,
|
||||
// since it's possible that user changed the game data folder path
|
||||
// during the file system initialization
|
||||
gameSettings.GameDataFolderPath = gameDataFolderPath;
|
||||
string userPickedGameDataFolderPath = null;
|
||||
|
||||
yield return WaitForUserToPickGameDataFolder((path) => userPickedGameDataFolderPath = path);
|
||||
|
||||
if (!string.IsNullOrEmpty(userPickedGameDataFolderPath))
|
||||
{
|
||||
// Enqueue the user picked game data folder path to the search
|
||||
// locations and retry
|
||||
gameDataFolderSearchLocations.Enqueue(userPickedGameDataFolderPath);
|
||||
loadingText.text = "正在重新加载游戏数据...";
|
||||
yield return null; // Wait for next frame to make sure the text is updated
|
||||
}
|
||||
else
|
||||
{
|
||||
loadingText.text = exception == null ? "游戏数据加载失败,未能找到原游戏数据文件" : $"{exception.Message}";
|
||||
yield break; // Stop initialization if failed to init file system
|
||||
}
|
||||
}
|
||||
|
||||
// Init TextureLoaderFactory
|
||||
@@ -129,23 +138,12 @@ namespace Pal3
|
||||
|
||||
// Init material factories
|
||||
IMaterialFactory unlitMaterialFactory = new UnlitMaterialFactory();
|
||||
IMaterialFactory litMaterialFactory;
|
||||
IMaterialFactory litMaterialFactory = null;
|
||||
|
||||
// Check if toon materials are present
|
||||
if (Resources.Load<Material>("Materials/ToonDefault") is { } toonDefaultMaterial &&
|
||||
Resources.Load<Material>("Materials/ToonTransparent") is { } toonTransparentMaterial )
|
||||
// Only create litMaterialFactory when toon materials are present
|
||||
if (_toonDefaultMaterial != null && _toonTransparentMaterial != null)
|
||||
{
|
||||
litMaterialFactory = new LitMaterialFactory(toonDefaultMaterial, toonTransparentMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback to unlit material factory
|
||||
litMaterialFactory = new UnlitMaterialFactory();
|
||||
|
||||
Debug.LogWarning("Toon materials not found. " +
|
||||
"Cannot create LitMaterialFactory. " +
|
||||
"Falling back to UnlitMaterialFactory instead. " +
|
||||
"Lighting and shadow may not work properly when enabled.");
|
||||
litMaterialFactory = new LitMaterialFactory(_toonDefaultMaterial, _toonTransparentMaterial);
|
||||
}
|
||||
|
||||
// Init Game resource provider
|
||||
@@ -169,6 +167,55 @@ namespace Pal3
|
||||
FinalizeInit();
|
||||
}
|
||||
|
||||
private IEnumerator WaitForUserToPickGameDataFolder(Action<string> callback)
|
||||
{
|
||||
string userPickedGameDataFolderPath = null;
|
||||
|
||||
yield return FileBrowser.WaitForLoadDialog(
|
||||
FileBrowser.PickMode.Folders,
|
||||
allowMultiSelection: false,
|
||||
initialPath: null,
|
||||
initialFilename: null,
|
||||
title: $"请选择<<{GameConstants.AppNameCNFull}>>原始游戏文件夹根目录",
|
||||
loadButtonText: "选择");
|
||||
|
||||
if (FileBrowser.Success &&
|
||||
FileBrowser.Result.Length == 1)
|
||||
{
|
||||
#if !UNITY_EDITOR && UNITY_ANDROID
|
||||
// On Android 10+, the result is a content URI of the selected folder in
|
||||
// SAF (Storage Access Framework) format, so we need to copy it to the
|
||||
// persistent data path in order to use it with System.IO APIs
|
||||
if (FileBrowserHelpers.ShouldUseSAF)
|
||||
{
|
||||
string persistentDataPath = Application.persistentDataPath +
|
||||
Path.DirectorySeparatorChar +
|
||||
GameConstants.AppName +
|
||||
Path.DirectorySeparatorChar;
|
||||
|
||||
// Delete the old folder if it exists
|
||||
if (Directory.Exists(persistentDataPath))
|
||||
{
|
||||
Directory.Delete(persistentDataPath, true);
|
||||
}
|
||||
|
||||
loadingText.text = "正在拷贝游戏数据至游戏可访问目录(预计需要几分钟)...";
|
||||
yield return null; // Wait for next frame to make sure the text is updated
|
||||
|
||||
FileBrowserHelpers.CopyDirectory(FileBrowser.Result[0], persistentDataPath);
|
||||
|
||||
userPickedGameDataFolderPath = persistentDataPath;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
userPickedGameDataFolderPath = FileBrowser.Result[0];
|
||||
}
|
||||
}
|
||||
|
||||
callback.Invoke(userPickedGameDataFolderPath);
|
||||
}
|
||||
|
||||
private void FinalizeInit()
|
||||
{
|
||||
foreach (Transform child in transform)
|
||||
@@ -186,7 +233,7 @@ namespace Pal3
|
||||
private IEnumerator InitFileSystemAsync(string gameDataFolderPath,
|
||||
CrcHash crcHash,
|
||||
int codepage,
|
||||
Action<ICpkFileSystem> callback)
|
||||
Action<ICpkFileSystem, Exception> callback)
|
||||
{
|
||||
ICpkFileSystem cpkFileSystem = null;
|
||||
var path = gameDataFolderPath;
|
||||
@@ -222,15 +269,7 @@ namespace Pal3
|
||||
yield return null;
|
||||
}
|
||||
|
||||
if (cpkFileSystem != null)
|
||||
{
|
||||
callback?.Invoke(cpkFileSystem);
|
||||
}
|
||||
else
|
||||
{
|
||||
loadingText.text = $"{exception.Message}";
|
||||
yield return null; // Wait for next frame to make sure the text is updated
|
||||
}
|
||||
callback?.Invoke(cpkFileSystem, exception);
|
||||
}
|
||||
|
||||
private IEnumerator FadeTextAndBackgroundImageAsync()
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Pal3.Input
|
||||
using System;
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Core.Utils;
|
||||
using State;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
@@ -18,8 +19,11 @@ namespace Pal3.Input
|
||||
|
||||
public InputManager(PlayerInputActions playerInputActions)
|
||||
{
|
||||
_playerInputActions = playerInputActions ?? throw new ArgumentNullException(nameof(playerInputActions));
|
||||
SwitchCurrentActionMap(GameState.UI);
|
||||
_playerInputActions = Requires.IsNotNull(playerInputActions, nameof(playerInputActions));
|
||||
|
||||
// Goto initial state
|
||||
SwitchCurrentActionMap(GameState.MenuShowing);
|
||||
|
||||
InputSystem.onActionChange += OnInputActionChange;
|
||||
}
|
||||
|
||||
@@ -59,10 +63,10 @@ namespace Pal3.Input
|
||||
|
||||
InputActionMap inputActionMap = state switch
|
||||
{
|
||||
GameState.MenuShowing => _playerInputActions.UI.Get(),
|
||||
GameState.Gameplay => _playerInputActions.Gameplay.Get(),
|
||||
GameState.Cutscene => _playerInputActions.Cutscene.Get(),
|
||||
GameState.VideoPlaying => _playerInputActions.VideoPlaying.Get(),
|
||||
GameState.UI => _playerInputActions.UI.Get(),
|
||||
_ => null
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Pal3.MiniGame
|
||||
using System;
|
||||
using Command;
|
||||
using Command.SceCommands;
|
||||
using Core.Utils;
|
||||
using Script;
|
||||
|
||||
public sealed class SkiMiniGame : IDisposable,
|
||||
@@ -19,7 +20,7 @@ namespace Pal3.MiniGame
|
||||
|
||||
public SkiMiniGame(ScriptManager scriptManager)
|
||||
{
|
||||
_scriptManager = scriptManager ?? throw new ArgumentNullException(nameof(scriptManager));
|
||||
_scriptManager = Requires.IsNotNull(scriptManager, nameof(scriptManager));
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Pal3
|
||||
|
||||
// Dev tools
|
||||
private MazeSkipper _mazeSkipper;
|
||||
private StorySelector _storySelector;
|
||||
private MainMenu _mainMenu;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -312,8 +312,8 @@ namespace Pal3
|
||||
mazeExitButton);
|
||||
ServiceLocator.Instance.Register(_mazeSkipper);
|
||||
|
||||
_storySelector = gameObject.AddComponent<StorySelector>();
|
||||
_storySelector.Init(
|
||||
_mainMenu = gameObject.AddComponent<MainMenu>();
|
||||
_mainMenu.Init(
|
||||
_gameSettings,
|
||||
_inputManager,
|
||||
eventSystem,
|
||||
@@ -325,7 +325,7 @@ namespace Pal3
|
||||
_informationManager,
|
||||
storySelectionCanvasGroup,
|
||||
storySelectionButtonPrefab);
|
||||
ServiceLocator.Instance.Register(_storySelector);
|
||||
ServiceLocator.Instance.Register(_mainMenu);
|
||||
|
||||
DebugLogManager.Instance.OnLogWindowShown += OnDebugWindowShown;
|
||||
DebugLogManager.Instance.OnLogWindowHidden += OnDebugWindowHidden;
|
||||
@@ -337,7 +337,7 @@ namespace Pal3
|
||||
|
||||
DisableInGameDebugConsoleButtonNavigation();
|
||||
|
||||
_storySelector.Show();
|
||||
_mainMenu.Show();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@@ -376,10 +376,10 @@ namespace Pal3
|
||||
Destroy(_dialogueManager);
|
||||
Destroy(_hotelManager);
|
||||
Destroy(_bigMapManager);
|
||||
Destroy(_storySelector);
|
||||
Destroy(_captionRenderer);
|
||||
Destroy(_postProcessManager);
|
||||
Destroy(_effectManager);
|
||||
Destroy(_mainMenu);
|
||||
|
||||
if (_cursorManager != null)
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Pal3.Player
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.DataReader.Gdb;
|
||||
using Core.Utils;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -29,7 +30,7 @@ namespace Pal3.Player
|
||||
|
||||
public InventoryManager(GameResourceProvider resourceProvider)
|
||||
{
|
||||
_ = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));
|
||||
Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
|
||||
_gameItemsInfo = resourceProvider.GetGameItems();
|
||||
_items[MoneyItemID] = 0; // init money
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Pal3.Player
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using Core.Renderer;
|
||||
using Core.Utils;
|
||||
using Data;
|
||||
using Input;
|
||||
using MetaData;
|
||||
@@ -96,13 +97,13 @@ namespace Pal3.Player
|
||||
SceneManager sceneManager,
|
||||
Camera mainCamera)
|
||||
{
|
||||
_resourceProvider = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));
|
||||
_gameStateManager = gameStateManager ?? throw new ArgumentNullException(nameof(gameStateManager));
|
||||
_playerManager = playerManager ?? throw new ArgumentNullException(nameof(playerManager));
|
||||
_teamManager = teamManager ?? throw new ArgumentNullException(nameof(teamManager));
|
||||
_inputActions = inputActions ?? throw new ArgumentNullException(nameof(inputActions));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_camera = mainCamera != null ? mainCamera : throw new ArgumentNullException(nameof(mainCamera));
|
||||
_resourceProvider = Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
|
||||
_gameStateManager = Requires.IsNotNull(gameStateManager, nameof(gameStateManager));
|
||||
_playerManager = Requires.IsNotNull(playerManager, nameof(playerManager));
|
||||
_teamManager = Requires.IsNotNull(teamManager, nameof(teamManager));
|
||||
_inputActions = Requires.IsNotNull(inputActions, nameof(inputActions));
|
||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||
_camera = Requires.IsNotNull(mainCamera, nameof(mainCamera));
|
||||
|
||||
_inputActions.Gameplay.OnTap.performed += OnTapPerformed;
|
||||
_inputActions.Gameplay.OnMove.performed += OnMovePerformed;
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Pal3.Player
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.Utils;
|
||||
using MetaData;
|
||||
using Scene;
|
||||
using UnityEngine;
|
||||
@@ -52,8 +53,8 @@ namespace Pal3.Player
|
||||
|
||||
public TeamManager(PlayerManager playerManager, SceneManager sceneManager)
|
||||
{
|
||||
_playerManager = playerManager ?? throw new ArgumentNullException(nameof(playerManager));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_playerManager = Requires.IsNotNull(playerManager, nameof(playerManager));
|
||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Pal3.Scene
|
||||
using Command.SceCommands;
|
||||
using Core.DataReader.Sce;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.Utils;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using Newtonsoft.Json;
|
||||
@@ -45,11 +46,11 @@ namespace Pal3.Scene
|
||||
GameSettings gameSettings,
|
||||
Camera mainCamera)
|
||||
{
|
||||
_resourceProvider = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));
|
||||
_sceneStateManager = sceneStateManager ?? throw new ArgumentNullException(nameof(sceneStateManager));
|
||||
_scriptManager = scriptManager ?? throw new ArgumentNullException(nameof(scriptManager));
|
||||
_gameSettings = gameSettings ?? throw new ArgumentNullException(nameof(gameSettings));
|
||||
_mainCamera = mainCamera != null ? mainCamera : throw new ArgumentNullException(nameof(mainCamera));
|
||||
_resourceProvider = Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
|
||||
_sceneStateManager = Requires.IsNotNull(sceneStateManager, nameof(sceneStateManager));
|
||||
_scriptManager = Requires.IsNotNull(scriptManager, nameof(scriptManager));
|
||||
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
|
||||
_mainCamera = Requires.IsNotNull(mainCamera, nameof(mainCamera));
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Pal3.Script
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.DataReader.Sce;
|
||||
using Core.Utils;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using Newtonsoft.Json;
|
||||
@@ -37,7 +38,7 @@ namespace Pal3.Script
|
||||
|
||||
public ScriptManager(GameResourceProvider resourceProvider)
|
||||
{
|
||||
resourceProvider = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));
|
||||
resourceProvider = Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
|
||||
_systemSceFile = resourceProvider.GetSystemSce();
|
||||
_bigMapSceFile = resourceProvider.GetBigMapSce();
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
@@ -210,6 +211,8 @@ namespace Pal3.Script
|
||||
|
||||
public void Execute(ResetGameStateCommand command)
|
||||
{
|
||||
_pendingSceneScriptExecution = false;
|
||||
|
||||
foreach (PalScriptRunner script in _pendingScripts)
|
||||
{
|
||||
script.OnCommandExecutionRequested -= OnCommandExecutionRequested;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
namespace Pal3.Settings
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -21,8 +22,12 @@ namespace Pal3.Settings
|
||||
{
|
||||
private static Resolution _nativeResolution;
|
||||
|
||||
public GameSettings(ITransactionalKeyValueStore settingsStore) : base(settingsStore)
|
||||
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.Last();
|
||||
@@ -47,15 +52,19 @@ namespace Pal3.Settings
|
||||
"设置音乐音量设定(0.0:静音,1.0:最大音量)", _ => MusicVolume = _);
|
||||
DebugLogConsole.AddCommand<float>("Settings.SfxVolume",
|
||||
"设置音效音量设定(0.0:静音,1.0:最大音量)", _ => SfxVolume = _);
|
||||
DebugLogConsole.AddCommand<bool>("Settings.IsRealtimeLightingAndShadowsEnabled",
|
||||
"设置实时光照和阴影设定(true:开启,false:关闭)", _ => IsRealtimeLightingAndShadowsEnabled = _);
|
||||
DebugLogConsole.AddCommand<bool>("Settings.IsAmbientOcclusionEnabled",
|
||||
"设置环境光遮蔽设定(true:开启,false:关闭)", _ => IsAmbientOcclusionEnabled = _);
|
||||
DebugLogConsole.AddCommand<bool>("Settings.IsVoiceOverEnabled",
|
||||
"设置角色配音设定(true:开启,false:关闭)", _ => IsVoiceOverEnabled = _);
|
||||
DebugLogConsole.AddCommand<string>("Settings.GameDataFolderPath",
|
||||
"设置自定义游戏数据文件夹路径", _ => GameDataFolderPath = _);
|
||||
|
||||
if (!IsOpenSourceVersion)
|
||||
{
|
||||
DebugLogConsole.AddCommand<bool>("Settings.IsRealtimeLightingAndShadowsEnabled",
|
||||
"设置实时光照和阴影设定(true:开启,false:关闭)", _ => IsRealtimeLightingAndShadowsEnabled = _);
|
||||
DebugLogConsole.AddCommand<bool>("Settings.IsAmbientOcclusionEnabled",
|
||||
"设置环境光遮蔽设定(true:开启,false:关闭)", _ => IsAmbientOcclusionEnabled = _);
|
||||
}
|
||||
|
||||
DebugLogConsole.AddCommand("Settings.Save",
|
||||
"保存所有设置", SaveSettings);
|
||||
DebugLogConsole.AddCommand("Settings.Reset",
|
||||
@@ -187,21 +196,18 @@ namespace Pal3.Settings
|
||||
SfxVolume = 0.5f;
|
||||
}
|
||||
|
||||
if (SettingsStore.TryGet(nameof(IsRealtimeLightingAndShadowsEnabled),
|
||||
out bool isRealtimeLightingAndShadowsEnabled))
|
||||
if (IsOpenSourceVersion)
|
||||
{
|
||||
IsRealtimeLightingAndShadowsEnabled = isRealtimeLightingAndShadowsEnabled;
|
||||
// Toon materials are available in closed source builds only
|
||||
// so there will be no lit shader variants in the build for lighting to work
|
||||
IsRealtimeLightingAndShadowsEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if Toon materials are available
|
||||
// (Note: Toon materials are not open sourced on GitHub since it's a paid asset)
|
||||
if (Resources.Load<Material>("Materials/ToonDefault") == null ||
|
||||
Resources.Load<Material>("Materials/ToonTransparent") == null)
|
||||
if (SettingsStore.TryGet(nameof(IsRealtimeLightingAndShadowsEnabled),
|
||||
out bool isRealtimeLightingAndShadowsEnabled))
|
||||
{
|
||||
Debug.LogWarning("Toon materials not found. Cannot enable realtime lighting and shadows. " +
|
||||
"Falling back to baked lighting and shadows.");
|
||||
IsRealtimeLightingAndShadowsEnabled = false;
|
||||
IsRealtimeLightingAndShadowsEnabled = isRealtimeLightingAndShadowsEnabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -210,18 +216,28 @@ namespace Pal3.Settings
|
||||
}
|
||||
}
|
||||
|
||||
if (SettingsStore.TryGet(nameof(IsAmbientOcclusionEnabled), out bool isAmbientOcclusionEnabled))
|
||||
if (IsOpenSourceVersion)
|
||||
{
|
||||
IsAmbientOcclusionEnabled = isAmbientOcclusionEnabled;
|
||||
// Toon materials are available in closed source builds only
|
||||
// so there will be no lit shader variants in the build for lighting to work
|
||||
// thus AO will not work anyway
|
||||
IsAmbientOcclusionEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_ANDROID // AO not working well with OpenGL on Android
|
||||
IsAmbientOcclusionEnabled = false;
|
||||
#else
|
||||
// Enable ambient occlusion by default on desktop devices
|
||||
IsAmbientOcclusionEnabled = Utility.IsDesktopDevice();
|
||||
#endif
|
||||
if (SettingsStore.TryGet(nameof(IsAmbientOcclusionEnabled), out bool isAmbientOcclusionEnabled))
|
||||
{
|
||||
IsAmbientOcclusionEnabled = isAmbientOcclusionEnabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_ANDROID // AO not working well with OpenGL on Android
|
||||
IsAmbientOcclusionEnabled = false;
|
||||
#else
|
||||
// Enable ambient occlusion by default on desktop devices
|
||||
IsAmbientOcclusionEnabled = Utility.IsDesktopDevice();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (SettingsStore.TryGet(nameof(IsVoiceOverEnabled), out bool isVoiceOverEnabled))
|
||||
@@ -234,33 +250,33 @@ namespace Pal3.Settings
|
||||
IsVoiceOverEnabled = true;
|
||||
}
|
||||
|
||||
// Only allow game data folder path to be customized on standalone platforms
|
||||
#if UNITY_STANDALONE
|
||||
if (SettingsStore.TryGet(nameof(GameDataFolderPath), out string gameDataFolderPath))
|
||||
{
|
||||
GameDataFolderPath = gameDataFolderPath;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetGameDataFolderSearchLocations()
|
||||
{
|
||||
// Use game data folder path if it is not empty
|
||||
// GameDataFolderPath is either set by the user or the last
|
||||
// successfully loaded game data folder path
|
||||
if (!string.IsNullOrEmpty(GameDataFolderPath))
|
||||
{
|
||||
// Set game data folder path to persistent data path by default
|
||||
// Note: On iOS, I am using streaming assets path instead of persistent
|
||||
// data path because I ship game data with the app bundle for TestFlight.
|
||||
// You can change this to persistent data path if you want to upload
|
||||
// game data to the device via iTunes File Sharing. This is useful for
|
||||
// locally testing and debugging since you can rebuild and update the
|
||||
// app without having to re-upload the game data every time (XCode will
|
||||
// re-upload game data to your device for every new build if data is
|
||||
// stored inside streaming assets folder).
|
||||
#if UNITY_IOS
|
||||
GameDataFolderPath = Application.streamingAssetsPath +
|
||||
#else
|
||||
GameDataFolderPath = Application.persistentDataPath +
|
||||
#endif
|
||||
Path.DirectorySeparatorChar +
|
||||
GameConstants.AppName +
|
||||
Path.DirectorySeparatorChar;
|
||||
yield return GameDataFolderPath;
|
||||
}
|
||||
|
||||
// Streaming assets path
|
||||
yield return Application.streamingAssetsPath +
|
||||
Path.DirectorySeparatorChar +
|
||||
GameConstants.AppName +
|
||||
Path.DirectorySeparatorChar;
|
||||
|
||||
// Persistent data path
|
||||
yield return Application.persistentDataPath +
|
||||
Path.DirectorySeparatorChar +
|
||||
GameConstants.AppName +
|
||||
Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Pal3.Settings
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
using Core.Utils;
|
||||
|
||||
/// <summary>
|
||||
/// Base class to hold all settings properties.
|
||||
@@ -21,7 +21,7 @@ namespace Pal3.Settings
|
||||
|
||||
internal SettingsBase(ITransactionalKeyValueStore settingsStore)
|
||||
{
|
||||
SettingsStore = settingsStore ?? throw new ArgumentNullException(nameof(settingsStore));
|
||||
SettingsStore = Requires.IsNotNull(settingsStore, nameof(settingsStore));
|
||||
}
|
||||
|
||||
private void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace Pal3.State
|
||||
{
|
||||
public enum GameState
|
||||
{
|
||||
MenuShowing,
|
||||
Gameplay,
|
||||
Cutscene,
|
||||
VideoPlaying,
|
||||
UI
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ namespace Pal3.State
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.Utils;
|
||||
using Input;
|
||||
using Script;
|
||||
using UnityEngine;
|
||||
@@ -34,10 +35,10 @@ namespace Pal3.State
|
||||
|
||||
public GameStateManager(InputManager inputManager, ScriptManager scriptManager)
|
||||
{
|
||||
_inputManager = inputManager ?? throw new ArgumentNullException(nameof(inputManager));
|
||||
_scriptManager = scriptManager ?? throw new ArgumentNullException(nameof(scriptManager));
|
||||
_previousState = GameState.UI;
|
||||
_currentState = GameState.UI;
|
||||
_inputManager = Requires.IsNotNull(inputManager, nameof(inputManager));
|
||||
_scriptManager = Requires.IsNotNull(scriptManager, nameof(scriptManager));
|
||||
_previousState = GameState.MenuShowing; // Initial state
|
||||
_currentState = GameState.MenuShowing; // Initial state
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ namespace Pal3.State
|
||||
public void EnterDebugState()
|
||||
{
|
||||
_isDebugging = true;
|
||||
_inputManager.SwitchCurrentActionMap(GameState.UI);
|
||||
_inputManager.SwitchCurrentActionMap(GameState.MenuShowing);
|
||||
}
|
||||
|
||||
public void LeaveDebugState()
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Pal3.State
|
||||
using Command.SceCommands;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using Core.Utils;
|
||||
using Effect;
|
||||
using Effect.PostProcessing;
|
||||
using Feature;
|
||||
@@ -62,17 +63,17 @@ namespace Pal3.State
|
||||
AudioManager audioManager,
|
||||
PostProcessManager postProcessManager)
|
||||
{
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_playerManager = playerManager ?? throw new ArgumentNullException(nameof(playerManager));
|
||||
_teamManager = teamManager ?? throw new ArgumentNullException(nameof(teamManager));
|
||||
_inventoryManager = inventoryManager ?? throw new ArgumentNullException(nameof(inventoryManager));
|
||||
_sceneStateManager = sceneStateManager ?? throw new ArgumentNullException(nameof(sceneStateManager));
|
||||
_bigMapManager = bigMapManager != null ? bigMapManager : throw new ArgumentNullException(nameof(bigMapManager));
|
||||
_scriptManager = scriptManager ?? throw new ArgumentNullException(nameof(scriptManager));
|
||||
_favorManager = favorManager ?? throw new ArgumentNullException(nameof(favorManager));
|
||||
_cameraManager = cameraManager != null ? cameraManager : throw new ArgumentNullException(nameof(cameraManager));
|
||||
_audioManager = audioManager != null ? audioManager : throw new ArgumentNullException(nameof(audioManager));
|
||||
_postProcessManager = postProcessManager != null ? postProcessManager : throw new ArgumentNullException(nameof(postProcessManager));
|
||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||
_playerManager = Requires.IsNotNull(playerManager, nameof(playerManager));
|
||||
_teamManager = Requires.IsNotNull(teamManager, nameof(teamManager));
|
||||
_inventoryManager = Requires.IsNotNull(inventoryManager, nameof(inventoryManager));
|
||||
_sceneStateManager = Requires.IsNotNull(sceneStateManager, nameof(sceneStateManager));
|
||||
_bigMapManager = Requires.IsNotNull(bigMapManager, nameof(bigMapManager));
|
||||
_scriptManager = Requires.IsNotNull(scriptManager, nameof(scriptManager));
|
||||
_favorManager = Requires.IsNotNull(favorManager, nameof(favorManager));
|
||||
_cameraManager = Requires.IsNotNull(cameraManager, nameof(cameraManager));
|
||||
_audioManager = Requires.IsNotNull(audioManager, nameof(audioManager));
|
||||
_postProcessManager = Requires.IsNotNull(postProcessManager, nameof(postProcessManager));
|
||||
}
|
||||
|
||||
private string GetSaveFilePath()
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Pal3.UI
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.Utils;
|
||||
using Input;
|
||||
using Script;
|
||||
using MetaData;
|
||||
@@ -54,14 +55,15 @@ namespace Pal3.UI
|
||||
CanvasGroup bigMapCanvas,
|
||||
GameObject bigMapRegionButtonPrefab)
|
||||
{
|
||||
_eventSystem = eventSystem != null ? eventSystem : throw new ArgumentNullException(nameof(eventSystem));
|
||||
_gameStateManager = gameStateManager ?? throw new ArgumentNullException(nameof(gameStateManager));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_inputManager = inputManager ?? throw new ArgumentNullException(nameof(inputManager));
|
||||
_eventSystem = Requires.IsNotNull(eventSystem, nameof(eventSystem));
|
||||
_gameStateManager = Requires.IsNotNull(gameStateManager, nameof(gameStateManager));
|
||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||
_inputManager = Requires.IsNotNull(inputManager, nameof(inputManager));
|
||||
_scriptManager = Requires.IsNotNull(scriptManager, nameof(scriptManager));
|
||||
_bigMapCanvas = Requires.IsNotNull(bigMapCanvas, nameof(bigMapCanvas));
|
||||
_bigMapRegionButtonPrefab = Requires.IsNotNull(bigMapRegionButtonPrefab, nameof(bigMapRegionButtonPrefab));
|
||||
|
||||
_playerInputActions = inputManager.GetPlayerInputActions();
|
||||
_scriptManager = scriptManager ?? throw new ArgumentNullException(nameof(scriptManager));
|
||||
_bigMapCanvas = bigMapCanvas != null ? bigMapCanvas : throw new ArgumentNullException(nameof(bigMapCanvas));
|
||||
_bigMapRegionButtonPrefab = bigMapRegionButtonPrefab != null ? bigMapRegionButtonPrefab : throw new ArgumentNullException(nameof(bigMapRegionButtonPrefab));
|
||||
|
||||
_bigMapCanvas.alpha = 0f;
|
||||
_bigMapCanvas.interactable = false;
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Pal3.UI
|
||||
using System;
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Core.Utils;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
@@ -20,7 +21,7 @@ namespace Pal3.UI
|
||||
|
||||
public void Init(GameResourceProvider gameResourceProvider)
|
||||
{
|
||||
gameResourceProvider = gameResourceProvider ?? throw new ArgumentNullException(nameof(gameResourceProvider));
|
||||
gameResourceProvider = Requires.IsNotNull(gameResourceProvider, nameof(gameResourceProvider));
|
||||
_cursorTextureNormal = gameResourceProvider.GetCursorTexture();
|
||||
Cursor.SetCursor(_cursorTextureNormal, Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Pal3.UI
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.Utils;
|
||||
using Data;
|
||||
using Input;
|
||||
using MetaData;
|
||||
@@ -81,24 +82,24 @@ namespace Pal3.UI
|
||||
Canvas dialogueSelectionButtonsCanvas,
|
||||
GameObject dialogueSelectionButtonPrefab)
|
||||
{
|
||||
_dialogueCanvas = dialogueCanvas != null ? dialogueCanvas : throw new ArgumentNullException(nameof(dialogueCanvas));
|
||||
_gameStateManager = gameStateManager ?? throw new ArgumentNullException(nameof(gameStateManager));
|
||||
_dialogueBackgroundImage = dialogueBackgroundImage != null ? dialogueBackgroundImage : throw new ArgumentNullException(nameof(dialogueBackgroundImage));
|
||||
_resourceProvider = Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
|
||||
_gameStateManager = Requires.IsNotNull(gameStateManager, nameof(gameStateManager));
|
||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||
_inputManager = Requires.IsNotNull(inputManager, nameof(inputManager));
|
||||
_eventSystem = Requires.IsNotNull(eventSystem, nameof(eventSystem));
|
||||
|
||||
_avatarImageLeft = avatarImageLeft != null ? avatarImageLeft : throw new ArgumentNullException(nameof(avatarImageLeft));
|
||||
_avatarImageRight = avatarImageRight != null ? avatarImageRight : throw new ArgumentNullException(nameof(avatarImageRight));
|
||||
_dialogueCanvas = Requires.IsNotNull(dialogueCanvas, nameof(dialogueCanvas));
|
||||
_dialogueBackgroundImage = Requires.IsNotNull(dialogueBackgroundImage, nameof(dialogueBackgroundImage));
|
||||
|
||||
_dialogueTextLeft = textLeft != null ? textLeft : throw new ArgumentNullException(nameof(textLeft));
|
||||
_dialogueTextRight = textRight != null ? textRight : throw new ArgumentNullException(nameof(textRight));
|
||||
_dialogueTextDefault = textDefault != null ? textDefault : throw new ArgumentNullException(nameof(textDefault));
|
||||
_avatarImageLeft = Requires.IsNotNull(avatarImageLeft, nameof(avatarImageLeft));
|
||||
_avatarImageRight = Requires.IsNotNull(avatarImageRight, nameof(avatarImageRight));
|
||||
|
||||
_dialogueSelectionButtonsCanvas = dialogueSelectionButtonsCanvas != null ? dialogueSelectionButtonsCanvas : throw new ArgumentNullException(nameof(dialogueSelectionButtonsCanvas));
|
||||
_dialogueSelectionButtonPrefab = dialogueSelectionButtonPrefab != null ? dialogueSelectionButtonPrefab : throw new ArgumentNullException(nameof(dialogueSelectionButtonPrefab));
|
||||
_dialogueTextLeft = Requires.IsNotNull(textLeft, nameof(textLeft));
|
||||
_dialogueTextRight = Requires.IsNotNull(textRight, nameof(textRight));
|
||||
_dialogueTextDefault = Requires.IsNotNull(textDefault, nameof(textDefault));
|
||||
|
||||
_eventSystem = eventSystem != null ? eventSystem : throw new ArgumentNullException(nameof(eventSystem));
|
||||
_resourceProvider = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
_inputManager = inputManager ?? throw new ArgumentNullException(nameof(inputManager));
|
||||
_dialogueSelectionButtonsCanvas = Requires.IsNotNull(dialogueSelectionButtonsCanvas, nameof(dialogueSelectionButtonsCanvas));
|
||||
_dialogueSelectionButtonPrefab = Requires.IsNotNull(dialogueSelectionButtonPrefab, nameof(dialogueSelectionButtonPrefab));
|
||||
|
||||
_avatarImageLeft.preserveAspect = true;
|
||||
_avatarImageRight.preserveAspect = true;
|
||||
@@ -454,7 +455,7 @@ namespace Pal3.UI
|
||||
|
||||
public void Execute(DialogueAddSelectionsCommand command)
|
||||
{
|
||||
_gameStateManager.GoToState(GameState.UI);
|
||||
_gameStateManager.GoToState(GameState.MenuShowing);
|
||||
|
||||
var waiter = new WaitUntilCanceled();
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
|
||||
|
||||
@@ -41,9 +41,9 @@ namespace Pal3.UI
|
||||
|
||||
public void Init(CanvasGroup noteCanvasGroup, TextMeshProUGUI noteText, TextMeshProUGUI debugInfo)
|
||||
{
|
||||
_noteCanvasGroup = noteCanvasGroup != null ? noteCanvasGroup : throw new ArgumentNullException(nameof(noteCanvasGroup));
|
||||
_noteText = noteText != null ? noteText : throw new ArgumentNullException(nameof(noteText));
|
||||
_debugInfo = debugInfo != null ? debugInfo : throw new ArgumentNullException(nameof(debugInfo));
|
||||
_noteCanvasGroup = Requires.IsNotNull(noteCanvasGroup, nameof(noteCanvasGroup));
|
||||
_noteText = Requires.IsNotNull(noteText, nameof(noteText));
|
||||
_debugInfo = Requires.IsNotNull(debugInfo, nameof(debugInfo));
|
||||
|
||||
_noteCanvasGroup.alpha = 0f;
|
||||
_heapSize = GC.GetTotalMemory(false) / (1024f * 1024f);
|
||||
|
||||
@@ -33,10 +33,10 @@ namespace Pal3.UI
|
||||
Button bigMapButton,
|
||||
Button storySelectionButton)
|
||||
{
|
||||
_touchControlUI = touchControlUI != null ? touchControlUI : throw new ArgumentNullException(nameof(touchControlUI));
|
||||
_interactionButton = interactionButton != null ? interactionButton : throw new ArgumentNullException(nameof(interactionButton));
|
||||
_bigMapButton = bigMapButton != null ? bigMapButton : throw new ArgumentNullException(nameof(bigMapButton));
|
||||
_storySelectionButton = storySelectionButton != null ? storySelectionButton : throw new ArgumentNullException(nameof(storySelectionButton));
|
||||
_touchControlUI = Requires.IsNotNull(touchControlUI, nameof(touchControlUI));
|
||||
_interactionButton = Requires.IsNotNull(interactionButton, nameof(interactionButton));
|
||||
_bigMapButton = Requires.IsNotNull(bigMapButton, nameof(bigMapButton));
|
||||
_storySelectionButton = Requires.IsNotNull(storySelectionButton, nameof(storySelectionButton));
|
||||
|
||||
_touchControlUI.enabled = false;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Pal3.Video
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.Utils;
|
||||
using Data;
|
||||
using Input;
|
||||
using Script.Waiter;
|
||||
@@ -34,11 +35,11 @@ namespace Pal3.Video
|
||||
Canvas videoPlayerUI,
|
||||
VideoPlayer videoPlayer)
|
||||
{
|
||||
_resourceProvider = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));
|
||||
_gameStateManager = gameStateManager ?? throw new ArgumentNullException(nameof(gameStateManager));
|
||||
_inputActions = inputActions ?? throw new ArgumentNullException(nameof(inputActions));
|
||||
_videoPlayerUI = videoPlayerUI != null ? videoPlayerUI : throw new ArgumentNullException(nameof(videoPlayerUI));
|
||||
_videoPlayer = videoPlayer != null ? videoPlayer : throw new ArgumentNullException(nameof(videoPlayer));
|
||||
_resourceProvider = Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
|
||||
_gameStateManager = Requires.IsNotNull(gameStateManager, nameof(gameStateManager));
|
||||
_inputActions = Requires.IsNotNull(inputActions, nameof(inputActions));
|
||||
_videoPlayerUI = Requires.IsNotNull(videoPlayerUI, nameof(videoPlayerUI));
|
||||
_videoPlayer = Requires.IsNotNull(videoPlayer, nameof(videoPlayer));
|
||||
|
||||
_videoPlayerUI.enabled = false;
|
||||
_videoPlayer.loopPointReached += StopVideoInternal;
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace ResourceViewer
|
||||
using IngameDebugConsole;
|
||||
using Newtonsoft.Json;
|
||||
using Pal3.Command;
|
||||
using Pal3.Command.SceCommands;
|
||||
using Pal3.Data;
|
||||
using Pal3.MetaData;
|
||||
using Pal3.Renderer;
|
||||
@@ -105,8 +106,15 @@ namespace ResourceViewer
|
||||
DebugLogConsole.AddCommand<string>("Search", "Search files using keyword.", Search);
|
||||
DebugLogConsole.AddCommand<string, bool>("Load", "Load a file to the viewer (.pol, .cvd, .mp3 or .mv3).", Load);
|
||||
#if UNITY_EDITOR
|
||||
DebugLogConsole.AddCommand("DecompileAllSceScripts", "Decompile all .sce scripts into txt format.", DecompileAllSceScripts);
|
||||
DebugLogConsole.AddCommand("ExtractAllCpkArchives", "Extract all .cpk archives into the output directory.", ExtractAllCpkArchives);
|
||||
DebugLogConsole.AddCommand("DecompileAllSceScripts",
|
||||
"Decompile all .sce scripts into txt format.",
|
||||
() => DecompileAllSceScripts(dialogueOnly: false));
|
||||
DebugLogConsole.AddCommand("DecompileAllDialogues",
|
||||
"Decompile all dialogues in .sce scripts into txt format.",
|
||||
() => DecompileAllSceScripts(dialogueOnly: true));
|
||||
DebugLogConsole.AddCommand("ExtractAllCpkArchives",
|
||||
"Extract all .cpk archives into the output directory.",
|
||||
ExtractAllCpkArchives);
|
||||
#endif
|
||||
|
||||
//__Malicious__Dev_Only__();
|
||||
@@ -355,20 +363,22 @@ namespace ResourceViewer
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void DecompileAllSceScripts()
|
||||
private void DecompileAllSceScripts(bool dialogueOnly)
|
||||
{
|
||||
var sceFiles = _fileSystem.Search(".sce")
|
||||
.Where(_ => !_.Contains(".bak", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
var outputFolderPath = EditorUtility.SaveFolderPanel("选择脚本导出目录", "", "");
|
||||
outputFolderPath += $"{Path.DirectorySeparatorChar}{GameConstants.AppName}";
|
||||
string title = dialogueOnly ? "选择脚本导出目录(仅对话)" : "选择脚本导出目录";
|
||||
|
||||
var outputFolderPath = EditorUtility.SaveFolderPanel(title, "", "");
|
||||
outputFolderPath += $"{Path.DirectorySeparatorChar}{GameConstants.AppName}" + (dialogueOnly ? "_对话脚本" : "");
|
||||
|
||||
if (!Directory.Exists(outputFolderPath))
|
||||
{
|
||||
Directory.CreateDirectory(outputFolderPath);
|
||||
}
|
||||
|
||||
foreach (var sceFile in sceFiles) if (!DecompileSce(sceFile, outputFolderPath)) break;
|
||||
foreach (var sceFile in sceFiles) if (!DecompileSce(sceFile, outputFolderPath, dialogueOnly)) break;
|
||||
}
|
||||
|
||||
private void ExtractAllCpkArchives()
|
||||
@@ -407,7 +417,8 @@ namespace ResourceViewer
|
||||
}
|
||||
#endif
|
||||
|
||||
private bool DecompileSce(string filePath, string outputFolderPath)
|
||||
private readonly Dictionary<string, int> _actorDialogueCountMap = new ();
|
||||
private bool DecompileSce(string filePath, string outputFolderPath, bool dialogueOnly)
|
||||
{
|
||||
var output = new StringBuilder();
|
||||
|
||||
@@ -432,6 +443,9 @@ namespace ResourceViewer
|
||||
|
||||
using var scriptDataReader = new BinaryReader(new MemoryStream(scriptBlock.Value.ScriptData));
|
||||
|
||||
int dialogueIndex = 1;
|
||||
ICommand lastCommand = null;
|
||||
|
||||
while (scriptDataReader.BaseStream.Position < scriptDataReader.BaseStream.Length)
|
||||
{
|
||||
var currentPosition = scriptDataReader.BaseStream.Position;
|
||||
@@ -440,11 +454,54 @@ namespace ResourceViewer
|
||||
|
||||
ICommand command = SceCommandParser.ParseSceCommand(scriptDataReader, commandId, parameterFlag, DEFAULT_CODE_PAGE);
|
||||
|
||||
output.Append($"{currentPosition} {command.GetType().Name.Replace("Command", "")} " +
|
||||
$"{JsonConvert.SerializeObject(command)}\n");
|
||||
if (dialogueOnly && command is DialogueRenderTextCommand
|
||||
or DialogueRenderTextWithTimeLimitCommand)
|
||||
{
|
||||
string dialogueText = command is DialogueRenderTextCommand textCommand
|
||||
? textCommand.DialogueText
|
||||
: ((DialogueRenderTextWithTimeLimitCommand) command).DialogueText;
|
||||
|
||||
bool isTimeLimited = command is DialogueRenderTextWithTimeLimitCommand;
|
||||
|
||||
string avatarTextureName = lastCommand is DialogueRenderActorAvatarCommand avatarCommand
|
||||
? avatarCommand.AvatarTextureName
|
||||
: string.Empty;
|
||||
|
||||
if (dialogueText.Contains("龙葵") && avatarTextureName.StartsWith("106"))
|
||||
{
|
||||
dialogueText = dialogueText.Replace("龙葵", "龙葵(红)");
|
||||
}
|
||||
|
||||
dialogueText = dialogueText
|
||||
.Replace("\\n", "")
|
||||
.Replace("\\i", "")
|
||||
.Replace("\\r", "");
|
||||
|
||||
output.Append(isTimeLimited
|
||||
? $"{dialogueIndex:000} [限时对话] {dialogueText}\n"
|
||||
: $"{dialogueIndex:000} {dialogueText}\n");
|
||||
|
||||
if (dialogueText.Contains(":"))
|
||||
{
|
||||
var actorName = dialogueText.Substring(0, dialogueText.IndexOf(":", StringComparison.Ordinal));
|
||||
if (_actorDialogueCountMap.ContainsKey(actorName)) _actorDialogueCountMap[actorName]++;
|
||||
else _actorDialogueCountMap.Add(actorName, 1);
|
||||
}
|
||||
|
||||
dialogueIndex++;
|
||||
}
|
||||
else if (!dialogueOnly)
|
||||
{
|
||||
output.Append($"{currentPosition} {command.GetType().Name.Replace("Command", "")} " +
|
||||
$"{JsonConvert.SerializeObject(command)}\n");
|
||||
}
|
||||
|
||||
lastCommand = command;
|
||||
}
|
||||
|
||||
output.Append($"{scriptDataReader.BaseStream.Length} __END__\n");
|
||||
output.Append(dialogueOnly
|
||||
? $"共{dialogueIndex - 1}句对话 \n"
|
||||
: $"{scriptDataReader.BaseStream.Length} __END__\n");
|
||||
}
|
||||
|
||||
var cpkFileName = filePath.Substring(filePath.LastIndexOf(CpkConstants.DirectorySeparator) + 1).Replace(".sce", "");
|
||||
@@ -452,10 +509,22 @@ namespace ResourceViewer
|
||||
var sceneName = SceneConstants.SceneCpkNameInfos
|
||||
.FirstOrDefault(_ => string.Equals(_.cpkName, cpkFileName + CpkConstants.FileExtension, StringComparison.OrdinalIgnoreCase)).sceneName;
|
||||
|
||||
if (dialogueOnly && _actorDialogueCountMap.Count > 0)
|
||||
{
|
||||
output.AppendLine().AppendLine();
|
||||
output.Append("-----角色对话统计----\n");
|
||||
foreach (var actorDialogueCount in from entry
|
||||
in _actorDialogueCountMap orderby entry.Value descending select entry)
|
||||
{
|
||||
output.Append($"{actorDialogueCount.Key} - {actorDialogueCount.Value}句\n");
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(string.IsNullOrEmpty(sceneName)
|
||||
? $"{outputFolderPath}{Path.DirectorySeparatorChar}{cpkFileName}.txt"
|
||||
: $"{outputFolderPath}{Path.DirectorySeparatorChar}{cpkFileName}_{sceneName}.txt", output.ToString());
|
||||
|
||||
_actorDialogueCountMap.Clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"com.unity.test-framework": "1.1.33",
|
||||
"com.unity.textmeshpro": "3.0.6",
|
||||
"com.unity.timeline": "1.7.4",
|
||||
"com.unity.toolchain.macos-x86_64-linux-x86_64": "2.0.4",
|
||||
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.4",
|
||||
"com.unity.ugui": "1.0.0",
|
||||
"com.unity.visualscripting": "1.8.0",
|
||||
|
||||
@@ -161,6 +161,16 @@
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.toolchain.macos-x86_64-linux-x86_64": {
|
||||
"version": "2.0.4",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.sysroot": "2.0.5",
|
||||
"com.unity.sysroot.linux-x86_64": "2.0.4"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.toolchain.win-x86_64-linux-x86_64": {
|
||||
"version": "2.0.4",
|
||||
"depth": 0,
|
||||
|
||||
@@ -133,7 +133,7 @@ PlayerSettings:
|
||||
vulkanEnableLateAcquireNextImage: 0
|
||||
vulkanEnableCommandBufferRecycling: 1
|
||||
loadStoreDebugModeEnabled: 0
|
||||
bundleVersion: 0.51
|
||||
bundleVersion: 0.52
|
||||
preloadedAssets: []
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
@@ -530,16 +530,16 @@ PlayerSettings:
|
||||
m_SubKind:
|
||||
m_BuildTargetBatching:
|
||||
- m_BuildTarget: Standalone
|
||||
m_StaticBatching: 1
|
||||
m_StaticBatching: 0
|
||||
m_DynamicBatching: 0
|
||||
- m_BuildTarget: tvOS
|
||||
m_StaticBatching: 1
|
||||
m_StaticBatching: 0
|
||||
m_DynamicBatching: 0
|
||||
- m_BuildTarget: Android
|
||||
m_StaticBatching: 1
|
||||
m_StaticBatching: 0
|
||||
m_DynamicBatching: 0
|
||||
- m_BuildTarget: iPhone
|
||||
m_StaticBatching: 1
|
||||
m_StaticBatching: 0
|
||||
m_DynamicBatching: 0
|
||||
- m_BuildTarget: WebGL
|
||||
m_StaticBatching: 0
|
||||
@@ -547,7 +547,7 @@ PlayerSettings:
|
||||
m_BuildTargetShaderSettings: []
|
||||
m_BuildTargetGraphicsJobs:
|
||||
- m_BuildTarget: MacStandaloneSupport
|
||||
m_GraphicsJobs: 0
|
||||
m_GraphicsJobs: 1
|
||||
- m_BuildTarget: Switch
|
||||
m_GraphicsJobs: 1
|
||||
- m_BuildTarget: MetroSupport
|
||||
@@ -921,8 +921,9 @@ PlayerSettings:
|
||||
additionalCompilerArguments: {}
|
||||
platformArchitecture: {}
|
||||
scriptingBackend:
|
||||
Android: 1
|
||||
Standalone: 1
|
||||
Android: 0
|
||||
Standalone: 0
|
||||
iPhone: 1
|
||||
il2cppCompilerConfiguration: {}
|
||||
il2cppCodeGeneration: {}
|
||||
managedStrippingLevel:
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
m_EditorVersion: 2022.2.11f1
|
||||
m_EditorVersionWithRevision: 2022.2.11f1 (621cd60d08fd)
|
||||
m_EditorVersion: 2022.2.12f1
|
||||
m_EditorVersionWithRevision: 2022.2.12f1 (022dac4955a3)
|
||||
@@ -0,0 +1,84 @@
|
||||
<p align="center">
|
||||
<img width="128" align="center" src="Assets/Resources/UI/game-icon-PAL3.png">
|
||||
+
|
||||
<img width="128" align="center" src="Assets/Resources/UI/game-icon-PAL3A.png">
|
||||
</p>
|
||||
<h1 align="center">
|
||||
Pal3.Unity
|
||||
</h1>
|
||||
<p align="center">
|
||||
The Legend of Sword and Fairy 3 & The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian re-implementation using C#/Unity
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="README.md">简体中文</a> | English
|
||||
</p>
|
||||
<p align="center">
|
||||
<a style="text-decoration:none">
|
||||
<img src="https://img.shields.io/badge/unity-2022.2.12-blue?style=flat-square" alt="Unity Version" />
|
||||
</a>
|
||||
<a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/releases">
|
||||
<img src="https://img.shields.io/github/v/release/0x7c13/Pal3.Unity.svg?label=alpha&style=flat-square&color=yellow" alt="Releases" />
|
||||
</a>
|
||||
<a style="text-decoration:none">
|
||||
<img src="https://img.shields.io/badge/platform-Linux%20%7C%20Win%20%7C%20Mac%20%7C%20iOS%20%7C%20Android-orange?style=flat-square" alt="Platform" />
|
||||
</a>
|
||||
<a style="text-decoration:none">
|
||||
<img src="https://img.shields.io/badge/license-GPL--3.0-green?style=flat-square" alt="License" />
|
||||
</a>
|
||||
<a style="text-decoration:none">
|
||||
<img src="https://img.shields.io/github/repo-size/jasonstein/pal3.unity?style=flat-square" alt="Size" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
# Intro
|
||||
This is an open-source project that re-implements [The Legend of Sword and Fairy 3](https://en.wikipedia.org/wiki/Chinese_Paladin_3) and [The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian](https://en.wikipedia.org/wiki/Chinese_Paladin_3_Gaiden:_Wenqing_Pian) using C#/Unity. The implementation involves rewriting of the game logic, loading and utilizing the original game assets, and recreating the original game's behavior and effects. Please refer to the source code to see how it is been made.
|
||||
|
||||
Note: The Legend of Sword and Fairy 3 and The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian are original works of Softstar Technology (Shanghai) Co., Ltd., with copyrights belonging to Softstar Technology (Shanghai) Co., Ltd. and Softstar International Inc. (I might be wrong but please verify yourself). This project does not contain any game data from the original game. The project is under the GPL-3.0 license but is limited to the code of this project excluding Unity assets and other assets and plugins that I used and get from Unity Asset Store. Any textures, audio, video, or game data related to The Legend of Sword and Fairy 3 or The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian are not covered by this license.
|
||||
|
||||
## Build status
|
||||
| Game Variant | Windows | Linux | MacOS | Android | iOS |
|
||||
|-------------------------|---------|-------|-------|---------|-----|
|
||||
| The Legend of Sword and Fairy 3 | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3-mono-windows.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3-mono-windows.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3-mono-linux.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3-mono-linux.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3-mono-macos.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3-mono-macos.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3-mono-android.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3-mono-android.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3-mono-ios.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3-mono-ios.yml" alt="Size" /></a> |
|
||||
| The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3a-mono-windows.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3a-mono-windows.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3a-mono-linux.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3a-mono-linux.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3a-mono-macos.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3a-mono-macos.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3a-mono-android.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3a-mono-android.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3a-mono-ios.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3a-mono-ios.yml" alt="Size" /></a> |
|
||||
|
||||
## How to run the project
|
||||
Open the current project folder using Unity 2022.2.X. For the specific Unity version required for the current project, please check the badge displayed above. In theory, any Unity 2022.2+ version should work. You can also try a lower version to see if it builds.
|
||||
Since the project itself does not contain any game data from the original game, you will need a copy of the original game files for The Legend of Sword and Fairy 3 or The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian (Link to the game on Steam: [The Legend of Sword and Fairy 3](https://store.steampowered.com/app/1536070) and [The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian](https://store.steampowered.com/app/1536080); Note: currently the build only supports Simplified Chinese version).
|
||||
|
||||
After opening the Unity project for the first time, double-click to select "Scenes\Game" as the current scene, and then press the play button. If you select "Scenes\ResourceViewer", it will open the game resource viewer.
|
||||
The first time you open it, a folder selection window will automatically pop up. Please select the installation folder for The Legend of Sword and Fairy 3 (or The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian) on your computer.
|
||||
Since the original game's cutscene videos are in Bink format, which Unity does not natively support, please convert the videos to a format supported by Unity and place them in the movie folder at the game's root directory (most devices and platforms support mainstream formats like .mp4, while Linux only supports .webm format).
|
||||
Linux users can use FFmpeg to convert videos to .webm format
|
||||
```
|
||||
ffmpeg -i input.mp4 -c:v libvpx -b:v 3M -c:a libvorbis output.webm // vp8 + vorbis
|
||||
```
|
||||
Note: You need to first decompress the OG game data to get the .bik videos. You can do this by running "ExtractAllCpkArchives" command under "Scenes\ResourceViewer" scene, which decompress all the CPK archives in the OG game data folder to a destination folder you choose. All .bik videos will be extracted to the output location once complete.
|
||||
|
||||
## How to run the game
|
||||
- In runtime, when the game is launched for the first time, it will search the [Application.persistentDataPath](https://docs.unity3d.com/2022.2/Documentation/ScriptReference/Application-persistentDataPath.html) directory or the [StreamingAssets](https://docs.unity3d.com/2022.2/Documentation/Manual/StreamingAssets.html) directory to detect whether the game data exists. If the original game data files cannot be detected on desktop clients, the game will pop up a folder selection window for you to select the root directory of the original game installation files on the current device.
|
||||
- If the previous step is unsuccessful, please copy the entire "The Legend of Sword and Fairy 3" (or The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian) original game installation directory to [Application.persistentDataPath](https://docs.unity3d.com/2022.2/Documentation/ScriptReference/Application-persistentDataPath.html). Note: If you manually copy the game data to this directory, the folder name must be PAL3 for "The Legend of Sword and Fairy 3," and PAL3A for The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian. For iOS devices, please use iTunes to share the folder with the game application (this location is where the persistentDataPath is located), or you can package the original game data into the StreamingAssets folder during compilation with Unity, so you don't have to pick a folder when deployed.
|
||||
|
||||
## How to switch between two variants of the game
|
||||
The version switching is implemented through [Custom scripting symbols](https://docs.unity3d.com/2022.2/Documentation/Manual/CustomScriptingSymbols.html). PAL3 corresponds to The Legend of Sword and Fairy 3, and PAL3A corresponds to The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian. I added a shortcut button in the Unity editor menu bar for one-click switching (Menu bar->Pal3->Switch Variant->PAL3A). After switching, the corresponding game folder will automatically change from PAL3 to PAL3A.
|
||||
|
||||
## Screenshots with realtime lighting and toon shading enabled
|
||||

|
||||

|
||||

|
||||
|
||||
## About VFX and Toon Rendering
|
||||
Note: All currently implemented special effects and toon rendering in the game use resources from the Unity Asset Store, so there is no way to open-source this part of the implementation (VFX Prefabs and Toon shader). The project will use the open-source Shader for rendering by default (consistent with the original game's rendering style), and VFX will not be displayed in your cloned project (it won't affect the build and run of the project).
|
||||
|
||||
## Controls
|
||||
- Mouse and keyboard: Left mouse button to click and control character movement (arrow keys can also be used), A/D to control camera rotation, Spacebar to interact with nearby items or NPCs (also used as the jump button when available), M key to toggle the big map, U key or ESC key to open the story selection menu, Tab key to switch characters (in the maze).
|
||||
- Gamepad: Left joystick to control character movement, right joystick to control camera rotation, use gamepad south button to interact, menu and select buttons corresponding to the map and story selection menu, LB/RB to switch to the previous/next character (in the maze).
|
||||
- Touchscreen: Only enabled on handheld devices with a touch screen, virtual joystick for movement, interaction button for interaction.
|
||||
|
||||
## Project State and Roadmap
|
||||
The story parts of The Legend of Sword and Fairy 3 and The Legend of Sword and Fairy 3 Gaiden: Wenqing Pian are complete. Both games can be played entirely from start to finish to experience the story, and the story selection menu provided in the game can be used to jump to different story points in the game. Most of the switches and puzzles in the mazes in both games have also been implemented, but combat, mini-games, and various systems and features related to supporting the combat system have not been implemented or realized. In addition, the main menu and most of the UI/UX need to be redesigned and implemented as well.
|
||||
|
||||
## How to Contribute?
|
||||
Since the project is still in the early stages, many systems have not yet been implemented, thus I am temporarily not accepting large Pull Requests, especially feature ones. If you have good ideas, suggestions, or have discovered bugs, please feel free to submit an issue.
|
||||
|
||||
## Why make this [TL;DR]
|
||||
After learning Unity for a few weeks, I've been looking for a project to practice. As I surfing the Internet, I discovered the [PAL3patch](https://github.com/zhangboyang/PAL3patch) project created by zby and the [OpenPAL3](https://github.com/dontpanic92/OpenPAL3) project created by dontpanic92, which made the re-implementation of a remake for The Legend of Sword and Fairy 3 possible. As for why I chose C#/Unity, there are two reasons: First, Unity has excellent cross-platform support and packaging, and second, Unity provides native IDE support for Mac with M1/M2 chips (Why? I spend about half of my time coding on a Macbook). Although this project barely uses most of Unity's engine features, especially its editor features, since it's almost 100% code-based, it could theoretically be ported to other engines that support C# scripting with minimal effort.
|
||||
@@ -7,11 +7,17 @@
|
||||
Pal3.Unity
|
||||
</h1>
|
||||
<p align="center">
|
||||
仙剑奇侠传三(以及外传)C#/Unity实现
|
||||
<<仙剑奇侠传三>>和<<仙剑奇侠传三外传:问情篇>>C#/Unity实现
|
||||
</p>
|
||||
<p align="center">
|
||||
简体中文 | <a href="README.en-US.md">English</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a style="text-decoration:none">
|
||||
<img src="https://img.shields.io/badge/unity-2022.2.11-blue?style=flat-square" alt="Unity Version" />
|
||||
<img src="https://img.shields.io/badge/unity-2022.2.12-blue?style=flat-square" alt="Unity Version" />
|
||||
</a>
|
||||
<a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/releases">
|
||||
<img src="https://img.shields.io/github/v/release/0x7c13/Pal3.Unity.svg?label=alpha&style=flat-square&color=yellow" alt="Releases" />
|
||||
</a>
|
||||
<a style="text-decoration:none">
|
||||
<img src="https://img.shields.io/badge/platform-Linux%20%7C%20Win%20%7C%20Mac%20%7C%20iOS%20%7C%20Android-orange?style=flat-square" alt="Platform" />
|
||||
@@ -25,10 +31,15 @@
|
||||
</p>
|
||||
|
||||
# 简介
|
||||
这是一个使用C#/Unity重新实现的仙剑奇侠传三以及仙剑奇侠传三外传的开源项目,注意:不是移植,是重写/利用原始游戏资源从零开始重新实现。仙剑奇侠传三以及仙剑奇侠传三外传属于原上海软星作品,版权属于软星科技以及大宇公司所有,本项目不包含任何仙剑奇侠传三以及仙剑奇侠传三外传的游戏本体数据。本项目的实现方式为运行时读取仙剑奇侠传三原始游戏数据实现,具体实现方法请见源代码。本项目遵循GPL-3.0协议,但仅限于此项目的代码,任何与仙剑奇侠传三或者外传有关的图片,音视频,游戏数据均不在此范围,任何未经版权方许可的情况下使用仙剑奇侠传三或者外传游戏数据进行商业行为都是违法的。
|
||||
这是一个使用C#/Unity重新实现的仙剑奇侠传三以及仙剑奇侠传三外传的开源项目(注意:不是移植,是重写)。实现方式为重写游戏逻辑和加载读取利用原始游戏资源并按照原始游戏的运行方式和效果进行的重新实现,具体实现方法请阅读源代码。
|
||||
|
||||
## 为什么要做这个?
|
||||
学了几周Unity,想找项目练手,一开始自己尝试做了一下新仙剑的第一关,大概了解了RPG游戏的制作流程,后因机缘巧合发现了zby大佬的[PAL3patch](https://github.com/zhangboyang/PAL3patch)项目以及dontpanic92大佬的[OpenPAL3](https://github.com/dontpanic92/OpenPAL3)项目,所以给技术上实现仙三复刻带来了可能。至于为什么选择C#/Unity?选择Unity的原因有两点,第一是Unity对全平台全端的打包做的很好很方便,第二个是Unity提供Mac上arm64原生IDE支持(我大概有一半时间是在Mac上写代码的)。当然其实本项目的实现几乎没有用到Unity引擎的大部分功能,特别是编辑器功能,因为几乎是100%纯代码实现的,所以其实理论上不需要花太大的代价就可以把本项目移植到其他支持C#脚本的引擎中。
|
||||
注意:仙剑奇侠传三以及仙剑奇侠传三外传属于原上海软星作品,版权属于软星科技以及大宇公司所有,本项目不包含任何仙剑奇侠传三以及仙剑奇侠传三外传的游戏本体数据。本项目遵循GPL-3.0协议,但仅限于此项目的代码,任何与仙剑奇侠传三或者外传有关的图片,音视频,游戏数据均不在此范围,任何未经版权方许可的情况下使用仙剑奇侠传三或者外传游戏数据进行商业行为都是违法的。
|
||||
|
||||
## 主分支当前编译状态
|
||||
| 游戏版本 | Windows | Linux | MacOS | Android | iOS |
|
||||
|-------------------------|---------|-------|-------|---------|-----|
|
||||
| 仙剑奇侠传三 | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3-mono-windows.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3-mono-windows.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3-mono-linux.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3-mono-linux.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3-mono-macos.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3-mono-macos.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3-mono-android.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3-mono-android.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3-mono-ios.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3-mono-ios.yml" alt="Size" /></a> |
|
||||
| 仙剑奇侠传三外传:问情篇 | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3a-mono-windows.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3a-mono-windows.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3a-mono-linux.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3a-mono-linux.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3a-mono-macos.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3a-mono-macos.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3a-mono-android.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3a-mono-android.yml" alt="Size" /></a> | <a style="text-decoration:none" href="https://github.com/0x7c13/Pal3.Unity/actions/workflows/build-pal3a-mono-ios.yml"><img src="https://img.shields.io/github/actions/workflow/status/0x7c13/Pal3.Unity/build-pal3a-mono-ios.yml" alt="Size" /></a> |
|
||||
|
||||
## 如何运行项目
|
||||
使用 Unity 2022.2.X 打开当前项目文件夹即可,具体当前项目所需要的Unity版本请查看上面的Badge显示的版本,理论上任何Unity 2022.2+版本都没问题。
|
||||
@@ -36,15 +47,17 @@
|
||||
- 第一次打开Unity项目之后,先双击选择Scenes\Game作为当前场景,然后点播放键即可。如果选择Scenes\ResourceViewer,则会打开游戏资源查看器。
|
||||
- 第一次打开的时候会自动弹出文件夹选择窗口,请选择当前电脑上仙剑奇侠传三(或者外传)的安装文件夹即可。
|
||||
- 因为原始游戏的过场动画为Bink格式,Unity并不原生支持,所以请自行转码视频为Unity所支持的格式放在游戏根目录下的movie文件夹即可(大部分设备和系统支持.mp4等主流格式视频,Linux下仅支持.webm格式视频)。
|
||||
* Linux用户可以使用FFmpeg转码视频为.webm格式封装(vp8 + vorbis):ffmpeg -i input.mp4 -c:v libvpx -b:v 3M -c:a libvorbis output.webm
|
||||
* Linux用户可以使用FFmpeg转码视频为.webm格式封装,首先您需要选择Scenes\ResourceViewer场景,然后输入"ExtractAllCpkArchives"指令来解压所有原始游戏中的.cpk压缩包(包含movie.cpk,所有的Bink动画文件均在这个压缩包中)
|
||||
```
|
||||
ffmpeg -i input.mp4 -c:v libvpx -b:v 3M -c:a libvorbis output.webm // vp8 + vorbis
|
||||
```
|
||||
|
||||
## 如何在手持设备上运行
|
||||
- 在打包后的运行时,所有平台都默认使用Application.persistentDataPath目录读取仙剑三文件,具体这个目录在哪里,根据平台决定,请阅读Unity文档:[Application.persistentDataPath](https://docs.unity3d.com/2022.2/Documentation/ScriptReference/Application-persistentDataPath.html)
|
||||
- 第一次安装游戏到手持设备后,请先运行一次,然后将手持设备连接电脑,拷贝整个仙剑奇侠三(或者外传)原游戏目录到游戏App目录下即可,如果是仙剑三,文件夹的名必须为PAL3,如果是仙剑三外传,文件夹名必须为PAL3A。
|
||||
- iOS设备请使用iTunes将文件夹共享给游戏应用。
|
||||
## 如何在终端设备上运行游戏
|
||||
- 在打包后的运行时,第一次游戏启动的时候,游戏会搜索 [Application.persistentDataPath](https://docs.unity3d.com/2022.2/Documentation/ScriptReference/Application-persistentDataPath.html) 目录或者 [StreamingAssets](https://docs.unity3d.com/2022.2/Documentation/Manual/StreamingAssets.html) 目录来检测游戏数据是否存在。在桌面版本的游戏中,如果未能检测到原始游戏的数据文件,游戏则会弹出文件夹选择窗口,请选择当前设备上原游戏安装文件的根目录即可。
|
||||
- 如果上一步未成功,请拷贝整个仙剑奇侠三(或者外传)原游戏目录到 [Application.persistentDataPath](https://docs.unity3d.com/2022.2/Documentation/ScriptReference/Application-persistentDataPath.html) 下即可。注意:如果自行拷贝游戏数据至这个目录的话,如果是仙剑三,文件夹的名称必须为PAL3,如果是仙剑三外传,文件夹名必须为PAL3A。iOS设备请使用iTunes将文件夹共享给游戏应用(这个位置就是persistentDataPath所在的地方)或者在编译时自行打包游戏原始数据到StreamingAssets文件夹下也可。
|
||||
|
||||
## 如何切换仙剑奇侠传三/仙剑奇侠传三外传
|
||||
版本的切换是靠Define symbol实现的,PAL3对应仙剑奇侠传三,PAL3A对应仙剑奇侠传三外传。我在Unity编辑器菜单栏里面加了一个快捷按钮可以一键切换(菜单栏->Pal3->Switch Variant->PAL3A),切换之后对应的游戏文件夹也自动的从PAL3转换成PAL3A。
|
||||
两部游戏版本在项目中的切换是靠 [Custom scripting symbols](https://docs.unity3d.com/2022.2/Documentation/Manual/CustomScriptingSymbols.html) 实现的,PAL3对应仙剑奇侠传三,PAL3A对应仙剑奇侠传三外传。我在Unity编辑器菜单栏里面加了一个快捷按钮可以一键切换(菜单栏->Pal3->Switch Variant->PAL3A),切换之后对应的游戏文件夹也自动的从PAL3转换成PAL3A。切换的过程中,包括Symbol,图标和应用程序名在内的所有名称和标示都会由PAL3变为PAL3A。
|
||||
|
||||
## 卡通渲染与光影下的截图
|
||||

|
||||
@@ -52,7 +65,7 @@
|
||||

|
||||
|
||||
## 关于特效和卡通渲染
|
||||
注意:游戏当前实现的所有特效以及卡通渲染部分使用了Unity Asset Store的资源,所以这部分实现(特效Prefab和Toon shader)没有办法开源。项目启动后默认会使用开源实现的Shader进行渲染(与原始游戏渲染风格一致),特效的话则会不显示。
|
||||
注意:游戏当前实现的所有特效以及卡通渲染部分使用了Unity Asset Store的资源,所以这部分实现(特效Prefab和Toon shader)没有办法开源。项目启动后默认会使用开源实现的Shader进行渲染(与原始游戏渲染风格一致),特效的话则会不显示,注意:这并不会影响游戏的编译和运行。
|
||||
|
||||
## 按键以及操作
|
||||
- 鼠标键盘:鼠标左键点击操作人物行走方向(键盘方向键也可以),AD控制镜头旋转,空格与周边附近的物品或者NPC交互(也是跳跃键),M键打开大地图,U键或ESC键打开剧情选择菜单,Tab键切换角色(迷宫中)。
|
||||
@@ -60,12 +73,15 @@
|
||||
- 触屏:仅在有触摸屏的手持设备上才会启用,虚拟摇杆控制行走,交互键互动。
|
||||
|
||||
## 项目进度以及路线图
|
||||
仙剑奇侠传三以及仙剑奇侠传三外传的剧情部分已经全部完成,两部游戏都可以完整的从头玩到尾体验一遍剧情,也可以使用游戏内提供的剧情选择菜单跳转至预设好的剧情时间点。两部游戏中的迷宫机关也基本全部实现,但是战斗,小游戏以及围绕支持战斗系统的各类系统和功能均尚未完成。另外主菜单和大部分界面也需要重新设计和实现(毕竟现在还要做手机端的适配)。
|
||||
仙剑奇侠传三以及仙剑奇侠传三外传的剧情部分已经全部完成,两部游戏都可以完整的从头玩到尾体验一遍剧情,也可以使用游戏内提供的剧情选择菜单跳转至预设好的剧情时间点。两部游戏中的迷宫机关也基本全部实现,剧情中出现的大部分特效也已经重新实现。但是战斗,小游戏以及围绕支持战斗系统的各类系统和功能均尚未完成。另外主菜单和大部分界面也需要重新设计和实现(毕竟现在还要做手机端的适配)。
|
||||
|
||||
## 如何贡献?
|
||||
因为项目还处于早期实现过程中,很多系统还没有实现,暂时不接受比较大的Pull request,特别是feature类型,如果您有好的想法,意见或者发现了Bug请欢迎提交issue或者加入交流群与我讨论。
|
||||
另外您还可以参考这个项目解析视频:https://www.bilibili.com/video/BV1Pr4y167sF
|
||||
|
||||
## 为什么要做这个?[TL;DR]
|
||||
学了几周Unity之后,一直想找项目练手,一开始自己尝试做了一下新仙剑的第一关,大概了解了RPG游戏的制作流程,后因机缘巧合发现了zby大佬的[PAL3patch](https://github.com/zhangboyang/PAL3patch)项目以及dontpanic92大佬的[OpenPAL3](https://github.com/dontpanic92/OpenPAL3)项目,所以给技术上实现仙三复刻带来了可能。至于为什么选择C#/Unity?选择Unity的原因有两点,第一是Unity对全平台全端的支持和打包做的很好很方便,第二个是Unity提供Mac上arm64原生IDE支持(我大概有一半时间是在Mac上写代码的)。当然其实本项目的实现几乎没有用到Unity引擎的大部分功能,特别是编辑器功能,因为几乎是100%纯代码实现的,所以其实理论上不需要花太大的代价就可以把本项目移植到其他支持C#脚本的引擎中。
|
||||
|
||||
## 社区
|
||||
* 仙剑三(及外传)复刻版讨论群:252315306
|
||||
* 仙剑三(及外传)复刻版开发群:330680869
|
||||
Reference in new issue
Block a user