Sfoglia il codice sorgente

刷怪与生命值

龙腾猫跃 4 anni fa
parent
commit
941cee5605

File diff suppressed because it is too large
+ 0 - 0
Assets/Plugins/TextMesh Pro/Resources/Fonts & Materials/SOURCEHANSANSCN-NORMAL SDF.asset


+ 0 - 1
Assets/Resources/Entities/EnemyArrow.cs

@@ -4,7 +4,6 @@ using UnityEngine;
 
 
 public class EnemyArrow : EnemyBase {
 public class EnemyArrow : EnemyBase {
 
 
-    public bool movingLeft = false;
     internal override bool isPressingCrouch() => false;
     internal override bool isPressingCrouch() => false;
     internal override bool isPressDownJump() => false;
     internal override bool isPressDownJump() => false;
     internal override bool isPressingLeft() => movingLeft;
     internal override bool isPressingLeft() => movingLeft;

+ 153 - 0
Assets/Resources/Entities/EnemyArrow.prefab

@@ -0,0 +1,153 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!1 &9208206627614078511
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 9208206627614078480}
+  - component: {fileID: 9208206627614078484}
+  - component: {fileID: 9208206627614078483}
+  - component: {fileID: 5079371025613871385}
+  - component: {fileID: 9208206627614078485}
+  m_Layer: 13
+  m_Name: EnemyArrow
+  m_TagString: Enemy
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!4 &9208206627614078480
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 9208206627614078511}
+  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_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!212 &9208206627614078484
+SpriteRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 9208206627614078511}
+  m_Enabled: 1
+  m_CastShadows: 0
+  m_ReceiveShadows: 0
+  m_DynamicOccludee: 1
+  m_StaticShadowCaster: 0
+  m_MotionVectors: 1
+  m_LightProbeUsage: 1
+  m_ReflectionProbeUsage: 1
+  m_RayTracingMode: 0
+  m_RayTraceProcedural: 0
+  m_RenderingLayerMask: 1
+  m_RendererPriority: 0
+  m_Materials:
+  - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
+  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: 0
+  m_MinimumChartSize: 4
+  m_AutoUVMaxDistance: 0.5
+  m_AutoUVMaxAngle: 89
+  m_LightmapParameters: {fileID: 0}
+  m_SortingLayerID: 0
+  m_SortingLayer: 0
+  m_SortingOrder: 0
+  m_Sprite: {fileID: 21300000, guid: ba0316890c5b9ad459c082afd99f8431, type: 3}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_FlipX: 0
+  m_FlipY: 0
+  m_DrawMode: 0
+  m_Size: {x: 1, y: 1}
+  m_AdaptiveModeThreshold: 0.5
+  m_SpriteTileMode: 0
+  m_WasSpriteAssigned: 1
+  m_MaskInteraction: 0
+  m_SpriteSortPoint: 0
+--- !u!50 &9208206627614078483
+Rigidbody2D:
+  serializedVersion: 4
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 9208206627614078511}
+  m_BodyType: 0
+  m_Simulated: 1
+  m_UseFullKinematicContacts: 0
+  m_UseAutoMass: 0
+  m_Mass: 1
+  m_LinearDrag: 0
+  m_AngularDrag: 0.05
+  m_GravityScale: 0
+  m_Material: {fileID: 6200000, guid: 6a9410bb3043e384eba63a5622b25c09, type: 2}
+  m_Interpolate: 0
+  m_SleepingMode: 1
+  m_CollisionDetection: 1
+  m_Constraints: 6
+--- !u!70 &5079371025613871385
+CapsuleCollider2D:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 9208206627614078511}
+  m_Enabled: 1
+  m_Density: 1
+  m_Material: {fileID: 0}
+  m_IsTrigger: 0
+  m_UsedByEffector: 0
+  m_UsedByComposite: 0
+  m_Offset: {x: 0, y: 0}
+  m_Size: {x: 1, y: 0.4}
+  m_Direction: 1
+--- !u!114 &9208206627614078485
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 9208206627614078511}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 7c0ce08e22f5fb44a9359cc9a2ead88c, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  spriteNormal: {fileID: 21300000, guid: 10f7659f313c52a4da5e95cf35f7955b, type: 3}
+  spriteDown: {fileID: 0}
+  canCrouch: 0
+  movementSpeed: 8
+  jumpForce: 20
+  horizontalF: 0.9
+  horizontalA: 0.3
+  jumpThreshold: 0.1
+  downA: 0.3
+  fallA: 0.6
+  filpSpeed: 0.3
+  jumpBufferTime: 0.2
+  jumpWolfTime: 0.2
+  movingLeft: 0
+  hp: 2

+ 7 - 0
Assets/Resources/Entities/EnemyArrow.prefab.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 1d43eb8fb0111f94e9fdf3e2e4cc078e
+PrefabImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 5 - 2
Assets/Resources/Entities/EnemyBase.cs

@@ -5,16 +5,19 @@ using DG.Tweening;
 
 
 public abstract class EnemyBase : EntityBase {
 public abstract class EnemyBase : EntityBase {
 
 
+    public bool movingLeft = false;
     internal override void OnHitBorder() {
     internal override void OnHitBorder() {
         Destroy(gameObject);
         Destroy(gameObject);
     }
     }
 
 
+    public int hp; internal int currentHp = -1;
     internal override void OnHitBullet() {
     internal override void OnHitBullet() {
         // 受伤动画
         // 受伤动画
         sprite.DOColor(new Color(1f, 0.5f, 0.5f), 0.04f).SetLoops(2, LoopType.Yoyo);
         sprite.DOColor(new Color(1f, 0.5f, 0.5f), 0.04f).SetLoops(2, LoopType.Yoyo);
         // 死亡判断
         // 死亡判断
-        hp--;
-        if (hp < 0) {
+        if (currentHp == -1) currentHp = hp;
+        currentHp--;
+        if (currentHp < 0) {
             //TODO: 敌人死亡音效
             //TODO: 敌人死亡音效
             transform.localScale = Vector3.zero;
             transform.localScale = Vector3.zero;
             Destroy(gameObject, 1); // 防止动画没播放完导致报错
             Destroy(gameObject, 1); // 防止动画没播放完导致报错

+ 0 - 1
Assets/Resources/Entities/EnemyHeavy.cs

@@ -4,7 +4,6 @@ using UnityEngine;
 
 
 public class EnemyHeavy : EnemyBase {
 public class EnemyHeavy : EnemyBase {
 
 
-    public bool movingLeft = false;
     internal override bool isPressingCrouch() => false;
     internal override bool isPressingCrouch() => false;
     internal override bool isPressDownJump() => false;
     internal override bool isPressDownJump() => false;
     internal override bool isPressingLeft() => movingLeft;
     internal override bool isPressingLeft() => movingLeft;

+ 165 - 0
Assets/Resources/Entities/EnemyHeavy.prefab

@@ -0,0 +1,165 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!1 &9040011293892009551
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 9040011293892009548}
+  - component: {fileID: 9040011293892009544}
+  - component: {fileID: 9040011293892009547}
+  - component: {fileID: 9040011293892009546}
+  - component: {fileID: 9040011293892009549}
+  m_Layer: 8
+  m_Name: EnemyHeavy
+  m_TagString: Enemy
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!4 &9040011293892009548
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 9040011293892009551}
+  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_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!212 &9040011293892009544
+SpriteRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 9040011293892009551}
+  m_Enabled: 1
+  m_CastShadows: 0
+  m_ReceiveShadows: 0
+  m_DynamicOccludee: 1
+  m_StaticShadowCaster: 0
+  m_MotionVectors: 1
+  m_LightProbeUsage: 1
+  m_ReflectionProbeUsage: 1
+  m_RayTracingMode: 0
+  m_RayTraceProcedural: 0
+  m_RenderingLayerMask: 1
+  m_RendererPriority: 0
+  m_Materials:
+  - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
+  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: 0
+  m_MinimumChartSize: 4
+  m_AutoUVMaxDistance: 0.5
+  m_AutoUVMaxAngle: 89
+  m_LightmapParameters: {fileID: 0}
+  m_SortingLayerID: 0
+  m_SortingLayer: 0
+  m_SortingOrder: 0
+  m_Sprite: {fileID: 21300000, guid: 19c156188586cd949b5aa6bcd9d8b6e0, type: 3}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_FlipX: 0
+  m_FlipY: 0
+  m_DrawMode: 0
+  m_Size: {x: 1, y: 1}
+  m_AdaptiveModeThreshold: 0.5
+  m_SpriteTileMode: 0
+  m_WasSpriteAssigned: 1
+  m_MaskInteraction: 0
+  m_SpriteSortPoint: 0
+--- !u!50 &9040011293892009547
+Rigidbody2D:
+  serializedVersion: 4
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 9040011293892009551}
+  m_BodyType: 0
+  m_Simulated: 1
+  m_UseFullKinematicContacts: 0
+  m_UseAutoMass: 0
+  m_Mass: 3
+  m_LinearDrag: 0
+  m_AngularDrag: 0.05
+  m_GravityScale: 1
+  m_Material: {fileID: 6200000, guid: 6a9410bb3043e384eba63a5622b25c09, type: 2}
+  m_Interpolate: 0
+  m_SleepingMode: 1
+  m_CollisionDetection: 1
+  m_Constraints: 4
+--- !u!61 &9040011293892009546
+BoxCollider2D:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 9040011293892009551}
+  m_Enabled: 1
+  m_Density: 1
+  m_Material: {fileID: 0}
+  m_IsTrigger: 0
+  m_UsedByEffector: 0
+  m_UsedByComposite: 0
+  m_Offset: {x: 0, y: 0.5}
+  m_SpriteTilingProperty:
+    border: {x: 0, y: 0, z: 0, w: 0}
+    pivot: {x: 0.5, y: 0}
+    oldSize: {x: 1, y: 1}
+    newSize: {x: 1, y: 1}
+    adaptiveTilingThreshold: 0.5
+    drawMode: 0
+    adaptiveTiling: 0
+  m_AutoTiling: 0
+  serializedVersion: 2
+  m_Size: {x: 1, y: 1}
+  m_EdgeRadius: 0
+--- !u!114 &9040011293892009549
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 9040011293892009551}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: ae9167703f6e09f41942622771eef1ba, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  spriteNormal: {fileID: 21300000, guid: 19c156188586cd949b5aa6bcd9d8b6e0, type: 3}
+  spriteDown: {fileID: 0}
+  canCrouch: 0
+  movementSpeed: 5
+  jumpForce: 20
+  horizontalF: 0.8
+  horizontalA: 0.07
+  jumpThreshold: 0.1
+  downA: 0.4
+  fallA: 0
+  filpSpeed: 10000
+  jumpBufferTime: 0.15
+  jumpWolfTime: 0.2
+  movingLeft: 0
+  hp: 15
+  knockbackForceH: 30
+  knockbackForceV: 8

+ 7 - 0
Assets/Resources/Entities/EnemyHeavy.prefab.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: ed5e9f0841bbdda4087f0793cdabc5fb
+PrefabImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 0 - 1
Assets/Resources/Entities/EnemyMover.cs

@@ -4,7 +4,6 @@ using UnityEngine;
 
 
 public class EnemyMover : EnemyBase {
 public class EnemyMover : EnemyBase {
 
 
-    public bool movingLeft = false;
     internal override bool isPressingCrouch() => false;
     internal override bool isPressingCrouch() => false;
     internal override bool isPressDownJump() => false;
     internal override bool isPressDownJump() => false;
     internal override bool isPressingLeft() => movingLeft;
     internal override bool isPressingLeft() => movingLeft;

+ 165 - 0
Assets/Resources/Entities/EnemyMover.prefab

@@ -0,0 +1,165 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!1 &2161513460606968894
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 2161513460606968893}
+  - component: {fileID: 2161513460606968898}
+  - component: {fileID: 2161513460606968899}
+  - component: {fileID: 2161513460606968892}
+  - component: {fileID: 2161513460606968897}
+  m_Layer: 8
+  m_Name: EnemyMover
+  m_TagString: Enemy
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!4 &2161513460606968893
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2161513460606968894}
+  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_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!212 &2161513460606968898
+SpriteRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2161513460606968894}
+  m_Enabled: 1
+  m_CastShadows: 0
+  m_ReceiveShadows: 0
+  m_DynamicOccludee: 1
+  m_StaticShadowCaster: 0
+  m_MotionVectors: 1
+  m_LightProbeUsage: 1
+  m_ReflectionProbeUsage: 1
+  m_RayTracingMode: 0
+  m_RayTraceProcedural: 0
+  m_RenderingLayerMask: 1
+  m_RendererPriority: 0
+  m_Materials:
+  - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
+  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: 0
+  m_MinimumChartSize: 4
+  m_AutoUVMaxDistance: 0.5
+  m_AutoUVMaxAngle: 89
+  m_LightmapParameters: {fileID: 0}
+  m_SortingLayerID: 0
+  m_SortingLayer: 0
+  m_SortingOrder: 0
+  m_Sprite: {fileID: 21300000, guid: 10f7659f313c52a4da5e95cf35f7955b, type: 3}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_FlipX: 0
+  m_FlipY: 0
+  m_DrawMode: 0
+  m_Size: {x: 1, y: 1}
+  m_AdaptiveModeThreshold: 0.5
+  m_SpriteTileMode: 0
+  m_WasSpriteAssigned: 1
+  m_MaskInteraction: 0
+  m_SpriteSortPoint: 0
+--- !u!50 &2161513460606968899
+Rigidbody2D:
+  serializedVersion: 4
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2161513460606968894}
+  m_BodyType: 0
+  m_Simulated: 1
+  m_UseFullKinematicContacts: 0
+  m_UseAutoMass: 0
+  m_Mass: 1
+  m_LinearDrag: 0
+  m_AngularDrag: 0.05
+  m_GravityScale: 1
+  m_Material: {fileID: 6200000, guid: 6a9410bb3043e384eba63a5622b25c09, type: 2}
+  m_Interpolate: 0
+  m_SleepingMode: 1
+  m_CollisionDetection: 1
+  m_Constraints: 4
+--- !u!61 &2161513460606968892
+BoxCollider2D:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2161513460606968894}
+  m_Enabled: 1
+  m_Density: 1
+  m_Material: {fileID: 0}
+  m_IsTrigger: 0
+  m_UsedByEffector: 0
+  m_UsedByComposite: 0
+  m_Offset: {x: 0, y: 0.5}
+  m_SpriteTilingProperty:
+    border: {x: 0, y: 0, z: 0, w: 0}
+    pivot: {x: 0.5, y: 0}
+    oldSize: {x: 1, y: 1}
+    newSize: {x: 1, y: 1}
+    adaptiveTilingThreshold: 0.5
+    drawMode: 0
+    adaptiveTiling: 0
+  m_AutoTiling: 0
+  serializedVersion: 2
+  m_Size: {x: 1, y: 1}
+  m_EdgeRadius: 0
+--- !u!114 &2161513460606968897
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2161513460606968894}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 39b999b4bcb380647b8ab07c919e5bc8, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  spriteNormal: {fileID: 21300000, guid: 10f7659f313c52a4da5e95cf35f7955b, type: 3}
+  spriteDown: {fileID: 0}
+  canCrouch: 0
+  movementSpeed: 8
+  jumpForce: 22
+  horizontalF: 0.8
+  horizontalA: 0.07
+  jumpThreshold: 0.05
+  downA: 0.4
+  fallA: 0
+  filpSpeed: 0.3
+  jumpBufferTime: 0.15
+  jumpWolfTime: 0.2
+  movingLeft: 0
+  hp: 6
+  knockbackForceH: 40
+  knockbackForceV: 10

+ 7 - 0
Assets/Resources/Entities/EnemyMover.prefab.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 3b28b6de7da18cf4083f06957807f5ed
+PrefabImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 5
Assets/Resources/Entities/EntityBase.cs

@@ -10,7 +10,6 @@ public abstract class EntityBase : MonoBehaviour {
     internal BoxCollider2D coll;
     internal BoxCollider2D coll;
     public Sprite spriteNormal, spriteDown;
     public Sprite spriteNormal, spriteDown;
     void Start() {
     void Start() {
-        currentHp = hp;
         rb = GetComponent<Rigidbody2D>();
         rb = GetComponent<Rigidbody2D>();
         sprite = GetComponent<SpriteRenderer>();
         sprite = GetComponent<SpriteRenderer>();
         coll = GetComponent<BoxCollider2D>();
         coll = GetComponent<BoxCollider2D>();
@@ -19,13 +18,13 @@ public abstract class EntityBase : MonoBehaviour {
     public bool canCrouch = false;
     public bool canCrouch = false;
     public float movementSpeed = 10f, jumpForce = 20f, horizontalF = 0.9f, horizontalA = 0.3f, jumpThreshold = 0.1f, downA = 0.3f, fallA = 0.1f, filpSpeed = 0.3f;
     public float movementSpeed = 10f, jumpForce = 20f, horizontalF = 0.9f, horizontalA = 0.3f, jumpThreshold = 0.1f, downA = 0.3f, fallA = 0.1f, filpSpeed = 0.3f;
     public float jumpBufferTime = 0.2f, jumpWolfTime = 0.2f; internal float jumpBuffer = 0f, jumpWolf = 0f, jumping = 0f;
     public float jumpBufferTime = 0.2f, jumpWolfTime = 0.2f; internal float jumpBuffer = 0f, jumpWolf = 0f, jumping = 0f;
-    private bool towardsRight = true;
+    internal bool towardsRight = true, isLand = false;
     void Update() {
     void Update() {
         OnUpdate();
         OnUpdate();
         // 获取当前情况
         // 获取当前情况
         float speedX = rb.velocity.x, speedY = rb.velocity.y;
         float speedX = rb.velocity.x, speedY = rb.velocity.y;
         bool isCrouch = isPressingCrouch();
         bool isCrouch = isPressingCrouch();
-        bool isLand = Physics2D.OverlapCircle(transform.position + Vector3.left * 0.1f, jumpThreshold, LayerMask.GetMask("Tilemap")) || 
+        isLand = Physics2D.OverlapCircle(transform.position + Vector3.left * 0.1f, jumpThreshold, LayerMask.GetMask("Tilemap")) || 
             Physics2D.OverlapCircle(transform.position + Vector3.left * -0.1f, jumpThreshold, LayerMask.GetMask("Tilemap"));
             Physics2D.OverlapCircle(transform.position + Vector3.left * -0.1f, jumpThreshold, LayerMask.GetMask("Tilemap"));
         float moveHorizontal = (isCrouch && isLand ? 0.35f : 1) * // 下蹲减速
         float moveHorizontal = (isCrouch && isLand ? 0.35f : 1) * // 下蹲减速
             (isPressingLeft() == isPressingRight() ? 0 : // 没有同时按住左右
             (isPressingLeft() == isPressingRight() ? 0 : // 没有同时按住左右
@@ -77,8 +76,6 @@ public abstract class EntityBase : MonoBehaviour {
     internal abstract bool isPressingCrouch();
     internal abstract bool isPressingCrouch();
     internal virtual void OnUpdate() {}
     internal virtual void OnUpdate() {}
 
 
-    public int hp; internal int currentHp;
-
     // 碰撞检测
     // 碰撞检测
     private void OnCollisionEnter2D(Collision2D collision) {
     private void OnCollisionEnter2D(Collision2D collision) {
         if (collision.gameObject.CompareTag("Border")) OnHitBorder();
         if (collision.gameObject.CompareTag("Border")) OnHitBorder();

+ 35 - 2
Assets/Resources/Entities/Player.cs

@@ -12,23 +12,45 @@ public class Player : EntityBase {
     internal override bool isPressingLeft() => InputM.GetKeyEvent(InputM.KeyType.Left);
     internal override bool isPressingLeft() => InputM.GetKeyEvent(InputM.KeyType.Left);
     internal override bool isPressingRight() => InputM.GetKeyEvent(InputM.KeyType.Right);
     internal override bool isPressingRight() => InputM.GetKeyEvent(InputM.KeyType.Right);
 
 
+    // 生命
+    public RectTransform[] hearts;
+    private int _hp = 3;
+    private int hp {
+        get { return _hp; }
+        set {
+            if (_hp == value) return;
+            _hp = value;
+            if (_hp == 0) _hp = 3;
+            RefreshHearts();
+        }
+    }
+    public float knockbackForceH = 30f, knockbackForceV = 15f;
     internal override void OnHitBorder() {
     internal override void OnHitBorder() {
         Hurt();
         Hurt();
         transform.position = new Vector3(0, 8, 0);
         transform.position = new Vector3(0, 8, 0);
     }
     }
-    public float knockbackForceH = 30f, knockbackForceV = 15f;
     internal override void OnHitEnemy(Collision2D collision) {
     internal override void OnHitEnemy(Collision2D collision) {
         Hurt();
         Hurt();
         int face = collision.transform.position.x < transform.position.x ? 1 : -1;
         int face = collision.transform.position.x < transform.position.x ? 1 : -1;
         rb.velocity = new Vector2(face * knockbackForceH, knockbackForceV);
         rb.velocity = new Vector2(face * knockbackForceH, knockbackForceV);
     }
     }
     public void Hurt() {
     public void Hurt() {
+        hp--;
         AudioM.Play("hurt");
         AudioM.Play("hurt");
         rb.velocity = Vector2.zero;
         rb.velocity = Vector2.zero;
         DOTween.Kill("ScreenShake");
         DOTween.Kill("ScreenShake");
         Camera.current.DOShakePosition(0.3f, 0.3f, 20).SetId("ScreenShake");
         Camera.current.DOShakePosition(0.3f, 0.3f, 20).SetId("ScreenShake");
     }
     }
 
 
+    // 治疗
+    public float healTime = 4f; private float currentHealTime = 0f;
+    private void RefreshHearts() {
+        float totalHp = Mathf.Clamp(hp + Mathf.Pow(currentHealTime / healTime, 7f) * 0.7f + currentHealTime / healTime * 0.3f, 0, 3);
+        for (int i = 0; i < 3; i++) {
+            hearts[i].localScale = Vector3.one * Mathf.Clamp(totalHp - i, 0, 1);
+        }
+    }
+
     // 射击
     // 射击
     public int maxBullet = 20, currentBullet = 20;
     public int maxBullet = 20, currentBullet = 20;
     public float shootDelay = 0.15f; private float currentShootDelay = 0f;
     public float shootDelay = 0.15f; private float currentShootDelay = 0f;
@@ -36,6 +58,17 @@ public class Player : EntityBase {
     public float bulletSpeed = 50f, bulletKnockback = 1f;
     public float bulletSpeed = 50f, bulletKnockback = 1f;
     public GameObject bullet; public TMPro.TextMeshProUGUI textBullet;
     public GameObject bullet; public TMPro.TextMeshProUGUI textBullet;
     internal override void OnUpdate() {
     internal override void OnUpdate() {
+        // 治疗
+        if (isPressingCrouch() && hp < 3 && isLand) {
+            currentHealTime += Time.deltaTime;
+            if (currentHealTime > healTime) {
+                currentHealTime -= healTime;
+                hp++;
+            }
+            RefreshHearts();
+        } else {
+            currentHealTime = 0f;
+        }
         // 装填
         // 装填
         if (InputM.GetKeyEvent(InputM.KeyType.Reload) && currentBullet < maxBullet && currentReloadDelay <= 0f) {
         if (InputM.GetKeyEvent(InputM.KeyType.Reload) && currentBullet < maxBullet && currentReloadDelay <= 0f) {
             // TODO: 装填音效(总时长为 reloadDelay,看 Unity 里的 Player 右边栏,这里的数字可能是过期的)
             // TODO: 装填音效(总时长为 reloadDelay,看 Unity 里的 Player 右边栏,这里的数字可能是过期的)
@@ -64,7 +97,7 @@ public class Player : EntityBase {
         textBullet.text = currentReloadDelay > 0f ?
         textBullet.text = currentReloadDelay > 0f ?
             "".PadLeft(maxBullet - Mathf.RoundToInt(currentReloadDelay / reloadDelay * maxBullet), "|".ToCharArray().First()) : 
             "".PadLeft(maxBullet - Mathf.RoundToInt(currentReloadDelay / reloadDelay * maxBullet), "|".ToCharArray().First()) : 
             "".PadLeft(currentBullet, "|".ToCharArray().First());
             "".PadLeft(currentBullet, "|".ToCharArray().First());
-        textBullet.color = currentReloadDelay > 0f ? new Color(0.5f, 0.5f, 0.5f) : new Color(1, 1, 0.6f);
+        textBullet.color = currentReloadDelay > 0f ? new Color(0.6f, 0.6f, 0.6f) : new Color(1, 1, 0.5f);
     }
     }
 
 
 }
 }

+ 3 - 2
Assets/Resources/System/Modules.cs

@@ -6,11 +6,12 @@ using UnityEngine;
 
 
 public static class Module {
 public static class Module {
 
 
+    public static System.Random randomDefault = new();
     /// <summary>
     /// <summary>
     /// 将 List 随机打乱。
     /// 将 List 随机打乱。
     /// </summary>
     /// </summary>
     public static List<T> Shuffle<T>(this List<T> list, System.Random random = null) {
     public static List<T> Shuffle<T>(this List<T> list, System.Random random = null) {
-        random ??= new System.Random();
+        random ??= randomDefault;
         for (int i = 0; i < list.Count; i++) {
         for (int i = 0; i < list.Count; i++) {
             int randomIndex = random.Next(list.Count);
             int randomIndex = random.Next(list.Count);
             (list[randomIndex], list[i]) = (list[i], list[randomIndex]);
             (list[randomIndex], list[i]) = (list[i], list[randomIndex]);
@@ -21,7 +22,7 @@ public static class Module {
     /// 随机返回数组中的一个元素。
     /// 随机返回数组中的一个元素。
     /// </summary>
     /// </summary>
     public static T RandomOne<T>(this List<T> list, System.Random random = null) {
     public static T RandomOne<T>(this List<T> list, System.Random random = null) {
-        random ??= new System.Random();
+        random ??= randomDefault;
         return list[random.Next(list.Count)];
         return list[random.Next(list.Count)];
     }
     }
     /// <summary>
     /// <summary>

+ 15 - 0
Assets/Resources/System/Spawner.cs

@@ -0,0 +1,15 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Spawner : MonoBehaviour {
+    public GameObject prefeb;
+    public EnemyType type;
+    public enum EnemyType { Arrow, Mover, Heavy }
+    public GameObject parent;
+    public void Spawn() {
+        GameObject obj = Instantiate(prefeb, transform);
+        obj.transform.parent = parent.transform;
+        obj.GetComponent<EnemyBase>().movingLeft = transform.localScale.x < 0;
+    }
+}

+ 11 - 0
Assets/Resources/System/Spawner.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6bb1106f1c02e544582be4b765d03602
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 38 - 8
Assets/Resources/System/StoryM.cs

@@ -7,17 +7,18 @@ using UnityEngine.UI;
 
 
 public class StoryM : MonoBehaviour {
 public class StoryM : MonoBehaviour {
 
 
-    
+    // 文本
     public TMPro.TextMeshProUGUI textStory;
     public TMPro.TextMeshProUGUI textStory;
     public RectTransform shapeBack;
     public RectTransform shapeBack;
-    void Start() {
-        StartCoroutine(test());
-    }
     IEnumerator SetStoryText(string textCh, string textEn = "English", float hideTime = 2f) {
     IEnumerator SetStoryText(string textCh, string textEn = "English", float hideTime = 2f) {
         textStory.text = LocalizationSettings.SelectedLocale.LocaleName == "Chinese (Simplified) (zh-CN)" ? textCh : textEn;
         textStory.text = LocalizationSettings.SelectedLocale.LocaleName == "Chinese (Simplified) (zh-CN)" ? textCh : textEn;
         LayoutRebuilder.ForceRebuildLayoutImmediate(textStory.rectTransform);
         LayoutRebuilder.ForceRebuildLayoutImmediate(textStory.rectTransform);
+        // 动画
+        DOTween.Kill("StoryFont");
+        textStory.color = Color.black;
+        textStory.DOColor(Color.white, 0.2f).SetId("StoryFont");
         DOTween.Kill("StoryBackground");
         DOTween.Kill("StoryBackground");
-        shapeBack.DOScaleX((textStory.rectTransform.rect.width + 40f) / 100f, 0.06f).SetId("StoryBackground");
+        shapeBack.DOScaleX((textStory.rectTransform.rect.width + 40f) / 100f, 0.1f).SetId("StoryBackground");
         yield return new WaitForSeconds(hideTime);
         yield return new WaitForSeconds(hideTime);
     }
     }
     public void HideStoryText() {
     public void HideStoryText() {
@@ -25,12 +26,41 @@ public class StoryM : MonoBehaviour {
         shapeBack.DOScaleX(0, 0.06f);
         shapeBack.DOScaleX(0, 0.06f);
     }
     }
 
 
+    // 刷怪
+    private Dictionary<Spawner.EnemyType, List<Spawner>> spawners = null;
+    public void Spawn(Spawner.EnemyType type, int count = 1) {
+        // 初始化
+        if (spawners == null) {
+            spawners = new();
+            foreach (Spawner spawner in FindObjectsOfType<Spawner>()) {
+                if (spawners.ContainsKey(spawner.type)) {
+                    spawners[spawner.type].Add(spawner);
+                } else {
+                    spawners[spawner.type] = new() { spawner };
+                }
+            }
+        }
+        // 实际刷怪
+        spawners[type].Shuffle();
+        for (int i = 0; i < Mathf.Min(6, count); i++) {
+            spawners[type][i].Spawn();
+        }
+    }
+
+    void Start() {
+        StartCoroutine(test());
+    }
     IEnumerator test() {
     IEnumerator test() {
         while (true) {
         while (true) {
-            yield return StartCoroutine(SetStoryText("这是第一句话", "Eng" , 2f));
-            yield return StartCoroutine(SetStoryText("这是第二句话,文本框大小改变了吗?"));
+            Spawn(Spawner.EnemyType.Mover);
+            yield return StartCoroutine(SetStoryText("先刷一个瞎晃悠的", "Eng" , 3f));
+            Spawn(Spawner.EnemyType.Arrow, 3);
+            yield return StartCoroutine(SetStoryText("再刷……三个戳脑门的", "", 3f));
+            Spawn(Spawner.EnemyType.Heavy);
+            yield return StartCoroutine(SetStoryText("最后是一个贼硬的,完事", "", 3f));
             HideStoryText();
             HideStoryText();
-            yield return new WaitForSeconds(2f);
+            yield return new WaitForSeconds(5f);
+            yield return StartCoroutine(SetStoryText("准备下一轮……", "", 3f));
         }
         }
     }
     }
 
 

BIN
Assets/Resources/UI/Heart.png


+ 98 - 0
Assets/Resources/UI/Heart.png.meta

@@ -0,0 +1,98 @@
+fileFormatVersion: 2
+guid: 71d2fbc4589a5804b9d1d961bd5b91d4
+TextureImporter:
+  internalIDToNameTable: []
+  externalObjects: {}
+  serializedVersion: 11
+  mipmaps:
+    mipMapMode: 0
+    enableMipMap: 0
+    sRGBTexture: 1
+    linearTexture: 0
+    fadeOut: 0
+    borderMipMap: 0
+    mipMapsPreserveCoverage: 0
+    alphaTestReferenceValue: 0.5
+    mipMapFadeDistanceStart: 1
+    mipMapFadeDistanceEnd: 3
+  bumpmap:
+    convertToNormalMap: 0
+    externalNormalMap: 0
+    heightScale: 0.25
+    normalMapFilter: 0
+  isReadable: 0
+  streamingMipmaps: 0
+  streamingMipmapsPriority: 0
+  vTOnly: 0
+  ignoreMasterTextureLimit: 0
+  grayScaleToAlpha: 0
+  generateCubemap: 6
+  cubemapConvolution: 0
+  seamlessCubemap: 0
+  textureFormat: 1
+  maxTextureSize: 2048
+  textureSettings:
+    serializedVersion: 2
+    filterMode: 1
+    aniso: 1
+    mipBias: 0
+    wrapU: 1
+    wrapV: 1
+    wrapW: 1
+  nPOTScale: 0
+  lightmap: 0
+  compressionQuality: 50
+  spriteMode: 1
+  spriteExtrude: 1
+  spriteMeshType: 1
+  alignment: 0
+  spritePivot: {x: 0.5, y: 0.5}
+  spritePixelsToUnits: 100
+  spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+  spriteGenerateFallbackPhysicsShape: 1
+  alphaUsage: 1
+  alphaIsTransparency: 1
+  spriteTessellationDetail: -1
+  textureType: 8
+  textureShape: 1
+  singleChannelComponent: 0
+  flipbookRows: 1
+  flipbookColumns: 1
+  maxTextureSizeSet: 0
+  compressionQualitySet: 0
+  textureFormatSet: 0
+  ignorePngGamma: 0
+  applyGammaDecoding: 0
+  platformSettings:
+  - serializedVersion: 3
+    buildTarget: DefaultTexturePlatform
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  spriteSheet:
+    serializedVersion: 2
+    sprites: []
+    outline: []
+    physicsShape: []
+    bones: []
+    spriteID: 5e97eb03825dee720800000000000000
+    internalID: 0
+    vertices: []
+    indices: 
+    edges: []
+    weights: []
+    secondaryTextures: []
+    nameFileIdTable: {}
+  spritePackingTag: 
+  pSDRemoveMatte: 0
+  pSDShowRemoveMatteOption: 0
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Assets/Resources/UI/HeartEmpty.png


+ 98 - 0
Assets/Resources/UI/HeartEmpty.png.meta

@@ -0,0 +1,98 @@
+fileFormatVersion: 2
+guid: e4f5cb242928f03409fb308b2fa899b6
+TextureImporter:
+  internalIDToNameTable: []
+  externalObjects: {}
+  serializedVersion: 11
+  mipmaps:
+    mipMapMode: 0
+    enableMipMap: 0
+    sRGBTexture: 1
+    linearTexture: 0
+    fadeOut: 0
+    borderMipMap: 0
+    mipMapsPreserveCoverage: 0
+    alphaTestReferenceValue: 0.5
+    mipMapFadeDistanceStart: 1
+    mipMapFadeDistanceEnd: 3
+  bumpmap:
+    convertToNormalMap: 0
+    externalNormalMap: 0
+    heightScale: 0.25
+    normalMapFilter: 0
+  isReadable: 0
+  streamingMipmaps: 0
+  streamingMipmapsPriority: 0
+  vTOnly: 0
+  ignoreMasterTextureLimit: 0
+  grayScaleToAlpha: 0
+  generateCubemap: 6
+  cubemapConvolution: 0
+  seamlessCubemap: 0
+  textureFormat: 1
+  maxTextureSize: 2048
+  textureSettings:
+    serializedVersion: 2
+    filterMode: 1
+    aniso: 1
+    mipBias: 0
+    wrapU: 1
+    wrapV: 1
+    wrapW: 1
+  nPOTScale: 0
+  lightmap: 0
+  compressionQuality: 50
+  spriteMode: 1
+  spriteExtrude: 1
+  spriteMeshType: 1
+  alignment: 0
+  spritePivot: {x: 0.5, y: 0.5}
+  spritePixelsToUnits: 100
+  spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+  spriteGenerateFallbackPhysicsShape: 1
+  alphaUsage: 1
+  alphaIsTransparency: 1
+  spriteTessellationDetail: -1
+  textureType: 8
+  textureShape: 1
+  singleChannelComponent: 0
+  flipbookRows: 1
+  flipbookColumns: 1
+  maxTextureSizeSet: 0
+  compressionQualitySet: 0
+  textureFormatSet: 0
+  ignorePngGamma: 0
+  applyGammaDecoding: 0
+  platformSettings:
+  - serializedVersion: 3
+    buildTarget: DefaultTexturePlatform
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  spriteSheet:
+    serializedVersion: 2
+    sprites: []
+    outline: []
+    physicsShape: []
+    bones: []
+    spriteID: 5e97eb03825dee720800000000000000
+    internalID: 0
+    vertices: []
+    indices: 
+    edges: []
+    weights: []
+    secondaryTextures: []
+    nameFileIdTable: {}
+  spritePackingTag: 
+  pSDRemoveMatte: 0
+  pSDShowRemoveMatteOption: 0
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

File diff suppressed because it is too large
+ 661 - 222
Assets/Scenes/SceneMain.unity


+ 1 - 1
ProjectSettings/Physics2DSettings.asset

@@ -53,4 +53,4 @@ Physics2DSettings:
   m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
   m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
   m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
   m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
   m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
   m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
-  m_LayerCollisionMatrix: bbffffffbbf7ffff88f7fffffff7ffffbbf7ffffbbf7ffffc8f7ffffffe7fffffff7fffffff3fffffff5ffff01e0ffff7fe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+  m_LayerCollisionMatrix: bbffffffbbf7ffff88f7fffffff7ffffbbf7ffffbbf7ffffc8f7ffffffe7ffffffd7fffffff3fffffff5ffff01c0ffff7fe7ffffffd6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

+ 1 - 1
ProjectSettings/TagManager.asset

@@ -23,7 +23,7 @@ TagManager:
   - Dice
   - Dice
   - Marker
   - Marker
   - Bullet
   - Bullet
-  - 
+  - EnemyArrow
   - 
   - 
   - 
   - 
   - 
   - 

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