Compare commits

..
2 Commits
Author SHA1 Message Date
basil 7590d78e74 增加收获属性逻辑,优化掉落物表现效果 2026-10-05 17:02:29 +08:00
basil d55b1013ca 添加掉落物模型,调整项目结构 2026-10-05 16:54:48 +08:00
111 changed files with 2239 additions and 433 deletions
@@ -1,4 +1,3 @@
FollowCameraFollowCamera.prefabPlayer␍Player.prefab
␍ FollowCameraFollowCamera.prefabPlayer␍Player.prefab
MeleeEnemyMeleeEnemy.prefab RemoteEnemyRemoteEnemy.prefab WeaponKnifeWeaponKnife.prefab␍WeaponHandgunWeaponHandgun.prefab WeaponSlashWeaponSlash.prefabWeaponLightningWeaponLightning.prefab WeaponLanceWeaponLance.prefab
DropEntityDropEntity.prefab
ProjectileProjectile.prefab
ProjectileProjectile.prefab DropEntity01Drop/DropEntity01.prefab DropEntity02Drop/DropEntity02.prefab DropEntity03Drop/DropEntity03.prefab
+12 -4
View File
@@ -35,12 +35,20 @@
"assetName": "WeaponLance",
"prefabPath": "WeaponLance.prefab"
},
{
"assetName": "DropEntity",
"prefabPath": "DropEntity.prefab"
},
{
"assetName": "Projectile",
"prefabPath": "Projectile.prefab"
},
{
"assetName": "DropEntity01",
"prefabPath": "Drop/DropEntity01.prefab"
},
{
"assetName": "DropEntity02",
"prefabPath": "Drop/DropEntity02.prefab"
},
{
"assetName": "DropEntity03",
"prefabPath": "Drop/DropEntity03.prefab"
}
]
Binary file not shown.
+11 -1
View File
@@ -34,7 +34,17 @@
"critMultiplier": 1.5,
"dropEntityCoinCount": 1,
"dropEntityExpCount": 1,
"dropEntityAssetNames": [
"DropEntity01",
"DropEntity02",
"DropEntity03"
],
"enemyBodyRadius": 0.45,
"enemySeparationIterations": 2
"enemySeparationIterations": 2,
"recoilDistance": 0.25,
"recoilDuration": 0.1,
"dashAccelerationDuration": 0.1,
"dashMaxSpeedMultiplier": 2,
"turnSpeed": 720
}
]
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 04562a88c52cd2f449a6f5f52a1afb13
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,85 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1008105315272539365
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1936384946241160746}
- component: {fileID: 628759564136564965}
- component: {fileID: 3413110330421916486}
m_Layer: 13
m_Name: DropEntity01
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1936384946241160746
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &628759564136564965
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
m_Mesh: {fileID: -2437261350238378569, guid: b0df1c310a0f037418a05a052bb085bb, type: 3}
--- !u!23 &3413110330421916486
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 4cbf218826364797b5f9e4bd8ff5b674, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
@@ -0,0 +1,85 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1008105315272539365
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1936384946241160746}
- component: {fileID: 628759564136564965}
- component: {fileID: 3413110330421916486}
m_Layer: 13
m_Name: DropEntity02
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1936384946241160746
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &628759564136564965
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
m_Mesh: {fileID: 306618357957470380, guid: 716b72b19369a9948b5d72eddab06c30, type: 3}
--- !u!23 &3413110330421916486
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 4cbf218826364797b5f9e4bd8ff5b674, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8c3c1389c3a6f76468cc3539ba3319d4
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,85 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1008105315272539365
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1936384946241160746}
- component: {fileID: 628759564136564965}
- component: {fileID: 3413110330421916486}
m_Layer: 13
m_Name: DropEntity03
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1936384946241160746
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &628759564136564965
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
m_Mesh: {fileID: -1072659629790535479, guid: 395ec7c091a772848a2b259af5f78ca3, type: 3}
--- !u!23 &3413110330421916486
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 4cbf218826364797b5f9e4bd8ff5b674, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 63f13262ef86e934a8b333528fc2219d
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
-189
View File
@@ -1,189 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1008105315272539365
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1936384946241160746}
- component: {fileID: 329236603994037521}
- component: {fileID: 972481648254179963}
- component: {fileID: 1416665683957493982}
- component: {fileID: 8311088257134752687}
m_Layer: 13
m_Name: DropEntity
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1936384946241160746
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
m_ConstrainProportionsScale: 1
m_Children:
- {fileID: 3234774818843687234}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &329236603994037521
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &972481648254179963
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 2257393dd6ed51a49a6c3fd178382b59, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!54 &1416665683957493982
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!135 &8311088257134752687
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1008105315272539365}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 1
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &8058217899104858011
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3234774818843687234}
- component: {fileID: 5442478298252225551}
m_Layer: 13
m_Name: Board
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3234774818843687234
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8058217899104858011}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1936384946241160746}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!135 &5442478298252225551
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8058217899104858011}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 1
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 128
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
@@ -0,0 +1,32 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: DropEmission
m_Shader: {fileID: 4800000, guid: ee6321f7c35d4f41a692ace420f07421, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2020
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Ints: []
m_Floats:
- _EmissionIntensity: 0.25
m_Colors:
- _BaseColor: {r: 0.04, g: 0.85, b: 0.22, a: 1}
- _EmissionColor: {r: 0.12, g: 1, b: 0.38, a: 1}
m_BuildTextureStacks: []
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4cbf218826364797b5f9e4bd8ff5b674
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1d9bc2d0d723681449aaea6bc054f6ce
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,118 @@
Shader "SepCore/Drop/Instanced Emission"
{
Properties
{
_BaseColor ("Base Color", Color) = (0.04, 0.85, 0.22, 1)
[HDR] _EmissionColor ("Emission Color", Color) = (0.12, 1, 0.38, 1)
_EmissionIntensity ("Emission Intensity", Range(0, 10)) = 1.8
}
SubShader
{
Tags
{
"RenderType" = "Opaque"
"RenderPipeline" = "UniversalPipeline"
"Queue" = "Geometry"
}
LOD 100
Pass
{
Name "ForwardLit"
Tags { "LightMode" = "UniversalForward" }
HLSLPROGRAM
#pragma target 3.0
#pragma vertex Vert
#pragma fragment Frag
#pragma multi_compile_instancing
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
UNITY_INSTANCING_BUFFER_START(DropProperties)
UNITY_DEFINE_INSTANCED_PROP(float4, _BaseColor)
UNITY_DEFINE_INSTANCED_PROP(float4, _EmissionColor)
UNITY_DEFINE_INSTANCED_PROP(float, _EmissionIntensity)
UNITY_INSTANCING_BUFFER_END(DropProperties)
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float3 normalWS : TEXCOORD0;
float4 shadowCoord : TEXCOORD1;
half fogFactor : TEXCOORD2;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
Varyings Vert(Attributes input)
{
Varyings output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
VertexPositionInputs positionInputs = GetVertexPositionInputs(input.positionOS.xyz);
VertexNormalInputs normalInputs = GetVertexNormalInputs(input.normalOS);
output.positionCS = positionInputs.positionCS;
output.normalWS = normalInputs.normalWS;
output.shadowCoord = GetShadowCoord(positionInputs);
output.fogFactor = ComputeFogFactor(positionInputs.positionCS.z);
return output;
}
half4 Frag(Varyings input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
half4 baseColor = UNITY_ACCESS_INSTANCED_PROP(DropProperties, _BaseColor);
half3 emissionColor = UNITY_ACCESS_INSTANCED_PROP(DropProperties, _EmissionColor).rgb;
half emissionIntensity = UNITY_ACCESS_INSTANCED_PROP(DropProperties, _EmissionIntensity);
half3 normalWS = normalize(input.normalWS);
Light mainLight = GetMainLight(input.shadowCoord);
half diffuse = saturate(dot(normalWS, mainLight.direction)) * mainLight.shadowAttenuation;
half3 ambientLighting = SampleSH(normalWS);
half3 baseLighting = baseColor.rgb * (ambientLighting + mainLight.color * diffuse);
half3 color = MixFog(baseLighting + emissionColor * emissionIntensity, input.fogFactor);
return half4(color, baseColor.a);
}
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
ZWrite On
ZTest LEqual
ColorMask 0
Cull Back
HLSLPROGRAM
#pragma target 3.0
#pragma vertex ShadowPassVertex
#pragma fragment ShadowPassFragment
#pragma multi_compile_instancing
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
ENDHLSL
}
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: ee6321f7c35d4f41a692ace420f07421
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
+109
View File
@@ -0,0 +1,109 @@
fileFormatVersion: 2
guid: 395ec7c091a772848a2b259af5f78ca3
ModelImporter:
serializedVersion: 22200
internalIDToNameTable: []
externalObjects: {}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 0.15
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 0.15
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
+109
View File
@@ -0,0 +1,109 @@
fileFormatVersion: 2
guid: b0df1c310a0f037418a05a052bb085bb
ModelImporter:
serializedVersion: 22200
internalIDToNameTable: []
externalObjects: {}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 0.15
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 0.15
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
+109
View File
@@ -0,0 +1,109 @@
fileFormatVersion: 2
guid: 716b72b19369a9948b5d72eddab06c30
ModelImporter:
serializedVersion: 22200
internalIDToNameTable: []
externalObjects: {}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 0.15
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 0.15
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
using GameFramework;
using GameFramework.Event;
using UnityEngine;
namespace SepCore.Event
{
public class DropSpawnRequestedEventArgs : GameEventArgs
{
public static readonly int EventId = typeof(DropSpawnRequestedEventArgs).GetHashCode();
public override int Id => EventId;
public Vector3 Position { get; private set; }
public DropSpawnRequestedEventArgs()
{
Position = Vector3.zero;
}
public static DropSpawnRequestedEventArgs Create(Vector3 position)
{
var args = ReferencePool.Acquire<DropSpawnRequestedEventArgs>();
args.Position = position;
return args;
}
public override void Clear()
{
Position = Vector3.zero;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17f56868934d4df4b230b3a12924fba7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,39 @@
using GameFramework;
using GameFramework.Event;
namespace SepCore.Event
{
public class WaveHarvestSettlementEventArgs : GameEventArgs
{
public static readonly int EventId = typeof(WaveHarvestSettlementEventArgs).GetHashCode();
public override int Id => EventId;
public int HarvestIncome { get; private set; }
public int HarvestGrowth { get; private set; }
public int CurrentHarvest { get; private set; }
public WaveHarvestSettlementEventArgs()
{
HarvestIncome = 0;
HarvestGrowth = 0;
CurrentHarvest = 0;
}
public static WaveHarvestSettlementEventArgs Create(int income, int growth, int currentHarvest)
{
var args = ReferencePool.Acquire<WaveHarvestSettlementEventArgs>();
args.HarvestIncome = income;
args.HarvestGrowth = growth;
args.CurrentHarvest = currentHarvest;
return args;
}
public override void Clear()
{
HarvestIncome = 0;
HarvestGrowth = 0;
CurrentHarvest = 0;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b78ae26ee6734a84aad77ca563607ee2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,31 @@
using GameFramework;
using GameFramework.Event;
namespace SepCore.Event
{
public class ShopGoodsLockEventArgs : GameEventArgs
{
public static readonly int EventId = typeof(ShopGoodsLockEventArgs).GetHashCode();
public override int Id => EventId;
public int GoodsIndex { get; private set; }
public ShopGoodsLockEventArgs()
{
GoodsIndex = -1;
}
public static ShopGoodsLockEventArgs Create(int index)
{
var args = ReferencePool.Acquire<ShopGoodsLockEventArgs>();
args.GoodsIndex = index;
return args;
}
public override void Clear()
{
GoodsIndex = -1;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 57dd9523362d470fa6e823b2478c18ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -52,8 +52,14 @@ public sealed partial class GlobalConfig : Luban.BeanBase
CritMultiplier = _buf.ReadFloat();
DropEntityCoinCount = _buf.ReadInt();
DropEntityExpCount = _buf.ReadInt();
{int n0 = System.Math.Min(_buf.ReadSize(), _buf.Size);DropEntityAssetNames = new System.Collections.Generic.List<string>(n0);for(var i0 = 0 ; i0 < n0 ; i0++) { string _e0; _e0 = _buf.ReadString(); DropEntityAssetNames.Add(_e0);}}
EnemyBodyRadius = _buf.ReadFloat();
EnemySeparationIterations = _buf.ReadInt();
RecoilDistance = _buf.ReadFloat();
RecoilDuration = _buf.ReadFloat();
DashAccelerationDuration = _buf.ReadFloat();
DashMaxSpeedMultiplier = _buf.ReadFloat();
TurnSpeed = _buf.ReadFloat();
}
public static GlobalConfig DeserializeGlobalConfig(ByteBuf _buf)
@@ -200,6 +206,11 @@ public sealed partial class GlobalConfig : Luban.BeanBase
/// </summary>
public readonly int DropEntityExpCount;
/// <summary>
/// 掉落物预制体名列表
/// </summary>
public readonly System.Collections.Generic.List<string> DropEntityAssetNames;
public System.Collections.Generic.List<EntityConfig> DropEntityAssetNames_Ref;
/// <summary>
/// 敌人碰撞半径
/// </summary>
public readonly float EnemyBodyRadius;
@@ -207,6 +218,26 @@ public sealed partial class GlobalConfig : Luban.BeanBase
/// 敌人分离迭代次数
/// </summary>
public readonly int EnemySeparationIterations;
/// <summary>
/// 掉落物拾取时后退距离
/// </summary>
public readonly float RecoilDistance;
/// <summary>
/// 掉落物拾取时后退时间
/// </summary>
public readonly float RecoilDuration;
/// <summary>
/// 冲刺加速时长
/// </summary>
public readonly float DashAccelerationDuration;
/// <summary>
/// 冲刺最高倍率(基于吸收速度)
/// </summary>
public readonly float DashMaxSpeedMultiplier;
/// <summary>
/// 转向速度
/// </summary>
public readonly float TurnSpeed;
public const int __ID__ = -958250779;
public override int GetTypeId() => __ID__;
@@ -247,6 +278,14 @@ public sealed partial class GlobalConfig : Luban.BeanBase
DropEntityAssetNames_Ref = new System.Collections.Generic.List<EntityConfig>();
foreach (var _v in DropEntityAssetNames) { DropEntityAssetNames_Ref.Add(tables.TbEntityConfig.GetOrDefault(_v)); }
}
@@ -288,8 +327,14 @@ public sealed partial class GlobalConfig : Luban.BeanBase
+ "critMultiplier:" + CritMultiplier + ","
+ "dropEntityCoinCount:" + DropEntityCoinCount + ","
+ "dropEntityExpCount:" + DropEntityExpCount + ","
+ "dropEntityAssetNames:" + Luban.StringUtil.CollectionToString(DropEntityAssetNames) + ","
+ "enemyBodyRadius:" + EnemyBodyRadius + ","
+ "enemySeparationIterations:" + EnemySeparationIterations + ","
+ "recoilDistance:" + RecoilDistance + ","
+ "recoilDuration:" + RecoilDuration + ","
+ "dashAccelerationDuration:" + DashAccelerationDuration + ","
+ "dashMaxSpeedMultiplier:" + DashMaxSpeedMultiplier + ","
+ "turnSpeed:" + TurnSpeed + ","
+ "}";
}
}
@@ -167,6 +167,10 @@ public partial class TbGlobalConfig
/// </summary>
public int DropEntityExpCount => _data.DropEntityExpCount;
/// <summary>
/// 掉落物预制体名列表
/// </summary>
public System.Collections.Generic.List<string> DropEntityAssetNames => _data.DropEntityAssetNames;
/// <summary>
/// 敌人碰撞半径
/// </summary>
public float EnemyBodyRadius => _data.EnemyBodyRadius;
@@ -174,6 +178,26 @@ public partial class TbGlobalConfig
/// 敌人分离迭代次数
/// </summary>
public int EnemySeparationIterations => _data.EnemySeparationIterations;
/// <summary>
/// 掉落物拾取时后退距离
/// </summary>
public float RecoilDistance => _data.RecoilDistance;
/// <summary>
/// 掉落物拾取时后退时间
/// </summary>
public float RecoilDuration => _data.RecoilDuration;
/// <summary>
/// 冲刺加速时长
/// </summary>
public float DashAccelerationDuration => _data.DashAccelerationDuration;
/// <summary>
/// 冲刺最高倍率(基于吸收速度)
/// </summary>
public float DashMaxSpeedMultiplier => _data.DashMaxSpeedMultiplier;
/// <summary>
/// 转向速度
/// </summary>
public float TurnSpeed => _data.TurnSpeed;
public void ResolveRef(Tables tables)
{
@@ -16,6 +16,7 @@ namespace SepCore.UI
public string TypeName;
public string Description;
public int Price;
public bool IsLocked;
public GoodsItemContext()
{
@@ -26,6 +27,7 @@ namespace SepCore.UI
Price = 0;
Icon = null;
ItemType = ItemType.Weapon;
IsLocked = false;
}
public GoodsItemContext(GoodsItemRawData rawData) : this()
@@ -33,6 +35,7 @@ namespace SepCore.UI
Price = rawData.Price;
Rarity = rawData.Rarity;
ItemType = rawData.ItemType;
IsLocked = rawData.IsLocked;
if (ItemType == ItemType.Weapon)
{
@@ -25,6 +25,7 @@ namespace SepCore.UI
protected override void SubscribeCustomEvents()
{
GameEntry.Event.Subscribe(ShopRefreshEventArgs.EventId, ShopRefresh);
GameEntry.Event.Subscribe(ShopGoodsLockEventArgs.EventId, ShopGoodsLock);
GameEntry.Event.Subscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
GameEntry.Event.Subscribe(ShopContinueEventArgs.EventId, ShopContinue);
GameEntry.Event.Subscribe(DisplayItemHoverEventArgs.EventId, DisplayItemHover);
@@ -38,6 +39,7 @@ namespace SepCore.UI
protected override void UnsubscribeCustomEvents()
{
GameEntry.Event.Unsubscribe(ShopRefreshEventArgs.EventId, ShopRefresh);
GameEntry.Event.Unsubscribe(ShopGoodsLockEventArgs.EventId, ShopGoodsLock);
GameEntry.Event.Unsubscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
GameEntry.Event.Unsubscribe(ShopContinueEventArgs.EventId, ShopContinue);
GameEntry.Event.Unsubscribe(DisplayItemHoverEventArgs.EventId, DisplayItemHover);
@@ -355,6 +357,27 @@ namespace SepCore.UI
ApplyGoodsPurchased(result);
}
private void ShopGoodsLock(object sender, GameEventArgs e)
{
if (e is not ShopGoodsLockEventArgs args)
{
return;
}
if (_useCase == null || Context == null)
{
return;
}
bool isLocked = _useCase.ToggleLock(args.GoodsIndex);
if (args.GoodsIndex >= 0 && args.GoodsIndex < Context.GoodsItems.Count && Context.GoodsItems[args.GoodsIndex] != null)
{
Context.GoodsItems[args.GoodsIndex].IsLocked = isLocked;
Context.NeedRefreshGoodsItems = true;
RefreshUI(Form, Context);
}
}
private void ShopContinue(object sender, GameEventArgs e)
{
if (e is not ShopContinueEventArgs)
@@ -20,6 +20,8 @@ namespace SepCore.UI
[SerializeField] private TMP_Text _costText;
[SerializeField] private CommonButton _purchaseButton = null;
[SerializeField] private TMP_Text _purchaseLabel = null;
[SerializeField] private CommonButton _lockButton = null;
[SerializeField] private TMP_Text _lockLabel = null;
[SerializeField] private CanvasGroup _canvasGroup = null;
[SerializeField] private RarityPalette _rarityPalette = null;
[SerializeField] private Image _rarityBackground = null;
@@ -46,6 +48,12 @@ namespace SepCore.UI
_typeText.text = data.TypeName;
_descriptionText.text = data.Description;
_costText.text = $"{data.Price} <sprite name=\"coin\" index=0>";
UpdateLockDisplay(data.IsLocked);
}
public void UpdateLockDisplay(bool isLocked)
{
_lockLabel.text = isLocked ? "已锁定" : "锁定";
}
public void OnReset()
@@ -54,6 +62,8 @@ namespace SepCore.UI
_data = null;
_iconArea.OnReset();
SetRarity(Rarity.None);
_lockButton.interactable = true;
_lockLabel.text = "锁定";
}
public void MarkPurchased()
@@ -63,6 +73,8 @@ namespace SepCore.UI
_canvasGroup.alpha = 0.5f;
_purchaseButton.interactable = false;
_purchaseLabel.text = "已购买";
_lockButton.interactable = false;
_lockLabel.text = "锁定";
}
private void SetRarity(Rarity rarity)
@@ -95,6 +107,7 @@ namespace SepCore.UI
_listenersBound = true;
_purchaseButton.onClick.AddListener(OnPurchaseClick);
_lockButton.onClick.AddListener(OnLockClick);
}
private void OnPurchaseClick()
@@ -106,5 +119,15 @@ namespace SepCore.UI
GameEntry.Event.Fire(this, ShopPurchaseEventArgs.Create(_index));
}
private void OnLockClick()
{
if (_index < 0)
{
return;
}
GameEntry.Event.Fire(this, ShopGoodsLockEventArgs.Create(_index));
}
}
}
@@ -3,6 +3,7 @@ using SepCore.Event;
using SepCore.Entity;
using SepCore.Definition;
using SepCore.EnemyManager;
using SepCore.Battle;
using SepCore.Simulation;
using SepCore.Timer;
using UnityEngine;
@@ -12,16 +13,13 @@ namespace SepCore.Procedure
{
public class GameStateBattle : GameStateBase
{
private const float VacuumMaxDuration = 0.8f;
private const float VacuumAbsorbSpeed = 30f;
public override GameStateType GameStateType => GameStateType.Battle;
private EnemyManagerComponent _enemyManager;
private DropService _dropService;
private int _currentLevel;
private TimerHandle _levelTimerHandle;
private bool _isWaveEnding;
private float _vacuumTimer;
private Player Player => _procedureGame.Player;
private ProcedureGame _procedureGame;
@@ -41,14 +39,15 @@ namespace SepCore.Procedure
public override void OnInit(ProcedureGame master)
{
_enemyManager = GameEntry.EnemyManager;
_dropService = new DropService();
_procedureGame = master;
}
public override void OnEnter()
{
_dropService.Subscribe();
_currentLevel = _procedureGame.CurrentLevel;
_isWaveEnding = false;
_vacuumTimer = 0f;
var levelConfig = GameEntry.Luban.Get<LevelConfig>(_currentLevel);
_levelTimerHandle = GameEntry.Timer.ScheduleOnce(levelConfig.Duration, OnLevelTimeUp, this);
@@ -69,10 +68,9 @@ namespace SepCore.Procedure
Vector3 currentPos = Player.CachedTransform.position;
GameEntry.SimulationWorld.Tick(new SimulationTickContext(elapseSeconds, currentPos));
_vacuumTimer -= elapseSeconds;
if (GameEntry.SimulationWorld.PickupCount == 0 || _vacuumTimer <= 0f)
if (_dropService.UpdateVacuum(elapseSeconds, Player))
{
CollectAllRemainingDrops(Player);
HarvestSettlementUtility.Settle(Player);
_isWaveEnding = false;
_procedureGame.BattleToShopOrLevelUp();
}
@@ -93,7 +91,6 @@ namespace SepCore.Procedure
if (_isWaveEnding) return;
_isWaveEnding = true;
_vacuumTimer = VacuumMaxDuration;
// 1. 停止玩家移动与射击
Player.Enable = false;
@@ -104,9 +101,8 @@ namespace SepCore.Procedure
// 3. 隐藏所有投射物
HideEntityGroup(GameEntry.Luban.Global.ProjectileGroupName);
// 4. 触发全图磁铁,并提高吸附速度
GameEntry.SimulationWorld.TriggerFullMapMagnet();
GameEntry.SimulationWorld.SyncPlayerAbsorbSettings(999f, VacuumAbsorbSpeed, GameEntry.Luban.Global.CollectDistance);
// 4. 触发掉落物全图吸附
_dropService.StartVacuum();
}
public override void OnLeave()
@@ -127,35 +123,20 @@ namespace SepCore.Procedure
// 停止玩家逻辑
Player.Enable = false;
// 隐藏所有掉落物与投射物实体
HideEntityGroup(GameEntry.Luban.Global.DropGroupName);
// 清理掉落物并隐藏所有投射物实体
_dropService.HideAllDrops();
HideEntityGroup(GameEntry.Luban.Global.ProjectileGroupName);
_dropService.Unsubscribe();
}
public override void OnDestroy()
{
_dropService.Unsubscribe();
_enemyManager = null;
_dropService = null;
_procedureGame = null;
}
private static void CollectAllRemainingDrops(Player player)
{
if (player == null || !GameEntry.Entity.HasEntityGroup(GameEntry.Luban.Global.DropGroupName))
{
return;
}
var entityGroup = GameEntry.Entity.GetEntityGroup(GameEntry.Luban.Global.DropGroupName);
var entities = entityGroup.GetAllEntities();
foreach (var entity in entities)
{
if (entity is UnityGameFramework.Runtime.Entity runtimeEntity && runtimeEntity.Logic is DropEntity drop)
{
drop.TryCollect(player);
}
}
}
private static void HideEntityGroup(string groupName)
{
if (!GameEntry.Entity.HasEntityGroup(groupName))
@@ -23,7 +23,7 @@ namespace SepCore.Procedure
_procedureGame = master;
var shopFormUseCase =
new ShopUseCase(_procedureGame.Player, _procedureGame.CurrentLevel, () => ShopFinish = true);
new ShopUseCase(_procedureGame.Player, () => _procedureGame.CurrentLevel, () => ShopFinish = true);
GameEntry.UIRouter.BindUIUseCase(UIFormType.ShopForm, shopFormUseCase);
}
@@ -0,0 +1,107 @@
using Cysharp.Threading.Tasks;
using GameFramework.Event;
using SepCore.AsyncTask;
using SepCore.CustomComponent;
using SepCore.Definition;
using SepCore.Entity;
using SepCore.Event;
using Random = UnityEngine.Random;
namespace SepCore.Battle
{
public sealed class DropService
{
private const float VacuumMaxDuration = 0.8f;
private const float VacuumAbsorbSpeed = 30f;
private TbGlobalConfig _globalConfig;
private bool _isListening;
private float _vacuumTimer;
public void Subscribe()
{
if (_isListening)
{
return;
}
_globalConfig = GameEntry.Luban.Global;
GameEntry.Event.Subscribe(DropSpawnRequestedEventArgs.EventId, OnDropSpawnRequested);
_isListening = true;
}
public void Unsubscribe()
{
if (!_isListening)
{
return;
}
_globalConfig = null;
GameEntry.Event.Unsubscribe(DropSpawnRequestedEventArgs.EventId, OnDropSpawnRequested);
_isListening = false;
}
public void StartVacuum()
{
_vacuumTimer = VacuumMaxDuration;
GameEntry.SimulationWorld.TriggerFullMapMagnet();
GameEntry.SimulationWorld.SyncPlayerAbsorbSettings(999f, VacuumAbsorbSpeed,
_globalConfig.CollectDistance, _globalConfig.RecoilDistance,
_globalConfig.RecoilDuration, _globalConfig.DashAccelerationDuration,
_globalConfig.DashMaxSpeedMultiplier, _globalConfig.TurnSpeed);
}
public bool UpdateVacuum(float elapseSeconds, Player player)
{
_vacuumTimer -= elapseSeconds;
if (GameEntry.SimulationWorld.PickupCount > 0 && _vacuumTimer > 0f)
{
return false;
}
CollectAllRemainingDrops(player);
return true;
}
public void HideAllDrops()
{
_vacuumTimer = 0f;
var entityGroup = GameEntry.Entity.GetEntityGroup(_globalConfig.DropGroupName);
var entities = entityGroup.GetAllEntities();
foreach (var entity in entities)
{
GameEntry.Entity.HideEntity(entity.Id);
}
}
private void CollectAllRemainingDrops(Player player)
{
var entityGroup = GameEntry.Entity.GetEntityGroup(_globalConfig.DropGroupName);
var entities = entityGroup.GetAllEntities();
foreach (var entity in entities)
{
if (entity is UnityGameFramework.Runtime.Entity runtimeEntity && runtimeEntity.Logic is DropEntity drop)
{
drop.TryCollect(player);
}
}
}
private void OnDropSpawnRequested(object sender, GameEventArgs e)
{
var eventArgs = (DropSpawnRequestedEventArgs)e;
int idx = Random.Range(0, _globalConfig.DropEntityAssetNames.Count);
var dropEntityAssetName = _globalConfig.DropEntityAssetNames[idx];
var data = new DropData(_globalConfig.DropEntityCoinCount, _globalConfig.DropEntityExpCount,
GameEntry.Entity.NextId(), dropEntityAssetName)
{
Position = eventArgs.Position
};
GameEntry.Entity.ShowDropAsync(data).Forget();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 567ca35279f741d79f25e6d04bda5a63
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,63 @@
using SepCore.Definition;
using SepCore.Entity;
using SepCore.Event;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace SepCore.Battle
{
public readonly struct HarvestSettlementResult
{
public static readonly HarvestSettlementResult Empty = new(0, 0, 0);
public int Income { get; }
public int Growth { get; }
public int NewHarvest { get; }
public HarvestSettlementResult(int income, int growth, int newHarvest)
{
Income = income;
Growth = growth;
NewHarvest = newHarvest;
}
}
public static class HarvestSettlementUtility
{
public const float HarvestCompoundRate = 0.05f;
public const string HarvestModifierSource = "HarvestInterest";
public static HarvestSettlementResult Settle(Player player)
{
if (player == null || !player.Available)
{
return HarvestSettlementResult.Empty;
}
int currentHarvest = Mathf.FloorToInt(player.StatComponent.GetStatValue(StatType.Harvesting));
if (currentHarvest <= 0)
{
return HarvestSettlementResult.Empty;
}
// 1. 发放等额金币/材料
player.Coin += currentHarvest;
// 2. 复合增长(利息):永久提升 5%(向上取整)
int growth = Mathf.CeilToInt(currentHarvest * HarvestCompoundRate);
if (growth > 0)
{
player.StatComponent.AddModifier(
StatType.Harvesting,
new StatModifier(growth, ModifierType.Flat, HarvestModifierSource));
}
int newHarvest = Mathf.FloorToInt(player.StatComponent.GetStatValue(StatType.Harvesting));
// 3. 广播收获结算事件
GameEntry.Event.Fire(player, WaveHarvestSettlementEventArgs.Create(currentHarvest, growth, newHarvest));
return new HarvestSettlementResult(currentHarvest, growth, newHarvest);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 193a30e24142468791b5c899b31ccae8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -11,6 +11,11 @@ namespace SepCore.Components
public float AbsorbRange => GameEntry.Luban.Global.DefaultAbsorbRange;
public float AbsorbSpeed => GameEntry.Luban.Global.AbsorbSpeed;
public float CollectDistance => GameEntry.Luban.Global.CollectDistance;
public float RecoilDistance => GameEntry.Luban.Global.RecoilDistance;
public float RecoilDuration => GameEntry.Luban.Global.RecoilDuration;
public float DashAccelerationDuration => GameEntry.Luban.Global.DashAccelerationDuration;
public float DashMaxSpeedMultiplier => GameEntry.Luban.Global.DashMaxSpeedMultiplier;
public float TurnSpeed => GameEntry.Luban.Global.TurnSpeed;
public void OnInit(Player player)
{
@@ -22,7 +27,8 @@ namespace SepCore.Components
{
if (!_player.Available) return;
GameEntry.SimulationWorld.SyncPlayerAbsorbSettings(AbsorbRange, AbsorbSpeed, CollectDistance);
GameEntry.SimulationWorld.SyncPlayerAbsorbSettings(AbsorbRange, AbsorbSpeed, CollectDistance,
RecoilDistance, RecoilDuration, DashAccelerationDuration, DashMaxSpeedMultiplier, TurnSpeed);
}
public void OnReset()
@@ -37,8 +37,8 @@ namespace SepCore.Components
_cachedTransform = target;
_direction = Vector3.forward;
_avoidEnemyOverlap = avoidEnemyOverlap;
_enemyBodyRadius = GameEntry.Luban.Global.EnemyBodyRadius;
_separationIterations = GameEntry.Luban.Global.EnemySeparationIterations;
_enemyBodyRadius = enemyBodyRadius ?? GameEntry.Luban.Global.EnemyBodyRadius;
_separationIterations = separationIterations ?? GameEntry.Luban.Global.EnemySeparationIterations;
TryGetComponent(out _player);
TryGetComponent(out _enemy);
@@ -3,8 +3,16 @@ namespace SepCore.Simulation
internal struct PickupStateSim : ISimulationComponent
{
public const int StateIdle = 0;
public const int StateAbsorbing = 1;
public const int StateAbsorbRequested = 1;
public const int StateRecoil = 2;
public const int StateDash = 3;
public const int StateCollected = 4;
public int State;
public float PhaseElapsed;
public float IdleElapsed;
public float FloatBaseHeight;
public Unity.Mathematics.float3 RecoilStartPosition;
public Unity.Mathematics.float3 RecoilDirection;
}
}
@@ -5,5 +5,6 @@ namespace SepCore.Simulation
internal struct PickupTransformSim : ISimulationComponent
{
public float3 Position;
public float3 Forward;
}
}
@@ -30,7 +30,9 @@ namespace SepCore.Simulation
void SyncEnemyMovementInput(int entityId, bool isMoving, in Vector3 direction, float speed,
bool avoidEnemyOverlap, float enemyBodyRadius, int separationIterations);
void SyncPlayerAbsorbSettings(float absorbRange, float absorbSpeed, float collectDistance);
void SyncPlayerAbsorbSettings(float absorbRange, float absorbSpeed, float collectDistance,
float recoilDistance, float recoilDuration, float dashAccelerationDuration,
float dashMaxSpeedMultiplier, float turnSpeed);
void TriggerFullMapMagnet();
}
@@ -12,30 +12,72 @@ namespace SepCore.Simulation
private float _playerAbsorbRange = -1f;
private float _playerAbsorbSpeed = -1f;
private float _playerCollectDistance = -1f;
private float _playerRecoilDistance = -1f;
private float _playerRecoilDuration = -1f;
private float _playerDashAccelerationDuration = -1f;
private float _playerDashMaxSpeedMultiplier = -1f;
private float _playerTurnSpeed = -1f;
public void SyncPlayerAbsorbSettings(float absorbRange, float absorbSpeed, float collectDistance)
public void SyncPlayerAbsorbSettings(float absorbRange, float absorbSpeed, float collectDistance,
float recoilDistance, float recoilDuration, float dashAccelerationDuration,
float dashMaxSpeedMultiplier, float turnSpeed)
{
_playerAbsorbRange = absorbRange;
_playerAbsorbSpeed = absorbSpeed;
_playerCollectDistance = collectDistance;
_playerRecoilDistance = recoilDistance;
_playerRecoilDuration = recoilDuration;
_playerDashAccelerationDuration = dashAccelerationDuration;
_playerDashMaxSpeedMultiplier = dashMaxSpeedMultiplier;
_playerTurnSpeed = turnSpeed;
}
private float ResolveAbsorbRange()
{
if (_playerAbsorbRange >= 0f) return _playerAbsorbRange;
return GameEntry.Luban != null ? GameEntry.Luban.Global.DefaultAbsorbRange : 2f;
return GameEntry.Luban.Global.DefaultAbsorbRange;
}
private float ResolveAbsorbSpeed()
{
if (_playerAbsorbSpeed >= 0f) return _playerAbsorbSpeed;
return GameEntry.Luban != null ? GameEntry.Luban.Global.AbsorbSpeed : 8f;
return GameEntry.Luban.Global.AbsorbSpeed;
}
private float ResolveCollectDistance()
{
if (_playerCollectDistance >= 0f) return _playerCollectDistance;
return GameEntry.Luban != null ? GameEntry.Luban.Global.CollectDistance : 0.5f;
return GameEntry.Luban.Global.CollectDistance;
}
private float ResolveRecoilDistance()
{
if (_playerRecoilDistance >= 0f) return _playerRecoilDistance;
return GameEntry.Luban.Global.RecoilDistance;
}
private float ResolveRecoilDuration()
{
if (_playerRecoilDuration >= 0f) return _playerRecoilDuration;
return GameEntry.Luban.Global.RecoilDuration;
}
private float ResolveDashAccelerationDuration()
{
if (_playerDashAccelerationDuration >= 0f) return _playerDashAccelerationDuration;
return GameEntry.Luban.Global.DashAccelerationDuration;
}
private float ResolveDashMaxSpeedMultiplier()
{
if (_playerDashMaxSpeedMultiplier >= 0f) return _playerDashMaxSpeedMultiplier;
return GameEntry.Luban.Global.DashMaxSpeedMultiplier;
}
private float ResolveTurnSpeed()
{
if (_playerTurnSpeed >= 0f) return _playerTurnSpeed;
return GameEntry.Luban.Global.TurnSpeed;
}
[Header("敌人互斥参数")]
@@ -146,8 +188,14 @@ namespace SepCore.Simulation
float absorbRange = ResolveAbsorbRange();
float absorbSpeed = ResolveAbsorbSpeed();
float collectDistance = ResolveCollectDistance();
float recoilDistance = ResolveRecoilDistance();
float recoilDuration = ResolveRecoilDuration();
float dashAccelerationDuration = ResolveDashAccelerationDuration();
float dashMaxSpeedMultiplier = ResolveDashMaxSpeedMultiplier();
float turnSpeed = ResolveTurnSpeed();
pickupMovementHandle = PickupMovementSystem.Schedule(_pickups, _collectedPickups, context.DeltaTime,
planarPlayerPosition, absorbRange, absorbSpeed, collectDistance, default);
planarPlayerPosition, absorbRange, absorbSpeed, collectDistance, recoilDistance,
recoilDuration, dashAccelerationDuration, dashMaxSpeedMultiplier, turnSpeed, default);
}
}
@@ -232,20 +280,12 @@ namespace SepCore.Simulation
}
else
{
var entityComponent = GameEntry.Entity;
if (entityComponent != null)
{
entityComponent.HideEntity(drop);
}
GameEntry.Entity.HideEntity(drop);
}
}
else
{
var entityComponent = GameEntry.Entity;
if (entityComponent != null)
{
entityComponent.HideEntity(entity);
}
GameEntry.Entity.HideEntity(entity);
}
}
@@ -264,19 +304,16 @@ namespace SepCore.Simulation
}
var entityComponent = GameEntry.Entity;
if (entityComponent != null && GameEntry.Luban != null)
var group = entityComponent.GetEntityGroup(GameEntry.Luban.Global.PlayerGroupName);
if (group != null && group.EntityCount > 0)
{
var group = entityComponent.GetEntityGroup(GameEntry.Luban.Global.PlayerGroupName);
if (group != null && group.EntityCount > 0)
var entities = group.GetAllEntities();
for (int i = 0; i < entities.Length; i++)
{
var entities = group.GetAllEntities();
for (int i = 0; i < entities.Length; i++)
if (entities[i] is UnityGameFramework.Runtime.Entity ugfEntity &&
ugfEntity.Logic is Player player && player.Available)
{
if (entities[i] is UnityGameFramework.Runtime.Entity ugfEntity &&
ugfEntity.Logic is Player player && player.Available)
{
return player;
}
return player;
}
}
}
@@ -16,30 +16,22 @@ namespace SepCore.Simulation
public void OnLateUpdate()
{
if (_world == null)
{
return;
}
var enemyManager = GameEntry.EnemyManager;
if (enemyManager != null && enemyManager.Enemies != null)
var enemies = enemyManager.Enemies;
foreach (var enemy in enemies)
{
var enemies = enemyManager.Enemies;
foreach (var enemy in enemies)
if (enemy is not EnemyBase enemyEntity || !enemyEntity.Available)
{
if (enemy is not EnemyBase enemyEntity || !enemyEntity.Available)
{
continue;
}
if (!_world._enemies.TryGetSimulationIndex(enemyEntity.Id, out int simulationIndex))
{
continue;
}
EnemyTransformSim enemyData = _world._enemies.Transform[simulationIndex];
ApplyEnemyPresentation(enemyEntity, in enemyData);
continue;
}
if (!_world._enemies.TryGetSimulationIndex(enemyEntity.Id, out int simulationIndex))
{
continue;
}
EnemyTransformSim enemyData = _world._enemies.Transform[simulationIndex];
ApplyEnemyPresentation(enemyEntity, in enemyData);
}
var projectiles = _world._projectiles;
@@ -69,7 +61,15 @@ namespace SepCore.Simulation
continue;
}
pickupEntity.CachedTransform.position = ToVector3(pickups.Transform[i].Position);
PickupTransformSim transformData = pickups.Transform[i];
Transform pickupTransform = pickupEntity.CachedTransform;
pickupTransform.position = ToVector3(transformData.Position);
Vector3 forward = ToVector3(transformData.Forward);
forward.y = 0f;
if (forward.sqrMagnitude > float.Epsilon)
{
pickupTransform.rotation = Quaternion.LookRotation(forward.normalized, Vector3.up);
}
}
}
@@ -99,11 +99,6 @@ namespace SepCore.Simulation
in ProjectileTransformSim projectileData)
{
Transform projectileTransform = projectileEntity.CachedTransform;
if (projectileTransform == null)
{
return;
}
projectileTransform.position = ToVector3(projectileData.Position);
Vector3 forward = ToVector3(projectileData.Forward);
if (forward.sqrMagnitude <= float.Epsilon)
@@ -6,6 +6,7 @@ namespace SepCore.Simulation
{
public int EntityId;
public Vector3 Position;
public Vector3 Forward;
public float PickupRadius;
public int State;
}
@@ -95,6 +95,7 @@ namespace SepCore.Simulation
{
EntityId = pickupEntity.Id,
Position = pickupEntity.CachedTransform.position,
Forward = pickupEntity.CachedTransform.forward,
PickupRadius = 0.35f
};
}
@@ -290,6 +290,7 @@ namespace SepCore.Simulation
{
EntityId = entityId,
Position = ToVector3(transform.Position),
Forward = ToVector3(transform.Forward),
PickupRadius = radius.Radius,
State = state.State
};
@@ -302,9 +303,9 @@ namespace SepCore.Simulation
return _pickups.Add(
new PickupIdentitySim { EntityId = simData.EntityId },
new PickupTransformSim { Position = ToFloat3(simData.Position) },
new PickupTransformSim { Position = ToFloat3(simData.Position), Forward = ToFloat3(simData.Forward) },
new PickupRadiusSim { Radius = simData.PickupRadius },
new PickupStateSim { State = simData.State });
new PickupStateSim { State = simData.State, FloatBaseHeight = simData.Position.y });
}
internal int UpsertPickup(in PickupSimData simData)
@@ -315,9 +316,17 @@ namespace SepCore.Simulation
}
_pickups.Identity[index] = new PickupIdentitySim { EntityId = simData.EntityId };
_pickups.Transform[index] = new PickupTransformSim { Position = ToFloat3(simData.Position) };
_pickups.Transform[index] = new PickupTransformSim
{
Position = ToFloat3(simData.Position),
Forward = ToFloat3(simData.Forward)
};
_pickups.Radius[index] = new PickupRadiusSim { Radius = simData.PickupRadius };
_pickups.State[index] = new PickupStateSim { State = simData.State };
_pickups.State[index] = new PickupStateSim
{
State = simData.State,
FloatBaseHeight = simData.Position.y
};
return index;
}
@@ -326,7 +335,15 @@ namespace SepCore.Simulation
int pickupCount = _pickups.Count;
for (int i = 0; i < pickupCount; i++)
{
_pickups.State[i] = new PickupStateSim { State = PickupStateSim.StateAbsorbing };
PickupStateSim state = _pickups.State[i];
if (state.State != PickupStateSim.StateIdle)
{
continue;
}
state.State = PickupStateSim.StateAbsorbRequested;
state.PhaseElapsed = 0f;
_pickups.State[i] = state;
}
}
@@ -11,14 +11,10 @@ namespace SepCore.Simulation
// W CollectedPickups
public static JobHandle Schedule(PickupStore pickups, NativeList<int> collectedPickups,
float deltaTime, float3 playerPosition, float absorbRange, float absorbSpeed, float collectDistance,
JobHandle dependency)
float recoilDistance, float recoilDuration, float dashAccelerationDuration,
float dashMaxSpeedMultiplier, float turnSpeed, JobHandle dependency)
{
int pickupCount = pickups.Count;
if (pickupCount == 0)
{
return dependency;
}
PickupMovementJob job = new PickupMovementJob
{
Transforms = pickups.Transform.Data.AsArray(),
@@ -27,9 +23,14 @@ namespace SepCore.Simulation
Radii = pickups.Radius.Data.AsArray(),
CollectedPickups = collectedPickups.AsParallelWriter(),
PlayerPosition = playerPosition,
AbsorbRange = math.max(0f, absorbRange),
AbsorbSpeed = math.max(0f, absorbSpeed),
CollectDistance = math.max(0f, collectDistance),
AbsorbRange = absorbRange,
AbsorbSpeed = absorbSpeed,
CollectDistance = collectDistance,
RecoilDistance = recoilDistance,
RecoilDuration = recoilDuration,
DashAccelerationDuration = dashAccelerationDuration,
DashMaxSpeedMultiplier = dashMaxSpeedMultiplier,
TurnSpeedRadians = math.radians(turnSpeed),
DeltaTime = deltaTime
};
return job.Schedule(pickupCount, 64, dependency);
@@ -39,6 +40,10 @@ namespace SepCore.Simulation
[BurstCompile]
internal struct PickupMovementJob : IJobParallelFor
{
private const float IdleFloatAmplitude = 0.08f;
private const float IdleFloatAngularFrequency = 3.14159265f;
private const float IdleRotationSpeedRadians = 0.610865238f;
public NativeArray<PickupTransformSim> Transforms;
public NativeArray<PickupStateSim> States;
[ReadOnly] public NativeArray<PickupIdentitySim> Identities;
@@ -48,52 +53,189 @@ namespace SepCore.Simulation
public float AbsorbRange;
public float AbsorbSpeed;
public float CollectDistance;
public float RecoilDistance;
public float RecoilDuration;
public float DashAccelerationDuration;
public float DashMaxSpeedMultiplier;
public float TurnSpeedRadians;
public float DeltaTime;
public void Execute(int index)
{
PickupTransformSim transform = Transforms[index];
PickupStateSim state = States[index];
PickupIdentitySim identity = Identities[index];
PickupRadiusSim radius = Radii[index];
float3 currentPosition = transform.Position;
float3 horizontalPosition = new float3(currentPosition.x, 0f, currentPosition.z);
float3 toPlayer = PlayerPosition - horizontalPosition;
float sqrDistance = math.lengthsq(toPlayer);
float effectiveCollectDistance = math.max(CollectDistance, radius.Radius);
float sqrCollectDistance = effectiveCollectDistance * effectiveCollectDistance;
if (sqrDistance <= sqrCollectDistance)
if (state.State == PickupStateSim.StateCollected)
{
CollectedPickups.AddNoResize(identity.EntityId);
return;
}
bool isAbsorbing = state.State == PickupStateSim.StateAbsorbing;
bool shouldAbsorb = isAbsorbing || (AbsorbRange > 0f && sqrDistance <= AbsorbRange * AbsorbRange);
PickupIdentitySim identity = Identities[index];
PickupRadiusSim radius = Radii[index];
float effectiveCollectDistance = math.max(CollectDistance, radius.Radius);
float deltaTime = DeltaTime;
if (shouldAbsorb && AbsorbSpeed > 0f && sqrDistance > float.Epsilon)
if (state.State == PickupStateSim.StateIdle)
{
state.State = PickupStateSim.StateAbsorbing;
float distance = math.sqrt(sqrDistance);
float step = AbsorbSpeed * DeltaTime;
state.IdleElapsed = math.fmod(state.IdleElapsed + deltaTime,
2f * math.PI / IdleFloatAngularFrequency);
transform.Position.y = state.FloatBaseHeight +
math.sin(state.IdleElapsed * IdleFloatAngularFrequency) * IdleFloatAmplitude;
RotateWhileIdle(ref transform, deltaTime);
if (step >= distance)
float3 toPlayer = PlayerPosition - transform.Position;
toPlayer.y = 0f;
if (AbsorbRange <= 0f || math.lengthsq(toPlayer) > AbsorbRange * AbsorbRange || AbsorbSpeed <= 0f)
{
transform.Position = new float3(PlayerPosition.x, currentPosition.y, PlayerPosition.z);
CollectedPickups.AddNoResize(identity.EntityId);
Transforms[index] = transform;
States[index] = state;
return;
}
BeginRecoil(ref transform, ref state, PlayerPosition);
}
else if (state.State == PickupStateSim.StateAbsorbRequested)
{
BeginRecoil(ref transform, ref state, PlayerPosition);
}
float remainingDeltaTime = deltaTime;
if (state.State == PickupStateSim.StateRecoil && remainingDeltaTime > 0f)
{
if (RecoilDuration <= 0f)
{
transform.Position = state.RecoilStartPosition + state.RecoilDirection * RecoilDistance;
state.State = PickupStateSim.StateDash;
state.PhaseElapsed = 0f;
}
else
{
float3 direction = toPlayer / distance;
transform.Position = currentPosition + direction * step;
}
float phaseRemaining = RecoilDuration - state.PhaseElapsed;
float stepTime = math.min(remainingDeltaTime, phaseRemaining);
state.PhaseElapsed += stepTime;
float recoilProgress = math.saturate(state.PhaseElapsed / RecoilDuration);
transform.Position = state.RecoilStartPosition +
state.RecoilDirection * (RecoilDistance * recoilProgress);
remainingDeltaTime -= stepTime;
Transforms[index] = transform;
States[index] = state;
if (state.PhaseElapsed >= RecoilDuration)
{
state.State = PickupStateSim.StateDash;
state.PhaseElapsed = 0f;
}
}
}
if (state.State == PickupStateSim.StateDash)
{
float3 toPlayer = PlayerPosition - transform.Position;
toPlayer.y = 0f;
float distance = math.length(toPlayer);
if (distance <= effectiveCollectDistance)
{
MarkCollected(ref state, identity.EntityId);
}
else if (remainingDeltaTime > 0f && AbsorbSpeed > 0f)
{
float step = GetDashDistance(AbsorbSpeed, state.PhaseElapsed, remainingDeltaTime,
DashAccelerationDuration, DashMaxSpeedMultiplier);
float distanceToCollect = distance - effectiveCollectDistance;
float movedDistance = math.min(step, distanceToCollect);
transform.Position += toPlayer / distance * movedDistance;
state.PhaseElapsed += remainingDeltaTime;
if (movedDistance >= distanceToCollect)
{
MarkCollected(ref state, identity.EntityId);
}
}
}
RotateTowardPlayer(ref transform, PlayerPosition, deltaTime);
Transforms[index] = transform;
States[index] = state;
}
private static void BeginRecoil(ref PickupTransformSim transform, ref PickupStateSim state,
float3 playerPosition)
{
float3 direction = transform.Position - playerPosition;
direction.y = 0f;
if (math.lengthsq(direction) <= float.Epsilon)
{
direction = new float3(0f, 0f, -1f);
}
else
{
direction = math.normalize(direction);
}
state.State = PickupStateSim.StateRecoil;
state.PhaseElapsed = 0f;
state.RecoilStartPosition = transform.Position;
state.RecoilDirection = direction;
if (math.lengthsq(transform.Forward) <= float.Epsilon)
{
transform.Forward = new float3(0f, 0f, 1f);
}
}
private static void RotateWhileIdle(ref PickupTransformSim transform, float deltaTime)
{
float3 forward = transform.Forward;
forward.y = 0f;
forward = math.lengthsq(forward) <= float.Epsilon
? new float3(0f, 0f, 1f)
: math.normalize(forward);
transform.Forward = math.normalize(math.rotate(
quaternion.AxisAngle(new float3(0f, 1f, 0f), IdleRotationSpeedRadians * deltaTime), forward));
}
private void MarkCollected(ref PickupStateSim state, int entityId)
{
state.State = PickupStateSim.StateCollected;
CollectedPickups.AddNoResize(entityId);
}
private static float GetDashDistance(float speed, float elapsed, float deltaTime,
float accelerationDuration, float maxSpeedMultiplier)
{
if (accelerationDuration <= 0f)
{
return speed * maxSpeedMultiplier * deltaTime;
}
float acceleratedUntil = math.min(accelerationDuration, elapsed + deltaTime);
float acceleratedDuration = math.max(0f, acceleratedUntil - elapsed);
float averageMultiplier = 1f + (maxSpeedMultiplier - 1f) *
(elapsed + acceleratedUntil) / (2f * accelerationDuration);
float distance = speed * acceleratedDuration * averageMultiplier;
float constantDuration = deltaTime - acceleratedDuration;
return distance + speed * maxSpeedMultiplier * constantDuration;
}
private void RotateTowardPlayer(ref PickupTransformSim transform, float3 playerPosition,
float deltaTime)
{
float3 targetDirection = playerPosition - transform.Position;
targetDirection.y = 0f;
if (math.lengthsq(targetDirection) <= float.Epsilon)
{
return;
}
targetDirection = math.normalize(targetDirection);
float3 currentForward = transform.Forward;
currentForward.y = 0f;
currentForward = math.lengthsq(currentForward) <= float.Epsilon
? new float3(0f, 0f, 1f)
: math.normalize(currentForward);
float signedAngle = math.atan2(math.cross(currentForward, targetDirection).y,
math.dot(currentForward, targetDirection));
float angleStep = math.clamp(signedAngle, -TurnSpeedRadians * deltaTime,
TurnSpeedRadians * deltaTime);
transform.Forward = math.normalize(math.rotate(quaternion.AxisAngle(new float3(0f, 1f, 0f), angleStep),
currentForward));
}
}
}
@@ -1,4 +1,3 @@
using SepCore.Entity;
using UnityEngine;
using UnityGameFramework.Runtime;
@@ -22,8 +21,6 @@ namespace SepCore.Entity
{
Log.Error("DropEntity.OnShow() called with wrong type: {0}.", userData?.GetType().Name);
}
CachedTransform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
}
public bool TryCollect(Player player, float collectDistance = 0f)
@@ -48,10 +45,5 @@ namespace SepCore.Entity
GameEntry.Entity.HideEntity(this);
return true;
}
private void OnTriggerEnter(Collider other)
{
TryCollect(other.GetComponent<Player>());
}
}
}
@@ -1,7 +1,6 @@
using Cysharp.Threading.Tasks;
using SepCore.AsyncTask;
using SepCore.Components;
using SepCore.Definition;
using SepCore.Event;
using UnityEngine;
using UnityGameFramework.Runtime;
@@ -75,13 +74,7 @@ namespace SepCore.Entity
{
if (Random.value < EnemyData.DropPercent)
{
int coinCount = GameEntry.Luban.Global.DropEntityCoinCount;
int expCount = GameEntry.Luban.Global.DropEntityExpCount;
var data = new DropData(coinCount, expCount, GameEntry.Entity.NextId())
{
Position = CachedTransform.position
};
GameEntry.Entity.ShowDropAsync(data).Forget();
GameEntry.Event.Fire(this, DropSpawnRequestedEventArgs.Create(CachedTransform.position));
}
base.OnDead(attacker);
@@ -10,5 +10,6 @@ namespace SepCore.UI
public ItemType ItemType;
public int Price;
public object DataRow;
public bool IsLocked;
}
}
@@ -7,5 +7,6 @@ namespace SepCore.UI
public GoodsType GoodsType;
public int RefId;
public int Price;
public bool IsLocked;
}
}

Some files were not shown because too many files have changed in this diff Show More