Ver código fonte

整理demonic、enemy脚本;修改法师出场大招代码位置

SZAND\msx_2 1 ano atrás
pai
commit
a83f8446ea

+ 63 - 74
ActionTowerDefense/Assets/Resources/Prefab/MySpirit/Spirits_Float.prefab

@@ -921,6 +921,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: c42213c575288a148b692aad7ab56bab, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  rb: {fileID: 0}
+  haveGravity: 1
   trigGroundList: []
 --- !u!1 &8639832132491289359
 GameObject:
@@ -973,8 +975,7 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   maxHeight: 8
   minHeight: 6
-  floatProbability: 5
-  abilityTimes: -1
+  effect: {fileID: 417478504669294145, guid: 243eb0eff66414445990654286d861d1, type: 3}
 --- !u!114 &8639832132491289351
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -987,13 +988,6 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: c1bedfb340186164dbac1499b49b879e, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  isTran: 0
-  pc: {fileID: 0}
-  isSpirit: 1
-  HitCols:
-  - {fileID: 5388987656270167698}
-  - {fileID: 1190225091429982147}
-  cookNum: 3
   mecanim: {fileID: 3354085511906294621}
   meshRenderer: {fileID: 0}
   ani: {fileID: 5978259926173120695}
@@ -1001,19 +995,33 @@ MonoBehaviour:
   rb: {fileID: 8639832132491289349}
   bodyTrans: {fileID: 5769591908339262981}
   beSearchTrigger: {fileID: 316813748882225178}
+  searchTrigger: {fileID: 3566347593191160092}
   beHitTrigger: {fileID: 9020361017135710302}
   bodyCollider: {fileID: 2616922587087395095}
   uiHp: {fileID: 3586716274361854270}
   state: 0
+  totalHp: 100
+  hp: 0
+  isDie: 0
+  isRevive: 0
+  linked: 0
+  canNotAddForce: 0
+  canNotChangeHurt: 0
+  invincibleTime: 0
+  dieKeepTime: 0
+  totalDieKeepTime: 2
+  isNonAttack: 0
+  canHitFly: 1
   attackTime: 0
   totalAttack1Time: 1.8
   totalAttack2Time: 1.3
-  isNonAttack: 0
-  hptp: 0
-  isDie: 0
-  isRevive: 0
-  totalHp: 100
-  hp: 0
+  attackType: 1
+  bulletPrefab: {fileID: 7473170563405908938, guid: 5a7a8caaf3e79ec4f814d34467f0bf46, type: 3}
+  shootPos:
+  - {fileID: 8482269351142858204}
+  - {fileID: 776105162125788029}
+  - {fileID: 6220414675483084992}
+  shootTrack: 1
   attack1Infos:
   - damage: 20
     attackDir: {x: -1, y: 0, z: 0}
@@ -1037,75 +1045,57 @@ MonoBehaviour:
     changeHurt: 0
     repelValue: 10
   attackTriggers: []
-  attackType: 1
-  bulletPrefab: {fileID: 7473170563405908938, guid: 5a7a8caaf3e79ec4f814d34467f0bf46, type: 3}
-  shootPos:
-  - {fileID: 8482269351142858204}
-  - {fileID: 776105162125788029}
-  - {fileID: 6220414675483084992}
-  dieKeepTime: 0
-  totalDieKeepTime: 2
-  attackTarget: {fileID: 0}
-  shootTrack: 1
-  invincibleTime: 0
-  totalInvincibleTime: 0
+  targetTypes: 0400000005000000
   targetCharacter: {fileID: 0}
+  attackTarget: {fileID: 0}
   beTargetCharacter: []
-  searchTrigger: {fileID: 3566347593191160092}
-  targetTypes: 0400000005000000
-  canHitFly: 1
-  linked: 0
+  HitCols:
+  - {fileID: 5388987656270167698}
+  - {fileID: 1190225091429982147}
+  isSpirit: 1
+  isTran: 0
+  pc: {fileID: 0}
+  hptp: 0
   joint: {fileID: 0}
   rope: {fileID: 0}
-  hasHpUp: 0
   beLarger: 0
-  canHitFloat: 0
-  floatProbability: 0
-  attackToFloat: 0
-  floatTimes: 0
-  hasFloatTimes: 0
-  criticalChance: 0
-  criticalMultiplier: 0
-  canMove: 1
+  cookEffect: {fileID: 0}
+  matState: 1
+  spinee: {fileID: 0}
+  mesh: {fileID: 0}
+  mats: []
+  outlineMats:
+  - {fileID: 2100000, guid: b89f4b5b01e92784ab27611e2b014a10, type: 2}
+  - {fileID: 2100000, guid: 0d24ea357a09df448b788aed95b96541, type: 2}
+  - {fileID: 2100000, guid: b89f4b5b01e92784ab27611e2b014a10, type: 2}
+  outline1Mats: []
   foot: {fileID: 8639832132450015562}
   extraRiseGravity: -28.8
   extraFallGravity: -14.4
+  canMove: 1
   moveSpeed: 8
   beRepelValue: 0
   totalBeRepelValue: 100
   weakTime: 0
   totalWeakTime: 3
-  weakUpSpeed: 10
+  weakHitRate: 2
+  easyToGetHit: 0.2
+  isDamageReduction: 0
+  reductionDegree: 0
+  reductionEffect: {fileID: 0}
   decelerationRatio: 1
-  minHurtKeepTime: 0.2
-  hurtKeepTime: 0
-  hurtChangeVelocity: 1
   comaTime: 5
   pastComaTime: 0
-  isCaughtByCook: 0
-  isBeDropped: 0
+  floatState: 0
   maxTime: 1.5
   minTime: 0.1
   maxHeight: 12
   minHeight: 7
+  floatTime: 10
   maxRotateSpeed: 10
   minRotateSpeed: 4
-  floatTime: 10
   isFloat: 0
-  dropDamage: 100
   normalFallSpeed: 10
-  rapidFallSpeed: 30
-  curFallSpeed: 0
-  floatState: 0
-  matState: 1
-  spinee: {fileID: 0}
-  mesh: {fileID: 0}
-  mats: []
-  outlineMats:
-  - {fileID: 2100000, guid: b89f4b5b01e92784ab27611e2b014a10, type: 2}
-  - {fileID: 2100000, guid: 0d24ea357a09df448b788aed95b96541, type: 2}
-  - {fileID: 2100000, guid: b89f4b5b01e92784ab27611e2b014a10, type: 2}
-  outline1Mats: []
   playerMe: {fileID: 0}
   playerAni: {fileID: 0}
   playerCol: {fileID: 0}
@@ -1118,33 +1108,32 @@ MonoBehaviour:
   playerMesh: {fileID: 0}
   playerMats: []
   playerOut: []
-  canNotChangeHurt: 0
   soulPrefab: {fileID: 0}
   soulStartSpeed: 1
   isInvisible: 0
   invisibleTime: 0
-  easyToGetHit: 0.2
+  velocityAddition: 0
+  transmitTime: 0
+  haveTransmit: 0
+  portalsController: {fileID: 0}
   player: {fileID: 0}
+  playerID: 0
   id: 0
   costMp: 1
   totalSummonTime: 0.5
-  searchState: 0
-  attackDistance: 10
-  maxAttackDis: 0
-  minAttackDis: 0
-  needToChange: 0
   canFly: 1
+  isBack: 0
+  hasEffect: 0
   flyHeight: 0
   flyUpSpeed: 10
   sortingOrder: 2000
-  playerID: 0
-  hasEffect: 0
-  soulCollector: {fileID: 0}
-  isBack: 0
   runSpeed: 0
-  attributeUpEffect: {fileID: 0}
-  hasUp: 0
-  isFirst: 1
+  searchState: 0
+  soulCollector: {fileID: 0}
+  attackDistance: 10
+  maxAttackDis: 0
+  minAttackDis: 0
+  needToChange: 0
 --- !u!54 &8639832132491289349
 Rigidbody:
   m_ObjectHideFlags: 0

+ 10 - 9
ActionTowerDefense/Assets/Scripts/Demonic.cs

@@ -6,26 +6,27 @@ using UnityEngine;
 
 public class Demonic : MoveCharacter
 {
+    [Header("友方单位属性")]
     public PlayerController player;      //召唤师
+    public int playerID;
     public int id;
     public float costMp = 10;
     public float totalSummonTime = 0.5f;
-    public SearchState searchState;
-    public float attackDistance;
-    public float maxAttackDis, minAttackDis;
-    public bool needToChange;
     public bool canFly = false;
+    public bool isBack = false;         //往反方向走
     public float flyHeight;
     public float flyUpSpeed = 10;
     public int sortingOrder = 0;
+    public float runSpeed;
 
-    public int playerID;
-    public bool hasEffect = false;
-
+    [Header("友方单位组件")]
+    public SearchState searchState;
     public Collider soulCollector;
-    public bool isBack = false;         //往反方向走
 
-    public float runSpeed;
+    [Header("攻击")]
+    public float attackDistance;
+    public float maxAttackDis, minAttackDis;
+    public bool needToChange;
 
     private void Awake()
     {

+ 25 - 89
ActionTowerDefense/Assets/Scripts/Enemy.cs

@@ -18,59 +18,68 @@ public enum TargetType
 
 public enum SearchState
 {
-    NoTarget = 0,//搜索范围内没有目标
-    InSearchScope = 1,//在搜索范围内发现目标,但不在攻击范围内
-    InAttackScope = 2,//目标在攻击范围内
+    NoTarget = 0,       //搜索范围内没有目标
+    InSearchScope = 1,  //在搜索范围内发现目标,但不在攻击范围内
+    InAttackScope = 2,  //目标在攻击范围内
 }
 
 public class Enemy : MoveCharacter
 {
+    [Header("敌方单位属性")]
     public int id;
+    public int sortingOrder = 0;
+    public bool canFly = false;
+    public bool isBack = false; //往反方向走
+    public float flyHeight;
+    public float flyUpSpeed = 10;
     public float jumpSpeed = 10;
+    public float maxMoveSpeed, minMoveSpeed;
+    public float runSpeed;
+
+
+    [Header("敌方单位组件")]
     public SearchState searchState;
+
+    [Header("攻击")]
     public float attackDistance;
     public float maxAttackDis, minAttackDis;
     public bool needToChange;
-    public bool canFly = false;
-    public float flyHeight;
-    public float flyUpSpeed = 10;
-    public int sortingOrder = 0;
-
     public float attackRatio;
-    public float maxMoveSpeed, minMoveSpeed;
-    public float runSpeed;
-    public int dropSoul = 1;
 
-    
+    [Header("掉落魂")]
+    public int dropSoul = 1;
     public float dropSoulAngle = 60f;
 
+    [Header("冲刺攻击")]
+    public GameObject aimEffect;
+    public DashEffect dashEffect;
+
     [HideInInspector]
     public bool noOnSearchState;
     [HideInInspector]
     public bool isFindingPlayer;
     [HideInInspector]
     public bool isFindPlayer;
+
     public float hateDistance;
     [HideInInspector]
     public float distance;
     [HideInInspector]
     public Vector3 rushEndPos;
-    public GameObject aimEffect;
+
     public float aimDistance;
     public float rushTime;
     public float rushSpeed;
     [HideInInspector]
     public float time;
     public float readyCD;
-    public DashEffect dashEffect;
+
     [HideInInspector]
     public Vector3 targetDir;
     public bool haveDownRush;   //冲刺结束后是否可以接落地斩
     public bool rushHaveAttack; //冲刺是否带伤害
     public float downRushTime;
     public float finishRushTime;
-    public bool isBack = false; //往反方向走
-
 
     private void Awake()
     {
@@ -105,9 +114,6 @@ public class Enemy : MoveCharacter
 
         }
         OnState();
-
-
-
     }
 
     public override Vector3 GetMoveDir()
@@ -385,16 +391,6 @@ public class Enemy : MoveCharacter
                     ChangeState(CharacterState.Fall);
                     break;
                 }
-                //if (btnJumpPress || cacheJumpTime > 0)
-                //{
-                //    if (!airJumped && rb.velocity.y < airJumpSpeed)
-                //    {
-                //        airJumped = true;
-                //        AirJump();
-                //        break;
-                //    }
-                //}
-
                 rb.velocity += Vector3.up * extraRiseGravity * Time.deltaTime;
                 break;
             case CharacterState.Fall:
@@ -410,48 +406,8 @@ public class Enemy : MoveCharacter
                     }
                     break;
                 }
-                //if (foot.canStepPlayers.Count > 0)
-                //{
-                //    Jump(jumpSpeed / 2);
-                //    StepOther();
-                //    break;
-                //}
-                //if (foot.canStepEnemyList.Count > 0)
-                //{
-                //    Jump(jumpSpeed / 2);
-                //    StepEnemy();
-                //    break;
-                //}
-                //if (btnJumpPress || cacheJumpTime > 0)
-                //{
-                //    if (!airJumped)
-                //    {
-                //        airJumped = true;
-                //        AirJump();
-                //        break;
-                //    }
-                //    else if (canJumpTick >= runner.Tick)
-                //    {
-                //        Jump();
-                //        break;
-                //    }
-                //}
                 rb.velocity += Vector3.up * extraFallGravity * Time.deltaTime;
                 break;
-            //case CharacterState.Hurt:
-            //    if (hurtKeepTime <= 0 && rb.velocity.magnitude < hurtChangeVelocity)
-            //    {
-            //        ChangeState(CharacterState.Idle);
-            //        break;
-            //    }
-            //    if (!foot.TrigGround && !canFly)
-            //    {
-            //        rb.velocity += Vector3.up * extraFallGravity * Time.deltaTime;
-            //    }
-            //    Vector3 vel = rb.velocity;
-            //    vel.x = vel.x * (1 - decelerationRatio * Time.deltaTime);
-            //    rb.velocity = vel;
-            //    break;
             case CharacterState.Attack:
                 if (attackTime <= 0)
                 {
@@ -766,27 +722,7 @@ public class Enemy : MoveCharacter
                 break;
             case CharacterState.Fall:
                 aniCollider.Play("Fall", 0, 0);
-                //animalAni.SetInteger("state", (int)PlayerState.Fall);
                 break;
-            //case CharacterState.Hurt:
-            //    switch (oldState)
-            //    {
-            //        case CharacterState.ReadyToRush:
-            //        case CharacterState.RushAttack:
-            //        case CharacterState.ReadyToDownRush:
-            //        case CharacterState.DownRush:
-            //        case CharacterState.Rush:
-            //            state = oldState;
-            //            beRepelValue = totalBeRepelValue;
-            //            break;
-            //        default:
-            //            ani.Play("hitted", 0, 0);
-            //            aniCollider.Play("Hurt", 0, 0);
-            //            invincibleTime = totalInvincibleTime;
-            //            hurtKeepTime = minHurtKeepTime;
-            //            break;
-            //    }
-            //    break;
             case CharacterState.Float:
                 canMove = false;
                 break;

+ 0 - 12
ActionTowerDefense/Assets/Scripts/PlayerController.cs

@@ -1900,18 +1900,6 @@ public class PlayerController : MoveCharacter
         {
             demonic.flyHeight = demonic.transform.position.y;
         }
-
-        if (id == 3)
-        {
-            if ((int)spirits.currentSpirit == 0)
-            {
-                if (!demonicObj.GetComponent<Demonic>().hasEffect)
-                {
-                    demonicObj.GetComponent<Demonic>().hasEffect = true;
-                    Instantiate(spirits.floatEffect, demonicObj.transform.position, new Quaternion(0, 0, 0, 0), demonicObj.transform);
-                }
-            }
-        }
         demonic.player = this;
         demonic.Init();
         demonic.SetSortingOrder(demonic.sortingOrder + demonicId[id]);

+ 0 - 2
ActionTowerDefense/Assets/Scripts/Spirits/Base_Spirits/Spirits.cs

@@ -15,8 +15,6 @@ public class Spirits : MonoBehaviour
 
     public int types;               //英灵数量
 
-    public GameObject floatEffect;  //漂浮特效预制体
-
     public SpiritType currentSpirit = SpiritType.Float;
     public int hasSpirits;          //已有的英灵牌数量
     public int maxCards;            //最多有多少张英灵牌

+ 2 - 0
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Float.cs

@@ -10,6 +10,7 @@ public class Spirits_Float : MonoBehaviour
     private float curHeight;
     private float speed = 1;
     private Vector3 origPos;
+    public GameObject effect;
 
     private void Start()
     {
@@ -18,6 +19,7 @@ public class Spirits_Float : MonoBehaviour
         height = Random.Range(minHeight, maxHeight);
         Demonic dem = GetComponent<Demonic>();
         dem.flyHeight = height;
+        Instantiate(effect, transform.position, new Quaternion(0, 0, 0, 0), transform);
     }
 
     private void MoveToHeight()