Przeglądaj źródła

攻击信息移到AttackController脚本

SZAND\msx_2 7 miesięcy temu
rodzic
commit
832d482bed
23 zmienionych plików z 457 dodań i 492 usunięć
  1. 7 7
      ActionTowerDefense/Assets/Editor/SkeletonDataReader.cs
  2. 44 57
      ActionTowerDefense/Assets/Resources/Prefab/Conduct/Demonic_BigGiant.prefab
  3. 49 76
      ActionTowerDefense/Assets/Resources/Prefab/Enemy/Enemy_11001.prefab
  4. 2 2
      ActionTowerDefense/Assets/Scripts/Boss/YuMenGuan/YuMenGuan.cs
  5. 1 1
      ActionTowerDefense/Assets/Scripts/Bullet.cs
  6. 246 1
      ActionTowerDefense/Assets/Scripts/Characters/AttackController.cs
  7. 1 1
      ActionTowerDefense/Assets/Scripts/Characters/AttackTrigger.cs
  8. 15 245
      ActionTowerDefense/Assets/Scripts/Characters/Character.cs
  9. 2 2
      ActionTowerDefense/Assets/Scripts/Characters/CharacterColliders.cs
  10. 17 22
      ActionTowerDefense/Assets/Scripts/Characters/Demonic.cs
  11. 28 33
      ActionTowerDefense/Assets/Scripts/Characters/Enemy.cs
  12. 1 1
      ActionTowerDefense/Assets/Scripts/Characters/MoveCharacter.cs
  13. 11 11
      ActionTowerDefense/Assets/Scripts/Characters/PlayerController.cs
  14. 7 7
      ActionTowerDefense/Assets/Scripts/Characters/SearchTrigger.cs
  15. 8 8
      ActionTowerDefense/Assets/Scripts/EnemyCreater.cs
  16. 2 2
      ActionTowerDefense/Assets/Scripts/Spirits/DashEffect.cs
  17. 2 2
      ActionTowerDefense/Assets/Scripts/Spirits/ESpirits_Cook.cs
  18. 1 1
      ActionTowerDefense/Assets/Scripts/Spirits/SmokeDestroy.cs
  19. 2 2
      ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Dash.cs
  20. 1 1
      ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Invisible.cs
  21. 2 2
      ActionTowerDefense/Assets/Scripts/Spirits/Trans_Assassin.cs
  22. 4 4
      ActionTowerDefense/Assets/Scripts/Tower/EnemyTower.cs
  23. 4 4
      ActionTowerDefense/Assets/Scripts/Tower/Tower.cs

+ 7 - 7
ActionTowerDefense/Assets/Editor/SkeletonDataReader.cs

@@ -195,7 +195,7 @@ public class SkeletonDataMonitor
             return;
         }
 
-        cha.attackKeys = new List<SpineAniKey>();
+        cha.attackController.attackKeys = new List<AttackController.SpineAniKey>();
         // 遍历所有动画
         foreach (var animation in skeletonData.Animations)
         {
@@ -216,10 +216,10 @@ public class SkeletonDataMonitor
                 cha.totalAttack_marchTime = animationDuration;
             }
 
-            SpineAniKey sak;
+            AttackController.SpineAniKey sak;
             sak.aniName = animationName;
-            sak.keys = new List<AttackKeyType>();
-            AttackKeyType akt = new AttackKeyType();
+            sak.keys = new List<AttackController.AttackKeyType>();
+            AttackController.AttackKeyType akt = new AttackController.AttackKeyType();
             bool isStartKey = true;
             int canWrite = 0;
             // 遍历动画中的事件
@@ -236,14 +236,14 @@ public class SkeletonDataMonitor
                         {
                             akt.startKeyName = eventName;
                             akt.startKeyTime = eventTime;
-                            akt.attackType = KeyType.AttackStart;
+                            akt.attackType = AttackController.KeyType.AttackStart;
                             canWrite = 1;
                         }
                         else if (canWrite == 1)
                         {
                             akt.endKeyName = eventName;
                             akt.endKeyTime = eventTime;
-                            akt.endType = KeyType.AttackEnd;
+                            akt.endType = AttackController.KeyType.AttackEnd;
                             sak.keys.Add(akt);
                             canWrite = 2;
                         }
@@ -251,7 +251,7 @@ public class SkeletonDataMonitor
                     }
                 }
             }
-            if (canWrite == 2) cha.attackKeys.Add(sak);
+            if (canWrite == 2) cha.attackController.attackKeys.Add(sak);
         }
     }
 

+ 44 - 57
ActionTowerDefense/Assets/Resources/Prefab/Conduct/Demonic_BigGiant.prefab

@@ -389,7 +389,6 @@ MonoBehaviour:
   trigGroundList: []
   myBaGuaTrigger: {fileID: 0}
   baGuaTrigger: []
-  notOnGiant: 0
 --- !u!1 &5440846222648032759
 GameObject:
   m_ObjectHideFlags: 0
@@ -401,6 +400,7 @@ GameObject:
   - component: {fileID: 5440846222648032754}
   - component: {fileID: 5440846222648032765}
   - component: {fileID: 8998661745613780778}
+  - component: {fileID: 1713614217752587255}
   m_Layer: 7
   m_Name: Demonic_BigGiant
   m_TagString: Demonic
@@ -461,23 +461,6 @@ MonoBehaviour:
   totalDieKeepTime: 0
   totalAttack_summonTime: 2.2
   totalAttack_marchTime: 4
-  attackKeys:
-  - aniName: attack_march
-    keys:
-    - attackType: 0
-      startKeyName: attack_on
-      startKeyTime: 1.2666668
-      endType: 1
-      endKeyName: attack_off
-      endKeyTime: 2
-  - aniName: attack_summon
-    keys:
-    - attackType: 0
-      startKeyName: attack_on
-      startKeyTime: 0.20000002
-      endType: 1
-      endKeyName: attack_off
-      endKeyTime: 0.6666667
   dieKeepTime: 0
   rb: {fileID: 5440846222648032765}
   bodyTrans: {fileID: 6459001683917408033}
@@ -485,13 +468,15 @@ MonoBehaviour:
   searchTrigger: {fileID: 2932762729738363159}
   bodyCollider: {fileID: 4543619153787591511}
   uiHp: {fileID: 478072938412589135}
-  beHitTrigger: {fileID: 0}
+  beHitTrigger: {fileID: 3377671071202039733}
+  attackController: {fileID: 1713614217752587255}
+  targetCharacter: {fileID: 0}
+  attackTarget: {fileID: 0}
   state: 0
   totalHp: 4000
   hp: 0
   isDie: 0
   isRevive: 0
-  linked: 0
   canNotAddForce: 0
   canNotChangeHurt: 0
   invincibleTime: 0
@@ -501,43 +486,6 @@ MonoBehaviour:
   armor: 0
   ls: {fileID: 0}
   isInSoulTower: 0
-  canHitFly: 1
-  isNonAttack: 0
-  attackType: 0
-  bulletPrefab: {fileID: 0}
-  shootPos: []
-  shootTrack: 0
-  shootAlwaysTrack: 0
-  Attack_summonInfos:
-  - damage: 50
-    attackDir: {x: 0, y: 0, z: 0}
-    force: 0
-    changeHurt: 0
-    repelValue: 0
-  Attack_marchInfos:
-  - damage: 50
-    attackDir: {x: 0, y: 0, z: 0}
-    force: 0
-    changeHurt: 0
-    repelValue: 0
-  attackTriggers:
-  - {fileID: 7729941002223262554}
-  addAttackEffect: {fileID: 0}
-  armorPiercing: 0
-  curDamage1: 
-  curDamage2: 
-  attackTime: 0
-  attackKeyCount: 0
-  nextStartKeyTime: 0
-  nextEndKeyTime: 0
-  keyTimes: []
-  curKeyNum: 0
-  isAttackTriggerOn: 0
-  targetTypes: 040000000500000006000000
-  targetCharacter: {fileID: 0}
-  attackTarget: {fileID: 0}
-  beTargetCharacter: []
-  getDistanceOffset: 0
   isSpirit: 0
   isTran: 0
   pc: {fileID: 0}
@@ -645,6 +593,45 @@ MonoBehaviour:
   normalDem: {fileID: 5440846222648032759, guid: 05825e721b2832f478f66e78daed901f, type: 3}
   itnHP: 100
   changeSizeSpeed: 0.2
+--- !u!114 &1713614217752587255
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 5440846222648032759}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 565fb65a48a8ef648b3096d46e15efd9, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  attackKeys: []
+  attackType: 0
+  canHitFly: 0
+  armorPiercing: 0
+  Attack_summonInfos: []
+  Attack_marchInfos: []
+  isNonAttack: 0
+  addAttackEffect: {fileID: 0}
+  curDamage1: 
+  curDamage2: 
+  attackTrigger: {fileID: 0}
+  keyTimes: []
+  attackTime: 0
+  attackKeyCount: 0
+  nextStartKeyTime: 0
+  nextEndKeyTime: 0
+  curKeyNum: 0
+  isAttackTriggerOn: 0
+  bulletPrefab: {fileID: 0}
+  shootPos: []
+  shootTrack: 0
+  shootAlwaysTrack: 0
+  targetTypes: 
+  targetCharacter: {fileID: 0}
+  attackTarget: {fileID: 0}
+  beTargetCharacter: []
+  getDistanceOffset: 0
 --- !u!1 &6139679835290116115
 GameObject:
   m_ObjectHideFlags: 0

+ 49 - 76
ActionTowerDefense/Assets/Resources/Prefab/Enemy/Enemy_11001.prefab

@@ -169,6 +169,7 @@ MonoBehaviour:
   type: 0
   owner: {fileID: 0}
   isSingleAttack: 1
+  cantSingleAttack: 0
   trigedObjs: []
   damage: 0
   force: {x: 0, y: 0, z: 0}
@@ -187,6 +188,7 @@ GameObject:
   m_Component:
   - component: {fileID: 2437299196472462364}
   - component: {fileID: 5720304588384615462}
+  - component: {fileID: 1837193195824484407}
   - component: {fileID: 2437299196472462355}
   m_Layer: 8
   m_Name: Enemy_11001
@@ -231,23 +233,6 @@ MonoBehaviour:
   totalDieKeepTime: 1
   totalAttack_summonTime: 1.8333334
   totalAttack_marchTime: 1.8333334
-  attackKeys:
-  - aniName: attack_march
-    keys:
-    - attackType: 0
-      startKeyName: attack_on
-      startKeyTime: 1.1
-      endType: 1
-      endKeyName: attack_off
-      endKeyTime: 1.3333334
-  - aniName: attack_summon
-    keys:
-    - attackType: 0
-      startKeyName: attack_on
-      startKeyTime: 1.1
-      endType: 1
-      endKeyName: attack_off
-      endKeyTime: 1.3333334
   dieKeepTime: 0
   rb: {fileID: 2437299196472462355}
   bodyTrans: {fileID: 5075820377452290163}
@@ -256,12 +241,14 @@ MonoBehaviour:
   bodyCollider: {fileID: 7970625495845499240}
   uiHp: {fileID: 5757877461832872043}
   beHitTrigger: {fileID: 6427563181875878110}
+  attackController: {fileID: 0}
+  targetCharacter: {fileID: 0}
+  attackTarget: {fileID: 0}
   state: 1
   totalHp: 500
   hp: 500
   isDie: 0
   isRevive: 0
-  linked: 0
   canNotAddForce: 0
   canNotChangeHurt: 0
   invincibleTime: 0
@@ -271,49 +258,10 @@ MonoBehaviour:
   armor: 0
   ls: {fileID: 0}
   isInSoulTower: 0
-  canHitFly: 1
-  isNonAttack: 0
-  attackType: 0
-  bulletPrefab: {fileID: 0}
-  shootPos: []
-  shootTrack: 0
-  shootAlwaysTrack: 0
-  Attack_summonInfos:
-  - damage: 0
-    attackDir: {x: 0, y: 0, z: 0}
-    force: 0
-    changeHurt: 0
-    repelValue: 0
-  Attack_marchInfos:
-  - damage: 40
-    attackDir: {x: 0, y: 0, z: 0}
-    force: 0
-    changeHurt: 0
-    repelValue: 0
-  attackTriggers:
-  - {fileID: 2280520615464243483}
-  addAttackEffect: {fileID: 0}
-  armorPiercing: 0
-  curDamage1: 00000000
-  curDamage2: 28000000
-  attackTime: 0
-  attackKeyCount: 0
-  nextStartKeyTime: 0
-  nextEndKeyTime: 0
-  keyTimes: []
-  curKeyNum: 0
-  isAttackTriggerOn: 0
-  targetTypes: 010000000300000002000000
-  targetCharacter: {fileID: 0}
-  attackTarget: {fileID: 0}
-  beTargetCharacter: []
-  getDistanceOffset: 0
   isSpirit: 0
   isTran: 0
   pc: {fileID: 0}
   hptp: 0
-  joint: {fileID: 0}
-  rope: {fileID: 0}
   beLarger: 0
   toLargeSize: 0
   cookEffect: {fileID: 0}
@@ -410,25 +358,51 @@ MonoBehaviour:
   dropSoulMax: 2
   dropSoulMin: 2
   dropSoulAngle: 90
-  aimEffect: {fileID: 0}
-  dashEffect: {fileID: 0}
-  noOnSearchState: 0
-  isFindingPlayer: 0
-  isFindPlayer: 0
-  hateDistance: 0
-  distance: 0
-  rushEndPos: {x: 0, y: 0, z: 0}
-  aimDistance: 0
-  rushTime: 0
-  rushSpeed: 0
-  time: 0
-  readyCD: 0
-  targetDir: {x: 0, y: 0, z: 0}
-  haveDownRush: 0
-  rushHaveAttack: 0
-  downRushTime: 0
-  finishRushTime: 0
   upFirstAfterWeaknessOrNot: 0
+--- !u!114 &1837193195824484407
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2437299196472462361}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 565fb65a48a8ef648b3096d46e15efd9, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  attackKeys: []
+  attackType: 0
+  canHitFly: 0
+  armorPiercing: 0
+  Attack_summonInfos: []
+  Attack_marchInfos:
+  - damage: 30
+    attackDir: {x: 0, y: 0, z: 0}
+    force: 0
+    changeHurt: 0
+    repelValue: 0
+  isNonAttack: 0
+  addAttackEffect: {fileID: 0}
+  curDamage1: 
+  curDamage2: 
+  attackTrigger: {fileID: 2280520615464243483}
+  keyTimes: []
+  attackTime: 0
+  attackKeyCount: 0
+  nextStartKeyTime: 0
+  nextEndKeyTime: 0
+  curKeyNum: 0
+  isAttackTriggerOn: 0
+  bulletPrefab: {fileID: 0}
+  shootPos: []
+  shootTrack: 0
+  shootAlwaysTrack: 0
+  targetTypes: 010000000300000002000000
+  targetCharacter: {fileID: 0}
+  attackTarget: {fileID: 0}
+  beTargetCharacter: []
+  getDistanceOffset: 0
 --- !u!54 &2437299196472462355
 Rigidbody:
   m_ObjectHideFlags: 0
@@ -508,7 +482,6 @@ MonoBehaviour:
   trigGroundList: []
   myBaGuaTrigger: {fileID: 0}
   baGuaTrigger: []
-  notOnGiant: 0
 --- !u!1 &3381575400802596466
 GameObject:
   m_ObjectHideFlags: 0

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

@@ -184,7 +184,7 @@ public class YuMenGuan : Boss
         }
         else
         {
-            otherTarget = searchTrigger.GetMinDisTarget(targetTypes, canHitFly);
+            otherTarget = searchTrigger.GetMinDisTarget(attackController.targetTypes, attackController.canHitFly);
             if (otherTarget != null)
             {
                 EndCurAttackState(false);
@@ -455,7 +455,7 @@ public class YuMenGuan : Boss
             case AttackCategories.A:
                 searchTrigger.enabled = true;
                 otherTarget = null;
-                otherTarget = searchTrigger.GetMinDisTarget(targetTypes, canHitFly);
+                otherTarget = searchTrigger.GetMinDisTarget(attackController.targetTypes, attackController.canHitFly);
                 if (otherTarget == null)
                 {
                     isAttackWalk = false;

+ 1 - 1
ActionTowerDefense/Assets/Scripts/Bullet.cs

@@ -165,7 +165,7 @@ public class Bullet : MonoBehaviour
                     int am = hitTrigger.owner.armor;
                     if (am > 0)
                     {
-                        int ap = owner.armorPiercing;
+                        int ap = owner.attackController.armorPiercing;
                         int c = am - ap;
                         if (c < 0)
                         {

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

@@ -4,5 +4,250 @@ using UnityEngine;
 
 public class AttackController : MonoBehaviour
 {
-    
+    //攻击类型
+    public enum AttackType
+    {
+        Melee = 0,      //近战
+        Shoot = 1,      //射击
+        Dash = 2,       //英灵刺客
+    }
+
+    [System.Serializable]
+    public struct SpineAniKey
+    {
+        public string aniName;
+        public List<AttackKeyType> keys;
+    }
+
+    public enum KeyType
+    {
+        AttackStart,
+        AttackEnd,
+    }
+
+    [System.Serializable]
+    public struct AttackKeyType
+    {
+        public KeyType attackType;
+        public string startKeyName;
+        public float startKeyTime;
+        public KeyType endType;
+        public string endKeyName;
+        public float endKeyTime;
+    }
+
+    private Character owner;
+
+    [Header("所有攻击帧事件及时间")]
+    public List<SpineAniKey> attackKeys;
+
+    [Header("攻击类型")]
+    public AttackType attackType;
+
+    [Header("攻击参数")]
+    public bool canHitFly;
+    public int armorPiercing;                   //穿甲率
+    public List<AttackInfo> Attack_summonInfos;
+    public List<AttackInfo> Attack_marchInfos;
+    //以下信息不在面板显示
+    [HideInInspector]
+    public bool isNonAttack = false;            //无普攻
+    [HideInInspector]
+    public GameObject addAttackEffect;
+    [HideInInspector]
+    public int[] curDamage1;
+    [HideInInspector]
+    public int[] curDamage2;
+
+    [Header("攻击动画")]
+    public AttackTrigger attackTrigger;
+    public List<float> keyTimes;                //所有的帧事件时间
+    //以下信息不在面板显示
+    [HideInInspector]
+    public float attackTime;                    //攻击剩余时间
+    [HideInInspector]
+    public float attackKeyCount;                //攻击进行时间
+    [HideInInspector]
+    public float nextStartKeyTime, nextEndKeyTime;
+    [HideInInspector]
+    public int curKeyNum;                       //当前锁定到第几个帧事件
+    [HideInInspector]
+    public bool isAttackTriggerOn = false;      //当前Attack Trigger是否开启
+
+    [Header("远程单位")]
+    public GameObject bulletPrefab;             //子弹
+    public List<Transform> shootPos;            //子弹发射位置
+    public bool shootTrack = false;             //是否初始时瞄准目标
+    public bool shootAlwaysTrack = false;       //是否始终追踪
+
+    [Header("目标")]
+    public List<TargetType> targetTypes;
+    [HideInInspector]
+    public Character targetCharacter;
+    [HideInInspector]
+    public Character attackTarget;
+    public List<Character> beTargetCharacter = new List<Character>(); //被哪些锁定
+    public float getDistanceOffset = 0f;
+
+    public void Init()
+    {
+        owner = GetComponent<Character>();
+        curDamage1 = new int[Attack_summonInfos.Count];
+        for (int i = 0; i < Attack_summonInfos.Count; i++)
+        {
+            curDamage1[i] = Attack_summonInfos[i].damage;
+        }
+        curDamage2 = new int[Attack_marchInfos.Count];
+        for (int i = 0; i < Attack_marchInfos.Count; i++)
+        {
+            curDamage2[i] = Attack_marchInfos[i].damage;
+        }
+    }
+
+    private void OnEnable()
+    {
+        if (attackTrigger != null)
+        {
+            attackTrigger.gameObject.SetActive(false);
+        }
+    }
+
+    public void SetNextKeyTimes()
+    {
+        if (curKeyNum < keyTimes.Count)
+        {
+            nextStartKeyTime = keyTimes[curKeyNum];
+            nextEndKeyTime = keyTimes[curKeyNum + 1];
+            curKeyNum += 2;
+        }
+    }
+
+    public virtual void Attack_summon()
+    {
+        owner.ani.Play("attack_summon", 0, 0);
+        if (!isNonAttack)
+        {
+            if (attackType == AttackType.Shoot)
+            {
+                attackTrigger.isShoot = true;
+                attackTrigger.GetComponent<Collider>().enabled = false;
+                attackTrigger.type = AttackTrigger.attackTpye.summon;
+            }
+            attackTime = owner.totalAttack_summonTime;
+            attackKeyCount = 0;
+            keyTimes = new List<float>();
+            foreach (SpineAniKey sak in attackKeys)
+            {
+                if (sak.aniName == "attack_summon")
+                {
+                    foreach (AttackKeyType akt in sak.keys)
+                    {
+                        keyTimes.Add(akt.startKeyTime);
+                        keyTimes.Add(akt.endKeyTime);
+                    }
+                }
+            }
+            curKeyNum = 0;
+            SetNextKeyTimes();
+
+            switch (attackType)
+            {
+                case AttackType.Melee:
+                    attackTrigger.damage = curDamage1[0];
+                    attackTrigger.changeHurt = Attack_summonInfos[0].changeHurt;
+                    attackTrigger.repelValue = Attack_summonInfos[0].repelValue;
+                    Vector3 attackDir = Attack_summonInfos[0].attackDir.normalized;
+                    if (owner.bodyTrans.localScale.x < 0)
+                    {
+                        attackDir.x = -attackDir.x;
+                    }
+                    attackTrigger.force = attackDir * Attack_summonInfos[0].force;
+                    break;
+                default:
+                    break;
+            }
+            owner.ChangeState(CharacterState.Attack);
+        }
+    }
+
+    public virtual void Attack_march()
+    {
+        Vector3 leftDir = owner.GetMoveDir();
+        if (leftDir.x > 0.3f)
+        {
+            if (owner.bodyTrans.localScale.x > 0)
+            {
+                owner.Turn();
+            }
+        }
+        else if (leftDir.x < -0.3f)
+        {
+            if (owner.bodyTrans.localScale.x < 0)
+            {
+                owner.Turn();
+            }
+        }
+
+        owner.ani.Play("attack_march", 0, 0);
+        if (attackType == AttackType.Shoot)
+        {
+            attackTrigger.isShoot = true;
+            attackTrigger.GetComponent<Collider>().enabled = false;
+            attackTrigger.type = AttackTrigger.attackTpye.march;
+        }
+        attackTime = owner.totalAttack_marchTime;
+        attackKeyCount = 0;
+        keyTimes = new List<float>();
+        foreach (SpineAniKey sak in attackKeys)
+        {
+            if (sak.aniName == "attack_march")
+            {
+                foreach (AttackKeyType akt in sak.keys)
+                {
+                    keyTimes.Add(akt.startKeyTime);
+                    keyTimes.Add(akt.endKeyTime);
+                }
+            }
+        }
+        curKeyNum = 0;
+        SetNextKeyTimes();
+        attackTrigger.damage = curDamage2[0];
+        attackTrigger.changeHurt = Attack_marchInfos[0].changeHurt;
+        attackTrigger.repelValue = Attack_marchInfos[0].repelValue;
+        Vector3 attackDir = Attack_marchInfos[0].attackDir.normalized;
+        if (owner.bodyTrans.localScale.x < 0)
+        {
+            attackDir.x = -attackDir.x;
+        }
+        attackTrigger.force = attackDir * Attack_marchInfos[0].force;
+
+
+        owner.ChangeState(CharacterState.Attack);
+    }
+
+    public virtual void AttackShootEvent(int attackId, int shootId)
+    {
+        AttackInfo attackInfo;
+        if (attackId == 1)
+        {
+            attackInfo = Attack_summonInfos[shootId];
+        }
+        else
+        {
+            attackInfo = Attack_marchInfos[shootId];
+            attackInfo.damage = curDamage2[0];
+        }
+        GameObject bulletObj = PoolManager.Instantiate(bulletPrefab);
+        Bullet bullet = bulletObj.GetComponent<Bullet>();
+        Vector3 attackDir = attackInfo.attackDir.normalized;
+        if (owner.bodyTrans.localScale.x < 0)
+        {
+            attackDir.x = -attackDir.x;
+        }
+        if (attackId == 1 && owner.Attack_summonShootCanTransmit)
+        {
+            bullet.canTransmit = true;
+        }
+        bullet.BeShoot(owner, shootPos[shootId].position, attackDir, attackInfo.damage, attackInfo.force, attackInfo.changeHurt, attackInfo.repelValue, shootTrack, shootAlwaysTrack, attackTarget ? attackTarget : null);
+    }
 }

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

@@ -74,7 +74,7 @@ public class AttackTrigger : MonoBehaviour
                 int am = hitTrigger.owner.armor;
                 if (am > 0)
                 {
-                    int ap = owner.armorPiercing;
+                    int ap = owner.attackController.armorPiercing;
                     int c = am - ap;
                     if (c < 0)
                     {

+ 15 - 245
ActionTowerDefense/Assets/Scripts/Characters/Character.cs

@@ -32,14 +32,6 @@ public enum CharacterState
     SpecialStatus,
 }
 
-//攻击类型
-public enum AttackType
-{
-    Melee = 0,      //近战
-    Shoot = 1,      //射击
-    Dash = 2,       //英灵刺客
-}
-
 //血量上限增加类型
 public enum HpUpType
 {
@@ -48,30 +40,6 @@ public enum HpUpType
     Fixed = 2,      //加固定血量
 }
 
-[System.Serializable]
-public struct SpineAniKey
-{
-    public string aniName;
-    public List<AttackKeyType> keys;
-}
-
-public enum KeyType
-{
-    AttackStart,
-    AttackEnd,
-}
-
-[System.Serializable]
-public struct AttackKeyType
-{
-    public KeyType attackType;
-    public string startKeyName;
-    public float startKeyTime;
-    public KeyType endType;
-    public string endKeyName;
-    public float endKeyTime;
-}
-
 public class Character : MonoBehaviour
 {
     [Header("骨骼")]
@@ -88,9 +56,6 @@ public class Character : MonoBehaviour
     public float totalAttack_summonTime = 0.5f;
     public float totalAttack_marchTime = 0.5f;
 
-    [Header("所有攻击帧事件及时间")]
-    public List<SpineAniKey> attackKeys;
-
     [Header("死亡后多久尸体消失")]
     [HideInInspector]
     public float dieKeepTime;
@@ -104,13 +69,19 @@ public class Character : MonoBehaviour
     public UIHP uiHp;
     public BeHitTrigger beHitTrigger;
 
+    [HideInInspector]
+    public AttackController attackController;    
+    [HideInInspector]
+    public Character targetCharacter;
+    [HideInInspector]
+    public Character attackTarget;
+
     [Header("角色状态")]
     public CharacterState state;
     public int totalHp = 100;
     public int hp;
     public bool isDie = false;      //已死亡
     public bool isRevive;           //从虚弱状态恢复中
-    public bool linked;             //被铁链连着
     public bool canNotAddForce;     //不会被打飞
     public bool canNotChangeHurt;   //不会被打虚弱
     [HideInInspector]
@@ -126,35 +97,8 @@ public class Character : MonoBehaviour
     public LockSoul ls;
     public bool isInSoulTower;      //在锁魂塔范围内
 
-    [Header("普通攻击信息")]
-    public bool canHitFly;
-    [HideInInspector]
-    public bool isNonAttack = false;            //无普攻
-    public AttackType attackType;               //攻击类型
-    public GameObject bulletPrefab;             //远程攻击的子弹
-    public List<Transform> shootPos;            //远程攻击的子弹发射位置
-    public bool shootTrack = false;             //远程攻击是否初始时瞄准目标
-    public bool shootAlwaysTrack = false;       //远程攻击是否始终追踪
-    public List<AttackInfo> Attack_summonInfos;       //普攻1信息(出场攻击)
-    public List<AttackInfo> Attack_marchInfos;       //普攻2信息
-    public List<AttackTrigger> attackTriggers;  //普攻触发器,敌方进入后播放动画进行攻击
-    public GameObject addAttackEffect;
-    public int armorPiercing;                   //穿甲率
-    public int[] curDamage1;
-    public int[] curDamage2;
-    public float attackTime;
-    public float attackKeyCount;                //攻击进行时间
-    public float nextStartKeyTime, nextEndKeyTime;  //下一个出现/消失attacktrigger的时间
-    public List<float> keyTimes;                //所有的帧事件时间
-    public int curKeyNum;                       //当前锁定到第几个帧事件
-    public bool isAttackTriggerOn = false;      //当前Attack Trigger是否开启
-
-    [Header("目标")]
-    public List<TargetType> targetTypes;
-    public Character targetCharacter;
-    public Character attackTarget;
-    public List<Character> beTargetCharacter = new List<Character>(); //被哪些锁定
-    public float getDistanceOffset = 0f;
+
+
 
     [Header("是否为英灵、是否为变身形态英灵")]
     public bool isSpirit;
@@ -200,22 +144,13 @@ public class Character : MonoBehaviour
 
         //血量重置
         hp = totalHp;
-        if (!isNonAttack)
-        {
-            uiHp.Show(hp, totalHp);
-        }
+        uiHp.Show(hp, totalHp);
         ChangeState(CharacterState.Idle);
 
-        curDamage1 = new int[Attack_summonInfos.Count];
-        for (int i = 0; i < Attack_summonInfos.Count; i++)
-        {
-            curDamage1[i] = Attack_summonInfos[i].damage;
-        }
-        curDamage2 = new int[Attack_marchInfos.Count];
-        for (int i = 0; i < Attack_marchInfos.Count; i++)
-        {
-            curDamage2[i] = Attack_marchInfos[i].damage;
-        }
+        attackController = GetComponent<AttackController>();
+        attackController.Init();
+        attackTarget = attackController.attackTarget;
+        targetCharacter = attackController.targetCharacter;
     }
 
     public virtual void FixedUpdate()
@@ -223,17 +158,6 @@ public class Character : MonoBehaviour
         OnState();
     }
 
-    private void OnEnable()
-    {
-        if (attackTriggers != null)
-        {
-            for (int i = 0; i < attackTriggers.Count; i++)
-            {
-                attackTriggers[i].gameObject.SetActive(false);
-            }
-        }
-    }
-
     public void Turn()
     {
         bodyTrans.localScale = new Vector3(-bodyTrans.localScale.x, bodyTrans.localScale.y, bodyTrans.localScale.z);
@@ -286,31 +210,7 @@ public class Character : MonoBehaviour
         }
     }
 
-    public virtual void AttackShootEvent(int attackId, int shootId)
-    {
-        AttackInfo attackInfo;
-        if (attackId == 1)
-        {
-            attackInfo = Attack_summonInfos[shootId];
-        }
-        else
-        {
-            attackInfo = Attack_marchInfos[shootId];
-            attackInfo.damage = curDamage2[0];
-        }
-        GameObject bulletObj = PoolManager.Instantiate(bulletPrefab);
-        Bullet bullet = bulletObj.GetComponent<Bullet>();
-        Vector3 attackDir = attackInfo.attackDir.normalized;
-        if (bodyTrans.localScale.x < 0)
-        {
-            attackDir.x = -attackDir.x;
-        }
-        if (attackId == 1 && Attack_summonShootCanTransmit)
-        {
-            bullet.canTransmit = true;
-        }
-        bullet.BeShoot(this, shootPos[shootId].position, attackDir, attackInfo.damage, attackInfo.force, attackInfo.changeHurt, attackInfo.repelValue, shootTrack, shootAlwaysTrack, attackTarget ? attackTarget : null);
-    }
+
 
     public virtual Vector3 GetMoveDir()
     {
@@ -318,137 +218,7 @@ public class Character : MonoBehaviour
         return moveDir;
     }
 
-    public void SetNextKeyTimes()
-    {
-        if (curKeyNum < keyTimes.Count)
-        {
-            nextStartKeyTime = keyTimes[curKeyNum];
-            nextEndKeyTime = keyTimes[curKeyNum + 1];
-            curKeyNum += 2;
-        }
-    }
 
-    public virtual void Attack_summon()
-    {
-        ani.Play("attack_summon", 0, 0);
-        if (!isNonAttack)
-        {
-            if (attackType == AttackType.Shoot)
-            {
-                foreach(AttackTrigger at in attackTriggers)
-                {
-                    at.isShoot = true;
-                    at.GetComponent<Collider>().enabled = false;
-                    at.type = AttackTrigger.attackTpye.summon;
-                }
-            }
-            attackTime = totalAttack_summonTime;
-            attackKeyCount = 0;
-            keyTimes = new List<float>();
-            foreach(SpineAniKey sak in attackKeys)
-            {
-                if (sak.aniName == "attack_summon")
-                {
-                    foreach(AttackKeyType akt in sak.keys)
-                    {
-                        keyTimes.Add(akt.startKeyTime);
-                        keyTimes.Add(akt.endKeyTime);
-                    }
-                }
-            }
-            curKeyNum = 0;
-            SetNextKeyTimes();
-
-            switch (attackType)
-            {
-                case AttackType.Melee:
-                    for (int i = 0; i < Attack_summonInfos.Count; i++)
-                    {
-                        attackTriggers[i].damage = curDamage1[i];
-                        attackTriggers[i].changeHurt = Attack_summonInfos[i].changeHurt;
-                        attackTriggers[i].repelValue = Attack_summonInfos[i].repelValue;
-                        Vector3 attackDir = Attack_summonInfos[i].attackDir.normalized;
-                        if (bodyTrans.localScale.x < 0)
-                        {
-                            attackDir.x = -attackDir.x;
-                        }
-                        attackTriggers[i].force = attackDir * Attack_summonInfos[i].force;
-                    }
-                    break;
-                case AttackType.Shoot:
-                case AttackType.Dash:
-                    break;
-
-                default:
-                    break;
-            }
-            ChangeState(CharacterState.Attack);
-        }
-    }
-
-    public virtual void Attack_march()
-    {
-        Vector3 leftDir = GetMoveDir();
-        if (leftDir.x > 0.3f)
-        {
-            if (bodyTrans.localScale.x > 0)
-            {
-                Turn();
-            }
-        }
-        else if (leftDir.x < -0.3f)
-        {
-            if (bodyTrans.localScale.x < 0)
-            {
-                Turn();
-            }
-        }
-
-        ani.Play("attack_march", 0, 0);
-        if (attackType == AttackType.Shoot)
-        {
-            foreach (AttackTrigger at in attackTriggers)
-            {
-                at.isShoot = true;
-                at.GetComponent<Collider>().enabled = false;
-                at.type = AttackTrigger.attackTpye.march;
-            }
-        }
-        attackTime = totalAttack_marchTime;
-        attackKeyCount = 0;
-        keyTimes = new List<float>();
-        foreach (SpineAniKey sak in attackKeys)
-        {
-            if (sak.aniName == "attack_march")
-            {
-                foreach (AttackKeyType akt in sak.keys)
-                {
-                    keyTimes.Add(akt.startKeyTime);
-                    keyTimes.Add(akt.endKeyTime);
-                }
-            }
-        }
-        curKeyNum = 0;
-        SetNextKeyTimes();
-        if (attackTriggers.Count > 0)
-        {
-            for (int i = 0; i < Attack_marchInfos.Count; i++)
-            {
-                attackTriggers[i].damage = curDamage2[i];
-                attackTriggers[i].changeHurt = Attack_marchInfos[i].changeHurt;
-                attackTriggers[i].repelValue = Attack_marchInfos[i].repelValue;
-                Vector3 attackDir = Attack_marchInfos[i].attackDir.normalized;
-                if (bodyTrans.localScale.x < 0)
-                {
-                    attackDir.x = -attackDir.x;
-                }
-                attackTriggers[i].force = attackDir * Attack_marchInfos[i].force;
-            }
-        }
-
-
-        ChangeState(CharacterState.Attack);
-    }
 
     public virtual void SetSortingOrder(int order)
     {

+ 2 - 2
ActionTowerDefense/Assets/Scripts/Characters/CharacterColliders.cs

@@ -23,7 +23,7 @@ public class CharacterColliders : MonoBehaviour
         {
             owner = GetComponentInParent<Character>();
         }
-        owner.AttackShootEvent(1, shootId);
+        owner.attackController.AttackShootEvent(1, shootId);
     }
 
     public void Attack_marchShootEvent(int shootId)
@@ -32,6 +32,6 @@ public class CharacterColliders : MonoBehaviour
         {
             owner = GetComponentInParent<Character>();
         }
-        owner.AttackShootEvent(2, shootId);
+        owner.attackController.AttackShootEvent(2, shootId);
     }
 }

+ 17 - 22
ActionTowerDefense/Assets/Scripts/Characters/Demonic.cs

@@ -64,7 +64,7 @@ public class Demonic : MoveCharacter
 
     public override void FixedUpdate()
     {
-        if (!isNonAttack)
+        if (!attackController.isNonAttack)
         {
             OnSearchState();
         }
@@ -73,7 +73,7 @@ public class Demonic : MoveCharacter
 
     public bool SearchTarget()
     {
-        targetCharacter = searchTrigger.GetMinDisTarget(targetTypes, canHitFly);
+        targetCharacter = searchTrigger.GetMinDisTarget(attackController.targetTypes, attackController.canHitFly);
         if (targetCharacter != null)
         {
             return true;
@@ -504,26 +504,21 @@ public class Demonic : MoveCharacter
                 }
                 break;
             case CharacterState.Attack:
-                attackTime -= Time.deltaTime;
-                attackKeyCount += Time.deltaTime;
-                if (!isAttackTriggerOn && attackKeyCount >= nextStartKeyTime && attackKeyCount <= nextEndKeyTime)
+                attackController.attackTime -= Time.deltaTime;
+                attackController.attackKeyCount += Time.deltaTime;
+                if (!attackController.isAttackTriggerOn && attackController.attackKeyCount >=
+                    attackController.nextStartKeyTime && attackController.attackKeyCount <= attackController.nextEndKeyTime)
                 {
-                    isAttackTriggerOn = true;
-                    foreach (AttackTrigger at in attackTriggers)
-                    {
-                        at.gameObject.SetActive(true);
-                    }
+                    attackController.isAttackTriggerOn = true;
+                    attackController.attackTrigger.gameObject.SetActive(true);
                 }
-                else if (isAttackTriggerOn && attackKeyCount >= nextEndKeyTime)
+                else if (attackController.isAttackTriggerOn && attackController.attackKeyCount >= attackController.nextEndKeyTime)
                 {
-                    isAttackTriggerOn = false;
-                    foreach (AttackTrigger at in attackTriggers)
-                    {
-                        at.gameObject.SetActive(false);
-                    }
-                    SetNextKeyTimes();
+                    attackController.isAttackTriggerOn = false;
+                    attackController.attackTrigger.gameObject.SetActive(false);
+                    attackController.SetNextKeyTimes();
                 }
-                if (attackTime <= 0)
+                if (attackController.attackTime <= 0)
                 {
                     if (isInSoulTower)
                     {
@@ -808,9 +803,9 @@ public class Demonic : MoveCharacter
         }
     }
 
-    public override void Attack_summon()
+    public void Attack_summon()
     {
-        base.Attack_summon();
+        attackController.Attack_summon();
         Vector3 moveDir;
         if (PlayersInput.instance[playerID].bodyTrans.localScale.x > 0)
         {
@@ -838,9 +833,9 @@ public class Demonic : MoveCharacter
         attackTarget = targetCharacter;
     }
 
-    public override void Attack_march()
+    public void Attack_march()
     {
-        base.Attack_march();
+        attackController.Attack_march();
         attackTarget = targetCharacter;
     }
 

+ 28 - 33
ActionTowerDefense/Assets/Scripts/Characters/Enemy.cs

@@ -428,26 +428,21 @@ public class Enemy : MoveCharacter
                 rb.velocity = velocity;
                 break;
             case CharacterState.Attack:
-                attackTime -= Time.deltaTime;
-                attackKeyCount += Time.deltaTime;
-                if (!isAttackTriggerOn && attackKeyCount >= nextStartKeyTime && attackKeyCount <= nextEndKeyTime)
+                attackController.attackTime -= Time.deltaTime;
+                attackController.attackKeyCount += Time.deltaTime;
+                if (!attackController.isAttackTriggerOn && attackController.attackKeyCount >=
+                    attackController.nextStartKeyTime && attackController.attackKeyCount <= attackController.nextEndKeyTime)
                 {
-                    isAttackTriggerOn = true;
-                    foreach (AttackTrigger at in attackTriggers)
-                    {
-                        at.gameObject.SetActive(true);
-                    }
+                    attackController.isAttackTriggerOn = true;
+                    attackController.attackTrigger.gameObject.SetActive(true);             
                 }
-                else if (isAttackTriggerOn && attackKeyCount >= nextEndKeyTime)
+                else if (attackController.isAttackTriggerOn && attackController.attackKeyCount >= attackController.nextEndKeyTime)
                 {
-                    isAttackTriggerOn = false;
-                    foreach (AttackTrigger at in attackTriggers)
-                    {
-                        at.gameObject.SetActive(false);
-                    }
-                    SetNextKeyTimes();
+                    attackController.isAttackTriggerOn = false;
+                    attackController.attackTrigger.gameObject.SetActive(false);
+                    attackController.SetNextKeyTimes();
                 }
-                if (attackTime <= 0)
+                if (attackController.attackTime <= 0)
                 {
                     ChangeState(CharacterState.Idle);
                     break;
@@ -760,13 +755,13 @@ public class Enemy : MoveCharacter
             case SearchState.NoTarget:
                 Character character0 = PlayersInput.instance[0];
                 Character character1 = PlayersInput.instance[1];
-                if (character0 && character0.beTargetCharacter.Exists(t => t == this))
+                if (character0 && character0.attackController.beTargetCharacter.Exists(t => t == this))
                 {
-                    character0.beTargetCharacter.Remove(this);
+                    character0.attackController.beTargetCharacter.Remove(this);
                 }
-                if (character1 && character1.beTargetCharacter.Exists(t => t == this))
+                if (character1 && character1.attackController.beTargetCharacter.Exists(t => t == this))
                 {
-                    character1.beTargetCharacter.Remove(this);
+                    character1.attackController.beTargetCharacter.Remove(this);
                 }
                 targetCharacter = null;
                 break;
@@ -781,21 +776,21 @@ public class Enemy : MoveCharacter
 
     public bool SearchTarget()
     {
-        targetCharacter = searchTrigger.GetMinDisTarget(targetTypes, canHitFly);
+        targetCharacter = searchTrigger.GetMinDisTarget(attackController.targetTypes, attackController.canHitFly);
 
         if (targetCharacter != null)
         {
             Character character0 = PlayersInput.instance[0];
             Character character1 = PlayersInput.instance[1];
             if (targetCharacter == character0
-                && !character0.beTargetCharacter.Exists(t => t == this))
+                && !character0.attackController.beTargetCharacter.Exists(t => t == this))
             {
-                character0.beTargetCharacter.Add(this);
+                character0.attackController.beTargetCharacter.Add(this);
             }
             if (targetCharacter == character1
-                && !character1.beTargetCharacter.Exists(t => t == this))
+                && !character1.attackController.beTargetCharacter.Exists(t => t == this))
             {
-                character1.beTargetCharacter.Add(this);
+                character1.attackController.beTargetCharacter.Add(this);
             }
             return true;
         }
@@ -849,15 +844,15 @@ public class Enemy : MoveCharacter
         }
     }
 
-    public override void Attack_summon()
+    public void Attack_summon()
     {
-        base.Attack_summon();
+        attackController.Attack_summon();
         attackTarget = targetCharacter;
     }
 
-    public override void Attack_march()
+    public void Attack_march()
     {
-        base.Attack_march();
+        attackController.Attack_march();
         attackTarget = targetCharacter;
     }
     public void ChosePlayer()
@@ -884,18 +879,18 @@ public class Enemy : MoveCharacter
         if (distance0 <= distance1)
         {
             targetCharacter = player0;
-            if (!player0.beTargetCharacter.Exists(t => t == this))
+            if (!player0.attackController.beTargetCharacter.Exists(t => t == this))
             {
-                player0.beTargetCharacter.Add(this);
+                player0.attackController.beTargetCharacter.Add(this);
             }
 
         }
         else
         {
             targetCharacter = player1;
-            if (!player1.beTargetCharacter.Exists(t => t == this))
+            if (!player1.attackController.beTargetCharacter.Exists(t => t == this))
             {
-                player1.beTargetCharacter.Add(this);
+                player1.attackController.beTargetCharacter.Add(this);
             }
         }
     }

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

@@ -139,7 +139,7 @@ public class MoveCharacter : Character
         playerAni = ani;
         playerTran = bodyTrans;
         playerBst = beSearchTrigger;
-        playerBullet = bulletPrefab;
+        playerBullet = attackController.bulletPrefab;
         playerST = searchTrigger;
         playerFoot = foot;
         playerSpinee = spinee;

+ 11 - 11
ActionTowerDefense/Assets/Scripts/Characters/PlayerController.cs

@@ -878,22 +878,22 @@ public class PlayerController : MoveCharacter
                         if (!d.isDie)
                         {
                             newGiants.Add(d);
-                            if (d.addAttackEffect == null)
+                            if (d.attackController.addAttackEffect == null)
                             {
-                                d.addAttackEffect = Instantiate(attackEffect, d.bodyTrans.position, new Quaternion(0, 0, 0, 0), d.bodyTrans);
+                                d.attackController.addAttackEffect = Instantiate(attackEffect, d.bodyTrans.position, new Quaternion(0, 0, 0, 0), d.bodyTrans);
                             }
-                            d.addAttackEffect.transform.GetChild(0).gameObject.SetActive(true);
+                            d.attackController.addAttackEffect.transform.GetChild(0).gameObject.SetActive(true);
                         }
                     }
                     giants = newGiants;
                     foreach (Demonic d in giants)
                     {
-                        int[] damages = d.curDamage2;
+                        int[] damages = d.attackController.curDamage2;
                         for (int i = 0; i < damages.Length; i++)
                         {
                             damages[i] += (int)(addRate * boostNum * damages[i]);
                         }
-                        d.curDamage2 = damages;
+                        d.attackController.curDamage2 = damages;
                     }
                     break;
                 //Æø¹¦Ê¦
@@ -1179,7 +1179,7 @@ public class PlayerController : MoveCharacter
         cacheSummonTime -= Time.deltaTime;
         canJumpTime -= Time.deltaTime;
         invincibleTime -= Time.deltaTime;
-        attackTime -= Time.deltaTime;
+        attackController.attackTime -= Time.deltaTime;
         summonTime -= Time.deltaTime;
         rushTime -= Time.deltaTime;
         cacheRushTime -= Time.deltaTime;
@@ -1327,7 +1327,7 @@ public class PlayerController : MoveCharacter
             case CharacterState.Coma:
                 break;
             case CharacterState.Attack:
-                if (attackTime <= 0)
+                if (attackController.attackTime <= 0)
                 {
                     if (btnNorthKeep)
                     {
@@ -1911,7 +1911,7 @@ public class PlayerController : MoveCharacter
                 rb.velocity = Vector3.zero;
                 break;
             case CharacterState.Attack:
-                attackTime = totalAttack_summonTime;
+                attackController.attackTime = totalAttack_summonTime;
                 break;
             case CharacterState.KeepAttack:
                 aniCollider.Play("Attack_summonKeep", 1, 0);
@@ -2156,9 +2156,9 @@ public class PlayerController : MoveCharacter
         return true;
     }
 
-    public override void Attack_summon()
+    public void Attack_summon()
     {
-        base.Attack_summon();
+        attackController.Attack_summon();
         if (leftDir.x > 0.3f)
         {
             if (bodyTrans.localScale.x > 0)
@@ -2190,7 +2190,7 @@ public class PlayerController : MoveCharacter
 
     public void SearchTarget()
     {
-        targetCharacter = searchTrigger.GetMinDisTarget(targetTypes, canHitFly);
+        targetCharacter = searchTrigger.GetMinDisTarget(attackController.targetTypes, attackController.canHitFly);
     }
 
     public void ChangeSpirit()

+ 7 - 7
ActionTowerDefense/Assets/Scripts/Characters/SearchTrigger.cs

@@ -37,11 +37,11 @@ public class SearchTrigger : MonoBehaviour
             { TargetType.Boss, trigBossList },
         };
         targetTypeDic = new Dictionary<TargetType, bool>();
-        for (int i = 0; i < owner.targetTypes.Count; i++)
+        for (int i = 0; i < owner.attackController.targetTypes.Count; i++)
         {
-            if (!targetTypeDic.ContainsKey(owner.targetTypes[i]))
+            if (!targetTypeDic.ContainsKey(owner.attackController.targetTypes[i]))
             {
-                targetTypeDic.Add(owner.targetTypes[i], true);
+                targetTypeDic.Add(owner.attackController.targetTypes[i], true);
             }
         }
     }
@@ -58,11 +58,11 @@ public class SearchTrigger : MonoBehaviour
 
     private void FixedUpdate()
     {
-        for (int i = 0; i < owner.targetTypes.Count; i++)
+        for (int i = 0; i < owner.attackController.targetTypes.Count; i++)
         {
-            if (trigCharacterDic.ContainsKey(owner.targetTypes[i]))
+            if (trigCharacterDic.ContainsKey(owner.attackController.targetTypes[i]))
             {
-                List<BeSearchTrigger> trigList = trigCharacterDic[owner.targetTypes[i]];
+                List<BeSearchTrigger> trigList = trigCharacterDic[owner.attackController.targetTypes[i]];
                 for (int j = 0; j < trigList.Count; j++)
                 {
                     if (trigList[j] == null || !trigList[j].enabled || !trigList[j].gameObject.activeInHierarchy || trigList[j].owner.isDie)
@@ -203,7 +203,7 @@ public class SearchTrigger : MonoBehaviour
         for (int i = 0; i < list.Count; i++)
         {
             Character character = list[i];
-            float distance = Mathf.Abs(character.transform.position.x - owner.transform.position.x) - character.getDistanceOffset * character.transform.localScale.y;
+            float distance = Mathf.Abs(character.transform.position.x - owner.transform.position.x) - character.attackController.getDistanceOffset * character.transform.localScale.y;
             if (minDisChar == null || minDistance == -1 || minDistance > distance)
             {
                 minDisChar = character;

+ 8 - 8
ActionTowerDefense/Assets/Scripts/EnemyCreater.cs

@@ -166,9 +166,9 @@ public class EnemyCreater : MonoBehaviour
                     enemyTower.totalHp = (int)(parameter.HP * hpRatio);
                     enemyTower.hp = enemyTower.totalHp;
 
-                    attackInfo = enemyTower.Attack_summonInfos[0];
+                    attackInfo = enemyTower.attackController.Attack_summonInfos[0];
                     attackInfo.damage = (int)(parameter.Attack_summon * attackRatio);
-                    enemyTower.Attack_summonInfos[0] = attackInfo;
+                    enemyTower.attackController.Attack_summonInfos[0] = attackInfo;
                     enemyTower.Init();
                 }
                 if (tower != null)
@@ -178,9 +178,9 @@ public class EnemyCreater : MonoBehaviour
                     tower.totalHp = (int)(parameter.HP * hpRatio);
                     tower.hp = tower.totalHp;
 
-                    attackInfo = tower.Attack_summonInfos[0];
+                    attackInfo = tower.attackController.Attack_summonInfos[0];
                     attackInfo.damage = (int)(parameter.Attack_summon * attackRatio);
-                    tower.Attack_summonInfos[0] = attackInfo;
+                    tower.attackController.Attack_summonInfos[0] = attackInfo;
                     tower.Init();
                 }
                 if (!buildingDic.ContainsKey(gameMapTile.id))
@@ -203,13 +203,13 @@ public class EnemyCreater : MonoBehaviour
                 enemy.hp = enemy.totalHp;
                 enemy.minMoveSpeed = parameter.MinMoveSpeed * moveSpeedRatio;
                 enemy.maxMoveSpeed = parameter.MaxMoveSpeed * moveSpeedRatio;
-                attackInfo = enemy.Attack_summonInfos[0];
+                attackInfo = enemy.attackController.Attack_summonInfos[0];
                 attackInfo.damage = (int)(parameter.Attack_summon * attackRatio);
-                enemy.Attack_summonInfos[0] = attackInfo;
+                enemy.attackController.Attack_summonInfos[0] = attackInfo;
 
-                attackInfo = enemy.Attack_marchInfos[0];
+                attackInfo = enemy.attackController.Attack_marchInfos[0];
                 attackInfo.damage = (int)(parameter.Attack_march * attackRatio);
-                enemy.Attack_marchInfos[0] = attackInfo;
+                enemy.attackController.Attack_marchInfos[0] = attackInfo;
 
                 if (enemy.canFly)
                 {

+ 2 - 2
ActionTowerDefense/Assets/Scripts/Spirits/DashEffect.cs

@@ -4,7 +4,7 @@ using System.Collections.Generic;
 using UnityEngine;
 
 public class DashEffect : MonoBehaviour
-{
+{/*
     public bool canHit;             //canHit==trueµÄʱºòÔì³ÉÉ˺¦
     public bool isEnemy;
     public bool isBoss;
@@ -122,5 +122,5 @@ public class DashEffect : MonoBehaviour
                 Vector3.Lerp(character.transform.position + Vector3.up * targetY * offset,
                 aim.transform.position, 0.5f);
         }
-    }
+    }*/
 }

+ 2 - 2
ActionTowerDefense/Assets/Scripts/Spirits/ESpirits_Cook.cs

@@ -6,7 +6,7 @@ using System;
 using Random = UnityEngine.Random;
 
 public class ESpirits_Cook : MonoBehaviour
-{
+{/*
     public TextMeshProUGUI text;        //剩余串的数量文本
     private GameObject dia;             //文本框
 
@@ -134,5 +134,5 @@ public class ESpirits_Cook : MonoBehaviour
         {
             TargetInteract();
         }
-    }
+    }*/
 }

+ 1 - 1
ActionTowerDefense/Assets/Scripts/Spirits/SmokeDestroy.cs

@@ -27,7 +27,7 @@ public class SmokeDestroy : MonoBehaviour
         }
         CharacterColliders characterColliders = other.GetComponentInParent<CharacterColliders>();
         
-        if(characterColliders != null && characterColliders.owner.attackType == AttackType.Shoot)
+        if(characterColliders != null && characterColliders.owner.attackController.attackType == AttackController.AttackType.Shoot)
         {
             characterColliders.hitRate = hitRate;
         }

+ 2 - 2
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Dash.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 using UnityEngine;
 
 public class Spirits_Dash : MonoBehaviour
-{
+{/*
     public float moveSpeed;
     public Rigidbody rb;
     public Demonic demonic;
@@ -142,5 +142,5 @@ public class Spirits_Dash : MonoBehaviour
                 new Vector3(-demonic.bodyTrans.localScale.x, demonic.bodyTrans.localScale.y,
                 demonic.bodyTrans.localScale.z);
         }
-    }
+    }*/
 }

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

@@ -43,7 +43,7 @@ public class Spirits_Invisible : MonoBehaviour
         {
             gameObject.SetActive(false);
         }
-        demonic.isNonAttack = true;
+        demonic.attackController.isNonAttack = true;
     }
 
     // Update is called once per frame

+ 2 - 2
ActionTowerDefense/Assets/Scripts/Spirits/Trans_Assassin.cs

@@ -15,7 +15,7 @@ public enum Trans_AssassinState
 
 public class Trans_Assassin : MonoBehaviour
 {
-
+    /*
     public PlayerController player;
     public float criticalChance;            //±©»÷ÂÊ
     public float criticalMultiplier;        //±©»÷±¶Êý
@@ -239,5 +239,5 @@ public class Trans_Assassin : MonoBehaviour
             player.bodyTrans.rotation = Quaternion.Euler(new Vector3(0, 0, k));
         }
         player.rb.velocity = targetDir * rushSpeed;
-    }
+    }*/
 }

+ 4 - 4
ActionTowerDefense/Assets/Scripts/Tower/EnemyTower.cs

@@ -39,14 +39,14 @@ public class EnemyTower : Character
 
     public void SearchTarget()
     {
-        targetCharacter = searchTrigger.GetMinDisTarget(targetTypes, true);
+        targetCharacter = searchTrigger.GetMinDisTarget(attackController.targetTypes, true);
     }
 
     public override void OnState()
     {
         base.OnState();
         SearchTarget();
-        attackTime -= Time.deltaTime;
+        attackController.attackTime -= Time.deltaTime;
         dieKeepTime -= Time.deltaTime;
         bool isAttack = GetAttack();
         switch (state)
@@ -54,12 +54,12 @@ public class EnemyTower : Character
             case CharacterState.Idle:
                 if (isAttack)
                 {
-                    Attack_summon();
+                    attackController.Attack_summon();
                     break;
                 }
                 break;
             case CharacterState.Attack:
-                if (attackTime <= 0)
+                if (attackController.attackTime <= 0)
                 {
                     ChangeState(CharacterState.Idle);
                     break;

+ 4 - 4
ActionTowerDefense/Assets/Scripts/Tower/Tower.cs

@@ -27,14 +27,14 @@ public class Tower : Character
 
     public void SearchTarget()
     {
-        targetCharacter = searchTrigger.GetMinDisTarget(targetTypes, true);
+        targetCharacter = searchTrigger.GetMinDisTarget(attackController.targetTypes, true);
     }
 
     public override void OnState()
     {
         base.OnState();
         SearchTarget();
-        attackTime -= Time.deltaTime;
+        attackController.attackTime -= Time.deltaTime;
         dieKeepTime -= Time.deltaTime;
         bool isAttack = GetAttack();
         switch (state)
@@ -42,12 +42,12 @@ public class Tower : Character
             case CharacterState.Idle:
                 if (isAttack)
                 {
-                    Attack_summon();
+                    attackController.Attack_summon();
                     break;
                 }
                 break;
             case CharacterState.Attack:
-                if (attackTime <= 0)
+                if (attackController.attackTime <= 0)
                 {
                     ChangeState(CharacterState.Idle);
                     break;