Compare commits

..
117 Commits
Author SHA1 Message Date
Jiaqi Liu 5944c664f1 Update QualitySettings.asset 2022-11-07 02:45:53 -08:00
Jiaqi Liu 72f77ff1a7 v0.31 2022-11-07 02:37:22 -08:00
Jiaqi Liu 41efbdce8e Use CascadedShadowMaps for tier 3 mobile devices 2022-11-07 02:36:42 -08:00
Jackie Liu d751d5ea2a Hide collectable and chests 2022-11-07 02:34:03 -08:00
Jackie Liu 12ef307fe6 VFX WIP 2022-11-07 02:09:22 -08:00
Jackie Liu bc672d6179 Fix CVD normal issue 2022-11-06 05:58:00 -08:00
Jackie Liu fbadf6766e Add GamePad deadzone processor & code refactoring 2022-11-06 04:42:47 -08:00
Jiaqi Liu 41502ddefb Lighting tweaks 2022-11-03 06:58:44 -07:00
Jackie Liu 61ca35b1b8 Code refactoring 2022-11-01 19:05:05 -07:00
Jiaqi Liu cbb4d5e575 Bug fixes 2022-11-01 05:12:40 -07:00
Jiaqi Liu b37ac428d2 Minor fixes 2022-11-01 01:13:40 -07:00
Jiaqi Liu f9d17a9896 Disable automatic graphics API on Android 2022-11-01 01:00:29 -07:00
Jackie Liu 65d4fefd6f Update QualitySettings.asset 2022-10-31 21:16:12 -07:00
Jackie Liu 5e746c7922 v0.30 2022-10-31 21:06:31 -07:00
Jackie Liu 3c31cb1787 Lighting tweaks 2022-10-31 20:30:16 -07:00
Jackie Liu b0ea2f8638 Effect sprite rendering issue fixes
Also fixed portal base sprite rotation issue
2022-10-31 05:06:44 -07:00
Jackie Liu e38ffc9a40 Distortion code refactoring 2022-10-31 02:56:04 -07:00
Jiaqi Liu 96e2d151f9 Update QualitySettings.asset 2022-10-31 02:46:49 -07:00
yunyouandJackie Liu 23fa70496b 使用官方 PostProcessing ,扩展出来了一个 Distortion 的后处理 (#9)
* +extend PostProcessing , integrate Water wave Distortion into the game. Test it with "EffectSetScreenEffect 0"

Co-authored-by: Jackie Liu <jackil@microsoft.com>
2022-10-31 16:54:42 +08:00
Jackie Liu b3f67d3683 Lighting tweaks 2022-10-31 01:32:49 -07:00
Jackie Liu 84e44d7eec Lighting tweaks 2022-10-30 01:38:27 -07:00
Jackie Liu 661d2ce1c0 Nav mesh fixes 2022-10-30 00:58:46 -07:00
Jackie Liu be695cc353 Lighting tweaks 2022-10-29 19:56:27 -07:00
Jackie Liu 6aa8da32ea Code refactoring and bug fixes 2022-10-29 19:01:45 -07:00
Jackie Liu 2de4bce9e1 Tweak camera nearClipPlane value 2022-10-28 19:07:08 -07:00
Jackie Liu 56ec4d81ad Fix poly and cvd normal issues 2022-10-28 18:49:40 -07:00
Jackie Liu 261ad74a74 Fix mv3 normal issue by splitting the vertices & fix nav mesh facing issue 2022-10-28 17:45:04 -07:00
Jiaqi Liu 654ade106e Update screenshots 2022-10-28 06:01:59 -07:00
Jiaqi Liu 15970562d7 Bump Unity version 2022-10-27 22:31:47 -07:00
Jackie Liu c3fe8198d4 Fix build error 2022-10-27 11:09:10 -07:00
Jackie Liu 593e915dcd Calculate MV3 normals in Mv3FileReader 2022-10-27 01:58:02 -07:00
Jackie Liu 6d6f195aad Enable Ambient Occlusion on desktop devices 2022-10-26 19:03:46 -07:00
Jackie Liu 17814972f4 Tweak fire effect light source location 2022-10-26 18:39:47 -07:00
Jackie Liu a898c69b79 Fix mv3 normals with code refactoring 2022-10-26 18:24:58 -07:00
Jackie Liu 4d473bf69b Reduce shadowResolution 2022-10-26 01:08:23 -07:00
Jackie Liu 9eb091ead6 Temp workaround for mv3 normals 2022-10-26 00:07:52 -07:00
Jackie Liu 49f25b255e Add ToonMaterialFactory, temp fix for normals 2022-10-26 00:07:05 -07:00
Jackie Liu 820c3f1795 Code refactoring 2022-10-25 19:16:25 -07:00
Jackie Liu dac1505886 Move shaders to resource folder 2022-10-25 10:56:50 -07:00
Jackie Liu 2f12c317c4 Lighting tweaks 2022-10-25 00:58:25 -07:00
Jackie Liu 421aeb4c3f Minor tweaks 2022-10-25 00:41:18 -07:00
Jackie Liu 7dfdd4396f All about normals 2022-10-24 18:55:08 -07:00
Jackie Liu 4cf4890693 Light color tweaks 2022-10-24 04:35:13 -07:00
Jiaqi Liu dbeef96411 Update QualitySettings.asset 2022-10-24 04:14:44 -07:00
Jiaqi Liu c47f5b8edb Update SettingsManager.cs 2022-10-24 03:31:05 -07:00
Jackie Liu 173c95c70d Typo fix 2022-10-24 03:20:20 -07:00
Jiaqi Liu 993b5e7653 Experimental (#8)
* Experimental feature
2022-10-24 18:12:03 +08:00
Jiaqi Liu bbeca7a6c6 PostProcessManager code refactoring 2022-10-22 23:19:01 -07:00
Jackie Liu 845f7e8fd5 Fix fire sprite and implement CPK extractor feature in GameResourceViewer 2022-10-21 22:14:33 -07:00
Jackie Liu f2fe362d53 Add bloom effect for VFX with code refactoring 2022-10-21 20:44:19 -07:00
Jackie Liu 53efd23d0f Fix default weapon model for ZiXuan 2022-10-21 01:26:59 -07:00
Jackie Liu 8730c457c2 v0.29 2022-10-21 00:52:32 -07:00
Jackie Liu 1e2e080657 Implement portal ray effect 2022-10-21 00:50:51 -07:00
Jackie Liu a14be2670b VFX WIP: Adding bridge effect 2022-10-21 00:08:50 -07:00
Jackie Liu 766fe2c430 VFX WIP 2022-10-20 02:18:16 -07:00
Jiaqi Liu f7c0aa8e71 Delete 262.prefab.meta 2022-10-19 21:18:52 -07:00
Jackie Liu 18563a5063 Preload VFX prefab 2022-10-19 18:52:40 -07:00
Jackie Liu 5a12990ce1 VFX WIP 2022-10-19 00:27:21 -07:00
Jackie Liu 4c31d56b78 Code refactoring for VFX gameobject 2022-10-18 19:01:33 -07:00
Jackie Liu 9de0e3f9cb Update gitignore 2022-10-18 18:47:21 -07:00
Jackie Liu 8ff5685ed8 VFX init 2022-10-18 18:16:11 -07:00
Jiaqi Liu 4ac04f9e06 Added missing shaders in build bundle 2022-10-17 20:10:38 -07:00
Jiaqi Liu f7c993ef22 Minor tweaks and fixes 2022-10-17 10:15:23 -07:00
Jackie Liu ba68240d77 Minor tweaks 2022-10-17 03:06:59 -07:00
Jackie Liu 76f1b1f551 Fix quaternion calculation for the light source 2022-10-17 02:17:06 -07:00
Jackie Liu dc8b9f6423 Minor fix 2022-10-16 22:40:40 -07:00
Jackie Liu 94b26e15c3 Read Lgt file and create light source objects in editor 2022-10-16 22:27:22 -07:00
yunyouandJiaqi Liu 7ff9146b5e +water using indie material. apply water shadow texture on it (#7)
* +water using indie material. apply water shadow texture on it

* +modify Pal3Water.shader default blend parameter

* Uses first pixel's alpha as water surface opacity

Uses first pixel's alpha as water surface opacity and code refactoring

* Minor tweaks with exposure amount

* Remove empty line

Co-authored-by: Jiaqi Liu <jackil@microsoft.com>
2022-10-16 12:12:57 -07:00
Jackie Liu 2e5421146b EffectDefinition WIP 2022-10-15 17:38:18 -07:00
Jiaqi Liu 780041ec27 Merge pull request #6 from yunyou730/render_order
* Introduce MaterialFactory to manage the creation of materials.
* Fixed semi-transparent object and actor rendering order issue by implementing corresponding shaders with correct render pass.
* Proper implementation of PAL3 sprite shader.
2022-10-15 13:28:43 -07:00
Jackie Liu 8d13753246 Format refactorings 2022-10-15 13:25:38 -07:00
Jackie Liu 1a865a32c0 Code refactoring 2022-10-15 13:03:12 -07:00
Jackie Liu 59d7af002b Fixed a bug where PAL3A portal effect is not rendered correctly 2022-10-15 12:45:18 -07:00
Jackie Liu 9d62fc637a Code refactoring 2022-10-15 12:13:29 -07:00
yunyou da132bdf91 +clean material code 2022-10-15 23:57:00 +08:00
yunyou 0ca80340bc + sync comment with code 2022-10-15 23:43:14 +08:00
yunyou 93228511c3 +fix BlendFlag = 2, additive blend performance issue 2022-10-15 23:33:49 +08:00
miaoyunlong 63b5ca8393 +fix water not perform uv anim issue. 2022-10-15 16:08:29 +08:00
miaoyunlong 9003dbe3fc +3 shaders add _TintColor back (Pal3_Opaque, Pal3_Transparent, Pal3_TransparentOpaquePart) 2022-10-15 14:55:40 +08:00
Jackie Liu d8181e8dd8 Update Mv3ModelRenderer.cs 2022-10-14 20:53:31 -07:00
miaoyunlong 60519b39ef +调整渲染顺序为:Opaque -> SkyBox -> Transparent. 半透明物体会拆成 Opaque 和 Transparent 两部分绘制 2022-10-14 03:26:12 +08:00
miaoyunlong 23d3809cb7 +modify paremters 2022-10-13 22:47:07 +08:00
Jackie Liu 6622b3737c Should only record camera last transform when in gameplay state 2022-10-12 20:45:43 -07:00
miaoyunlong e00eb972a2 +fix transparent material alpha color bug 2022-10-13 01:51:25 +08:00
miaoyunlong e71a244ca6 +fix render order issue 2022-10-13 01:14:42 +08:00
Jiaqi Liu 3b6730b60a Fixed issue with Virtual Joystick UI not showing on some of the Android devices 2022-10-10 06:42:24 -07:00
Jackie Liu 97272bbf0f v0.28 2022-10-10 03:38:48 -07:00
Jackie Liu 4a68472423 Remember last scene state for camera 2022-10-10 03:35:25 -07:00
Jackie Liu 51a5163fc1 Bug fix 2022-10-09 15:12:22 -07:00
Jackie Liu fd3e89c23b Fixed a racing condition when PlayMusicCommand is queued at start of the scene 2022-10-09 14:09:32 -07:00
Jackie Liu 170a78a0bf Use monitor's refresh rate as target frame rate in GameResourceViewer 2022-10-09 12:38:49 -07:00
Jackie Liu 5b69fd1c7f Fixed a bug where player actor might be accidentally activated 2022-10-08 22:31:00 -07:00
Jackie Liu be861dc536 v0.27 2022-10-08 07:07:19 -07:00
Jackie Liu 6dfff9ff57 Draw order issue temp fix 2022-10-08 06:13:58 -07:00
Jiaqi Liu cbe4f82489 Minor refactoring 2022-10-07 19:42:10 -07:00
Jackie Liu 01a41fa834 Proper reloading logic when executing commands from save file 2022-10-07 08:52:56 -07:00
Jackie Liu cb821a0901 Update Pal3AMv3TextureTilingIssue.cs 2022-10-07 04:42:36 -07:00
Jackie Liu 4b36a38b21 Fix render queue and cutoff for Mv3ModelRenderer 2022-10-06 22:10:05 -07:00
Jackie Liu 17ebee5b28 Use alpha blending based on BlendFlag setting 2022-10-06 21:44:16 -07:00
Jackie Liu f0e1b2db98 Properly implement HuaYing's pet following behavior 2022-10-06 18:28:57 -07:00
Jackie Liu 23673aae2a SaveManager WIP 2022-10-06 08:21:07 -07:00
Jackie Liu ca3b28a089 Use monitor's refresh rate as target fps, use Vulkan as default graphics API for Linux build
Use monitor's refresh rate as target fps, use Vulkan as default graphics API for Linux build. Also disable vSync for desktop clients.
2022-10-05 18:00:47 -07:00
Jackie Liu 45b5971ede Fixed a bug where camera is not correctly set for PAL3A start scene 2022-10-05 09:18:22 -07:00
Jiaqi Liu ad97b6a817 Minor fixes 2022-10-05 08:43:28 -07:00
Jackie Liu c92716f3e5 Minor fixes 2022-10-05 03:21:47 -07:00
Jackie Liu 7538ebe506 v0.26 2022-10-05 03:16:00 -07:00
Jackie Liu 1c5623ad7d Introduce UITheme 2022-10-05 03:02:59 -07:00
Jackie Liu eda6c9a1bf Fixed an issue where actor might stuck during collision 2022-10-05 02:47:32 -07:00
Jackie Liu fc4aec4e4d AudioManager bug fixes and refatcotring 2022-10-05 02:05:03 -07:00
Jackie Liu 84355c168f Code refactoring and bug fixes 2022-10-05 00:43:24 -07:00
Jackie Liu 809e55de82 Persist LongKui's current mode in save file 2022-10-04 04:53:24 -07:00
Jackie Liu 7d606ab1f6 Persist actor and object activation state in save file + PlaySfx command proper impl
Persist actor and object activation state in save file + PlaySfx command proper impl
2022-10-04 04:30:15 -07:00
Jackie Liu 14b006dc87 Fixed a bug in DialogueManager
Fixed a bug in DialogueManager where waiter is not properly handled when multiple commands fired at once due to invalid scripts
2022-10-04 01:52:34 -07:00
Jackie Liu 840de611dd UX tweaks and improvements 2022-10-04 01:16:52 -07:00
Jackie Liu 67209cb26e UI tweaks 2022-10-03 23:46:45 -07:00
Jackie Liu caf8c9cf3c Fixed a dialogue rendering issue caused by invalid script 2022-10-03 18:44:26 -07:00
Jiaqi Liu 7746523600 Set NSPrefersDisplaySafeAreaCompatibilityMode for mac build 2022-10-03 03:14:12 -07:00
183 changed files with 4379 additions and 1411 deletions

No files matched your search

+14
View File
@@ -70,3 +70,17 @@ crashlytics-build.properties
# Unity StreamingAssets folder
/Assets/StreamingAssets
# 3rd party plugin/assets
/Assets/Hovl Studio
/Assets/Hovl Studio.meta
/Assets/RealToon
/Assets/RealToon.meta
# VFX prefabs that are using 3rd party assets
/Assets/Resources/Prefabs/VFX/PAL3/*.prefab
/Assets/Resources/Prefabs/VFX/PAL3/*.meta
/Assets/Resources/Prefabs/VFX/PAL3A/*.prefab
/Assets/Resources/Prefabs/VFX/PAL3A/*.meta
# Materials that are using 3rd party assets
/Assets/Resources/Materials/
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0b0b27c9e5e4d2e4fbc9b6584f828f7b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File renamed without changes.
@@ -0,0 +1,54 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
/*
reference: https://www.shadertoy.com/view/MsKXDh
*/
Shader "Pal3/PostEffectDistortion"
{
Properties
{
_TimeScale ("Time Scale",float) = 4.0
_XFactor ("X Factor",float) = 15.0
_YFactor("Y Factor",float) = 10.0
}
HLSLINCLUDE
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
float _TimeScale;
float _XFactor;
float _YFactor;
float4 Frag(VaryingsDefault i) : SV_Target
{
float2 uv = i.texcoord;
const float time = _Time.y;
uv.x += sin(uv.y * _XFactor + time * _TimeScale) / 400.0;
uv.y += cos(uv.x * _YFactor + time * _TimeScale) / 450.0;
uv.x += sin((uv.y+uv.x) * _XFactor + time * _TimeScale) / (180.0 + (_TimeScale * sin(time)));
uv.y += cos((uv.y+uv.x) * _YFactor + time * _TimeScale) / (200.0 + (_TimeScale * sin(time)));
float4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex,uv);
return col;
}
ENDHLSL
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment Frag
ENDHLSL
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 0b8bcccc572f924448668c94cfa547b4
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -44,6 +44,105 @@ MonoBehaviour:
opacity:
overrideState: 0
value: 1
--- !u!114 &-8365138130595697379
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb4ad18ac69b12845a429aba13929a07, type: 3}
m_Name: Distortion
m_EditorClassIdentifier:
active: 0
enabled:
overrideState: 1
value: 1
timeScale:
overrideState: 0
value: 4
xFactor:
overrideState: 0
value: 15
yFactor:
overrideState: 0
value: 10
--- !u!114 &-806185241644601601
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb4ad18ac69b12845a429aba13929a07, type: 3}
m_Name: Distortion
m_EditorClassIdentifier:
active: 1
enabled:
overrideState: 1
value: 1
timeScale:
overrideState: 0
value: 4
xFactor:
overrideState: 0
value: 15
yFactor:
overrideState: 0
value: 10
--- !u!114 &-804113543285745465
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c1cb7e9e120078f43bce4f0b1be547a7, type: 3}
m_Name: AmbientOcclusion
m_EditorClassIdentifier:
active: 0
enabled:
overrideState: 1
value: 1
mode:
overrideState: 1
value: 1
intensity:
overrideState: 1
value: 0.25
color:
overrideState: 0
value: {r: 0, g: 0, b: 0, a: 1}
ambientOnly:
overrideState: 0
value: 1
noiseFilterTolerance:
overrideState: 0
value: 0
blurTolerance:
overrideState: 0
value: -4.6
upsampleTolerance:
overrideState: 0
value: -12
thicknessModifier:
overrideState: 0
value: 1
directLightingStrength:
overrideState: 0
value: 0
radius:
overrideState: 0
value: 0.25
quality:
overrideState: 0
value: 2
--- !u!114 &-118557119588518591
MonoBehaviour:
m_ObjectHideFlags: 3
@@ -1370,3 +1469,78 @@ MonoBehaviour:
settings:
- {fileID: -118557119588518591}
- {fileID: -8887095760420704611}
- {fileID: 455792505896753558}
- {fileID: -804113543285745465}
- {fileID: -8365138130595697379}
--- !u!114 &455792505896753558
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 48a79b01ea5641d4aa6daa2e23605641, type: 3}
m_Name: Bloom
m_EditorClassIdentifier:
active: 0
enabled:
overrideState: 1
value: 1
intensity:
overrideState: 1
value: 5
threshold:
overrideState: 1
value: 1.3
softKnee:
overrideState: 1
value: 0.5
clamp:
overrideState: 0
value: 65472
diffusion:
overrideState: 0
value: 7
anamorphicRatio:
overrideState: 0
value: 0
color:
overrideState: 0
value: {r: 1, g: 1, b: 1, a: 1}
fastMode:
overrideState: 1
value: 1
dirtTexture:
overrideState: 0
value: {fileID: 0}
defaultState: 1
dirtIntensity:
overrideState: 0
value: 0
--- !u!114 &954549172052332416
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb4ad18ac69b12845a429aba13929a07, type: 3}
m_Name: Distortion
m_EditorClassIdentifier:
active: 0
enabled:
overrideState: 1
value: 1
timeScale:
overrideState: 0
value: 4
xFactor:
overrideState: 0
value: 15
yFactor:
overrideState: 0
value: 10
@@ -100,9 +100,9 @@ MonoBehaviour:
m_Transition: 1
m_Colors:
m_NormalColor: {r: 0.15686275, g: 0.15686275, b: 0.15686275, a: 0.78431374}
m_HighlightedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.78431374}
m_PressedColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.78431374}
m_SelectedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.9019608}
m_HighlightedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.78431374}
m_PressedColor: {r: 0.078431375, g: 0.19607843, b: 0.39215687, a: 0.78431374}
m_SelectedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.78431374}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
@@ -11,6 +11,18 @@ PrefabInstance:
propertyPath: m_Name
value: IngameDebugConsole
objectReference: {fileID: 0}
- target: {fileID: 11414302, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Navigation.m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11420596, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Navigation.m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11437802, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Navigation.m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11452418, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: toggleBinding.m_Id
value: 06175ea3-1b47-4b6e-bcd7-4d191ce555d1
@@ -19,6 +31,18 @@ PrefabInstance:
propertyPath: toggleBinding.m_SingletonActionBindings.Array.data[0].m_Id
value: badbacc7-7d97-42d1-ac38-980883100f6e
objectReference: {fileID: 0}
- target: {fileID: 11466918, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Navigation.m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472314, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Navigation.m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11477250, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Navigation.m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.x
value: 0
@@ -235,6 +259,22 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114000010993257018, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Navigation.m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114466839828933532, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Navigation.m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114664465529608634, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Navigation.m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114786672304321734, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Navigation.m_Mode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.y
value: 0
@@ -286,36 +326,3 @@ PrefabInstance:
m_RemovedComponents:
- {fileID: 11492840, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
--- !u!1 &2755888773260686779 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 109254, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
m_PrefabInstance: {fileID: 2755888773260713853}
m_PrefabAsset: {fileID: 0}
--- !u!114 &2755888771526933940
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2755888773260686779}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
m_Name:
m_EditorClassIdentifier:
m_MoveRepeatDelay: 0.5
m_MoveRepeatRate: 0.1
m_XRTrackingOrigin: {fileID: 0}
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_DeselectOnBackgroundClick: 0
m_PointerBehavior: 0
+7 -105
View File
@@ -166,7 +166,6 @@ GameObject:
- component: {fileID: 311849592}
- component: {fileID: 311849591}
- component: {fileID: 311849595}
- component: {fileID: 311849594}
- component: {fileID: 7927220425085558669}
m_Layer: 0
m_Name: GameCamera
@@ -221,7 +220,7 @@ Camera:
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 55
m_Bits: 63
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
@@ -242,102 +241,6 @@ AudioListener:
m_GameObject: {fileID: 311849590}
m_Enabled: 1
--- !u!82 &311849595
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 311849590}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!82 &311849594
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@@ -440,7 +343,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 311849590}
m_Enabled: 0
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 948f4100a11a5c24981795d21301da5c, type: 3}
m_Name:
@@ -448,7 +351,7 @@ MonoBehaviour:
volumeTrigger: {fileID: 311849593}
volumeLayer:
serializedVersion: 2
m_Bits: 55
m_Bits: 136
stopNaNPropagation: 0
finalBlitToCameraTarget: 0
antialiasingMode: 0
@@ -460,7 +363,7 @@ MonoBehaviour:
subpixelMorphologicalAntialiasing:
quality: 2
fastApproximateAntialiasing:
fastMode: 0
fastMode: 1
keepAlpha: 0
fog:
enabled: 1
@@ -951,7 +854,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
@@ -1164,7 +1067,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
@@ -2852,7 +2755,7 @@ GameObject:
m_Component:
- component: {fileID: 5491488055271105370}
- component: {fileID: 8346885185333560231}
m_Layer: 0
m_Layer: 3
m_Name: PostProcessVolume
m_TagString: Untagged
m_Icon: {fileID: 0}
@@ -4132,7 +4035,6 @@ MonoBehaviour:
mainCamera: {fileID: 311849592}
curtainImage: {fileID: 147356289}
musicSource: {fileID: 311849595}
sfxSource: {fileID: 311849594}
videoPlayerCanvas: {fileID: 5102776189801015787}
videoPlayer: {fileID: 4844794614659113022}
noteCanvasGroup: {fileID: 6941303344842138483}
@@ -100,9 +100,9 @@ MonoBehaviour:
m_Transition: 1
m_Colors:
m_NormalColor: {r: 0, g: 0, b: 0, a: 0.7058824}
m_HighlightedColor: {r: 0.15686275, g: 0.15686275, b: 0.15686275, a: 0.6666667}
m_PressedColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.6666667}
m_SelectedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.9019608}
m_HighlightedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.6666667}
m_PressedColor: {r: 0.07450981, g: 0.19607843, b: 0.39215687, a: 0.6666667}
m_SelectedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.9019608}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
@@ -100,9 +100,9 @@ MonoBehaviour:
m_Transition: 1
m_Colors:
m_NormalColor: {r: 0.15686275, g: 0.15686275, b: 0.15686275, a: 0.78431374}
m_HighlightedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.78431374}
m_PressedColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.78431374}
m_SelectedColor: {r: 0.23529412, g: 0.23529412, b: 0.23529412, a: 0.9019608}
m_HighlightedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.78431374}
m_PressedColor: {r: 0.07450981, g: 0.19607843, b: 0.39215687, a: 0.78431374}
m_SelectedColor: {r: 0.11764706, g: 0.29411766, b: 0.54901963, a: 0.9019608}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2eaeb845461401e488e4640caf779ddf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b93923849ec63ad4ea52f79bf5bc9cb6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,45 @@
因为当前特效的实现方式使用了第三方插件和素材,所以此文件夹内的所有prefab均添加进了gitignore里。
请联系作者了解插件获取方式和特效prefab的获取方式。
0 => 传送法阵特效
15 => 单人传送特效
98 => 重楼施法帮龙葵恢复肉身时的特效
175 => 邪剑仙迷倒众人的特效
224 => 丁小侠剧情狼妖受击特效
251 => 邪剑仙变身特效
252 => 邪剑仙传送离开时的特效
254 => 重楼传送法术特效
255 => 龙葵穿衣服的特效
256 => 龙葵治疗他人特效
257 => 治疗咒施法特效
259 => 大型传送法施法前奏特效
260 => 大型传送法阵特效收尾
261 => 大型传送法阵特效开始
262 => 重楼当剑的时候剑插入地面的火光特效
263 => 火鬼王消失特效
264 => 古藤精施法特效
265 => 人物受到法术作用时候的特效
266 => 邪剑仙施法特效
270 => 天鬼皇复活后灵魂出窍特效
275 => 重楼创建的用来禁锢雪见/龙葵的法阵特效
276 => 迴魂施法结束特效
277 => 迴魂施法完全结束特效
278 => 迴魂施法特效
290 => 雪见传送出现时特效
295 => 重楼施法治疗特效
297 => 紫萱施法召唤水灵特效
337 => 古藤精风系法术特效
341 => 邪剑仙给镇妖剑施法特效
368 => 龙葵雷击单体施法特效
369 => 龙葵雷击范围施法特效
376 => 紫萱的土系法术特效
389 => 紫萱给江姑娘施法特效
452 => 花楹治疗他人特效
453 => 人物施法蓄力时的特效
454 => 龙葵施法让众人御剑飞行的特效
456 => 老婆婆施法特效
457 => 夕瑶给景天施法时的特效
458 => 灵力溢出特效
467 => 邪剑仙灰飞烟灭特效
468 => 蓝龙葵变红龙葵的特效
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 815b64a4a03e7b949bd85e1e5c19deb3
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a637ebcead3359c4f849f936d41707ee
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,67 @@
因为当前特效的实现方式使用了第三方插件和素材,所以此文件夹内的所有prefab均添加进了gitignore里。
请联系作者了解插件获取方式和特效prefab的获取方式。
0 => 传送法阵特效
9 => 茅山道士封印法术特效
40 => 单体风咒特效
50 => 单体雷咒特效
91 => 封印法术特效
157 => 角色传送出现特效
164 => 南宫煌变身狼形态时的特效
170 => 王蓬絮变身特效
171 => 人物施法特效
172 => 人物受到法术作用时候的特效
173 => 人物受到法术作用时候的特效
174 => 治疗特效
175 => 茅山术士打乱三杯盏特效
176 => 南宫煌打乱三杯盏特效
177 => 角色传送消失时的特效
178 => 南宫煌使关桃子的笼子消失的特效
179 => 南宫煌变出法桌的特效
181 => 南宫煌变出小东西的特效
182 => 南宫煌变出大东西的特效
186 => 大石块砸下后的尘土特效
189 => 地脉石门封印打开时的特效
198 => 南宫煌变出东西的特效
201 => 魁妖变小特效
205 => 照妖镜发光的特效
209 => 五灵轮特效
211 => 洒金笺特效
230 => 重楼施法消灭怪物的特效
254 => 重楼传送特效
257 => 隔空取物特效
258 => 迴魂传送特效
259 => 大型传送法施法前奏特效
260 => 大型传送法阵特效收尾
261 => 大型传送法阵特效开始
281 => 角色传送消失时的特效
282 => 雷咒特效
283 => 物品消失时的特效
285 => 南宫煌施法特效
287 => 土灵珠特效
289 => 血魂姬施法特效
290 => 回复法阵特效
292 => 五灵轮发光特效
299 => 重楼传送众人特效
314 => 倾国银弹波特效
315 => 南宫煌切换为人形态特效
316 => 魔物出现特效
318 => 千凝魔艮特效
320 => 幽娘变身特效
322 => 幽娘吸收怨气特效
323 => 幽娘收集怨气特效
325 => 陆北亭变身特效
328 => 风雅颂开心的特效
333 => 感月出现特效
355 => 王蓬絮治疗特效
359 => 蝎魃消失特效
360 => 星璇给南宫煌输入内力时的特效
367 => 五毒珠治疗特效
388 => 迴魂传送特效
389 => 迴魂传送特效
397 => 燎日变身特效
401 => 魔尊帮星璇灵肉合一的特效
404 => 思堂消失特效
408 => 星璇燎日变换时特效
424 => 王蓬絮对南宫煌施法特效
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f1d950c46b3119043a1919074fdc27c5
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4f33d244048b1054a8753633da7ffe28
guid: fcd2231fc0b299247b47f42991d73ab5
folderAsset: yes
DefaultImporter:
externalObjects: {}
@@ -10,14 +10,16 @@ Shader "Pal3/Dev"
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
SubShader
{
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
LOD 100
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
@@ -63,4 +65,4 @@ Shader "Pal3/Dev"
ENDCG
}
}
}
}
@@ -1,33 +1,30 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
Shader "Pal3/Standard"
Shader "Pal3/Opaque"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_ShadowTex ("Shadow map (RGB)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.0
_Exposure("Exposure Amount", Range(0.1,1.0)) = 0.4
_Transparency("Transparency Amount", Range(0.1,1.0)) = 1.0
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
_ShadowTex ("Shadow Texture", 2D) = "white" {}
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
}
SubShader
{
Tags { "Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="TransparentCutout" }
LOD 100
Lighting Off
Blend SrcAlpha OneMinusSrcAlpha
Tags { "QUEUE" = "Geometry" }
Pass
{
Tags{ "Qeueue" = "Geometry" }
Blend Off
ZWrite On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile_fog
#include "UnityCG.cginc"
@@ -44,18 +41,18 @@ Shader "Pal3/Standard"
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
float2 shadowcoord : TEXCOORD1;
UNITY_FOG_COORDS(2)
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _TintColor;
float _HasShadowTex;
sampler2D _ShadowTex;
float4 _ShadowTex_ST;
fixed _Cutoff;
float _Exposure;
float _Transparency;
v2f vert(appdata_t v)
{
v2f o;
@@ -64,22 +61,18 @@ Shader "Pal3/Standard"
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.shadowcoord = TRANSFORM_TEX(v.shadowcoord, _ShadowTex);
UNITY_TRANSFER_FOG(o, o.vertex);
return o;
}
half4 frag(v2f i) : SV_Target
{
half4 color = tex2D(_MainTex, i.texcoord);
// Cutout
clip(color.a - _Cutoff);
// Shadow
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
// Transparency
color.a = _Transparency;
UNITY_APPLY_FOG(i.fogCoord, color);
if(_HasShadowTex > 0.5f)
{
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
}
color *= _TintColor;
return color;
}
ENDCG
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: a83b1b6f4822140d58c7bad4e3b39932
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,55 @@
Shader "Pal3/Sprite"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "Queue" = "Transparent" }
LOD 100
Pass
{
Blend SrcAlpha One
ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
col.a = 1.0f; // force alpha to 1 to avoid transparency
return col;
}
ENDCG
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6122fb5a4bad8433982c0407309f8dbf
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,97 @@
Shader "Pal3/Transparent"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
_Threshold ("Transparent Threshold", Range(0, 1)) = 1.0
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
_ShadowTex ("Shadow Texture", 2D) = "white" {}
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
[Enum(UnityEngine.Rendering.BlendMode)]
_BlendSrcFactor("Source Blend Factor", int) = 5 // BlendMode.SrcAlpha as Default
[Enum(UnityEngine.Rendering.BlendMode)]
_BlendDstFactor("Dest Blend Factor", int) = 10 // BlendMode.OneMinusSrcAlpha as Default
}
SubShader
{
Lighting Off
Tags { "Queue" = "Transparent" }
// Pass 2 ,transparent part
Pass
{
Blend [_BlendSrcFactor] [_BlendDstFactor]
ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float2 shadowcoord : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
float2 shadowcoord : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Threshold;
float _HasShadowTex;
sampler2D _ShadowTex;
float4 _ShadowTex_ST;
float _Exposure;
float4 _TintColor;
v2f vert(appdata_t v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.shadowcoord = TRANSFORM_TEX(v.shadowcoord, _ShadowTex);
return o;
}
half4 frag(v2f i) : SV_Target
{
half4 color = tex2D(_MainTex, i.texcoord);
const float alpha = color.a;
if(color.a >= _Threshold)
{
discard;
}
if(_HasShadowTex > 0.5f)
{
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
color.a = alpha;
}
color *= _TintColor;
return color;
}
ENDCG
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 9a73f8d5b84814e63a97995e839fdabb
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -1,32 +1,31 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
Shader "Pal3/StandardNoShadow"
Shader "Pal3/TransparentOpaquePart"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.0
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
_Transparency("Transparency Amount", Range(0.1,1.0)) = 1.0
_Threshold ("Transparent Threshold", Range(0, 1)) = 1.0
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
_ShadowTex ("Shadow Texture", 2D) = "white" {}
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
}
SubShader
{
Tags { "Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="TransparentCutout" }
LOD 100
Lighting Off
Blend SrcAlpha OneMinusSrcAlpha
Tags { "Qeueue" = "Geometry" }
// pass 1 , opaque part
Pass
{
Blend Off
ZWrite On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile_fog
#include "UnityCG.cginc"
@@ -34,6 +33,7 @@ Shader "Pal3/StandardNoShadow"
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float2 shadowcoord : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
@@ -41,15 +41,21 @@ Shader "Pal3/StandardNoShadow"
{
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
UNITY_FOG_COORDS(1)
float2 shadowcoord : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed _Cutoff;
half4 _TintColor;
float _Transparency;
float _Threshold;
float _HasShadowTex;
sampler2D _ShadowTex;
float4 _ShadowTex_ST;
float _Exposure;
float4 _TintColor;
v2f vert(appdata_t v)
{
@@ -58,22 +64,21 @@ Shader "Pal3/StandardNoShadow"
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
UNITY_TRANSFER_FOG(o, o.vertex);
o.shadowcoord = TRANSFORM_TEX(v.shadowcoord, _ShadowTex);
return o;
}
half4 frag(v2f i) : SV_Target
{
half4 color = tex2D(_MainTex, i.texcoord);
clip(color.a - _Threshold);
// Cutout
clip(color.a - _Cutoff);
// Tint color
if(_HasShadowTex > 0.5f)
{
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
}
color *= _TintColor;
// Transparency
color.a = _Transparency;
UNITY_APPLY_FOG(i.fogCoord, color);
return color;
}
ENDCG
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 784c49f60e0c64f6595ed503bd3a3a69
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
+91
View File
@@ -0,0 +1,91 @@
Shader "Pal3/Water"
{
Properties
{
// main texture
_MainTex ("Main texture", 2D) = "white" {}
// alpha value
_Alpha ("Alpha",Range(0, 1)) = 0.5
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.3
// pre baked shadow texture
_ShadowTex ("Shadow texture", 2D) = "white" {}
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
[Enum(UnityEngine.Rendering.BlendMode)]
_BlendSrcFactor("Source Blend Factor", int) = 5 // BlendMode.SrcAlpha as Default
[Enum(UnityEngine.Rendering.BlendMode)]
_BlendDstFactor("Dest Blend Factor", int) = 10 // BlendMode.OneMinusSrcAlpha as Default
}
SubShader
{
Lighting Off
Tags { "QUEUE" = "Transparent-1" } // -1 to fix sorting order issue with semi-transparent trees etc.
Pass
{
Blend [_BlendSrcFactor] [_BlendDstFactor]
ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float2 texcoord2 : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
float2 texcoord2 : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Alpha;
float _Exposure;
float _HasShadowTex;
sampler2D _ShadowTex;
float4 _ShadowTex_ST;
v2f vert(appdata_t v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.texcoord2 = TRANSFORM_TEX(v.texcoord2, _ShadowTex);
return o;
}
half4 frag(v2f i) : SV_Target
{
const half4 color = tex2D(_MainTex, i.texcoord);
const half4 colorShadow = tex2D(_ShadowTex, i.texcoord2);
half4 mixedColor = color * colorShadow / (1 - _Exposure);
mixedColor.a = _Alpha; // use global alpha
return mixedColor;
}
ENDCG
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 54296b5ef906d4d219289838c47b2f01
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
+3 -3
View File
@@ -24,7 +24,7 @@ RenderSettings:
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1.3
m_AmbientMode: 0
m_AmbientMode: 3
m_SubtractiveShadowColor: {r: 1, g: 1, b: 1, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
@@ -97,8 +97,8 @@ LightmapSettings:
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 112000000, guid: c9e1768594f6afd479e0380c47ec2784, type: 2}
m_LightingSettings: {fileID: 4890085278179872738, guid: c3e8b810b348ed54ba97c7a4ee44d9eb, type: 2}
m_LightingDataAsset: {fileID: 112000000, guid: b024d577cdecd974eab12c932a37f51b, type: 2}
m_LightingSettings: {fileID: 4890085278179872738, guid: b0ad69fd7711b6842b5f287b194ede35, type: 2}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
@@ -0,0 +1,49 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
#if UNITY_EDITOR_OSX
namespace Build.Editor
{
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;
/// <summary>
/// Set NSPrefersDisplaySafeAreaCompatibilityMode in XCode project settings (Info.plist)
/// </summary>
public static class SetDisplaySafeAreaCompatibilityModeProcessor
{
[PostProcessBuild]
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
{
if (buildTarget != BuildTarget.StandaloneOSX) return;
// Get plist
#if PAL3
string plistPath = pathToBuiltProject + "/PAL3/Info.plist";
#elif PAL3A
string plistPath = pathToBuiltProject + "/PAL3A/Info.plist";
#endif
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
// Get root
PlistElementDict rootDict = plist.root;
rootDict.SetBoolean("NSPrefersDisplaySafeAreaCompatibilityMode", false);
// Write to file
File.WriteAllText(plistPath, plist.WriteToString());
Debug.Log("NSPrefersDisplaySafeAreaCompatibilityMode set to NO.");
}
}
}
#endif
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: acf008c658174728b71ceb4a88b76bc6
timeCreated: 1664790861
@@ -32,7 +32,6 @@ namespace Core.DataLoader
DxtHeader header = DxtHeader.ReadHeader(reader);
var format = header.DxtPixelFormat.Format;
hasAlphaChannel = format == "DXT1";
_width = header.Width;
_height = header.Height;
@@ -40,9 +39,11 @@ namespace Core.DataLoader
switch (format)
{
case "DXT1":
hasAlphaChannel = false;
LoadDxt1Texture(data);
break;
case "DXT3":
hasAlphaChannel = true;
LoadDxt3Texture(data);
break;
case "DXT5":
@@ -81,7 +82,7 @@ namespace Core.DataLoader
public Texture2D ToTexture2D()
{
if (_rawData == null) return null;
Texture2D texture = new Texture2D(_width, _height, _format, false);
Texture2D texture = new Texture2D(_width, _height, _format, mipChain: false);
texture.LoadRawTextureData(_rawData);
texture.Apply();
return texture;
@@ -74,7 +74,7 @@ namespace Core.DataLoader
public Texture2D ToTexture2D()
{
if (_pixels == null) return null;
var texture = new Texture2D(_width, _height);
var texture = new Texture2D(_width, _height, TextureFormat.RGBA32, mipChain: false);
texture.SetPixels32(_pixels);
texture.Apply();
return texture;
@@ -111,14 +111,17 @@ namespace Core.DataReader.Bmp
public Texture2D ToTexture2D()
{
var tex = new Texture2D(info.absWidth, info.absHeight);
var texture = new Texture2D(info.absWidth,
info.absHeight,
TextureFormat.RGBA32,
mipChain: false);
if (info.height < 0)
FlipImage();
tex.SetPixels32(imageData);
tex.Apply();
return tex;
texture.SetPixels32(imageData);
texture.Apply();
return texture;
}
// flip image if height is negative
@@ -11,6 +11,7 @@ namespace Core.DataReader.Cpk
using System.Runtime.InteropServices;
using System.Text;
using Lzo;
using UnityEngine;
using Utils;
/// <summary>
@@ -94,6 +95,33 @@ namespace Core.DataReader.Cpk
BuildCrcIndexMap();
}
/// <summary>
/// Extract the complete archive to the specified destination
/// </summary>
public void ExtractTo(string outputFolder)
{
ExtractToInternal(outputFolder, GetRootEntries());
}
private void ExtractToInternal(string outputFolder, IEnumerable<CpkEntry> nodes)
{
foreach (CpkEntry node in nodes)
{
var relativePath = node.VirtualPath.Replace(
CpkConstants.DirectorySeparator, Path.DirectorySeparatorChar);
if (node.IsDirectory)
{
new DirectoryInfo(outputFolder + relativePath).Create();
ExtractToInternal(outputFolder, node.Children);
}
else
{
File.WriteAllBytes(outputFolder + relativePath, ReadAllBytes(node.VirtualPath));
}
}
}
/// <summary>
/// Check if file exists inside the archive.
/// </summary>
@@ -152,7 +152,7 @@ namespace Core.DataReader.Cvd
{
public CvdVertex[][] FrameVertices;
public int[] Triangles;
public byte BlendFlag;
public GameBoxBlendFlag BlendFlag;
public GameBoxMaterial Material;
public string TextureName;
public float[] AnimationTimeKeys;
@@ -173,12 +173,12 @@ namespace Core.DataReader.Cvd
public class CvdAnimationScaleKeyFrame : CvdAnimationKeyFrame
{
public Vector3 Scale { get; set; }
public GameBoxQuaternion Rotation { get; set; }
public Quaternion Rotation { get; set; }
}
public class CvdAnimationRotationKeyFrame : CvdAnimationKeyFrame
{
public GameBoxQuaternion Rotation { get; set; }
public Quaternion Rotation { get; set; }
}
/// <summary>
@@ -193,7 +193,7 @@ namespace Core.DataReader.Cvd
{
KeyType = type,
Time = positionKey.TcbKey.AnimationKey.Time,
Position = positionKey.Value,
Position = GameBoxInterpreter.CvdPositionToUnityPosition(positionKey.Value),
};
break;
}
@@ -204,7 +204,7 @@ namespace Core.DataReader.Cvd
{
KeyType = type,
Time = positionKey.AnimationKey.Time,
Position = positionKey.Value,
Position = GameBoxInterpreter.CvdPositionToUnityPosition(positionKey.Value),
};
break;
}
@@ -215,7 +215,7 @@ namespace Core.DataReader.Cvd
{
KeyType = type,
Time = positionKey.AnimationKey.Time,
Position = positionKey.Value,
Position = GameBoxInterpreter.CvdPositionToUnityPosition(positionKey.Value),
};
break;
}
@@ -248,13 +248,13 @@ namespace Core.DataReader.Cvd
{
KeyType = type,
Time = rotationKey.TcbKey.AnimationKey.Time,
Rotation = new GameBoxQuaternion()
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(new GameBoxQuaternion()
{
X = quaternion.x,
Y = quaternion.y,
Z = quaternion.z,
W = quaternion.w,
}
})
};
break;
}
@@ -265,7 +265,7 @@ namespace Core.DataReader.Cvd
{
KeyType = type,
Time = rotationKey.AnimationKey.Time,
Rotation = rotationKey.Value
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(rotationKey.Value)
};
break;
}
@@ -276,7 +276,7 @@ namespace Core.DataReader.Cvd
{
KeyType = type,
Time = rotationKey.AnimationKey.Time,
Rotation = rotationKey.Value
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(rotationKey.Value)
};
break;
}
@@ -308,8 +308,8 @@ namespace Core.DataReader.Cvd
{
KeyType = type,
Time = scaleKey.TcbKey.AnimationKey.Time,
Scale = scaleKey.Value,
Rotation = scaleKey.Rotation
Scale = GameBoxInterpreter.CvdScaleToUnityScale(scaleKey.Value),
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(scaleKey.Rotation)
};
break;
}
@@ -320,8 +320,8 @@ namespace Core.DataReader.Cvd
{
KeyType = type,
Time = scaleKey.AnimationKey.Time,
Scale = scaleKey.Value,
Rotation = scaleKey.Rotation
Scale = GameBoxInterpreter.CvdScaleToUnityScale(scaleKey.Value),
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(scaleKey.Rotation)
};
break;
}
@@ -332,8 +332,8 @@ namespace Core.DataReader.Cvd
{
KeyType = type,
Time = scaleKey.AnimationKey.Time,
Scale = scaleKey.Value,
Rotation = scaleKey.Rotation
Scale = GameBoxInterpreter.CvdScaleToUnityScale(scaleKey.Value),
Rotation = GameBoxInterpreter.CvdQuaternionToUnityQuaternion(scaleKey.Rotation)
};
break;
}
@@ -352,9 +352,6 @@ namespace Core.DataReader.Cvd
var numberOfFrames = reader.ReadInt32();
var numberOfVertices = reader.ReadInt32();
//var vertexType = GameBoxVertexType.XYZ | GameBoxVertexType.Normal | GameBoxVertexType.UV0;
//var vertexSize = GameBoxVertex.GetSize((uint)vertexType);
var frameVertices = new CvdVertex[numberOfFrames][];
for (var i = 0; i < numberOfFrames; i++)
{
@@ -362,9 +359,12 @@ namespace Core.DataReader.Cvd
for (var j = 0; j < numberOfVertices; j++)
{
Vector2 uv = reader.ReadVector2();
Vector3 normal = reader.ReadVector3();
Vector3 position = reader.ReadVector3();
Vector3 normal = GameBoxInterpreter.ToUnityNormal(reader.ReadVector3());
Vector3 position = GameBoxInterpreter.CvdPositionToUnityPosition(reader.ReadVector3());
// Quick fix for the missing/wrong normals
if (normal == Vector3.zero) normal = Vector3.up;
vertices[j] = new CvdVertex()
{
Normal = normal,
@@ -407,7 +407,7 @@ namespace Core.DataReader.Cvd
int codepage)
#endif
{
var blendFlag = reader.ReadByte();
var blendFlag = (GameBoxBlendFlag)reader.ReadByte();
var material = new GameBoxMaterial()
{
@@ -458,11 +458,11 @@ namespace Core.DataReader.Cvd
}
var frameVertices = new CvdVertex[allFrameVertices.Length][];
List<int> triangles;
List<int> indexBuffer;
(triangles, indexBuffer) = CalculateTriangles(indices);
(List<int> triangles, List<int> indexBuffer) = CalculateTriangles(indices);
GameBoxInterpreter.ToUnityTriangles(triangles);
for (var i = 0; i < allFrameVertices.Length; i++)
{
var verts = new CvdVertex[indexBuffer.Count];
@@ -493,7 +493,7 @@ namespace Core.DataReader.Cvd
{
var indexBuffer = new List<int>();
var triangles = new List<int>();
var indexMap = new Dictionary<int, int>();
var index = 0;
for (var j = 0; j < allIndices.Length; j++)
{
@@ -506,17 +506,8 @@ namespace Core.DataReader.Cvd
for (var k = 0; k < 3; k++)
{
if (indexMap.ContainsKey(indices[k]))
{
triangles.Add(indexMap[indices[k]]);
}
else
{
var index = indexBuffer.Count;
indexBuffer.Add(indices[k]);
indexMap[indices[k]] = index;
triangles.Add(index);
}
indexBuffer.Add(indices[k]);
triangles.Add(index++);
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6277e4ab422e47bdadc0826e97a1dbe3
timeCreated: 1665782936
@@ -0,0 +1,129 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Core.DataReader.Data
{
//using System.Runtime.InteropServices;
//[StructLayout(LayoutKind.Explicit)]
public struct EffectDefinition
{
//[FieldOffset(0)]
public uint ClassNameCrc;
//[FieldOffset(4)]
//[MarshalAs (UnmanagedType.ByValArray, SizeConst = 30)]
public string TypeName;
//[FieldOffset(36)]
public uint TypeNameCrc;
//[FieldOffset(40)]
//[MarshalAs (UnmanagedType.ByValArray, SizeConst = 128)]
// Union
public string TextureName;
public string ParticleFileName;
public string SfxFileNamePrefix;
public string VideoFileNamePrefix;
//[FieldOffset(168)]
public int FramesPerRow;
//[FieldOffset(172)]
public int FramesPerColumn;
//[FieldOffset(176)]
public int FrameCount;
//[FieldOffset(180)]
public float FramePerSecond;
//[FieldOffset(184)]
public float InitXPosition;
//[FieldOffset(188)]
public float InitYPosition;
//[FieldOffset(192)]
public float InitZPosition;
//[FieldOffset(196)]
// Union
public float InitYRotation;
public float InitAngle;
//[FieldOffset(200)]
public int InitSize;
//[FieldOffset(204)]
public uint InitColor;
//[FieldOffset(208)]
public int MaxQuadCount;
//[FieldOffset(212)]
public bool IsValid;
//[FieldOffset(213)]
public bool IsAdditiveBlend;
//[FieldOffset(214)]
public bool IsBillboard;
//[FieldOffset(215)]
public bool IsZTestIgnored;
//[FieldOffset(216)]
public float InitXRotation;
//[FieldOffset(220)]
public float InitZRotation;
//[FieldOffset(224)]
public float RotationAngle;
//[FieldOffset(228)]
public float Width;
//[FieldOffset(232)]
public float DivisionCount;
//[FieldOffset(236)]
public float TopShrink;
//[FieldOffset(240)]
public float BottomShrink;
//[FieldOffset(244)]
public float TopRadius;
//[FieldOffset(248)]
public float BottomRadius;
//[FieldOffset(252)]
public float TopRadiusIncreaseSpeed;
//[FieldOffset(256)]
public float BottomRadiusIncreaseSpeed;
//[FieldOffset(260)]
public float TopRiseSpeed;
//[FieldOffset(264)]
public float BottomRiseSpeed;
//[FieldOffset(268)]
public float TextureRepeat;
//[FieldOffset(272)]
//[MarshalAs (UnmanagedType.ByValArray, SizeConst = 2)]
public float[] Param;
}
public class EffectDefinitionFile
{
public EffectDefinition[] EffectDefinitions;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3c47b38acef943118e9374c4113e7b5e
timeCreated: 1665782973
@@ -0,0 +1,107 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
//#define USE_UNSAFE_BINARY_READER
namespace Core.DataReader.Data
{
using System.IO;
using Extensions;
using Utils;
public static class EffectDefinitionFileReader
{
private const int NUM_OF_EFFECTS = 1324;
public static void Read(byte[] data, int codepage)
{
#if USE_UNSAFE_BINARY_READER
using var reader = new UnsafeBinaryReader(data);
#else
using var stream = new MemoryStream(data);
using var reader = new BinaryReader(stream);
#endif
var effectDefinitions = new EffectDefinition[NUM_OF_EFFECTS];
for (var i = 0; i < NUM_OF_EFFECTS; i++)
{
effectDefinitions[i] = ReadEffectDefinition(reader, codepage);
}
}
#if USE_UNSAFE_BINARY_READER
private static EffectDefinition ReadEffectDefinition(UnsafeBinaryReader reader, int codepage)
#else
private static EffectDefinition ReadEffectDefinition(BinaryReader reader, int codepage)
#endif
{
var effectDefinition = new EffectDefinition();
effectDefinition.ClassNameCrc = reader.ReadUInt32();
effectDefinition.TypeName = reader.ReadString(32, 936);
effectDefinition.TypeNameCrc = reader.ReadUInt32();
// union
{
var unionStr = reader.ReadString(128, 936);
effectDefinition.TextureName = unionStr;
effectDefinition.ParticleFileName = unionStr;
effectDefinition.SfxFileNamePrefix = unionStr;
effectDefinition.VideoFileNamePrefix = unionStr;
}
effectDefinition.FramesPerRow = reader.ReadInt32();
effectDefinition.FramesPerColumn = reader.ReadInt32();
effectDefinition.FrameCount = reader.ReadInt32();
effectDefinition.FramePerSecond = reader.ReadSingle();
effectDefinition.InitXPosition = reader.ReadSingle();
effectDefinition.InitYPosition = reader.ReadSingle();
effectDefinition.InitZPosition = reader.ReadSingle();
// union
{
var unionFloat = reader.ReadSingle();
effectDefinition.InitYRotation = unionFloat;
effectDefinition.InitAngle = unionFloat;
}
effectDefinition.InitSize = reader.ReadInt32();
effectDefinition.InitColor = reader.ReadUInt32();
effectDefinition.MaxQuadCount = reader.ReadInt32();
effectDefinition.IsValid = reader.ReadBoolean();
effectDefinition.IsAdditiveBlend = reader.ReadBoolean();
effectDefinition.IsBillboard = reader.ReadBoolean();
effectDefinition.IsZTestIgnored = reader.ReadBoolean();
effectDefinition.InitXRotation = reader.ReadSingle();
effectDefinition.InitZRotation = reader.ReadSingle();
effectDefinition.RotationAngle = reader.ReadSingle();
effectDefinition.Width = reader.ReadSingle();
effectDefinition.DivisionCount = reader.ReadSingle();
effectDefinition.TopShrink = reader.ReadSingle();
effectDefinition.BottomShrink = reader.ReadSingle();
effectDefinition.TopRadius = reader.ReadSingle();
effectDefinition.BottomRadius = reader.ReadSingle();
effectDefinition.TopRadiusIncreaseSpeed = reader.ReadSingle();
effectDefinition.BottomRadiusIncreaseSpeed = reader.ReadSingle();
effectDefinition.TopRiseSpeed = reader.ReadSingle();
effectDefinition.BottomRiseSpeed = reader.ReadSingle();
effectDefinition.TextureRepeat = reader.ReadSingle();
effectDefinition.Param = new[]
{
reader.ReadSingle(),
reader.ReadSingle(),
};
return effectDefinition;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a324f42c7b6346dc8c98a2c6c377c9d6
timeCreated: 1665784313
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7033622484af4557882d201a3784de14
timeCreated: 1665907414
@@ -0,0 +1,44 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Core.DataReader.Lgt
{
using GameBox;
using UnityEngine;
[System.Serializable]
public struct LightNode
{
public Matrix4x4 WorldMatrix;
public GameBoxLightType LightType;
public Color LightColor;
public Color AmbientColor;
public bool UseDiffuse;
public bool UseSpecular;
public float NearStart;
public float NearEnd;
public float FarStart;
public float FarEnd;
public GameBoxLightDecayType LightDecayType;
public float DecayRadius;
public GameBoxLightShapeType LightShapeType;
public float Size;
public float Falloff;
public float AspectRatio;
}
public class LgtFile
{
public LightNode[] LightNodes { get; }
public LgtFile(LightNode[] lightNodes)
{
LightNodes = lightNodes;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 25179e1de24d41698cd68a919c3d0990
timeCreated: 1665907430
@@ -0,0 +1,83 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
#define USE_UNSAFE_BINARY_READER
namespace Core.DataReader.Lgt
{
using System;
using System.Collections.Generic;
using System.IO;
using Extensions;
using GameBox;
using Utils;
public static class LgtFileReader
{
public static LgtFile Read(byte[] data)
{
#if USE_UNSAFE_BINARY_READER
using var reader = new UnsafeBinaryReader(data);
#else
using var stream = new MemoryStream(data);
using var reader = new BinaryReader(stream);
#endif
var numOfLightNodes = reader.ReadInt32();
var lightNodes = new List<LightNode>();
for (var i = 0; i < numOfLightNodes; i++)
{
var lightNode = ReadLightNode(reader);
if (Enum.IsDefined(typeof(GameBoxLightType), lightNode.LightType) &&
Enum.IsDefined(typeof(GameBoxLightShapeType), lightNode.LightShapeType))
{
lightNodes.Add(lightNode);
}
}
return new LgtFile(lightNodes.ToArray());
}
#if USE_UNSAFE_BINARY_READER
private static LightNode ReadLightNode(UnsafeBinaryReader reader)
#else
private static LightNode ReadLightNode(BinaryReader reader)
#endif
{
var transformMatrix = new GameBoxMatrix4X4()
{
Xx = reader.ReadSingle(), Xy = reader.ReadSingle(), Xz = reader.ReadSingle(), Xw = reader.ReadSingle(),
Yx = reader.ReadSingle(), Yy = reader.ReadSingle(), Yz = reader.ReadSingle(), Yw = reader.ReadSingle(),
Zx = reader.ReadSingle(), Zy = reader.ReadSingle(), Zz = reader.ReadSingle(), Zw = reader.ReadSingle(),
Tx = reader.ReadSingle(), Ty = reader.ReadSingle(), Tz = reader.ReadSingle(), Tw = reader.ReadSingle()
};
transformMatrix.Tw = 1f;
var lightNode = new LightNode
{
WorldMatrix = GameBoxInterpreter.ToUnityMatrix4x4(transformMatrix),
LightType = (GameBoxLightType)reader.ReadInt32(),
LightColor = Utility.ToColor(reader.ReadSingleArray(4)),
AmbientColor = Utility.ToColor(reader.ReadSingleArray(4)),
UseDiffuse = reader.ReadBoolean(),
UseSpecular = reader.ReadBoolean(),
NearStart = reader.ReadSingle(),
NearEnd = reader.ReadSingle(),
FarStart = reader.ReadSingle(),
FarEnd = reader.ReadSingle(),
LightDecayType = (GameBoxLightDecayType)reader.ReadInt32(),
DecayRadius = reader.ReadSingle(),
LightShapeType = (GameBoxLightShapeType)reader.ReadInt32(),
Size = reader.ReadSingle(),
Falloff = reader.ReadSingle(),
AspectRatio = reader.ReadSingle()
};
return lightNode;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f29568c4d19d4fcca931e8bf250ccc01
timeCreated: 1665907439
@@ -81,13 +81,13 @@ namespace Core.DataReader.Mv3
public Mv3Attribute[] Attributes;
public Mv3VertFrame[] Frames;
public Vector2[] TexCoords;
public Vector3[] Normals;
}
public struct VertexAnimationKeyFrame
{
public uint Tick;
public Vector3[] Vertices;
public Vector3[] Normals;
public int[] Triangles;
public Vector2[] Uv;
}
@@ -74,8 +74,9 @@ namespace Core.DataReader.Mv3
for (var i = 0; i < numberOfMeshes; i++)
{
Mv3Mesh mesh = ReadMesh(reader, codepage);
meshes[i] = mesh;
meshKeyFrames[i] = CalculateKeyFrameVertices(mesh);
mesh.Normals = Utility.CalculateNormals(meshKeyFrames[i][0].Vertices, meshKeyFrames[i][0].Triangles);
meshes[i] = mesh;
}
return new Mv3File(version,
@@ -185,38 +186,28 @@ namespace Core.DataReader.Mv3
{
var triangles = new List<int>();
var texCoords = mv3Mesh.TexCoords;
var indexMap = new Dictionary<int, int>();
var keyFrameInfo = new List<(Vector3 vertex, Vector2 uv)>[mv3Mesh.Frames.Length]
.Select(item=>new List<(Vector3 vertex, Vector2 uv)>()).ToArray();
var triangleIndex = 0;
for (var i = 0; i < mv3Mesh.Attributes[0].IndexBuffers.Length; i++)
{
Mv3IndexBuffer indexBuffer = mv3Mesh.Attributes[0].IndexBuffers[i];
for (var j = 0; j < 3; j++)
{
var hash = indexBuffer.TriangleIndex[j] * texCoords.Length + indexBuffer.TexCoordIndex[j];
if (indexMap.ContainsKey(hash))
for (var k = 0; k < mv3Mesh.Frames.Length; k++)
{
triangles.Add(indexMap[hash]);
Mv3VertFrame frame = mv3Mesh.Frames[k];
Mv3Vert vertex = frame.Vertices[indexBuffer.TriangleIndex[j]];
keyFrameInfo[k].Add((GameBoxInterpreter
.ToUnityVertex(new Vector3(vertex.X, vertex.Y, vertex.Z),
GameBoxInterpreter.GameBoxMv3UnitToUnityUnit),
texCoords[indexBuffer.TexCoordIndex[j]]));
}
else
{
var index = indexMap.Keys.Count;
for (var k = 0; k < mv3Mesh.Frames.Length; k++)
{
Mv3VertFrame frame = mv3Mesh.Frames[k];
Mv3Vert vertex = frame.Vertices[indexBuffer.TriangleIndex[j]];
keyFrameInfo[k].Add((GameBoxInterpreter
.ToUnityVertex(new Vector3(vertex.X, vertex.Y, vertex.Z),
GameBoxInterpreter.GameBoxMv3UnitToUnityUnit),
texCoords[indexBuffer.TexCoordIndex[j]]));
}
indexMap[hash] = index;
triangles.Add(index);
}
triangles.Add(triangleIndex++);
}
}
@@ -7,9 +7,11 @@ namespace Core.DataReader.Nav
{
using System;
using System.IO;
using System.Linq;
using Extensions;
using GameBox;
using UnityEngine;
using Utils;
public static class NavFileReader
{
@@ -106,7 +108,7 @@ namespace Core.DataReader.Nav
var vertices = new Vector3[numberOfVertices];
for (var i = 0; i < numberOfVertices; i++)
{
vertices[i] = reader.ReadVector3();
vertices[i] = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3());
}
var triangles = new int[numberOfFaces * 3];
@@ -118,6 +120,25 @@ namespace Core.DataReader.Nav
triangles[index + 2] = reader.ReadUInt16();
}
// Some of the nav meshes in the original game are upside down (don't know why),
// so we need to flip them if that's the case. You might argue that we can just
// make the mesh double sided, but that would cause some other issues (trust me).
{
Vector3[] normals = Utility.CalculateNormals(vertices, triangles);
for (var i = 0; i < numberOfFaces; i++)
{
var index = i * 3;
if (normals[triangles[index]].y +
normals[triangles[index + 1]].y +
normals[triangles[index + 2]].y < 0)
{
// Change the winding order of the face.
(triangles[index], triangles[index + 1]) = (triangles[index + 1], triangles[index]);
}
}
}
return new NavFaceLayer()
{
Vertices = vertices,
@@ -28,7 +28,6 @@ namespace Core.DataReader.Pol
{
public Vector3[] Positions;
public Vector3[] Normals;
public float[] Radii;
public Color32[] DiffuseColors;
public Color32[] SpecularColors;
public Vector2[][] Uvs;
@@ -44,7 +43,7 @@ namespace Core.DataReader.Pol
public struct PolTexture
{
public uint BlendFlag; // 0--opaque, 1--alpha blend, 2--invert color blend, 3--add
public GameBoxBlendFlag BlendFlag; // 0--opaque, 1--alpha blend, 2--invert color blend, 3--add
public GameBoxMaterial Material;
public string[] TextureNames;
public int VertStart;
@@ -42,7 +42,7 @@ namespace Core.DataReader.Pol
nodeInfos[i] = new PolGeometryNode
{
Name = reader.ReadString(32, codepage),
Position = reader.ReadVector3(),
Position = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3()),
Radius = reader.ReadSingle(),
Offset = reader.ReadInt32()
};
@@ -137,7 +137,6 @@ namespace Core.DataReader.Pol
var positions = new Vector3[numberOfVertices];
var normals = new Vector3[numberOfVertices];
var diffuseColors = new Color32[numberOfVertices];
var radii = new float[numberOfVertices];
var specularColors = new Color32[numberOfVertices];
var uvs = new Vector2[4][];
@@ -163,9 +162,7 @@ namespace Core.DataReader.Pol
}
if ((vertexTypeFlag & GameBoxVertexType.Normal) != 0)
{
normals[i] = GameBoxInterpreter
.ToUnityVertex(reader.ReadVector3(),
GameBoxInterpreter.GameBoxUnitToUnityUnit);
normals[i] = GameBoxInterpreter.ToUnityNormal(reader.ReadVector3());
}
if ((vertexTypeFlag & GameBoxVertexType.Diffuse) != 0)
{
@@ -199,6 +196,9 @@ namespace Core.DataReader.Pol
var y = reader.ReadSingle();
uvs[3][i] = new Vector2(x, y);
}
// Quick fix for the missing/wrong normals
if (normals[i] == Vector3.zero) normals[i] = Vector3.up;
}
var vertexInfo = new PolVertexInfo()
@@ -206,7 +206,6 @@ namespace Core.DataReader.Pol
Positions = positions,
Normals = normals,
DiffuseColors = diffuseColors,
Radii = radii,
SpecularColors = specularColors,
Uvs = uvs,
};
@@ -235,7 +234,7 @@ namespace Core.DataReader.Pol
private static PolTexture ReadTextureInfo(BinaryReader reader, int version, int codepage)
#endif
{
var blendFlag = reader.ReadUInt32();
var blendFlag = (GameBoxBlendFlag)reader.ReadUInt32();
var material = new GameBoxMaterial()
{
@@ -270,13 +269,13 @@ namespace Core.DataReader.Pol
for (var i = 0; i < numberOfFaces; i++)
{
var index = i * 3;
var x = reader.ReadInt16();
var y = reader.ReadInt16();
var z = reader.ReadInt16();
(triangles[index], triangles[index + 1], triangles[index + 2]) =
GameBoxInterpreter.ToUnityTriangle((x, y, z));
triangles[index] = reader.ReadInt16();
triangles[index + 1] = reader.ReadInt16();
triangles[index + 2] = reader.ReadInt16();
}
GameBoxInterpreter.ToUnityTriangles(triangles);
return new PolTexture()
{
BlendFlag = blendFlag,
@@ -5,6 +5,7 @@
namespace Core.DataReader.Scn
{
using System;
using GameBox;
using Newtonsoft.Json;
using UnityEngine;
@@ -139,6 +140,39 @@ namespace Core.DataReader.Scn
public int LightMap; // 0日景灯光, 1夜景灯光, -1不知道是什么意思(比如M01)
public uint SkyBox;
public uint[] Reserved; // 6 DWORDs
/// <summary>
/// Check if two scene share the same model.
/// </summary>
/// <param name="sceneInfo">ScnSceneInfo</param>
/// <returns>True if two scene share the same model</returns>
public bool ModelEquals(ScnSceneInfo sceneInfo)
{
#if PAL3
return string.Equals(CityName, sceneInfo.CityName, StringComparison.OrdinalIgnoreCase) &&
string.Equals(Model, sceneInfo.Model, StringComparison.OrdinalIgnoreCase);
#elif PAL3A
var modelAName = Model;
if (modelAName.EndsWith("y", StringComparison.OrdinalIgnoreCase))
{
modelAName = modelAName[..^1];
}
var modelBName = sceneInfo.Model;
if (modelBName.EndsWith("y", StringComparison.OrdinalIgnoreCase))
{
modelBName = modelBName[..^1];
}
return string.Equals(CityName, sceneInfo.CityName, StringComparison.OrdinalIgnoreCase) &&
string.Equals(modelAName, modelBName, StringComparison.OrdinalIgnoreCase);
#endif
}
public override string ToString()
{
return $"{CityName.ToLower()}_{Name.ToLower()}_{LightMap}";
}
}
[System.Serializable]
@@ -204,6 +204,25 @@ namespace Core.FileSystem
}
}
/// <summary>
/// Extract all archives to the specified destination
/// </summary>
public void ExtractTo(string outputFolder)
{
foreach ((string cpkFileName, CpkArchive cpkArchive) in _cpkArchives)
{
var outputDir = outputFolder + cpkFileName + Path.DirectorySeparatorChar;
if (!Directory.Exists(outputDir))
{
Directory.CreateDirectory(outputDir);
}
cpkArchive.ExtractTo(outputDir);
Debug.Log($"{cpkFileName} extracted to {outputDir}");
}
}
/// <summary>
/// Search files using keyword.
/// </summary>
@@ -64,6 +64,11 @@ namespace Core.FileSystem
/// </summary>
public void DisposeAllInMemoryArchives();
/// <summary>
/// Extract all archives to the specified destination
/// </summary>
public void ExtractTo(string outputFolder);
/// <summary>
/// Search files using keyword.
/// </summary>
@@ -55,6 +55,14 @@ namespace Core.GameBox
scale.y);
}
public static Vector3 ToUnityNormal(Vector3 normal)
{
return new Vector3(
-normal.x,
normal.y,
normal.z);
}
public static Quaternion CvdQuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
{
return new Quaternion(-quaternion.X, quaternion.Z, -quaternion.Y, quaternion.W);
@@ -64,6 +72,15 @@ namespace Core.GameBox
{
return new Quaternion(-quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
}
public static Quaternion LgtQuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
{
var rotation = new Quaternion(quaternion.X, quaternion.Y, -quaternion.Z, quaternion.W);
rotation.eulerAngles = new Vector3(rotation.eulerAngles.x + 90f,
-rotation.eulerAngles.y,
rotation.eulerAngles.z);
return rotation;
}
public static Quaternion ToUnityRotation(float pitch, float yaw, float roll)
{
@@ -77,33 +94,15 @@ namespace Core.GameBox
vector3.y / scale,
vector3.z / scale);
}
// Since GameBox's rendering pipeline uses different internal axis system
// Here we are switching x and y index to minor it back to the Unity axis
// for triangles
public static (short x, short y, short z) ToUnityTriangle((short x, short y, short z) triangle)
{
return (triangle.y, triangle.x, triangle.z);
}
public static void ToUnityTriangles(List<int> triangles)
{
for (var i = 0; i < triangles.Count; i += 3)
{
(triangles[i], triangles[i + 1]) = (triangles[i + 1], triangles[i]);
}
triangles.Reverse();
}
public static int[] ToUnityTriangles(ReadOnlySpan<int> triangles)
public static void ToUnityTriangles(int[] triangles)
{
var indices = new int[triangles.Length];
for (var i = 0; i < triangles.Length; i += 3)
{
indices[i] = triangles[i + 1];
indices[i + 1] = triangles[i];
indices[i + 2] = triangles[i + 2];
}
return indices;
Array.Reverse(triangles);
}
public static bool IsPositionInsideRect(GameBoxRect rect, Vector2Int position)
@@ -58,8 +58,8 @@ namespace Core.GameBox
public static class GameBoxVertexType
{
public const int MaxUvSet = 4;
public const int Null = 0;
public const int MaxUvSet = 4;
public const int XYZ = (1 << 0);
public const int Normal = (1 << 1);
public const int Diffuse = (1 << 2);
@@ -72,6 +72,34 @@ namespace Core.GameBox
public const int FlagMask = (1 << 31);
}
public enum GameBoxBlendFlag
{
Opaque, // opaque
AlphaBlend, // src.alpha, 1-src.alpha, +
InvertColorBlend, // srcAlpha, One , +
AdditiveBlend, //
}
public enum GameBoxLightType
{
Omni, // point light
Spot, // spot light
Directional, // directional light
}
public enum GameBoxLightDecayType
{
None,
Distance,
Square,
}
public enum GameBoxLightShapeType
{
Cone,
Square,
}
public static class GameBoxVertex
{
public static int GetSize(uint vertexType)
@@ -29,9 +29,15 @@ namespace Core.Renderer
public IEnumerator PlaySpriteAnimation(Sprite[] sprites,
float fps,
int loopCount)
int loopCount,
Material material = default)
{
_isPlaying = true;
if (material != default)
{
_spriteRenderer.material = material;
}
if (loopCount == -1)
{
+13 -6
View File
@@ -12,6 +12,13 @@ namespace Core.Renderer
{
private Skybox _skybox;
private static readonly int RightTexturePropertyID = Shader.PropertyToID("_RightTex");
private static readonly int BackTexturePropertyID = Shader.PropertyToID("_BackTex");
private static readonly int LeftTexturePropertyID = Shader.PropertyToID("_LeftTex");
private static readonly int FrontTexturePropertyID = Shader.PropertyToID("_FrontTex");
private static readonly int UpTexturePropertyID = Shader.PropertyToID("_UpTex");
private static readonly int DownTexturePropertyID = Shader.PropertyToID("_DownTex");
public void Render(Texture2D[] textures)
{
var mainCamera = GetComponent<Camera>();
@@ -32,12 +39,12 @@ namespace Core.Renderer
private static Material CreateSkyboxMaterial(Texture2D[] textures)
{
var material = new Material(Shader.Find("Skybox/6 Sided"));
material.SetTexture("_RightTex", textures[0]);
material.SetTexture("_BackTex", textures[1]);
material.SetTexture("_LeftTex", textures[2]);
material.SetTexture("_FrontTex", textures[3]);
material.SetTexture("_UpTex", textures[4]);
material.SetTexture("_DownTex", textures[5]);
material.SetTexture(RightTexturePropertyID, textures[0]);
material.SetTexture(BackTexturePropertyID, textures[1]);
material.SetTexture(LeftTexturePropertyID, textures[2]);
material.SetTexture(FrontTexturePropertyID, textures[3]);
material.SetTexture(UpTexturePropertyID, textures[4]);
material.SetTexture(DownTexturePropertyID, textures[5]);
return material;
}
}
@@ -5,10 +5,10 @@
namespace Core.Renderer
{
using System;
using UnityEngine;
using UnityEngine.Rendering;
public sealed class StaticMeshRenderer : MonoBehaviour
public sealed class StaticMeshRenderer : MonoBehaviour, IDisposable
{
private MeshRenderer _meshRenderer;
private MeshFilter _meshFilter;
@@ -16,58 +16,15 @@ namespace Core.Renderer
public Mesh Render(ref Vector3[] vertices,
ref int[] triangles,
ref Vector3[] normals,
ref Vector2[] uv,
ref Material material,
ref Vector2[] mainTextureUvs,
ref Vector2[] secondaryTextureUvs,
ref Material[] materials,
bool isDynamic)
{
Dispose();
_meshRenderer = gameObject.AddComponent<MeshRenderer>();
//_meshRenderer.receiveShadows = false;
//_meshRenderer.lightProbeUsage = LightProbeUsage.Off;
_meshRenderer.sharedMaterial = material;
_meshFilter = gameObject.AddComponent<MeshFilter>();
var mesh = new Mesh();
if (isDynamic)
{
mesh.MarkDynamic();
}
mesh.SetVertices(vertices);
mesh.SetTriangles(triangles, 0);
mesh.SetNormals(normals);
mesh.SetUVs(0, uv);
if (triangles.Length == 0)
{
// https://docs.unity3d.com/ScriptReference/Mesh.RecalculateBounds.html
// After modifying vertices you should call this function to ensure the
// bounding volume is correct. Assigning triangles automatically
// recalculates the bounding volume.
mesh.RecalculateBounds();
}
_meshFilter.sharedMesh = mesh;
return mesh;
}
public Mesh Render(ref Vector3[] vertices,
ref int[] triangles,
ref Vector3[] normals,
ref Vector2[] mainTextureUv,
ref Vector2[] secondaryTextureUv,
ref Material material,
bool isDynamic)
{
Dispose();
_meshRenderer = gameObject.AddComponent<MeshRenderer>();
//_meshRenderer.receiveShadows = false;
//_meshRenderer.lightProbeUsage = LightProbeUsage.Off;
_meshRenderer.sharedMaterial = material;
_meshRenderer.sharedMaterials = materials;
_meshFilter = gameObject.AddComponent<MeshFilter>();
var mesh = new Mesh();
@@ -79,8 +36,8 @@ namespace Core.Renderer
mesh.SetVertices(vertices);
mesh.SetTriangles(triangles, 0);
mesh.SetNormals(normals);
mesh.SetUVs(0, mainTextureUv);
mesh.SetUVs(1, secondaryTextureUv);
mesh.SetUVs(0, mainTextureUvs);
mesh.SetUVs(1, secondaryTextureUvs);
if (triangles.Length == 0)
{
@@ -121,7 +78,7 @@ namespace Core.Renderer
Dispose();
}
private void Dispose()
public void Dispose()
{
if (_meshFilter != null)
{
@@ -131,7 +88,11 @@ namespace Core.Renderer
if (_meshRenderer != null)
{
Destroy(_meshRenderer.sharedMaterial);
foreach (Material material in _meshRenderer.sharedMaterials)
{
Destroy(material);
}
Destroy(_meshRenderer);
}
}
@@ -74,7 +74,7 @@ namespace Core.Utils
RuntimePlatform.IPhonePlayer => iOSSupportedVideoFormats,
RuntimePlatform.Android => AndroidSupportedVideoFormats,
_ => new () {".mp4" }
_ => new HashSet<string> {".mp4" }
};
}
}
@@ -156,11 +156,6 @@ namespace Core.Utils
return Encoding.GetEncoding(codepage).GetString(strBytes, 0, i);
}
public void Close()
{
Dispose(true);
}
private bool _disposedValue;
private void Dispose(bool disposing)
{
+38
View File
@@ -164,6 +164,44 @@ namespace Core.Utils
return finalBounds;
}
public static Vector3[] CalculateNormals(Vector3[] vertices, int[] triangles)
{
Vector3[] normals = new Vector3[vertices.Length];
for (var face = 0; face < triangles.Length / 3; face++)
{
int v1 = triangles[face * 3];
int v2 = triangles[face * 3 + 1];
int v3 = triangles[face * 3 + 2];
Vector3 pt1 = vertices[v1];
Vector3 pt2 = vertices[v2];
Vector3 pt3 = vertices[v3];
Vector3 d1 = pt2 - pt1;
Vector3 d2 = pt3 - pt1;
Vector3 normal = Vector3.Normalize(Vector3.Cross(d1, d2));
normals[v1] += normal;
normals[v2] += normal;
normals[v3] += normal;
}
for (var i = 0; i < normals.Length; i++)
{
if (normals[i] == Vector3.zero)
{
normals[i] = Vector3.up;
}
else
{
normals[i] = Vector3.Normalize(normals[i]);
}
}
return normals;
}
public static void DrawBounds(Bounds b, float duration = 1000)
{
var p1 = new Vector3(b.min.x, b.min.y, b.min.z);
+3 -3
View File
@@ -39,7 +39,7 @@ namespace Editor
BuildTargetGroup.iOS,
};
}
private static NamedBuildTarget[] GetAllSupportedNamedBuildTargets()
{
return new[]
@@ -49,7 +49,7 @@ namespace Editor
NamedBuildTarget.iOS,
};
}
private static void ApplyPlayerSettingsForVariant(string appName)
{
PlayerSettings.productName = appName;
@@ -96,7 +96,7 @@ namespace Editor
{
allDefines.Add(symbolToAdd);
}
allDefines.Sort();
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup,
string.Join(";", allDefines.ToArray()));
}
@@ -166,12 +166,20 @@ namespace Pal3.Actor
$"{FileConstants.WeaponFolderName}{separator}{weaponName}{separator}{weaponName}.pol";
(PolFile polFile, ITextureResourceProvider weaponTextureProvider) = _resourceProvider.GetPol(weaponPath);
_mv3AnimationRenderer.Init(mv3File, textureProvider, _tintColor,
polFile, weaponTextureProvider, Color.white);
_mv3AnimationRenderer.Init(mv3File,
_resourceProvider.GetMaterialFactory(),
textureProvider,
_tintColor,
polFile,
weaponTextureProvider,
Color.white);
}
else
{
_mv3AnimationRenderer.Init(mv3File, textureProvider, _tintColor);
_mv3AnimationRenderer.Init(mv3File,
_resourceProvider.GetMaterialFactory(),
textureProvider,
_tintColor);
}
_mv3AnimationRenderer.AnimationLoopPointReached += AnimationLoopPointReached;
@@ -183,7 +191,10 @@ namespace Pal3.Actor
ActorActionType action = ActorConstants.ActionNames
.FirstOrDefault(a => a.Value.Equals(_currentAction)).Key;
#if !RTX_ON
SetupShadow(action);
#endif
SetupCollider();
SetupRigidBody();
}
+1
View File
@@ -61,6 +61,7 @@ namespace Pal3.Actor
protected void ChangeName(string name)
{
if (_actorName == name) return;
_actorName = name;
InitActorConfig(name);
}
+2 -2
View File
@@ -46,7 +46,7 @@ namespace Pal3.Actor
switch (actor.Info.Id)
{
case (byte)PlayerActorId.HuaYing:
actorGameObject.AddComponent<HuaYingController>().Init(actorController, actionController);
actorGameObject.AddComponent<HuaYingController>().Init(actor, actorController, actionController);
break;
case (byte)PlayerActorId.LongKui:
actorGameObject.AddComponent<LongKuiController>().Init(actor, actionController);
@@ -56,7 +56,7 @@ namespace Pal3.Actor
switch (actor.Info.Id)
{
case (byte)PlayerActorId.TaoZi:
actorGameObject.AddComponent<FlyingActorController>().Init(actionController);
actorGameObject.AddComponent<FlyingActorController>().Init(actor, actionController);
break;
}
#endif
@@ -51,9 +51,10 @@ namespace Pal3.Actor
private readonly Path _currentPath = new ();
private WaitUntilCanceled _movementWaiter;
private CancellationTokenSource _movementCts = new ();
private bool _isDuringCollision;
private Vector3 _lastKnownValidPositionDuringCollision;
private Vector3 _lastKnownValidPositionWhenCollisionEnter;
private Func<int, byte[], HashSet<Vector2Int>> _getAllActiveActorBlockingTilePositions;
@@ -106,6 +107,7 @@ namespace Pal3.Actor
{
_currentPath.Clear();
_movementWaiter?.CancelWait();
_movementCts?.Cancel();
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
@@ -160,14 +162,14 @@ namespace Pal3.Actor
Vector2Int tilePosition = _tilemap.GetTilePosition(currentPosition, _currentLayerIndex);
if (!_tilemap.IsTilePositionInsideTileMap(tilePosition, _currentLayerIndex))
{
transform.position = _lastKnownValidPositionDuringCollision;
transform.position = _lastKnownValidPositionWhenCollisionEnter;
}
else
{
NavTile currentTile = _tilemap.GetTile(tilePosition, _currentLayerIndex);
if (!currentTile.IsWalkable())
{
transform.position = _lastKnownValidPositionDuringCollision;
transform.position = _lastKnownValidPositionWhenCollisionEnter;
}
else
{
@@ -183,7 +185,24 @@ namespace Pal3.Actor
private void OnCollisionEnter(Collision _)
{
_isDuringCollision = true;
_lastKnownValidPositionDuringCollision = transform.position;
Vector3 currentActorPosition = transform.position;
Vector2Int currentTilePosition = _tilemap.GetTilePosition(currentActorPosition, _currentLayerIndex);
if (_tilemap.IsTilePositionInsideTileMap(currentTilePosition, _currentLayerIndex) &&
_tilemap.GetTile(currentActorPosition, _currentLayerIndex).IsWalkable())
{
_lastKnownValidPositionWhenCollisionEnter = currentActorPosition;
}
else
{
_lastKnownValidPositionWhenCollisionEnter =
_tilemap.TryGetAdjacentWalkableTile(currentTilePosition,
_currentLayerIndex,
out Vector2Int nearestWalkableTilePosition)
? _tilemap.GetWorldPosition(nearestWalkableTilePosition, _currentLayerIndex)
: currentActorPosition; // Highly unlikely to happen, but this is the best effort
}
}
private void OnCollisionExit(Collision _)
@@ -387,6 +406,7 @@ namespace Pal3.Actor
private void ReachingToEndOfPath()
{
_movementWaiter?.CancelWait();
switch (_currentPath.EndOfPathAction)
{
case EndOfPathActionType.DisposeSelf:
@@ -400,7 +420,9 @@ namespace Pal3.Actor
_actionController.PerformAction(_actor.GetIdleAction());
var waypoints = _currentPath.GetAllWayPoints();
waypoints.Reverse();
StartCoroutine(WaitForSomeTimeAndFollowPath(waypoints.ToArray(), _currentPath.MovementMode));
StartCoroutine(WaitForSomeTimeAndFollowPath(waypoints.ToArray(),
_currentPath.MovementMode,
_movementCts.Token));
break;
}
}
@@ -415,10 +437,13 @@ namespace Pal3.Actor
_currentPath.Clear();
}
private IEnumerator WaitForSomeTimeAndFollowPath(Vector3[] waypoints, int mode)
private IEnumerator WaitForSomeTimeAndFollowPath(Vector3[] waypoints, int mode, CancellationToken cancellationToken)
{
yield return new WaitForSeconds(Random.Range(3, 8));
SetupPath(waypoints, mode, EndOfPathActionType.Reverse, ignoreObstacle: true);
if (!cancellationToken.IsCancellationRequested)
{
SetupPath(waypoints, mode, EndOfPathActionType.Reverse, ignoreObstacle: true);
}
}
public IEnumerator MoveDirectlyTo(Vector3 position, int mode)
@@ -437,8 +462,9 @@ namespace Pal3.Actor
private IEnumerator FindPathAndMoveToTilePosition(Vector2Int position,
int mode,
EndOfPathActionType endOfPathAction,
CancellationToken cancellationToken,
bool moveTowardsPositionIfNoPathFound = false,
string specialAction = null)
string specialAction = default)
{
Vector2Int[] path = Array.Empty<Vector2Int>();
Vector2Int fromTile = _tilemap.GetTilePosition(transform.position, _currentLayerIndex);
@@ -460,6 +486,8 @@ namespace Pal3.Actor
yield return null;
}
if (cancellationToken.IsCancellationRequested) yield break;
if (path.Length <= 0)
{
if (moveTowardsPositionIfNoPathFound)
@@ -522,7 +550,7 @@ namespace Pal3.Actor
}
}
transform.position = _tilemap.GetWorldPosition(tilePosition, _currentLayerIndex);
transform.position = _tilemap.GetWorldPosition(tilePosition, _currentLayerIndex);
}
public void Execute(ActorPathToCommand command)
@@ -532,7 +560,7 @@ namespace Pal3.Actor
_movementWaiter = new WaitUntilCanceled(this);
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(_movementWaiter));
StartCoroutine(FindPathAndMoveToTilePosition(new Vector2Int(command.TileX, command.TileZ),
command.Mode, EndOfPathActionType.Idle));
command.Mode, EndOfPathActionType.Idle, _movementCts.Token));
}
#if PAL3A
@@ -543,7 +571,7 @@ namespace Pal3.Actor
_movementWaiter = new WaitUntilCanceled(this);
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerWaitRequest(_movementWaiter));
StartCoroutine(FindPathAndMoveToTilePosition(new Vector2Int(command.TileX, command.TileZ),
mode: 0, EndOfPathActionType.Idle, specialAction: command.Action));
mode: 0, EndOfPathActionType.Idle, _movementCts.Token, specialAction: command.Action));
}
#endif
@@ -573,6 +601,7 @@ namespace Pal3.Actor
new Vector2Int(command.TileX, command.TileZ),
command.Mode,
EndOfPathActionType.DisposeSelf,
_movementCts.Token,
true));
}
@@ -580,6 +609,8 @@ namespace Pal3.Actor
{
if (_actor.Info.Id != command.ActorId) return;
_movementWaiter?.CancelWait();
_movementCts?.Cancel();
_movementCts = new CancellationTokenSource();
_currentPath.Clear();
}
@@ -592,7 +623,13 @@ namespace Pal3.Actor
public void Execute(ActorActivateCommand command)
{
if (_actor.Info.Id != command.ActorId) return;
if (command.IsActive == 0) _currentPath.Clear();
if (command.IsActive == 0)
{
_movementWaiter?.CancelWait();
_movementCts?.Cancel();
_movementCts = new CancellationTokenSource();
_currentPath.Clear();
}
}
}
}
@@ -10,7 +10,6 @@ namespace Pal3.Actor
using Command.InternalCommands;
using Command.SceCommands;
using Core.GameBox;
using MetaData;
using Player;
using Script.Waiter;
using UnityEngine;
@@ -19,11 +18,14 @@ namespace Pal3.Actor
ICommandExecutor<FlyingActorFlyToCommand>
{
private const float FLY_SPEED = 144f / GameBoxInterpreter.GameBoxUnitToUnityUnit;
private const float FLYING_MOVEMENT_MODE_SWITCH_DISTANCE = 5f;
private Actor _actor;
private ActorActionController _actionController;
public void Init(ActorActionController actionController)
public void Init(Actor actor, ActorActionController actionController)
{
_actor = actor;
_actionController = actionController;
}
@@ -44,6 +46,7 @@ namespace Pal3.Actor
if (Vector3.Distance(transform.position, PlayerActorNpcInfo.InitPosition) < float.Epsilon)
{
transform.position = targetPosition;
_actionController.PerformAction(_actor.GetIdleAction());
return;
}
@@ -53,7 +56,10 @@ namespace Pal3.Actor
var distance = (targetPosition - transform.position).magnitude;
var duration = distance / FLY_SPEED;
_actionController.PerformAction(ActorActionType.Run);
_actionController.PerformAction(distance < FLYING_MOVEMENT_MODE_SWITCH_DISTANCE
? _actor.GetMovementAction(0)
: _actor.GetMovementAction(1));
StartCoroutine(Fly(targetPosition, duration, waiter));
}
@@ -62,9 +68,8 @@ namespace Pal3.Actor
Vector3 oldPosition = transform.position;
// Facing towards target position, ignoring y
transform.forward = (new Vector3(targetPosition.x, 0f, targetPosition.z)
- new Vector3(oldPosition.x, 0f, oldPosition.z)).normalized;
transform.LookAt(new Vector3(targetPosition.x, oldPosition.y, targetPosition.z));
var timePast = 0f;
while (timePast < duration)
{
@@ -78,6 +83,7 @@ namespace Pal3.Actor
}
transform.position = targetPosition;
_actionController.PerformAction(_actor.GetIdleAction());
waiter?.CancelWait();
}
}
+38 -8
View File
@@ -19,15 +19,19 @@ namespace Pal3.Actor
ICommandExecutor<HuaYingSwitchBehaviourModeCommand>
{
private const float FLY_SPEED = 144f / GameBoxInterpreter.GameBoxUnitToUnityUnit;
private const float ROTATION_SPEED = 10f;
private const float ROTATION_SYNCING_DISTANCE = 2f;
private const float FOLLOW_TARGET_MIN_DISTANCE = 1f;
private const float FOLLOW_TARGET_MAX_DISTANCE = 6f;
private const float FOLLOW_TARGET_X_OFFSET = -0.8f;
private const float FOLLOW_TARGET_Y_OFFSET = -0.8f;
private readonly PlayerActorId _followActorId = PlayerActorId.XueJian;
private const PlayerActorId FOLLOW_ACTOR_ID = PlayerActorId.XueJian;
private SceneManager _sceneManager;
private Actor _actor;
private ActorController _actorController;
private ActorActionController _actorActionController;
private bool _isTargetRegistered;
private GameObject _target;
@@ -35,15 +39,24 @@ namespace Pal3.Actor
private ActorActionController _targetActorActionController;
private float _targetHeight;
private bool _followTarget = true;
private int _currentMode = 1; // defaults to follow target actor
public void Init(ActorController actorController,
public void Init(Actor actor,
ActorController actorController,
ActorActionController actionController)
{
base.Init(actionController);
base.Init(actor, actionController);
_actor = actor;
_actorController = actorController;
_actorActionController = actionController;
_sceneManager = ServiceLocator.Instance.Get<SceneManager>();
}
public int GetCurrentMode()
{
return _currentMode;
}
private void OnEnable()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
@@ -96,27 +109,42 @@ namespace Pal3.Actor
}
Vector3 myNewPosition = GetTargetStayPosition();
var distanceToNewPosition = Vector3.Distance(myNewPosition, transform.position);
if (Vector3.Distance(myNewPosition, transform.position) > FOLLOW_TARGET_MAX_DISTANCE)
if (distanceToNewPosition < float.Epsilon)
{
transform.position = myNewPosition;
_actorActionController.PerformAction(_actor.GetIdleAction());
}
else
{
if (Vector3.Distance(myNewPosition, transform.position) < FOLLOW_TARGET_MAX_DISTANCE)
{
_actorActionController.PerformAction(_actor.GetMovementAction(0));
}
else
{
transform.position = (transform.position - myNewPosition).normalized * FOLLOW_TARGET_MAX_DISTANCE +
myNewPosition;
_actorActionController.PerformAction(_actor.GetMovementAction(1));
}
transform.position = Vector3.MoveTowards(transform.position,
myNewPosition,
Time.deltaTime * FLY_SPEED);
transform.LookAt(new Vector3(myNewPosition.x, transform.position.y, myNewPosition.z));
}
if (_isTargetRegistered)
if (distanceToNewPosition < ROTATION_SYNCING_DISTANCE)
{
transform.rotation = _target.transform.rotation;
Vector3 newRotation= Vector3.RotateTowards(transform.forward,
_target.transform.forward, ROTATION_SPEED * Time.deltaTime, 0.0f);
transform.rotation = Quaternion.LookRotation(newRotation);
}
}
private void FindAndSetTarget()
{
_target = _sceneManager.GetCurrentScene().GetActorGameObject((byte) _followActorId);
_target = _sceneManager.GetCurrentScene().GetActorGameObject((byte) FOLLOW_ACTOR_ID);
_targetActorController = _target.GetComponent<ActorController>();
_targetActorActionController = _target.GetComponent<ActorActionController>();
_isTargetRegistered = true;
@@ -139,6 +167,8 @@ namespace Pal3.Actor
_followTarget = false;
break;
}
_currentMode = command.Mode;
}
}
}
@@ -18,6 +18,8 @@ namespace Pal3.Actor
private Actor _actor;
private ActorActionController _actionController;
private int _currentMode = 0;
public void Init(Actor actor, ActorActionController actionController)
{
_actor = actor;
@@ -33,12 +35,20 @@ namespace Pal3.Actor
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
public int GetCurrentMode()
{
return _currentMode;
}
public void Execute(LongKuiSwitchModeCommand command)
{
_currentMode = command.Mode;
_actor.ChangeName(command.Mode == 0 ?
ActorConstants.LongKuiHumanModeActorName :
ActorConstants.LongKuiGhostModeActorName);
if (_actor.IsActive)
{
_actionController.PerformAction(_actor.GetIdleAction(), overwrite: true);
+169 -95
View File
@@ -7,6 +7,7 @@ namespace Pal3.Audio
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Command;
@@ -25,7 +26,7 @@ namespace Pal3.Audio
public sealed class AudioManager : MonoBehaviour,
ICommandExecutor<PlaySfxCommand>,
ICommandExecutor<PlayMusicCommand>,
ICommandExecutor<PlaySfxAtGameObjectRequest>,
ICommandExecutor<AttachSfxToGameObjectRequest>,
ICommandExecutor<StopSfxPlayingAtGameObjectRequest>,
ICommandExecutor<GameStateChangedNotification>,
ICommandExecutor<StopMusicCommand>,
@@ -33,17 +34,18 @@ namespace Pal3.Audio
ICommandExecutor<ScenePostLoadingNotification>,
ICommandExecutor<ResetGameStateCommand>
{
public float MusicVolume { get; set; } = 0.45f;
public float SoundVolume { get; set; } = 0.65f;
public float DefaultMusicVolume { get; set; } = 0.45f;
public float DefaultSoundVolume { get; set; } = 0.65f;
private Camera _mainCamera;
private AudioSource _musicPlayer;
private AudioSource _sfxPlayer;
private GameResourceProvider _resourceProvider;
private SceneManager _sceneManager;
private const string STOP_MUSIC_NAME = "NONE";
private string _currentMusicClipName = string.Empty;
private string _currentScriptMusic = string.Empty;
private readonly List<string> _playingSfxSourceNames = new ();
// TODO: Fix and remove this hack
private const string PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME = "PlayerActorMovementSfx";
@@ -51,15 +53,15 @@ namespace Pal3.Audio
private CancellationTokenSource _sceneAudioCts = new ();
public void Init(GameResourceProvider resourceProvider,
public void Init(Camera mainCamera,
GameResourceProvider resourceProvider,
SceneManager sceneManager,
AudioSource musicSource,
AudioSource sfxSource)
AudioSource musicSource)
{
_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));
_sfxPlayer = sfxSource != null ? sfxSource : throw new ArgumentNullException(nameof(sfxSource));
}
private void OnEnable()
@@ -101,17 +103,20 @@ namespace Pal3.Audio
_currentMusicClipName = musicName;
var musicFileVirtualPath = GetMusicFileVirtualPath(musicName);
var musicFileCachePath = _resourceProvider.GetMp3FilePathInCacheFolder(musicFileVirtualPath);
yield return PlayMusic(musicFileVirtualPath, musicFileCachePath, -1);
yield return PlayMusic(musicName, musicFileVirtualPath, musicFileCachePath, -1);
}
public IEnumerator PlayAudioClip(AudioSource audioSource,
private IEnumerator PlayAudioClip(AudioSource audioSource,
AudioClip audioClip,
int loopCount,
float interval,
float volume,
CancellationToken cancellationToken)
{
if (loopCount <= 0 && interval == 0f)
if (audioSource == null || !audioSource.enabled) yield break;
if (loopCount == -1 && interval == 0f)
{
if (audioSource.clip != null)
{
@@ -124,7 +129,7 @@ namespace Pal3.Audio
audioSource.loop = true;
audioSource.Play();
}
else if (loopCount <= 0 && interval > 0f)
else if (loopCount == -1 && interval > 0f)
{
while (!cancellationToken.IsCancellationRequested && audioSource != null)
{
@@ -141,44 +146,42 @@ namespace Pal3.Audio
}
}
}
public IEnumerator PlaySfx(string sfxFilePath, int loopCount, CancellationToken cancellationToken)
{
AudioClip sfxAudioClip = null;
yield return _resourceProvider.LoadAudioClip(sfxFilePath, AudioType.WAV, audioClip =>
{
sfxAudioClip = audioClip;
});
if (sfxAudioClip == null || cancellationToken.IsCancellationRequested) yield break;
yield return PlayAudioClip(_sfxPlayer, sfxAudioClip, loopCount, 0f, SoundVolume, cancellationToken);
}
// Spatial Audio
public IEnumerator PlaySfx(GameObject parent,
private IEnumerator AttachSfxToGameObjectAndPlaySfx(GameObject parent,
string sfxFilePath,
string audioSourceName,
int loopCount,
float volume,
int loopCount = -1,
float interval = 0f,
CancellationToken cancellationToken = default)
{
if (parent == null || cancellationToken.IsCancellationRequested) yield break;
AudioClip sfxAudioClip = null;
yield return _resourceProvider.LoadAudioClip(sfxFilePath, AudioType.WAV, audioClip =>
{
sfxAudioClip = audioClip;
});
if (parent == null || cancellationToken.IsCancellationRequested || sfxAudioClip == null) yield break;
if (parent == null ||
cancellationToken.IsCancellationRequested ||
sfxAudioClip == null) yield break;
if (audioSourceName == PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME &&
if (parent != _mainCamera.gameObject &&
audioSourceName == PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME &&
_playerMovementSfxInProgress == false)
{
yield break;
yield break; // Means movement sfx is already stopped before it started due to the delay of the coroutine
}
if (parent == _mainCamera.gameObject &&
!_playingSfxSourceNames.Contains(audioSourceName))
{
yield break; // Means sfx is already stopped before it started due to the delay of the coroutine
}
GameObject audioSourceParent;
Transform audioSourceParentTransform = parent.transform.Find(audioSourceName);
if (audioSourceParentTransform != null)
@@ -199,6 +202,22 @@ namespace Pal3.Audio
yield return PlayAudioClip(audioSource, sfxAudioClip, loopCount, interval, volume, cancellationToken);
}
private IEnumerator StartWithDelay(
float delayInSeconds,
IEnumerator coroutine,
CancellationToken cancellationToken)
{
if (delayInSeconds > 0)
{
yield return new WaitForSeconds(delayInSeconds);
}
if (!cancellationToken.IsCancellationRequested)
{
yield return coroutine;
}
}
private string GetMusicFileVirtualPath(string musicName)
{
@@ -207,77 +226,129 @@ namespace Pal3.Audio
$"{FileConstants.MusicCpkPathInfo.relativePath}{separator}{musicName}.mp3";
}
public IEnumerator PlayMusic(string musicFileVirtualPath, string musicFileCachePath, int loopCount)
public IEnumerator PlayMusic(string musicName,
string musicFileVirtualPath,
string musicFileCachePath,
int loopCount)
{
yield return _resourceProvider.ExtractAndMoveMp3FileToCacheFolder(musicFileVirtualPath, musicFileCachePath);
AudioClip musicClip = null;
yield return _resourceProvider.LoadAudioClip(musicFileCachePath, AudioType.MPEG, audioClip =>
{
musicClip = audioClip;
});
if (musicClip == null) yield break;
StartCoroutine(PlayAudioClip(_musicPlayer, musicClip, loopCount, 0f, MusicVolume,
new CancellationToken(false))); // Should not stop music during scene switch
// We need to check if current music clip is the same as the one we are trying to play,
// since we are using coroutine to load and play music, there is a chance that the music
// clip we are trying to play is not the same as the one we supposed to play.
if (musicClip == null ||
!string.Equals(_currentMusicClipName, musicName, StringComparison.OrdinalIgnoreCase)) yield break;
yield return PlayAudioClip(_musicPlayer, musicClip, loopCount, 0f, DefaultMusicVolume,
new CancellationToken(false)); // Should not stop music during scene switch
}
private IEnumerator PlaySfxAtGameObject(string sfxFilePath,
string audioSourceName,
float volume,
float startDelayInSeconds,
int loopCount,
float interval,
GameObject parent,
CancellationToken cancellationToken)
public string GetCurrentScriptMusic()
{
if (startDelayInSeconds > 0)
{
yield return new WaitForSeconds(startDelayInSeconds);
}
return _currentScriptMusic;
}
if (!cancellationToken.IsCancellationRequested && parent != null)
private void DestroyAllSfxAudioSource()
{
// Destroy current playing sfx
foreach (Transform audioSourceParentTransform in _playingSfxSourceNames
.Select(sfxName => _mainCamera.transform.Find(sfxName))
.Where(audioSourceParentTransform => audioSourceParentTransform != null))
{
yield return PlaySfx(parent,
sfxFilePath,
audioSourceName,
volume,
loopCount,
interval,
cancellationToken);
if (audioSourceParentTransform.GetComponent<AudioSource>() is { } audioSource)
{
audioSource.Stop();
if (audioSource.clip != null)
{
Destroy(audioSource.clip);
}
}
Destroy(audioSourceParentTransform.gameObject);
}
_playingSfxSourceNames.Clear();
}
private void ChangeAllSfxAudioSourceMuteSetting(bool mute)
{
foreach (Transform audioSourceParentTransform in _playingSfxSourceNames
.Select(sfxName => _mainCamera.transform.Find(sfxName))
.Where(audioSourceParentTransform => audioSourceParentTransform != null))
{
if (audioSourceParentTransform.GetComponent<AudioSource>() is { } audioSource)
{
audioSource.mute = mute;
}
}
}
public void Execute(PlaySfxCommand command)
{
var sfxName = command.SfxName;
#if PAL3
var sfxName = command.SfxName.ToLower();
#elif PAL3A
var sfxName = command.SfxName.ToUpper();
#endif
var loopCount = command.LoopCount;
// TODO: Start/stop walk/run sfx based on actor behaviour
if (command.SfxName.Contains("we022", StringComparison.OrdinalIgnoreCase))
#if PAL3
// Fix actor movement sfx name
if (sfxName.Equals("we021", StringComparison.OrdinalIgnoreCase))
{
loopCount = 3;
sfxName = "we021a";
}
// TODO: Change walk/run sfx based on tile type
if (command.SfxName.Equals("we022", StringComparison.OrdinalIgnoreCase))
if (sfxName.Equals("we022", StringComparison.OrdinalIgnoreCase))
{
sfxName = "we022b";
sfxName = "we022a";
}
#endif
// TODO: This sfx will be triggered to loop forever after actor
// leaving the hotel. Maybe we should play it by attaching
// the sound to the hotel position?
if (command.SfxName.Equals("wc019", StringComparison.OrdinalIgnoreCase) &&
command.LoopCount == -1)
switch (loopCount)
{
return;
case 0: // start playing sfx indefinitely for the given sfxName
_playingSfxSourceNames.Add(sfxName);
StartCoroutine(AttachSfxToGameObjectAndPlaySfx(_mainCamera.gameObject,
_resourceProvider.GetSfxFilePath(sfxName),
sfxName, // use sfx name as audio source name
loopCount: -1, // loop indefinitely
DefaultSoundVolume,
interval: 0f,
_sceneAudioCts.Token));
break;
case -1: // stop playing sfx by sfxName
_playingSfxSourceNames.Remove(sfxName);
Execute(new StopSfxPlayingAtGameObjectRequest(
_mainCamera.gameObject,
sfxName,
disposeSource: true));
break;
default:
{
_playingSfxSourceNames.Add(sfxName);
var sfxFilePath = _resourceProvider.GetSfxFilePath(sfxName);
CancellationToken cancellationToken = _sceneAudioCts.Token;
StartCoroutine(AttachSfxToGameObjectAndPlaySfx(_mainCamera.gameObject,
sfxFilePath,
sfxName, // use sfx name as audio source name
loopCount,
DefaultSoundVolume,
interval: 0f,
cancellationToken));
break;
}
}
var sfxFilePath = _resourceProvider.GetSfxFilePath(sfxName);
CancellationToken cancellationToken = _sceneAudioCts.Token;
StartCoroutine(PlaySfx(sfxFilePath, loopCount, cancellationToken));
}
public void Execute(PlaySfxAtGameObjectRequest request)
public void Execute(AttachSfxToGameObjectRequest request)
{
if (request.AudioSourceName == PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME)
{
@@ -286,13 +357,14 @@ namespace Pal3.Audio
var sfxFilePath = _resourceProvider.GetSfxFilePath(request.SfxName);
CancellationToken cancellationToken = _sceneAudioCts.Token;
StartCoroutine(PlaySfxAtGameObject(sfxFilePath,
request.AudioSourceName,
request.Volume,
request.StartDelayInSeconds,
request.LoopCount,
request.Interval,
request.Parent,
StartCoroutine(StartWithDelay(request.StartDelayInSeconds,
AttachSfxToGameObjectAndPlaySfx(request.Parent,
sfxFilePath,
request.AudioSourceName,
request.LoopCount,
request.Volume,
request.Interval,
cancellationToken),
cancellationToken));
}
@@ -312,6 +384,11 @@ namespace Pal3.Audio
audioSource.Stop();
audioSource.clip = null;
if (command.DisposeSource)
{
Destroy(audioSourceParent);
}
}
public void Execute(PlayMusicCommand command)
@@ -325,7 +402,9 @@ namespace Pal3.Audio
// TODO: Disable combat music since combat system has not been implemented yet.
if (MusicConstants.CombatMusicInfo.Any(musicInfo =>
command.MusicName.Equals(musicInfo.Value, StringComparison.OrdinalIgnoreCase)))
command.MusicName.Equals(musicInfo.Value, StringComparison.OrdinalIgnoreCase)) ||
command.MusicName.Equals("PI25A", StringComparison.OrdinalIgnoreCase) ||
command.MusicName.Equals("PI25", StringComparison.OrdinalIgnoreCase))
{
return;
}
@@ -334,7 +413,8 @@ namespace Pal3.Audio
_currentMusicClipName = command.MusicName;
var musicFileVirtualPath = GetMusicFileVirtualPath(command.MusicName);
var musicFileCachePath = _resourceProvider.GetMp3FilePathInCacheFolder(musicFileVirtualPath);
StartCoroutine(PlayMusic(musicFileVirtualPath,
StartCoroutine(PlayMusic(command.MusicName,
musicFileVirtualPath,
musicFileCachePath,
command.Loop == 0 ? -1 : command.Loop));
}
@@ -355,13 +435,7 @@ namespace Pal3.Audio
public void Execute(ScenePreLoadingNotification command)
{
if (_sfxPlayer.clip != null)
{
_sfxPlayer.loop = false;
_sfxPlayer.Stop();
Destroy(_sfxPlayer.clip);
}
DestroyAllSfxAudioSource();
_sceneAudioCts.Cancel();
_sceneAudioCts = new CancellationTokenSource();
}
@@ -376,9 +450,9 @@ namespace Pal3.Audio
public void Execute(ResetGameStateCommand command)
{
DestroyAllSfxAudioSource();
_currentScriptMusic = string.Empty;
_musicPlayer.Stop();
_sfxPlayer.Stop();
}
public void Execute(GameStateChangedNotification command)
@@ -391,12 +465,12 @@ namespace Pal3.Audio
}
_musicPlayer.mute = true;
_sfxPlayer.mute = true;
ChangeAllSfxAudioSourceMuteSetting(true);
}
else
else if (command.PreviousState == GameState.VideoPlaying)
{
if (_musicPlayer.mute) _musicPlayer.mute = false;
if (_sfxPlayer.mute) _sfxPlayer.mute = false;
_musicPlayer.mute = false;
ChangeAllSfxAudioSourceMuteSetting(false);
}
}
}
+60 -9
View File
@@ -7,6 +7,8 @@ namespace Pal3.Camera
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Command;
using Command.InternalCommands;
@@ -46,7 +48,9 @@ namespace Pal3.Camera
ICommandExecutor<CameraFocusOnActorCommand>,
ICommandExecutor<CameraFocusOnSceneObjectCommand>,
ICommandExecutor<ScenePreLoadingNotification>,
ICommandExecutor<GameStateChangedNotification>
ICommandExecutor<SceneLeavingCurrentSceneNotification>,
ICommandExecutor<GameStateChangedNotification>,
ICommandExecutor<ResetGameStateCommand>
{
private const float FADE_ANIMATION_DURATION = 3f;
private const float SCENE_STORY_B_ROOM_HEIGHT = 32f;
@@ -89,6 +93,12 @@ namespace Pal3.Camera
private CancellationTokenSource _asyncCameraAnimationCts = new ();
private CancellationTokenSource _cameraFadeAnimationCts = new ();
private const int LAST_KNOWN_SCENE_STATE_LIST_MAX_LENGTH = 1;
private readonly List<(ScnSceneInfo sceneInfo,
Vector3 cameraPosition,
Quaternion cameraRotation,
Vector3 cameraOffset)> _cameraLastKnownSceneState = new ();
public void Init(PlayerInputActions inputActions,
PlayerGamePlayController gamePlayController,
SceneManager sceneManager,
@@ -369,7 +379,7 @@ namespace Pal3.Camera
return _currentAppliedDefaultTransformOption;
}
public void ApplySceneSettings(ScnSceneInfo sceneInfo)
private void ApplySceneSettings(ScnSceneInfo sceneInfo)
{
switch (sceneInfo.SceneType)
{
@@ -377,27 +387,27 @@ namespace Pal3.Camera
_freeToRotate = false;
_lookAtPointYOffset = SCENE_STORY_B_ROOM_HEIGHT /
GameBoxInterpreter.GameBoxUnitToUnityUnit;
_camera.nearClipPlane = 0.5f;
_camera.nearClipPlane = 1f;
_camera.farClipPlane = 500f;
ApplyDefaultSettings(1);
break;
case ScnSceneType.StoryA:
_freeToRotate = true;
_lookAtPointYOffset = 0;
_camera.nearClipPlane = 1f;
_camera.nearClipPlane = 2f;
_camera.farClipPlane = 800f;
ApplyDefaultSettings(0);
break;
case ScnSceneType.Maze:
_freeToRotate = true;
_lookAtPointYOffset = 0;
_camera.nearClipPlane = 1f;
_camera.nearClipPlane = 2f;
_camera.farClipPlane = 800f;
ApplyDefaultSettings(0);
break;
default:
_lookAtPointYOffset = 0;
_camera.nearClipPlane = 0.5f;
_camera.nearClipPlane = 1f;
_camera.farClipPlane = 500f;
ApplyDefaultSettings(0);
break;
@@ -406,7 +416,7 @@ namespace Pal3.Camera
_shouldResetVelocity = true;
}
public void ApplyDefaultSettings(int option)
private void ApplyDefaultSettings(int option)
{
Quaternion rotation;
float distance = 688.0f / GameBoxInterpreter.GameBoxUnitToUnityUnit;
@@ -692,16 +702,51 @@ namespace Pal3.Camera
public void Execute(CameraSetYawCommand command)
{
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
RotateToOrbitPoint(command.Yaw);
}
public void Execute(SceneLeavingCurrentSceneNotification command)
{
if (_sceneManager.GetCurrentScene() is not { } currentScene) return;
if (_gameStateManager.GetCurrentState() == GameState.Gameplay &&
currentScene.GetSceneInfo().SceneType != ScnSceneType.StoryB)
{
var cameraTransform = _camera.transform;
_cameraLastKnownSceneState.Add((
currentScene.GetSceneInfo(),
cameraTransform.position,
cameraTransform.rotation,
_cameraOffset));
if (_cameraLastKnownSceneState.Count > LAST_KNOWN_SCENE_STATE_LIST_MAX_LENGTH)
{
_cameraLastKnownSceneState.RemoveAt(0);
}
}
}
public void Execute(ScenePreLoadingNotification notification)
{
_currentAppliedDefaultTransformOption = 0;
ApplySceneSettings(notification.NewSceneInfo);
}
// Apply the last known scene state if found in record.
if (_gameStateManager.GetCurrentState() == GameState.Gameplay &&
notification.NewSceneInfo.SceneType != ScnSceneType.StoryB)
{
if (_cameraLastKnownSceneState.Count > 0 && _cameraLastKnownSceneState.Any(_ =>
_.sceneInfo.ModelEquals(notification.NewSceneInfo)))
{
(ScnSceneInfo _, Vector3 cameraPosition, Quaternion cameraRotation, Vector3 cameraOffset) =
_cameraLastKnownSceneState.Last(_ => _.sceneInfo.ModelEquals(notification.NewSceneInfo));
_camera.transform.SetPositionAndRotation(cameraPosition, cameraRotation);
_cameraOffset = cameraOffset;
}
}
}
public void Execute(CameraFocusOnActorCommand command)
{
if (command.ActorId == ActorConstants.PlayerActorVirtualID) return;
@@ -721,5 +766,11 @@ namespace Pal3.Camera
{
if (command.NewState == GameState.Gameplay) _free = true;
}
public void Execute(ResetGameStateCommand command)
{
_cameraLastKnownSceneState.Clear();
_free = true;
}
}
}
@@ -8,21 +8,21 @@ namespace Pal3.Command.InternalCommands
using Newtonsoft.Json;
using UnityEngine;
public class PlaySfxAtGameObjectRequest : ICommand
public class AttachSfxToGameObjectRequest : ICommand
{
public PlaySfxAtGameObjectRequest(GameObject parent,
public AttachSfxToGameObjectRequest(GameObject parent,
string sfxName,
string audioSourceName,
float volume,
int loopCount,
float volume,
float startDelayInSeconds,
float interval)
{
Parent = parent;
SfxName = sfxName;
AudioSourceName = audioSourceName;
Volume = volume;
LoopCount = loopCount;
Volume = volume;
StartDelayInSeconds = startDelayInSeconds;
Interval = interval;
}
@@ -30,10 +30,9 @@ namespace Pal3.Command.InternalCommands
[JsonIgnore] public GameObject Parent { get; }
public string SfxName { get; }
public string AudioSourceName { get; }
public float Volume { get; }
public int LoopCount { get; }
public float Volume { get; }
public float StartDelayInSeconds { get; }
public float Interval { get; }
}
}
@@ -9,11 +9,13 @@ namespace Pal3.Command.InternalCommands
public class GameStateChangedNotification : ICommand
{
public GameStateChangedNotification(GameState newState)
public GameStateChangedNotification(GameState previousState, GameState newState)
{
PreviousState = previousState;
NewState = newState;
}
public GameState PreviousState { get; }
public GameState NewState { get; }
}
}
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 6affef692c664172a6cc441fecd714cd
timeCreated: 1663649030
@@ -1,12 +1,12 @@
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Command.InternalCommands
{
public class SceneBeforeLoadingNotification : ICommand
public class SceneLeavingCurrentSceneNotification : ICommand
{
public SceneBeforeLoadingNotification() { }
public SceneLeavingCurrentSceneNotification() { }
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 332a46f38a2c43759aecfba77b293112
timeCreated: 1665352229
@@ -10,13 +10,15 @@ namespace Pal3.Command.InternalCommands
public class StopSfxPlayingAtGameObjectRequest : ICommand
{
public StopSfxPlayingAtGameObjectRequest(GameObject parent, string audioSourceName)
public StopSfxPlayingAtGameObjectRequest(GameObject parent, string audioSourceName, bool disposeSource)
{
Parent = parent;
AudioSourceName = audioSourceName;
DisposeSource = disposeSource;
}
[JsonIgnore] public GameObject Parent { get; }
public string AudioSourceName { get; }
public bool DisposeSource { get; }
}
}
@@ -704,7 +704,7 @@ namespace Pal3.Command
}
// <auto-generated/>
[ConsoleMethodAttribute("PlaySfx", "播放音效,参数:音效名,循环次数")]
[ConsoleMethodAttribute("PlaySfx", "播放音效,参数:音效名,循环次数(0表示开始无限循环,-1表示结束循环)")]
public static void PlaySfx(System.String sfxName, System.Int32 loopCount)
{
CommandDispatcher<ICommand>.Instance.Dispatch(
@@ -736,7 +736,7 @@ namespace Pal3.Command
}
// <auto-generated/>
[ConsoleMethodAttribute("PlaySfx", "播放音效,参数:音效名,循环次数")]
[ConsoleMethodAttribute("PlaySfx", "播放音效,参数:音效名,循环次数(0表示开始无限循环,-1表示结束循环)")]
public static void PlaySfx(System.String sfxName, System.Int32 loopCount)
{
CommandDispatcher<ICommand>.Instance.Dispatch(
@@ -6,7 +6,7 @@
namespace Pal3.Command.SceCommands
{
[SceCommand(79, "播放音效," +
"参数:音效名,循环次数")]
"参数:音效名,循环次数(0表示开始无限循环,-1表示结束循环)")]
public class PlaySfxCommand : ICommand
{
public PlaySfxCommand(string sfxName, int loopCount)
@@ -14,7 +14,7 @@ namespace Pal3.Data
/// <summary>
/// Cache/dispose Cpk archive into memory based on scenarios.
/// </summary>
public class FileSystemCacheManager :
public sealed class FileSystemCacheManager : IDisposable,
ICommandExecutor<ScenePreLoadingNotification>
{
private readonly ICpkFileSystem _fileSystem;
@@ -18,6 +18,7 @@ namespace Pal3.Data
using Core.DataReader.Cpk;
using Core.DataReader.Cvd;
using Core.DataReader.Ini;
using Core.DataReader.Lgt;
using Core.DataReader.Mv3;
using Core.DataReader.Nav;
using Core.DataReader.Pol;
@@ -26,29 +27,36 @@ namespace Pal3.Data
using Core.FileSystem;
using Core.Utils;
using MetaData;
using Renderer;
using UnityEngine;
using Debug = UnityEngine.Debug;
using Object = UnityEngine.Object;
/// <summary>
/// Single resource provider for accessing game data.
/// Also manages the lifecycle of the resource it provides.
/// </summary>
public class GameResourceProvider : ICommandExecutor<ScenePreLoadingNotification>
public class GameResourceProvider : IDisposable,
ICommandExecutor<ScenePreLoadingNotification>
{
private const string CACHE_FOLDER_NAME = "CacheData";
private const string MV3_ACTOR_CONFIG_HEADER = ";#MV3#";
private readonly ICpkFileSystem _fileSystem;
private readonly ITextureLoaderFactory _textureLoaderFactory;
private readonly IMaterialFactory _materialFactory;
private readonly int _codepage;
private TextureCache _textureCache;
private readonly Dictionary<string, Sprite> _spriteCache = new ();
private readonly Dictionary<string, (PolFile PolFile, ITextureResourceProvider TextureProvider)> _polCache = new ();
private readonly Dictionary<string, (CvdFile PolFile, ITextureResourceProvider TextureProvider)> _cvdCache = new ();
private readonly Dictionary<string, (Mv3File mv3File, ITextureResourceProvider textureProvider)> _mv3Cache = new ();
private readonly Dictionary<string, ActorConfigFile> _actorConfigCache = new (); // Cache forever
private readonly Dictionary<string, AudioClip> _audioClipCache = new ();
private readonly Dictionary<int, Object> _vfxEffectPrefabCache = new ();
// Cache player actor movement sfx audio clips
private readonly HashSet<string> _audioClipCacheList = new ()
{
@@ -72,17 +80,19 @@ namespace Pal3.Data
public GameResourceProvider(ICpkFileSystem fileSystem,
ITextureLoaderFactory textureLoaderFactory,
IMaterialFactory materialFactory,
int codepage)
{
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
_textureLoaderFactory = textureLoaderFactory ?? throw new ArgumentNullException(nameof(textureLoaderFactory));
_materialFactory = materialFactory ?? throw new ArgumentNullException(nameof(materialFactory));
_codepage = codepage;
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
public void Dispose()
{
_textureCache.DisposeAll();
_textureCache?.DisposeAll();
_spriteCache.Clear();
_polCache.Clear();
_mv3Cache.Clear();
@@ -106,6 +116,11 @@ namespace Pal3.Data
return ShadowTexture;
}
public IMaterialFactory GetMaterialFactory()
{
return _materialFactory;
}
private ITextureResourceProvider GetTextureResourceProvider(string relativePath, bool useCache = true)
{
return (_textureCache != null && useCache) ?
@@ -149,6 +164,11 @@ namespace Pal3.Data
return (mv3File, textureProvider);
}
public LgtFile GetLgt(string lgtFilePath)
{
return LgtFileReader.Read(_fileSystem.ReadAllBytes(lgtFilePath));
}
public NavFile GetNav(string sceneFileName, string sceneName)
{
var separator = CpkConstants.DirectorySeparator;
@@ -375,7 +395,7 @@ namespace Pal3.Data
return textures;
}
public Texture2D GetEffectTexture(string name)
public Texture2D GetEffectTexture(string name, out bool hasAlphaChannel)
{
var separator = CpkConstants.DirectorySeparator;
@@ -384,9 +404,7 @@ namespace Pal3.Data
$"{FileConstants.EffectFolderName}{separator}";
ITextureResourceProvider textureProvider = GetTextureResourceProvider(effectFolderRelativePath);
Texture2D effectTexture = textureProvider.GetTexture(name);
Utility.ApplyTransparencyBasedOnColorLuminance(effectTexture);
return effectTexture;
return textureProvider.GetTexture(name, out hasAlphaChannel);
}
public Sprite[] GetEmojiSprites(ActorEmojiType emojiType)
@@ -478,7 +496,7 @@ namespace Pal3.Data
$"Supported video formats are: {string.Join(" ", supportedVideoFormats)}.");
}
public Texture2D[] GetEffectTextures(GraphicsEffect effect, string texturePathFormat)
public (Texture2D texture, bool hasAlphaChannel)[] GetEffectTextures(GraphicsEffect effect, string texturePathFormat)
{
var separator = CpkConstants.DirectorySeparator;
ITextureResourceProvider textureProvider = GetTextureResourceProvider(
@@ -486,31 +504,78 @@ namespace Pal3.Data
if (effect == GraphicsEffect.Fire)
{
var numberOfFrames = EffectConstants.EffectAnimationInfo[effect].NumberOfFrames;
var textures = new Texture2D[numberOfFrames];
var numberOfFrames = EffectConstants.AnimatedFireEffectFrameCount;
var textures = new (Texture2D texture, bool hasAlphaChannel)[numberOfFrames];
for (var i = 0; i < numberOfFrames; i++)
{
var textureNameFormat = Utility.GetFileName(texturePathFormat, separator);
Texture2D texture = textureProvider.GetTexture(string.Format(textureNameFormat, i + 1));
textures[i] = texture;
Texture2D texture = textureProvider.GetTexture(string.Format(textureNameFormat, i + 1), out var hasAlphaChannel);
textures[i] = (texture, hasAlphaChannel);
}
return textures;
}
return Array.Empty<Texture2D>();
return Array.Empty<(Texture2D, bool)>();
}
private string GetVfxPrefabPath(int effectGroupId)
{
return $"Prefabs/VFX/{GameConstants.AppName}/{effectGroupId}";
}
public Object GetVfxEffectPrefab(int effectGroupId)
{
if (_vfxEffectPrefabCache.ContainsKey(effectGroupId))
{
return _vfxEffectPrefabCache[effectGroupId];
}
Object vfxPrefab = Resources.Load(GetVfxPrefabPath(effectGroupId));
if (vfxPrefab != null)
{
_vfxEffectPrefabCache[effectGroupId] = vfxPrefab;
return vfxPrefab;
}
else
{
Debug.LogWarning("VFX prefab not found: " + effectGroupId);
return null;
}
}
public IEnumerator PreLoadVfxEffectAsync(int effectGroupId)
{
if (_vfxEffectPrefabCache.ContainsKey(effectGroupId))
{
yield break;
}
ResourceRequest request = Resources.LoadAsync(GetVfxPrefabPath(effectGroupId));
while (!request.isDone)
{
yield return request;
}
if (request.asset != null)
{
_vfxEffectPrefabCache[effectGroupId] = request.asset;
Debug.Log("VFX prefab preloaded: " + effectGroupId);
}
}
public Texture2D GetCursorTexture()
{
var separator = CpkConstants.DirectorySeparator;
var emojiSpriteSheetRelativePath =
var cursorSpriteRelativePath =
$"{FileConstants.BaseDataCpkPathInfo.cpkName}{separator}" +
$"{FileConstants.UIFolderName}{separator}{FileConstants.CursorFolderName}{separator}";
ITextureResourceProvider textureProvider = GetTextureResourceProvider(emojiSpriteSheetRelativePath);
return textureProvider.GetTexture($"jt.tga");
ITextureResourceProvider textureProvider = GetTextureResourceProvider(cursorSpriteRelativePath);
Texture2D cursorTexture = textureProvider.GetTexture($"jt.tga");
return cursorTexture;
}
private string _currentSceneCityName;
@@ -527,13 +592,16 @@ namespace Pal3.Data
if (!newSceneCityName.Equals(_currentSceneCityName, StringComparison.OrdinalIgnoreCase))
{
// Clean up cache after exiting current scene block
_textureCache.DisposeAll();
_textureCache?.DisposeAll();
_spriteCache.Clear();
// TODO: Have a better way to manage the lifecycle of pol, mv3, cvd data.
// _polCache.Clear();
// _mv3Cache.Clear();
// _cvdCache.Clear();
// clear all vfx prefabs in cache
_vfxEffectPrefabCache.Clear();
// Unloads assets that are not used (textures etc.)
Resources.UnloadUnusedAssets();
@@ -0,0 +1,18 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Dev
{
using Core.DataReader.Lgt;
using UnityEngine;
/// <summary>
/// LightNode holder component to present LightNode in the Unity inspector.
/// </summary>
public class LightSourceInfoPresenter : MonoBehaviour
{
[SerializeField] public LightNode LightNode;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d762f91c6d264bbba826943e9b1a122b
timeCreated: 1665981881
@@ -13,7 +13,7 @@ namespace Pal3.Dev
/// </summary>
public class MaterialInfoPresenter : MonoBehaviour
{
[SerializeField] public uint blendFlag;
[SerializeField] public GameBoxBlendFlag blendFlag;
[SerializeField] public GameBoxMaterial material;
}
}
+10 -3
View File
@@ -17,10 +17,11 @@ namespace Pal3.Dev
using Scene;
using Script;
using State;
using UI;
using UnityEngine;
using UnityEngine.UI;
public sealed class MazeSkipper :
public sealed class MazeSkipper : IDisposable,
ICommandExecutor<ScenePostLoadingNotification>,
ICommandExecutor<GameStateChangedNotification>
{
@@ -251,6 +252,11 @@ namespace Pal3.Dev
{
new ActorSetNavLayerCommand(-1, 0),
new ActorSetTilePositionCommand(-1, 207, 255)
}},
{ "m20_1_120700", new List<ICommand>()
{
new ActorSetNavLayerCommand(-1, 0),
new ActorSetTilePositionCommand(-1, 72, 48)
}},
{ "m20_2_0", new List<ICommand>()
{
@@ -903,8 +909,10 @@ namespace Pal3.Dev
_mazeSkipperCanvasGroup.alpha = 0f;
_mazeSkipperCanvasGroup.interactable = false;
_mazeEntranceButton.colors = UITheme.GetButtonColors();
_mazeEntranceButton.onClick
.AddListener(EntranceButtonClicked);
_mazeExitButton.colors = UITheme.GetButtonColors();
_mazeExitButton.onClick
.AddListener(ExitButtonClicked);
@@ -962,12 +970,11 @@ namespace Pal3.Dev
public void Dispose()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
_mazeEntranceButton.onClick
.RemoveListener(EntranceButtonClicked);
_mazeExitButton.onClick
.RemoveListener(ExitButtonClicked);
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
private string GetCommandHashKeyPrefix(ScnSceneInfo sceneInfo)
@@ -15,6 +15,7 @@ namespace Pal3.Dev
// Should be (1, 1) but these are (1, -1)
public static readonly HashSet<string> KnownTextureFiles = new HashSet<string>
{
"basedata.cpk\\role\\607\\607.tga",
"basedata.cpk\\role\\611\\611.tga",
"basedata.cpk\\role\\613\\613.tga",
"basedata.cpk\\role\\b03\\b03.tga",
+99 -50
View File
@@ -18,6 +18,7 @@ namespace Pal3.Dev
using Script;
using State;
using TMPro;
using UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
@@ -26,7 +27,10 @@ namespace Pal3.Dev
public sealed class StorySelector : MonoBehaviour,
ICommandExecutor<ToggleStorySelectorRequest>,
ICommandExecutor<GameSwitchToMainMenuCommand>
ICommandExecutor<GameSwitchToMainMenuCommand>,
ICommandExecutor<ScriptFinishedRunningNotification>,
ICommandExecutor<GameStateChangedNotification>,
ICommandExecutor<ResetGameStateCommand>
{
private InputManager _inputManager;
private EventSystem _eventSystem;
@@ -38,11 +42,14 @@ namespace Pal3.Dev
private CanvasGroup _storySelectorCanvas;
private GameObject _storySelectorButtonPrefab;
private readonly List<string> _deferredExecutionCommands = new();
private readonly List<GameObject> _selectionButtons = new();
private readonly Dictionary<string, string> _storySelections = new()
{
{"关闭", ""},
{"退出游戏", ""},
{"继续游戏", ""},
{"保存当前游戏进度", ""},
{"新的游戏", ""},
@@ -1135,25 +1142,6 @@ namespace Pal3.Dev
BigMapEnableRegion 5 2
BigMapEnableRegion 6 1
CameraFadeIn"},
{"胜州-纳林河源", @"
ScriptVarSetValue -32768 50800
SceneLoad q05 q05
ActorActivate -1 1
ActorEnablePlayerControl -1
PlayerEnableInput 1
ActorSetNavLayer -1 0
ActorSetTilePosition -1 150 85
TeamAddOrRemoveActor 2 1
TeamAddOrRemoveActor 1 1
TeamAddOrRemoveActor 4 1
BigMapEnableRegion 0 2
BigMapEnableRegion 1 2
BigMapEnableRegion 2 2
BigMapEnableRegion 4 2
BigMapEnableRegion 5 2
BigMapEnableRegion 6 1
BigMapEnableRegion 7 2
CameraFadeIn"},
{"胜州祭坛欢庆盛典", @"
ScriptVarSetValue -32768 51100
SceneLoad q05 q05
@@ -1902,6 +1890,7 @@ namespace Pal3.Dev
_playerInputActions.Gameplay.ToggleStorySelector.performed += ToggleStorySelectorOnPerformed;
_playerInputActions.Cutscene.ToggleStorySelector.performed += ToggleStorySelectorOnPerformed;
_playerInputActions.Cutscene.ExitCurrentShowingMenu.performed += HideStorySelectorOnPerformed;
}
private void OnEnable()
@@ -1914,13 +1903,25 @@ namespace Pal3.Dev
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
_playerInputActions.Gameplay.ToggleStorySelector.performed -= ToggleStorySelectorOnPerformed;
_playerInputActions.Cutscene.ToggleStorySelector.performed -= ToggleStorySelectorOnPerformed;
_playerInputActions.Cutscene.ExitCurrentShowingMenu.performed -= HideStorySelectorOnPerformed;
}
private void ToggleStorySelectorOnPerformed(InputAction.CallbackContext obj)
private void ToggleStorySelectorOnPerformed(InputAction.CallbackContext _)
{
ToggleStorySelector();
}
private void HideStorySelectorOnPerformed(InputAction.CallbackContext _)
{
if (_sceneManager.GetCurrentScene() == null) return;
if (_storySelectorCanvas.interactable)
{
Hide();
_gameStateManager.GoToState(GameState.Gameplay);
}
}
private void ToggleStorySelector()
{
if (_sceneManager.GetCurrentScene() == null) return;
@@ -1945,52 +1946,44 @@ namespace Pal3.Dev
foreach (var story in _storySelections)
{
if (hideCloseButton && story.Key is "关闭" or "保存当前游戏进度") continue;
#if !UNITY_STANDALONE || UNITY_EDITOR
if (story.Key == "退出游戏") continue;
#endif
GameObject selectionButton = Instantiate(_storySelectorButtonPrefab, _storySelectorCanvas.transform);
var buttonTextUI = selectionButton.GetComponentInChildren<TextMeshProUGUI>();
buttonTextUI.text = story.Key;
if (story.Key is "关闭" or "保存当前游戏进度" or "退出游戏" or "新的游戏" or "继续游戏")
{
buttonTextUI.fontStyle = FontStyles.Underline;
}
var button = selectionButton.GetComponent<Button>();
Navigation buttonNavigation = button.navigation;
buttonNavigation.mode = Navigation.Mode.Horizontal | Navigation.Mode.Vertical;
button.navigation = buttonNavigation;
button.colors = UITheme.GetButtonColors();
button.onClick.AddListener(delegate { StorySelectionButtonClicked(story.Key);});
_selectionButtons.Add(selectionButton);
}
// Setup button navigation
for (var i = 0; i < _selectionButtons.Count; i++)
{
var button = _selectionButtons[i].GetComponent<Button>();
Navigation buttonNavigation = button.navigation;
buttonNavigation.mode = Navigation.Mode.Explicit;
if (i == 0)
{
buttonNavigation.selectOnLeft = _selectionButtons[^1].GetComponent<Button>();
buttonNavigation.selectOnRight = _selectionButtons[i + 1].GetComponent<Button>();
}
else if (i == _selectionButtons.Count - 1)
{
buttonNavigation.selectOnLeft = _selectionButtons[i - 1].GetComponent<Button>();
buttonNavigation.selectOnRight = _selectionButtons[0].GetComponent<Button>();
}
else
{
buttonNavigation.selectOnLeft = _selectionButtons[i - 1].GetComponent<Button>();
buttonNavigation.selectOnRight = _selectionButtons[i + 1].GetComponent<Button>();
}
button.navigation = buttonNavigation;
}
var firstButton = _selectionButtons.First().GetComponent<Button>();
_eventSystem.firstSelectedGameObject = firstButton.gameObject;
InputDevice lastActiveInputDevice = _inputManager.GetLastActiveInputDevice();
if (lastActiveInputDevice == Keyboard.current ||
lastActiveInputDevice == Gamepad.current ||
lastActiveInputDevice == DualShockGamepad.current)
{
_eventSystem.firstSelectedGameObject = firstButton.gameObject;
firstButton.Select();
}
else
{
_eventSystem.firstSelectedGameObject = null;
}
_storySelectorCanvas.alpha = 1f;
_storySelectorCanvas.interactable = true;
@@ -2004,6 +1997,9 @@ namespace Pal3.Dev
if (_sceneManager.GetCurrentScene() == null) return;
_gameStateManager.GoToState(GameState.Gameplay);
break;
case "退出游戏":
Application.Quit();
break;
case "新的游戏":
CommandDispatcher<ICommand>.Instance.Dispatch(new ResetGameStateCommand());
StartNewGame();
@@ -2024,7 +2020,7 @@ namespace Pal3.Dev
}
else
{
ExecuteCommands(commands);
ExecuteCommandsFromSaveFile(commands);
}
}
break;
@@ -2064,6 +2060,32 @@ namespace Pal3.Dev
}
}
}
private void ExecuteCommandsFromSaveFile(string commands)
{
foreach (var command in commands.Split('\n'))
{
if (string.IsNullOrEmpty(command)) continue;
var arguments = new List<string>();
DebugLogConsole.FetchArgumentsFromCommand(command, arguments);
if (arguments[0] == nameof(ActorActivateCommand).Replace("Command", string.Empty) &&
!Enum.GetValues(typeof(PlayerActorId)).Cast<int>().Contains(int.Parse(arguments[1])))
{
_deferredExecutionCommands.Add(command);
}
else if (arguments[0] == nameof(SceneActivateObjectCommand).Replace("Command", string.Empty))
{
_deferredExecutionCommands.Add(command);
}
else
{
DebugLogConsole.ExecuteCommand(command);
}
}
}
public void Hide()
{
@@ -2087,5 +2109,32 @@ namespace Pal3.Dev
{
if (!_storySelectorCanvas.interactable) Show();
}
public void Execute(ScriptFinishedRunningNotification command)
{
if (command.ScriptType == PalScriptType.Scene &&
_deferredExecutionCommands.Count > 0)
{
ExecuteCommands(string.Join('\n', _deferredExecutionCommands));
_deferredExecutionCommands.Clear();
}
}
public void Execute(GameStateChangedNotification command)
{
// Not every scene has init scene script to run,
// so we need to check if there are pending deferred commands to run.
if (command.NewState == GameState.Gameplay &&
_deferredExecutionCommands.Count > 0)
{
ExecuteCommands(string.Join('\n', _deferredExecutionCommands));
_deferredExecutionCommands.Clear();
}
}
public void Execute(ResetGameStateCommand command)
{
_deferredExecutionCommands.Clear();
}
}
}
+106
View File
@@ -0,0 +1,106 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Effect
{
using System;
using Data;
using UnityEngine;
using Object = UnityEngine.Object;
public class CombatEffect : MonoBehaviour, IEffect, IDisposable
{
#if PAL3
private const string SHUSHAN_BRIDGE_TEXTURE_NAME = "q08qiao.dds";
#elif PAL3A
private const string SHUSHAN_BRIDGE_TEXTURE_NAME = "q08qiao.tga";
#endif
private const float SHUSHAN_BRIDGE_DEFAULT_SIZE = 3.5f;
private const float SHUSHAN_BRIDGE_ANIMATION_ROTATION_SPEED = 15f;
#if PAL3
private const string SHUSHAN_BRIDGE_EFFECT_TEXTURE_NAME = "q08qiao2.dds";
#elif PAL3A
private const string SHUSHAN_BRIDGE_EFFECT_TEXTURE_NAME = "q08qiao2.tga";
#endif
private const float SHUSHAN_BRIDGE_EFFECT_DEFAULT_SIZE = 3.5f;
private const float SHUSHAN_BRIDGE_EFFECT_ANIMATION_ROTATION_SPEED = 40f;
private RotatingSpriteEffect _bridgeBaseEffect;
private RotatingSpriteEffect _bridgeEffect;
private GameObject _effect;
public void Init(GameResourceProvider resourceProvider, uint effectParameter)
{
// Object vfxPrefab = resourceProvider.GetVfxEffectPrefab((int)effectParameter);
//
// if (vfxPrefab != null)
// {
// _effect = (GameObject)Instantiate(vfxPrefab, transform, false);
// _effect.name = "VFX_" + effectParameter;
// }
#if PAL3
if (effectParameter == 465) // 蜀山太极桥特效
#elif PAL3A
if (effectParameter == 160) // 蜀山太极桥特效
#endif
{
_bridgeBaseEffect = gameObject.AddComponent<RotatingSpriteEffect>();
_bridgeBaseEffect.Init(resourceProvider,
SHUSHAN_BRIDGE_TEXTURE_NAME,
new Vector3(SHUSHAN_BRIDGE_DEFAULT_SIZE,
SHUSHAN_BRIDGE_DEFAULT_SIZE,
SHUSHAN_BRIDGE_DEFAULT_SIZE),
SHUSHAN_BRIDGE_ANIMATION_ROTATION_SPEED);
_bridgeEffect = gameObject.AddComponent<RotatingSpriteEffect>();
_bridgeEffect.Init(resourceProvider,
SHUSHAN_BRIDGE_EFFECT_TEXTURE_NAME,
new Vector3(SHUSHAN_BRIDGE_EFFECT_DEFAULT_SIZE,
SHUSHAN_BRIDGE_EFFECT_DEFAULT_SIZE,
SHUSHAN_BRIDGE_EFFECT_DEFAULT_SIZE),
SHUSHAN_BRIDGE_EFFECT_ANIMATION_ROTATION_SPEED);
}
#if PAL3
if (effectParameter == 275) // 重楼创建的用来禁锢雪见/龙葵的法阵特效
#elif PAL3A
if (effectParameter == 344) // 重盘古元灵特效
#endif
{
Object vfxPrefab = resourceProvider.GetVfxEffectPrefab((int)effectParameter);
if (vfxPrefab != null)
{
_effect = (GameObject)Instantiate(vfxPrefab, transform, false);
_effect.name = "VFX_" + effectParameter;
}
}
}
private void OnDisable()
{
Dispose();
}
public void Dispose()
{
if (_bridgeBaseEffect != null)
{
_bridgeBaseEffect.Dispose();
}
if (_bridgeEffect != null)
{
_bridgeEffect.Dispose();
}
if (_effect != null)
{
Destroy(_effect);
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b177a9f780034b4fb51cd37779b44581
timeCreated: 1666332304
+98 -21
View File
@@ -10,20 +10,29 @@ namespace Pal3.Effect
using Command;
using Command.InternalCommands;
using Command.SceCommands;
using Core.GameBox;
using Data;
using MetaData;
using Scene;
using UnityEngine;
using Object = UnityEngine.Object;
public sealed class EffectManager : MonoBehaviour,
public sealed class EffectManager : MonoBehaviour, IDisposable,
ICommandExecutor<EffectPreLoadCommand>,
ICommandExecutor<EffectAttachToActorCommand>,
ICommandExecutor<EffectSetPositionCommand>,
ICommandExecutor<EffectPlayCommand>,
ICommandExecutor<SceneLeavingCurrentSceneNotification>,
ICommandExecutor<ResetGameStateCommand>
{
private GameResourceProvider _resourceProvider;
private SceneManager _sceneManager;
private int _targetActorId = -1;
public void Init(SceneManager sceneManager)
private ICommand _effectPositionCommand;
public void Init(GameResourceProvider resourceProvider,
SceneManager sceneManager)
{
_resourceProvider = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
}
@@ -36,57 +45,125 @@ namespace Pal3.Effect
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
public void Dispose()
{
_effectPositionCommand = null;
}
public void Execute(EffectPreLoadCommand command)
{
// In PAL3A, PreLoad command is always issued right before the effect is played.
// So it is pointless to pre-load the effect here for PAL3A.
#if PAL3
StartCoroutine(_resourceProvider.PreLoadVfxEffectAsync(command.EffectGroupId));
#endif
}
public void Execute(EffectSetPositionCommand command)
{
_effectPositionCommand = command;
}
public void Execute(EffectAttachToActorCommand command)
{
if (command.ActorId == ActorConstants.PlayerActorVirtualID) return;
_targetActorId = command.ActorId;
_effectPositionCommand = command;
}
public void Execute(EffectPlayCommand command)
{
if (_targetActorId == -1) return;
if (_effectPositionCommand == null ||
_sceneManager.GetCurrentScene() is not {} currentScene) return;
#if PAL3A
switch (command.EffectGroupId)
if (_effectPositionCommand is EffectAttachToActorCommand effectAttachToActorCommand)
{
// 南宫煌形态切换为狼形态特效
HandleNanGongHuangTransformEffect(effectAttachToActorCommand, command, currentScene);
}
#endif
// Play VFX
Object vfxPrefab = _resourceProvider.GetVfxEffectPrefab(command.EffectGroupId);
if (vfxPrefab != null)
{
Transform parent = null;
Vector3 localPosition = Vector3.zero;
if (_effectPositionCommand is EffectSetPositionCommand positionCommand &&
_sceneManager.GetSceneRootGameObject() is {} sceneRootGameObject)
{
parent = sceneRootGameObject.transform;
localPosition = GameBoxInterpreter.ToUnityPosition(
new Vector3(positionCommand.X, positionCommand.Y, positionCommand.Z));
}
else if (_effectPositionCommand is EffectAttachToActorCommand actorCommand)
{
parent = currentScene.GetActorGameObject((byte)actorCommand.ActorId).transform;
}
if (parent != null)
{
var vfx = (GameObject)Instantiate(vfxPrefab, parent, false);
vfx.name = "VFX_" + command.EffectGroupId;
vfx.transform.localPosition += localPosition;
}
}
// Play SFX if any
if (EffectConstants.EffectSfxInfo.ContainsKey(command.EffectGroupId))
{
CommandDispatcher<ICommand>.Instance.Dispatch(
new PlaySfxCommand(EffectConstants.EffectSfxInfo[command.EffectGroupId], 1));
}
}
#if PAL3A
private void HandleNanGongHuangTransformEffect(EffectAttachToActorCommand effectAttachToActorCommand,
EffectPlayCommand effectPlayCommand,
Scene currentScene)
{
var actorId = effectAttachToActorCommand.ActorId;
switch (effectPlayCommand.EffectGroupId)
{
// 南宫煌切换为狼妖形态特效
case 164:
{
Scene scene = _sceneManager.GetCurrentScene();
Actor actor = scene.GetActor((byte)_targetActorId);
Actor actor = currentScene.GetActor((byte)actorId);
actor.ChangeName(ActorConstants.NanGongHuangWolfModeActorName);
if (actor.IsActive)
{
var actorActionController = scene.GetActorGameObject((byte)_targetActorId)
var actorActionController = currentScene.GetActorGameObject((byte)actorId)
.GetComponent<ActorActionController>();
actorActionController.PerformAction(actor.GetIdleAction(), overwrite: true);
}
break;
}
// 南宫煌形态切换为人形态特效
// 南宫煌切换为人形态特效
case 315:
{
Scene scene = _sceneManager.GetCurrentScene();
Actor actor = scene.GetActor((byte)_targetActorId);
Actor actor = currentScene.GetActor((byte)actorId);
actor.ChangeName(ActorConstants.NanGongHuangHumanModeActorName);
if (actor.IsActive)
{
var actorActionController = scene.GetActorGameObject((byte)_targetActorId)
var actorActionController = currentScene.GetActorGameObject((byte)actorId)
.GetComponent<ActorActionController>();
actorActionController.PerformAction(actor.GetIdleAction(), overwrite: true);
}
break;
}
}
#endif
_targetActorId = -1;
}
#endif
public void Execute(SceneLeavingCurrentSceneNotification command)
{
Dispose();
}
public void Execute(ResetGameStateCommand command)
{
_targetActorId = -1;
Dispose();
}
}
}
Loaded 100 of 183 files, more files were not shown because too many files have changed in this diff. Show more