Bläddra i källkod

在雾中有概率miss

LAPTOP-OM1V99U2\永远de小亡灵 1 år sedan
förälder
incheckning
7e9f62ea23

+ 1 - 0
ActionTowerDefense/Assets/Resources/Prefab/Transfiguration/Trans_Invisible.prefab

@@ -221,6 +221,7 @@ MonoBehaviour:
   stayTime: 5
   normalSpeed: 0
   kMp: 1
+  magnification: 0.5
 --- !u!114 &2437299196472462353
 MonoBehaviour:
   m_ObjectHideFlags: 0

+ 11 - 5
ActionTowerDefense/Assets/Scripts/AttackTrigger.cs

@@ -13,6 +13,7 @@ public class AttackTrigger : MonoBehaviour
     public float repelValue;
     public GameObject spiritsAttackEffect;
     public int offsetY = 1;
+    public float hitRate = 1;
     private void Awake()
     {
         owner = GetComponentInParent<Character>();
@@ -37,14 +38,19 @@ public class AttackTrigger : MonoBehaviour
                 trigedObjs.Add(hitTrigger);
                 if (Util.CheckCanHit(owner.tag, hitTrigger.owner.tag) && !hitTrigger.owner.isDie)
                 {
-                    hitTrigger.BeHit(damage, force, changeHurt, repelValue);
-                    if (spiritsAttackEffect != null)
+                    if (Random.Range(0, 1) < hitRate)
                     {
-                        GameObject effect = Instantiate(spiritsAttackEffect);
-                        effect.transform.position = new Vector3(hitTrigger.transform.position.x,
-                            transform.position.y + offsetY, 0);
+                        hitTrigger.BeHit(damage, force, changeHurt, repelValue);
+                        if (spiritsAttackEffect != null)
+                        {
+                            GameObject effect = Instantiate(spiritsAttackEffect);
+                            effect.transform.position = new Vector3(hitTrigger.transform.position.x,
+                                transform.position.y + offsetY, 0);
+                        }
                     }
 
+
+
                 }
             }
         }

+ 17 - 0
ActionTowerDefense/Assets/Scripts/Spirits/SmokeDestroy.cs

@@ -8,6 +8,7 @@ public class SmokeDestroy : MonoBehaviour
     public float stayTime;
     [HideInInspector]
     public float time;
+    public float hitRate;
     private void Update()
     {
         time += Time.deltaTime;
@@ -16,4 +17,20 @@ public class SmokeDestroy : MonoBehaviour
             gameObject.SetActive(false);
         }
     }
+    private void OnTriggerEnter(Collider other)
+    {
+        AttackTrigger attackTrigger = other.GetComponent<AttackTrigger>();
+        if (attackTrigger != null)
+        {
+            attackTrigger.hitRate = hitRate;
+        }
+    }
+    private void OnTriggerExit(Collider other)
+    {
+        AttackTrigger attackTrigger = other.GetComponent<AttackTrigger>();
+        if (attackTrigger != null)
+        {
+            attackTrigger.hitRate = 1;
+        }
+    }
 }

+ 2 - 1
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Invisible.cs

@@ -27,6 +27,7 @@ public class Spirits_Invisible : MonoBehaviour
     [HideInInspector]
     public float normalSpeed;
     public float kMp;
+    public float magnification;
 
     private void Start()
     {
@@ -64,7 +65,7 @@ public class Spirits_Invisible : MonoBehaviour
         {
 
             time = 0;
-            playerController.moveSpeed = normalSpeed/2;
+            playerController.moveSpeed = normalSpeed * magnification;
         }
         if (playerController.isinputK)
         {