diff --git a/Assets/InputSystem.inputsettings.asset b/Assets/InputSystem.inputsettings.asset
index 1b236ef..7319a87 100644
--- a/Assets/InputSystem.inputsettings.asset
+++ b/Assets/InputSystem.inputsettings.asset
@@ -12,7 +12,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c46f07b5ed07e4e92aa78254188d3d10, type: 3}
m_Name: InputSystem.inputsettings
m_EditorClassIdentifier:
- m_SupportedDevices: []
+ m_SupportedDevices:
+ - Gamepad
+ - Keyboard
m_UpdateMode: 1
m_CompensateForScreenOrientation: 1
m_FilterNoiseOnCurrent: 0
diff --git a/Assets/RawSignal.meta b/Assets/RawSignal.meta
new file mode 100644
index 0000000..9701b15
--- /dev/null
+++ b/Assets/RawSignal.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 72c6f95b400d3df408d9f067c6e6c74d
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/RawSignal/震动管理员 Raw Signal.asset b/Assets/RawSignal/震动管理员 Raw Signal.asset
new file mode 100644
index 0000000..185e7e1
--- /dev/null
+++ b/Assets/RawSignal/震动管理员 Raw Signal.asset
@@ -0,0 +1,28 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: b7f59e54f2bfd184b9dd451a678d089b, type: 3}
+ m_Name: "\u9707\u52A8\u7BA1\u7406\u5458 Raw Signal"
+ m_EditorClassIdentifier:
+ PositionNoise:
+ - X:
+ Frequency: 0
+ Amplitude: 0
+ Constant: 0
+ Y:
+ Frequency: 6
+ Amplitude: 1
+ Constant: 1
+ Z:
+ Frequency: 0
+ Amplitude: 0
+ Constant: 0
+ OrientationNoise: []
diff --git a/Assets/RawSignal/震动管理员 Raw Signal.asset.meta b/Assets/RawSignal/震动管理员 Raw Signal.asset.meta
new file mode 100644
index 0000000..0f8d75b
--- /dev/null
+++ b/Assets/RawSignal/震动管理员 Raw Signal.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: be080484924830741a80f3039f48e82b
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scenes/test.unity b/Assets/Scenes/test.unity
index bce5d6d..f74f09b 100644
--- a/Assets/Scenes/test.unity
+++ b/Assets/Scenes/test.unity
@@ -429,7 +429,7 @@ MonoBehaviour:
targetGO: {fileID: 0}
tweenTargetIsTargetGO: 1
delay: 0
- duration: 0.25
+ duration: 0.5
easeType: 1
easeCurve:
serializedVersion: 2
@@ -571,7 +571,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 326335321}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
- m_LocalPosition: {x: 9.45, y: 0.153, z: 0}
+ m_LocalPosition: {x: 4.24, y: 0.153, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 321454206}
@@ -879,7 +879,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519420028}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
- m_LocalPosition: {x: 10.219999, y: 0.953, z: -10}
+ m_LocalPosition: {x: 5.0099998, y: 0.953, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 189736997}
@@ -920,6 +920,188 @@ MonoBehaviour:
m_CameraActivatedEvent:
m_PersistentCalls:
m_Calls: []
+--- !u!1 &574826834
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 574826839}
+ - component: {fileID: 574826838}
+ - component: {fileID: 574826837}
+ - component: {fileID: 574826836}
+ - component: {fileID: 574826835}
+ - component: {fileID: 574826840}
+ m_Layer: 0
+ m_Name: "\u4F0A\u65AF\u5170"
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!114 &574826835
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 574826834}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: f3b862b4b8276d94ab3dfb01ab55e5dd, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ HP: 1
+ ATK: 1
+ speed: 3
+ coin: 5
+ canBeHit: 1
+ HPLeft: 0
+ state: 0
+ deadRotationRangeMax: 500
+ deadRotationRangeMin: 500
+ boomTime: 0
+ hitToflyParameter: {x: 3, y: 3}
+--- !u!61 &574826836
+BoxCollider2D:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 574826834}
+ m_Enabled: 1
+ m_Density: 1
+ m_Material: {fileID: 0}
+ m_IsTrigger: 1
+ m_UsedByEffector: 0
+ m_UsedByComposite: 0
+ m_Offset: {x: 0, y: 0}
+ m_SpriteTilingProperty:
+ border: {x: 0, y: 0, z: 0, w: 0}
+ pivot: {x: 0.5, y: 0.5}
+ oldSize: {x: 0.56, y: 1.08}
+ newSize: {x: 1, y: 1}
+ adaptiveTilingThreshold: 0.5
+ drawMode: 0
+ adaptiveTiling: 0
+ m_AutoTiling: 0
+ serializedVersion: 2
+ m_Size: {x: 0.56, y: 1.08}
+ m_EdgeRadius: 0
+--- !u!61 &574826837
+BoxCollider2D:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 574826834}
+ 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_SpriteTilingProperty:
+ border: {x: 0, y: 0, z: 0, w: 0}
+ pivot: {x: 0.5, y: 0.5}
+ oldSize: {x: 0.56, y: 1.08}
+ newSize: {x: 1, y: 1}
+ adaptiveTilingThreshold: 0.5
+ drawMode: 0
+ adaptiveTiling: 0
+ m_AutoTiling: 0
+ serializedVersion: 2
+ m_Size: {x: 0.56, y: 1.08}
+ m_EdgeRadius: 0
+--- !u!212 &574826838
+SpriteRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 574826834}
+ m_Enabled: 1
+ m_CastShadows: 0
+ m_ReceiveShadows: 0
+ m_DynamicOccludee: 1
+ m_MotionVectors: 1
+ m_LightProbeUsage: 1
+ m_ReflectionProbeUsage: 1
+ m_RayTracingMode: 0
+ m_RayTraceProcedural: 0
+ m_RenderingLayerMask: 1
+ m_RendererPriority: 0
+ m_Materials:
+ - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, 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: 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: 6ab25cc35002c7e49a620e5c373a83c8, type: 3}
+ m_Color: {r: 1, g: 1, b: 1, a: 1}
+ m_FlipX: 1
+ 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!4 &574826839
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 574826834}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 8.33, y: 0.37, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 7
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!50 &574826840
+Rigidbody2D:
+ serializedVersion: 4
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 574826834}
+ 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: 0}
+ m_Interpolate: 0
+ m_SleepingMode: 1
+ m_CollisionDetection: 0
+ m_Constraints: 0
--- !u!1 &659041640
GameObject:
m_ObjectHideFlags: 0
@@ -1379,6 +1561,7 @@ GameObject:
m_Component:
- component: {fileID: 1160673896}
- component: {fileID: 1160673895}
+ - component: {fileID: 1160673897}
m_Layer: 0
m_Name: CM vcam1
m_TagString: Untagged
@@ -1429,13 +1612,28 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1160673894}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
- m_LocalPosition: {x: 10.219999, y: 0.953, z: -10}
+ m_LocalPosition: {x: 5.0099998, y: 0.953, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1225561446}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!114 &1160673897
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1160673894}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 00b2d199b96b516448144ab30fb26aed, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_ChannelMask: 1
+ m_Gain: 1
+ m_Use2DDistance: 1
--- !u!1 &1225561445
GameObject:
m_ObjectHideFlags: 3
@@ -2024,6 +2222,128 @@ BoxCollider2D:
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
+--- !u!1 &1820087957
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 1820087959}
+ - component: {fileID: 1820087958}
+ - component: {fileID: 1820087960}
+ m_Layer: 0
+ m_Name: "\u9707\u52A8\u7BA1\u7406\u5458"
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!114 &1820087958
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1820087957}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 180ecf9b41d478f468eb3e9083753217, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_ImpulseDefinition:
+ m_ImpulseChannel: 1
+ m_RawSignal: {fileID: 11400000, guid: be080484924830741a80f3039f48e82b, type: 2}
+ m_AmplitudeGain: 1
+ m_FrequencyGain: 1
+ m_RepeatMode: 0
+ m_Randomize: 1
+ m_TimeEnvelope:
+ m_AttackShape:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: 0
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0
+ outWeight: 0
+ - serializedVersion: 3
+ time: 1
+ value: 1
+ inSlope: 0.0057156202
+ outSlope: 0.0057156202
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.6298815
+ outWeight: 0
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
+ m_DecayShape:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: 1
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0
+ outWeight: 0
+ - serializedVersion: 3
+ time: 1
+ value: 0
+ inSlope: -0.008401664
+ outSlope: -0.008401664
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.38794905
+ outWeight: 0
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
+ m_AttackTime: 0.1
+ m_SustainTime: 0.1
+ m_DecayTime: 0.1
+ m_ScaleWithImpact: 1
+ m_HoldForever: 0
+ m_ImpactRadius: 100
+ m_DirectionMode: 0
+ m_DissipationMode: 2
+ m_DissipationDistance: 1000
+ m_PropagationSpeed: 343
+--- !u!4 &1820087959
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1820087957}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 4.8626485, y: 0.5469756, z: -2.6886199}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 8
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!114 &1820087960
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1820087957}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 8552cc6ae4e3ee6439c72af8eff091ff, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
--- !u!1 &2098309882
GameObject:
m_ObjectHideFlags: 0
@@ -2115,7 +2435,7 @@ BoxCollider2D:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2098309882}
- m_Enabled: 1
+ m_Enabled: 0
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
diff --git a/Assets/Scripts/Enemy.cs b/Assets/Scripts/Enemy.cs
index 31e12e4..0c26480 100644
--- a/Assets/Scripts/Enemy.cs
+++ b/Assets/Scripts/Enemy.cs
@@ -46,6 +46,7 @@ public class Enemy : MonoBehaviour
///
/// 此时怪物能否被攻击
///
+ [FoldoutGroup("状态")][Header("当前是否能被攻击")][ReadOnly]
public bool canBeHit = true;
// _____ _ _
@@ -132,12 +133,9 @@ public class Enemy : MonoBehaviour
else if(other.gameObject.tag == "地面")
{OnRetouchedTheGround();}
}
- protected void OnTriggerEnter2D(Collider2D other)
+ protected virtual void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.TryGetComponent(out MyPlayer player))
{OnFindThePlayer(other.transform);}//如果监视范围出现玩家,则Call事件
}
-
-
-
}
diff --git a/Assets/Scripts/MyPlayer.cs b/Assets/Scripts/MyPlayer.cs
index 2ba7ecf..503dadf 100644
--- a/Assets/Scripts/MyPlayer.cs
+++ b/Assets/Scripts/MyPlayer.cs
@@ -5,15 +5,6 @@ using UnityEngine.InputSystem;
using DG.Tweening;
using Sirenix.OdinInspector;
-// _
-// | |
-// _ __ | | __ _ _ _ ___ _ __
-// | '_ \| |/ _` | | | |/ _ \ '__|
-// | |_) | | (_| | |_| | __/ |
-// | .__/|_|\__,_|\__, |\___|_|
-// | | __/ |
-// |_| |___/
-
///
/// 玩家类,控制玩家相关的东西
///
@@ -177,6 +168,9 @@ public class MyPlayer : MonoBehaviour
if(sickleCDLeft > 0) sickleCDLeft -= Time.deltaTime;
}
+ ///
+ /// 转身的时候触发
+ ///
private void TurnAround()
{
faceDir = inputDir;
@@ -229,7 +223,7 @@ public class MyPlayer : MonoBehaviour
private void CatchingHarm(){
HPLeft -= FindObjectOfType().ATK;
}
- //碰撞检测代码
+
// _____ _ _ _ _
// / ____| | | (_) (_)
// | | ___ | | |_ ___ _ ___ _ __
@@ -265,7 +259,7 @@ public class MyPlayer : MonoBehaviour
else inputDir = 0;
if(faceDir * inputDir < 0){
- if(inControl)TurnAround();
+ if(inControl && !isAttacking)TurnAround();
if(isCatching){catingAiYuPin.OnBreakFree();}
}
}
@@ -281,7 +275,9 @@ public class MyPlayer : MonoBehaviour
jumpForce);//垂直方向给予预设跳跃速度
//标记自身正在跳跃
isJumping = true;
- }
+ VibrationManager.ShakeScream(Vector2.up,0.5f);
+ StartCoroutine(VibrationManager.ShakePad(0.1f,0.2f,0.2f));
+ }
}
}
@@ -348,7 +344,13 @@ public class MyPlayer : MonoBehaviour
///
/// 锤子攻击动画结尾Event调用
///
- public void StopAttacking(){isAttacking = false;}
+ public void StopAttacking(){isAttacking = false;
+ //解决面部朝向的问题
+ if(faceDir * inputDir < 0){
+ if(inControl && !isAttacking)TurnAround();
+ if(isCatching){catingAiYuPin.OnBreakFree();}
+ }
+ }
///
/// 当玩家被爱欲品抓住后触发这个事件
diff --git a/Assets/Scripts/VibrationManager.cs b/Assets/Scripts/VibrationManager.cs
new file mode 100644
index 0000000..4616619
--- /dev/null
+++ b/Assets/Scripts/VibrationManager.cs
@@ -0,0 +1,37 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using Cinemachine;
+using Sirenix.OdinInspector;
+using UnityEngine.InputSystem;
+
+///
+/// 震动管理员,管理相机和手柄的震动,外部调用静态方法
+///
+public class VibrationManager : MonoBehaviour
+{
+ ///
+ /// 震动相机,仅对于一些微小短小震动使用
+ ///
+ /// 震动方向
+ /// 震动力度
+ public static void ShakeScream(Vector2 dir,float force){
+ FindObjectOfType().
+ GenerateImpulse(dir * force);
+ }
+
+ ///
+ /// 震动手柄
+ ///
+ /// 左马达力度(低频)
+ /// 右马达力度(高频)
+ /// 震动时间
+ public static IEnumerator ShakePad(float left, float right, float time){
+ if(Gamepad.current != null){
+ Gamepad.current.SetMotorSpeeds(left,right);
+ yield return new WaitForSeconds(time);
+ Gamepad.current.SetMotorSpeeds(0,0);
+ }
+ }
+
+}
diff --git a/Assets/Scripts/VibrationManager.cs.meta b/Assets/Scripts/VibrationManager.cs.meta
new file mode 100644
index 0000000..89d3bfe
--- /dev/null
+++ b/Assets/Scripts/VibrationManager.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8552cc6ae4e3ee6439c72af8eff091ff
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/YiSiLan.cs b/Assets/Scripts/YiSiLan.cs
new file mode 100644
index 0000000..ee24bcc
--- /dev/null
+++ b/Assets/Scripts/YiSiLan.cs
@@ -0,0 +1,167 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using Sirenix.OdinInspector;
+
+///
+/// 伊斯兰小怪类
+///
+public class YiSiLan : Enemy
+{
+ // _____ _ _ _
+ // | __ \ | | | (_)
+ // | |__) | _| |__ | |_ ___
+ // | ___/ | | | '_ \| | |/ __|
+ // | | | |_| | |_) | | | (__
+ // |_| \__,_|_.__/|_|_|\___|
+
+ [FoldoutGroup("其他",false,0)][Header("怪物死后旋转速度的随机区间")]
+ public float deadRotationRangeMax;
+ [FoldoutGroup("其他",false,0)]
+ public float deadRotationRangeMin;
+ ///
+ /// 抓到玩家后多长事件触发爆炸
+ ///
+ [Header("抓到玩家后多长事件触发爆炸")][FoldoutGroup("伊斯兰")]
+ public float boomTime;
+ ///
+ /// 被击飞力度的调整值
+ ///
+ [Header("被攻击后击飞的力度调整值")][FoldoutGroup("其他",false,0)]
+ public Vector2 hitToflyParameter;
+
+ // _____ _ _
+ // | __ \ (_) | |
+ // | |__) | __ ___ ____ _| |_ ___
+ // | ___/ '__| \ \ / / _` | __/ _ \
+ // | | | | | |\ V / (_| | || __/
+ // |_| |_| |_| \_/ \__,_|\__\___|
+
+ private Rigidbody2D m_rigidbody;
+ ///
+ /// seek函数中的追踪目标
+ ///
+ private Transform target;
+ ///
+ /// 记录此时玩家是否在爆炸范围内
+ ///
+ private bool canHitPlayer;
+
+ // _____ _ _ ____ _
+ // / ____| | | | _ \ | |
+ // | | __ _| | | |_) | __ _ ___| | __
+ // | | / _` | | | _ < / _` |/ __| |/ /
+ // | |___| (_| | | | |_) | (_| | (__| <
+ // \_____\__,_|_|_|____/ \__,_|\___|_|\_\
+
+ void Start(){Init();}//初始化
+ void FixedUpdate(){if(state == State.seek)Seek();}//seek
+
+ // _ _ _
+ // | \ | | | |
+ // | \| | ___ _ __ _ __ ___ __ _| |
+ // | . ` |/ _ \| '__| '_ ` _ \ / _` | |
+ // | |\ | (_) | | | | | | | | (_| | |
+ // |_| \_|\___/|_| |_| |_| |_|\__,_|_|
+
+ private void Init(){
+ //初始化状态为Seek
+ state = State.seek;
+ //找到必要的组件
+ m_rigidbody = GetComponent();
+ target = FindObjectOfType().transform;
+ }
+
+ ///
+ /// 寻找函数,每Fixed调用
+ ///
+ private void Seek(){
+ //构造一个方向,1代表向右,-1代表向左
+ int dir = (target.position.x - transform.position.x > 0) ? 1:-1;
+ //使刚体水平方向上获得速度
+ m_rigidbody.velocity = new Vector2(speed * dir,
+ m_rigidbody.velocity.y);
+ //矫正一下faceDir的问题,使其始终朝向玩家
+ transform.rotation = Quaternion.
+ Euler
+ (transform.rotation.x,
+ ((dir == 1) ? 0:-180),
+ transform.rotation.z);
+ }
+ ///
+ /// 伊斯兰爆炸的时候Call这个,通过协程触发,因为爆炸有个延时
+ ///
+ private void Boom(){
+ OnDead();
+ if(canHitPlayer){
+ FindObjectOfType().OnBeHit(ATK,(target.position.x - transform.position.x > 0) ? -1:1);
+ //加一个扭矩,营造死亡的效果
+ m_rigidbody.AddTorque(Random.Range(deadRotationRangeMin,deadRotationRangeMax) *
+ ((target.position.x - transform.position.x > 0) ? -1:1));
+ }
+ }
+
+ ///
+ /// 被击飞的击飞效果处理
+ ///
+ /// 被击方向
+ public void BeHitToFly(int dir){
+ m_rigidbody.velocity += new Vector2( //给予自身一个
+ -1 * dir * hitToflyParameter.x,//X方向为力度系数乘以受击方向
+ hitToflyParameter.y//Y方向为力度系数
+ //的绝对的速度
+ );
+ }
+
+ ///
+ /// 协程用,删除自己这个游戏物体
+ ///
+ protected void Dead(){Destroy(gameObject);}
+
+ // ______ _
+ // | ____| | |
+ // | |____ _____ _ __ | |_
+ // | __\ \ / / _ \ '_ \| __|
+ // | |___\ V / __/ | | | |_
+ // |______\_/ \___|_| |_|\__|
+
+ protected override void OnTouchThePlayer(MyPlayer player){Invoke("Boom",boomTime);}
+ protected override void OnDead(){
+ //标记当前状态为死亡
+ state = State.dead;
+ //加一个扭矩,营造死亡的效果
+ m_rigidbody.AddTorque(Random.Range(deadRotationRangeMin,deadRotationRangeMax) *
+ ((target.position.x - transform.position.x > 0) ? -1 : 1));
+ //关掉自己的碰撞体
+ GetComponent().enabled = false;
+ //两秒后自己毁灭
+ Invoke("Dead",2f);
+ }
+
+ public override void OnBeHit(MyPlayer.AtkMethod hitMethod, int hitDir){
+ //让自己被击飞
+ BeHitToFly(hitDir);
+ //结算生命值
+ HPLeft -= MyPlayer.atkMethodMagnification[hitMethod];
+ //看下死了没
+ //死了就记录下死亡时候的面部朝向,用来做死亡翻滚效果,然后再Call一下死亡事件
+ if(CheckDead()) {OnDead();}
+ //被打飞了在着地前都不会挨打了
+ canBeHit = false;
+ }
+
+ // _____ _ _ _ _
+ // / ____| | | (_) (_)
+ // | | ___ | | |_ ___ _ ___ _ __
+ // | | / _ \| | | / __| |/ _ \| '_ \
+ // | |___| (_) | | | \__ \ | (_) | | | |
+ // \_____\___/|_|_|_|___/_|\___/|_| |_|
+
+ //触发器代表炸弹范围,进入说明能炸到,离开说明炸不到了
+ protected override void OnTriggerEnter2D(Collider2D other){
+ base.OnTriggerEnter2D(other);
+ canHitPlayer = true;
+ }
+ void OnTriggerExit2D(Collider2D other){canHitPlayer = false;}
+
+}
\ No newline at end of file
diff --git a/Assets/Scripts/YiSiLan.cs.meta b/Assets/Scripts/YiSiLan.cs.meta
new file mode 100644
index 0000000..94666a6
--- /dev/null
+++ b/Assets/Scripts/YiSiLan.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f3b862b4b8276d94ab3dfb01ab55e5dd
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Sprites/早期临时混乱/2关怪.png.meta b/Assets/Sprites/早期临时混乱/2关怪.png.meta
index 3204854..5a974a3 100644
--- a/Assets/Sprites/早期临时混乱/2关怪.png.meta
+++ b/Assets/Sprites/早期临时混乱/2关怪.png.meta
@@ -46,7 +46,7 @@ TextureImporter:
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
- spritePixelsToUnits: 100
+ spritePixelsToUnits: 200
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
@@ -75,6 +75,42 @@ TextureImporter:
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
+ - serializedVersion: 3
+ buildTarget: Standalone
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ - serializedVersion: 3
+ buildTarget: iPhone
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ - serializedVersion: 3
+ buildTarget: Android
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []