SZAND\msx_2 10 сар өмнө
parent
commit
d83bb9b11e

+ 9 - 0
ActionTowerDefense/Assets/Scenes/SampleScene.unity

@@ -411,6 +411,8 @@ MonoBehaviour:
   down: {fileID: 363224843}
   left: {fileID: 1131594848}
   right: {fileID: 1543654651}
+  reboundXSpeed: 0.2
+  reboundYSpeed: 1
 --- !u!1 &306030530
 GameObject:
   m_ObjectHideFlags: 0
@@ -568,6 +570,7 @@ MonoBehaviour:
   searchTrigger: {fileID: 0}
   bodyCollider: {fileID: 0}
   uiHp: {fileID: 0}
+  beHitTrigger: {fileID: 0}
   state: 0
   totalHp: 100
   hp: 0
@@ -595,6 +598,8 @@ MonoBehaviour:
   attack1Infos: []
   attack2Infos: []
   attackTriggers: []
+  addAttackEffect: {fileID: 0}
+  curDamage: 
   targetTypes: 
   targetCharacter: {fileID: 0}
   attackTarget: {fileID: 0}
@@ -702,6 +707,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: d890663d05ab8ac41b4ebb46535db451, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  sc: {fileID: 0}
   canAffect: 0
   isUp: 0
   isDown: 1
@@ -12031,6 +12037,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: d890663d05ab8ac41b4ebb46535db451, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  sc: {fileID: 0}
   canAffect: 0
   isUp: 1
   isDown: 0
@@ -17835,6 +17842,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: d890663d05ab8ac41b4ebb46535db451, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  sc: {fileID: 0}
   canAffect: 0
   isUp: 0
   isDown: 0
@@ -18944,6 +18952,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: d890663d05ab8ac41b4ebb46535db451, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  sc: {fileID: 0}
   canAffect: 0
   isUp: 0
   isDown: 0

+ 26 - 8
ActionTowerDefense/Assets/Scripts/Enemy.cs

@@ -38,11 +38,15 @@ public class Enemy : MoveCharacter
     public float jumpSpeed = 10;
     public float maxMoveSpeed, minMoveSpeed;
     public float runSpeed;
+
+    [Header("击飞、屏幕反弹")]
     public bool isBeBlownUp;    //被击飞
     public bool isBeReboundedX; //X方向被反弹
     public bool isBeReboundedY; //Y方向被反弹
     private bool hasBeReboundedX;
     private bool hasBeReboundedY;
+    public float reboundXSpeed;
+    public float reboundYSpeed;
 
     [Header("落地眩晕")]
     public bool willBeComa;
@@ -481,17 +485,31 @@ public class Enemy : MoveCharacter
                     }
                     else
                     {
-                        vel.y += extraFallGravity * Time.deltaTime;
-                        vel.x -= vel.x * decelerationRatio * Time.deltaTime;
-                        if (!hasBeReboundedX && isBeReboundedX)
+                        if (hasBeReboundedX)
+                        {
+                            vel.x -= vel.x * decelerationRatio * Time.deltaTime * reboundXSpeed;
+                        }
+                        else
                         {
-                            hasBeReboundedX = true;
-                            vel.x = -vel.x;
+                            vel.x -= vel.x * decelerationRatio * Time.deltaTime;
+                            if (!hasBeReboundedX && isBeReboundedX)
+                            {
+                                hasBeReboundedX = true;
+                                vel.x = -vel.x;
+                            }
                         }
-                        if (!hasBeReboundedY && isBeReboundedY)
+                        if (hasBeReboundedY)
                         {
-                            hasBeReboundedY = true;
-                            vel.y = -vel.y;
+                            vel.y += extraFallGravity * Time.deltaTime * reboundYSpeed;
+                        }
+                        else
+                        {
+                            vel.y += extraFallGravity * Time.deltaTime;
+                            if (!hasBeReboundedY && isBeReboundedY)
+                            {
+                                hasBeReboundedY = true;
+                                vel.y = -vel.y;
+                            }
                         }
                     }
 

+ 9 - 1
ActionTowerDefense/Assets/Scripts/SystemReflect/ScreenCrash.cs

@@ -16,22 +16,30 @@ public class ScreenCrash : MonoBehaviour
     public SingleScreenBorder left;
     public SingleScreenBorder right;
 
+    [Header("反弹的力的大小")]
+    [Tooltip("撞到左右墙后反弹的速度")] public float reboundXSpeed;
+    [Tooltip("撞到上下墙后反弹的速度")] public float reboundYSpeed;
+
     private void Start()
     {
         if (isUpOpen)
         {
-            up.canAffect = true;
+            up.sc = this;
+            up.canAffect = true;   
         }
         if (isDownOpen)
         {
+            down.sc = this;
             down.canAffect = true;
         }
         if (isLeftOpen)
         {
+            left.sc = this;
             left.canAffect = true;
         }
         if (isRightOpen)
         {
+            right.sc = this;
             right.canAffect = true;
         }
     }

+ 5 - 1
ActionTowerDefense/Assets/Scripts/SystemReflect/SingleScreenBorder.cs

@@ -4,6 +4,8 @@ using UnityEngine;
 
 public class SingleScreenBorder : MonoBehaviour
 {
+    public ScreenCrash sc;
+
     [Header("ÊÇ·ñ¿ÉÉúЧ")]
     public bool canAffect;
 
@@ -22,11 +24,13 @@ public class SingleScreenBorder : MonoBehaviour
         Vector3 vel = ene.rb.velocity;
         if (isLeft && vel.x < 0 || isRight && vel.x > 0)
         {
+            ene.reboundXSpeed = sc.reboundXSpeed * (vel.x / Mathf.Abs(vel.x));
             ene.isBeReboundedX = true;
             return;
         }
         if (isUp && vel.y > 0 || isDown && vel.y < 0)
         {
+            ene.reboundYSpeed = sc.reboundYSpeed;
             ene.isBeReboundedY = true;
             return;
         }
@@ -35,7 +39,7 @@ public class SingleScreenBorder : MonoBehaviour
 
     private void OnTriggerEnter(Collider other)
     {
-        if (other.gameObject.layer == 8)
+        if (canAffect && other.gameObject.layer == 8)
         {
             Enemy e = other.GetComponentInParent<Enemy>();
             JudgeCanRebound(e);