Przeglądaj źródła

子弹兼容新的攻击效果模式

wgl 6 miesięcy temu
rodzic
commit
ee24feb190

+ 4 - 4
ActionTowerDefense/Assets/Scripts/Boss/YuMenGuan/YuMenGuan.cs

@@ -258,8 +258,8 @@ public class YuMenGuan : Boss
                 wv2.GetComponent<WaveShockDir>().scale = waveEnlargeScale[curStateId];
                 wv1.GetComponent<WaveShockDir>().CheckTurn();
                 wv2.GetComponent<WaveShockDir>().CheckTurn();
-                wv1.BeShoot(this, wave1pos.position, dir1, wave1Damage.damage, wave1Damage.force, wave1Damage.changeHurt, wave1Damage.repelValue, false);
-                wv2.BeShoot(this, wave2pos.position, dir2, wave1Damage.damage, wave1Damage.force, wave1Damage.changeHurt, wave1Damage.repelValue, false);
+                wv1.BeShoot(this, wave1pos.position, dir1,false);
+                wv2.BeShoot(this, wave2pos.position, dir2, false);
                 wv1.transform.right = dir;
                 wv2.transform.right = dir;
                 break;
@@ -279,8 +279,8 @@ public class YuMenGuan : Boss
                 wv2.GetComponent<WaveShockDir>().scale = waveEnlargeScale[curStateId];
                 wv1.GetComponent<WaveShockDir>().CheckTurn();
                 wv2.GetComponent<WaveShockDir>().CheckTurn();
-                wv1.BeShoot(this, wave1pos.position, dir1, wave2Damage[index].damage, wave2Damage[index].force, wave2Damage[index].changeHurt, wave2Damage[index].repelValue, false);
-                wv2.BeShoot(this, wave2pos.position, dir2, wave2Damage[index].damage, wave2Damage[index].force, wave2Damage[index].changeHurt, wave2Damage[index].repelValue, false);
+                wv1.BeShoot(this, wave1pos.position, dir1, false);
+                wv2.BeShoot(this, wave2pos.position, dir2, false);
                 wv1.transform.right = dir;
                 wv2.transform.right = dir;
                 break;

+ 10 - 15
ActionTowerDefense/Assets/Scripts/Bullet.cs

@@ -18,12 +18,9 @@ public class Bullet : MonoBehaviour
     
     [Header("组件")]
     public Character owner;
+    public AttackInfo attackInfo;
     public Rigidbody rb;
     public List<BeHitTrigger> trigedObjs;
-    public int damage;
-    public float force;
-    public bool changeHurt;
-    public float repelValue;
     public BulletType bulletType;
     public bool isGetTarget = false;
     public float speed;
@@ -69,10 +66,10 @@ public class Bullet : MonoBehaviour
             dis2.z = dis1.z;
             if (Vector3.Distance(dis1,dis2) < 0.1)
             {
-                trackTarget.BeHit(damage, Vector3.zero, false, 0);
+                trackTarget.BeHit(attackInfo, transform.position.x < trackTarget.transform.position.x?-1:1) ;
                 if (trackTarget.debugAttackFrom)
                 {
-                    trackTarget.DebugAttackFrom(owner.name, damage);
+                    trackTarget.DebugAttackFrom(owner.name, attackInfo.damage);
                 }
                 gameObject.SetActive(false);
             }
@@ -104,7 +101,7 @@ public class Bullet : MonoBehaviour
         }
     }
 
-    public void BeShoot(Character own, Vector3 shootPos, Vector3 dir, int dmg, float fc, bool hurt, float repel, bool aim = false, bool alwaysTrack = false, Character target = null)
+    public void BeShoot(Character own, Vector3 shootPos, Vector3 dir, bool aim = false, bool alwaysTrack = false, Character target = null)
     {
         transform.position = shootPos;
         transform.right = -dir;
@@ -121,12 +118,9 @@ public class Bullet : MonoBehaviour
         }
         gameObject.SetActive(true);
         isGetTarget = false;
-        damage = dmg;
-        force = fc;
-        changeHurt = hurt;
-        repelValue = repel;
         canAlwaysTrack = alwaysTrack;
         flyTime = 0;
+        attackInfo = own.attackController.attackInfo;
     }
 
     private void OnTriggerEnter(Collider other)
@@ -139,7 +133,7 @@ public class Bullet : MonoBehaviour
         if (photosphere && Util.CheckCanHit(owner.tag, "Player"))
         {
             isInVain = true;
-            photosphere.Reflex(owner.beHitTrigger, damage);
+            photosphere.Reflex(owner.beHitTrigger, owner.attackController.attackInfo.damage);
             gameObject.SetActive(false);
             return;
         }
@@ -161,7 +155,7 @@ public class Bullet : MonoBehaviour
                 if (Util.CheckCanHit(owner.tag, hitTrigger.owner.tag) && !hitTrigger.owner.isDie)
                 {
                     //计算护甲减免
-                    int curDamage = damage;
+                    int curDamage = owner.attackController.attackInfo.damage;
                     int am = hitTrigger.owner.armor;
                     if (am > 0)
                     {
@@ -173,10 +167,11 @@ public class Bullet : MonoBehaviour
                         }
                         curDamage = (int)(curDamage * (100f / (100 + c)) + 0.5f);
                     }
+                    float dir = transform.position.x < hitTrigger.transform.position.x ? -1 : 1;
                     switch (bulletType)
                     {
                         case BulletType.Single:
-                            hitTrigger.BeHit(curDamage, force * (-transform.right), changeHurt, repelValue);
+                            hitTrigger.BeHit(attackInfo, dir);
                             if (hitTrigger.owner.debugAttackFrom)
                             {
                                 hitTrigger.owner.DebugAttackFrom(owner.name, curDamage);
@@ -206,7 +201,7 @@ public class Bullet : MonoBehaviour
                             }
                             break;
                         case BulletType.Penetrate:
-                            hitTrigger.BeHit(curDamage, force * (-transform.right), changeHurt, repelValue);
+                            hitTrigger.BeHit(attackInfo,dir);
                             if (hitTrigger.owner.debugAttackFrom)
                             {
                                 hitTrigger.owner.DebugAttackFrom(owner.name, curDamage);

+ 1 - 2
ActionTowerDefense/Assets/Scripts/Characters/AttackController.cs

@@ -437,8 +437,7 @@ public class AttackController : MonoBehaviour
         {
             bullet.canTransmit = true;
         }
-        bullet.BeShoot(owner, shootPos[shootId].position, attackDir, attackInfo.damage, 
-            attackInfo.force, attackInfo.changeHurt, attackInfo.repelValue, shootTrack, 
+        bullet.BeShoot(owner, shootPos[shootId].position, attackDir, shootTrack, 
             shootAlwaysTrack, owner.attackTarget ? owner.attackTarget : null);
     }
 }

+ 1 - 1
ActionTowerDefense/Assets/Scripts/Characters/Character.cs

@@ -154,7 +154,7 @@ public class Character : MonoBehaviour
     
     public void DebugAttackFrom(string attackFrom, int damage)
     {
-        Debug.Log(attackFrom + "对" + gameObject.name + "造成了" + damage.ToString() + "点伤害");
+        Debug.Log(attackFrom + "对" + gameObject.name + "使用了" + damage.ToString() + "点伤害的攻击");
     }
 
     public virtual void BeHit(int damage, Vector3 force, bool changeHurt, float repelValue)

+ 1 - 1
ActionTowerDefense/Assets/Scripts/Conduct/FanFlyingSwords.cs

@@ -30,7 +30,7 @@ public class FanFlyingSwords : MonoBehaviour
             }
             angle = angle / 180 * Mathf.PI;
             dir = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0);
-            obj.GetComponent<Bullet>().BeShoot(owner, owner.transform.position + Vector3.up, dir, damage, 0, false, 0);
+            obj.GetComponent<Bullet>().BeShoot(owner, owner.transform.position + Vector3.up, dir, false);
         }
         
     }

+ 1 - 1
ActionTowerDefense/Assets/Scripts/Conduct/Photosphere.cs

@@ -27,7 +27,7 @@ public class Photosphere : MonoBehaviour
         hp -= damage;
         GameObject obj = Instantiate(bulletPrefab);
         Vector3 attackDir = (beHitTrigger.owner.beSearchTrigger.transform.position - transform.position).normalized;
-        obj.GetComponent<Bullet>().BeShoot(owner, transform.position, attackDir, (int)(damage * rate), 0, false, 0, true, beHitTrigger.owner);
+        obj.GetComponent<Bullet>().BeShoot(owner, transform.position, attackDir, true, beHitTrigger.owner);
         if (hp <= 0)
         {
             owner.conductCanRelease[conductId] = true;

+ 1 - 1
ActionTowerDefense/Assets/Scripts/Skills/MultiShot.cs

@@ -41,7 +41,7 @@ public class MultiShot : SpecialSkills
             }
             ang = ang / 180 * Mathf.PI;
             dir = new Vector3(Mathf.Cos(ang), Mathf.Sin(ang), 0);
-            obj.GetComponent<Bullet>().BeShoot(owner, owner.transform.position + Vector3.up, dir, damage, 0, false, 0);
+            obj.GetComponent<Bullet>().BeShoot(owner, owner.transform.position + Vector3.up, dir, false);
             arrowController.Initialize(gravity, speed);
         }
     }

+ 1 - 2
ActionTowerDefense/Assets/Scripts/Tower/EnemyTower.cs

@@ -25,8 +25,7 @@ public class EnemyTower : Character
         {
             attackDir.x = -attackDir.x;
         }
-        bullet.BeShoot(this, attackController.shootPos[0].position, attackDir, attackInfo.damage,
-            attackInfo.force, attackInfo.changeHurt, attackInfo.repelValue, attackController.shootTrack,
+        bullet.BeShoot(this, attackController.shootPos[0].position, attackDir, attackController.shootTrack,
             attackController.shootAlwaysTrack, attackTarget ? attackTarget : null);
     }
 

+ 1 - 2
ActionTowerDefense/Assets/Scripts/Tower/Tower.cs

@@ -41,8 +41,7 @@ public class Tower : Character
         {
             attackDir.x = -attackDir.x;
         }
-        bullet.BeShoot(this, attackController.shootPos[0].position, attackDir, attackInfo.damage,
-            attackInfo.force, attackInfo.changeHurt, attackInfo.repelValue, attackController.shootTrack,
+        bullet.BeShoot(this, attackController.shootPos[0].position, attackDir, attackController.shootTrack,
             attackController.shootAlwaysTrack, attackTarget ? attackTarget : null);
     }