ソースを参照

整理character脚本

SZAND\msx_2 1 年間 前
コミット
c04bb6c10d

+ 12 - 9
ActionTowerDefense/Assets/Resources/Prefab/Boss/Boss_YuMenGuan.prefab

@@ -9,7 +9,7 @@ GameObject:
   serializedVersion: 6
   m_Component:
   - component: {fileID: 6459001683917408033}
-  m_Layer: 15
+  m_Layer: 16
   m_Name: Body
   m_TagString: Untagged
   m_Icon: {fileID: 0}
@@ -110,7 +110,7 @@ GameObject:
   - component: {fileID: 6069085609270885073}
   - component: {fileID: 5217712517297835056}
   - component: {fileID: 3377671071202039733}
-  m_Layer: 15
+  m_Layer: 16
   m_Name: BeHitTrigger
   m_TagString: Untagged
   m_Icon: {fileID: 0}
@@ -227,7 +227,7 @@ GameObject:
   m_Component:
   - component: {fileID: 5669356131851076493}
   - component: {fileID: 925594141286007562}
-  m_Layer: 15
+  m_Layer: 16
   m_Name: BodyCollider
   m_TagString: Untagged
   m_Icon: {fileID: 0}
@@ -272,7 +272,7 @@ GameObject:
   m_Component:
   - component: {fileID: 901824162977467732}
   - component: {fileID: 2776251058442384869}
-  m_Layer: 15
+  m_Layer: 16
   m_Name: Colliders
   m_TagString: Untagged
   m_Icon: {fileID: 0}
@@ -391,7 +391,7 @@ GameObject:
   - component: {fileID: 5440846222648032754}
   - component: {fileID: 5440846222648032765}
   - component: {fileID: 4968756899114129375}
-  m_Layer: 15
+  m_Layer: 16
   m_Name: Boss_YuMenGuan
   m_TagString: Enemy
   m_Icon: {fileID: 0}
@@ -551,6 +551,9 @@ MonoBehaviour:
   isInvisible: 0
   invisibleTime: 0
   velocityAddition: 0
+  transmitTime: 0
+  haveTransmit: 0
+  portalsController: {fileID: 0}
   easyToGetHit: 0.2
   isDamageReduction: 0
   reductionDegree: 0
@@ -635,7 +638,7 @@ GameObject:
   - component: {fileID: 2385850797131186543}
   - component: {fileID: 5461569872495115226}
   - component: {fileID: 478072938412589135}
-  m_Layer: 8
+  m_Layer: 16
   m_Name: HP
   m_TagString: Untagged
   m_Icon: {fileID: 0}
@@ -742,7 +745,7 @@ GameObject:
   - component: {fileID: 9134347361501008817}
   - component: {fileID: 3333436509305836838}
   - component: {fileID: 7573527827155227431}
-  m_Layer: 15
+  m_Layer: 16
   m_Name: Spine
   m_TagString: Untagged
   m_Icon: {fileID: 0}
@@ -963,7 +966,7 @@ GameObject:
   - component: {fileID: 3837615663371647561}
   - component: {fileID: 5872138694498903774}
   - component: {fileID: 7461681167498147446}
-  m_Layer: 8
+  m_Layer: 16
   m_Name: UI
   m_TagString: Untagged
   m_Icon: {fileID: 0}
@@ -1064,7 +1067,7 @@ GameObject:
   - component: {fileID: 6463693681413461392}
   - component: {fileID: 4282168739455826133}
   - component: {fileID: 1388674300046094982}
-  m_Layer: 8
+  m_Layer: 16
   m_Name: name
   m_TagString: Untagged
   m_Icon: {fileID: 0}

+ 0 - 17
ActionTowerDefense/Assets/Scripts/Bullet.cs

@@ -33,9 +33,6 @@ public class Bullet : MonoBehaviour
     private Vector3 curDir;
     private bool hasBack = false;       //已经回来了
 
-    [Header("漂浮")]
-    public bool toFloat = false;
-
     private void Awake()
     {
         //owner = GetComponentInParent<Character>();
@@ -153,20 +150,6 @@ public class Bullet : MonoBehaviour
                         default:
                             break;
                     }
-                    if (toFloat)
-                    {
-                        owner.attackToFloat = false;
-                        owner.hasFloatTimes += 1;
-                        if (owner.hasFloatTimes == owner.floatTimes)
-                        {
-                            owner.canHitFloat = false;
-                        }
-                        toFloat = false;
-                        if (hitTrigger.tag != "EnemyTower")
-                        {
-                            hitTrigger.owner.GetComponent<MoveCharacter>().FloatStateOn();
-                        }
-                    }
                 }
             }
         }

+ 82 - 78
ActionTowerDefense/Assets/Scripts/Character.cs

@@ -4,13 +4,14 @@ using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
+//角色状态
 public enum CharacterState
 {
     None = 0,
     Idle = 1,
     Run = 2,
-    Rise = 3,//空中上升
-    Fall = 4,//空中下落
+    Rise = 3,               //空中上升
+    Fall = 4,               //空中下落
     //Hurt = 5,
     Attack = 6,
     KeepAttack = 7,
@@ -20,109 +21,120 @@ public enum CharacterState
     Die = 11,
     Weak = 12,
     PullRope = 13,
-    Spirits = 14,   //召唤英灵
-    Float = 15,   //空中漂浮
-    FindPlayer = 16,    //寻找玩家
-    ReadyToRush = 17,   //瞄准准备冲刺
+    Spirits = 14,           //召唤英灵
+    Float = 15,             //空中漂浮
+    FindPlayer = 16,        //寻找玩家
+    ReadyToRush = 17,       //瞄准准备冲刺
     ReadyToDownRush = 18,   //准备落地冲刺
-    DownRush = 19,  //落地冲刺
-    FinishRush = 20,    //结束冲刺
-    Coma = 21,      //昏迷
-    RushAttack, //带攻击的冲刺
+    DownRush = 19,          //落地冲刺
+    FinishRush = 20,        //结束冲刺
+    Coma = 21,              //昏迷
+    RushAttack,             //带攻击的冲刺
     Transfiguration = 23,   //变身
 }
 
+//攻击类型
 public enum AttackType
 {
-    Melee = 0,//近战
-    Shoot = 1,//射击
-    Dash = 2,   //英灵刺客
+    Melee = 0,      //近战
+    Shoot = 1,      //射击
+    Dash = 2,       //英灵刺客
 }
 
+//血量上限增加类型
 public enum HpUpType
 {
-    Degree = 0,
-    Add = 1,
-    Fixed = 2,
+    Degree = 0,     //按一定比例加血
+    Add = 1,        //直接加血
+    Fixed = 2,      //加固定血量
 }
 
 public class Character : MonoBehaviour
 {
-    public bool isTran;
-    public PlayerController pc;
-    public bool isSpirit;
-
-    public GameObject[] HitCols;
-
-    public int cookNum;   //能做成多少串肉
-
+    [Header("骨骼")]
     public SkeletonMecanim mecanim;
     public Skeleton skeleton;
+    [HideInInspector]
     public MeshRenderer meshRenderer;
 
+    [Header("动画控制器")]
     public Animator ani;
     public Animator aniCollider;
+
+    [Header("组件")]
     public Rigidbody rb;
     public Transform bodyTrans;
     public BeSearchTrigger beSearchTrigger;
+    public SearchTrigger searchTrigger;
     public BeHitTrigger beHitTrigger;
     public GameObject bodyCollider;
     public UIHP uiHp;
 
+    [Header("角色状态")]
     public CharacterState state;
-    [HideInInspector]
-    public float attackTime;
-    public float totalAttack1Time = 0.5f;
-    public float totalAttack2Time = 0.5f;
-
-    public bool isNonAttack = false;
-
-    public HpUpType hptp;
-    public bool isDie = false;
-    public bool isRevive;
     public int totalHp = 100;
     public int hp;
-    public List<AttackInfo> attack1Infos;
-    public List<AttackInfo> attack2Infos;
-    public List<AttackTrigger> attackTriggers;
-    public AttackType attackType;
-    public GameObject bulletPrefab;
-    public List<Transform> shootPos;
+    public bool isDie = false;      //已死亡
+    public bool isRevive;           //从虚弱状态恢复中
+    public bool linked;             //被铁链连着
+    public bool canNotAddForce;     //不会被打飞
+    public bool canNotChangeHurt;   //不会被打虚弱
+    [HideInInspector]
+    public float invincibleTime;    //无敌时间
+
+    [Header("死亡后多久尸体消失")]
     [HideInInspector]
     public float dieKeepTime;
     public float totalDieKeepTime = 2f;
-    public Character attackTarget;
-    public bool shootTrack = false;
+
+    [Header("普通攻击信息")]
     [HideInInspector]
-    public float invincibleTime;
-    //public float totalInvincibleTime = 2f;
+    public bool isNonAttack = false;            //无普攻
+    public bool canHitFly;
+    public float attackTime;
+    public float totalAttack1Time = 0.5f;
+    public float totalAttack2Time = 0.5f;
+    public AttackType attackType;               //攻击类型
+    public GameObject bulletPrefab;             //远程攻击的子弹
+    public List<Transform> shootPos;            //远程攻击的子弹发射位置
+    public bool shootTrack = false;             //远程攻击是否追踪目标
+    public List<AttackInfo> attack1Infos;       //普攻1信息(出场攻击)
+    public List<AttackInfo> attack2Infos;       //普攻2信息
+    public List<AttackTrigger> attackTriggers;  //普攻触发器,敌方进入后播放动画进行攻击
+
+    [Header("目标")]
+    public List<TargetType> targetTypes;
     public Character targetCharacter;
+    public Character attackTarget;
     public List<Character> beTargetCharacter = new List<Character>(); //被哪些锁定
-    public SearchTrigger searchTrigger;
-    public List<TargetType> targetTypes;
-    public bool canHitFly;
-    public bool linked;
+
+    [Header("被攻击的触发器")]
+    public GameObject[] HitCols;
+
+    [Header("是否为英灵、是否为变身形态英灵")]
+    public bool isSpirit;
+    public bool isTran;
+    [HideInInspector]
+    public PlayerController pc;
+
+    [Header("血量上限增加类型")]
+    public HpUpType hptp;
+
+    [Header("被铁链连着")]
     public RopeJoint joint;
     public CharacterRope rope;
 
-    public bool hasHpUp = false;
-
-    private float toLargeSize = 0;
-    private Vector3 speed = new Vector3(1, 1, 0);
+    [Header("体型增大")]
     public bool beLarger = false;
+    private float toLargeSize = 0;                  //变大程度
+    private Vector3 speed = new Vector3(1, 1, 0);   //变大速度
 
-    public bool canHitFloat;                //是否概率使敌方漂浮
-    public float floatProbability;          //漂浮概率
-    public bool attackToFloat = false;      //攻击使敌方漂浮
-    public int floatTimes;                  //漂浮次数
-    public int hasFloatTimes;
-    //public bool isSoulUnstable;             //灵魂不稳定状态
-    //public float soulUnstableTime;          //灵魂不稳定状态时间
-    public float criticalChance;            //暴击率
-    public float criticalMultiplier;       //暴击倍率
+    [Header("特效")]
+    public GameObject cookEffect;       //吃串加血
 
     public virtual void Init()
     {
+        //确保组件不丢失
         if (!mecanim)
         {
             mecanim = GetComponentInChildren<SkeletonMecanim>();
@@ -140,6 +152,7 @@ public class Character : MonoBehaviour
             ani = GetComponentInChildren<Animator>();
         }
 
+        //血量重置
         hp = totalHp;
         if (!isNonAttack)
         {
@@ -147,6 +160,7 @@ public class Character : MonoBehaviour
         }
         ChangeState(CharacterState.Idle);
 
+        //被链接状态重置
         linked = false;
         if (joint)
         {
@@ -179,25 +193,27 @@ public class Character : MonoBehaviour
 
     public virtual void OnState()
     {
-
     }
 
     public virtual void ChangeState(CharacterState newState)
     {
-
     }
 
     public virtual void BeHit(int damage, Vector3 force, bool changeHurt, float repelValue)
     {
+        //无敌状态下免伤
         if (invincibleTime > 0)
         {
             return;
         }
+
+        //非无敌状态扣血
         hp -= damage;
         uiHp.Show(hp, totalHp);
         if (hp <= 0)
         {
-            rb.AddForce(force);
+            if(!canNotAddForce)
+                rb.AddForce(force);
             ChangeState(CharacterState.Die);
             return;
         }
@@ -216,10 +232,6 @@ public class Character : MonoBehaviour
         }
         GameObject bulletObj = PoolManager.Instantiate(bulletPrefab);
         Bullet bullet = bulletObj.GetComponent<Bullet>();
-        if (attackToFloat)
-        {
-            bullet.toFloat = true;
-        }
         Vector3 attackDir = attackInfo.attackDir.normalized;
         if (bodyTrans.localScale.x < 0)
         {
@@ -270,14 +282,6 @@ public class Character : MonoBehaviour
 
     public virtual void Attack2()
     {
-        if (canHitFloat)
-        {
-            float k = Random.Range(0, 100);
-            if (hasFloatTimes == 0 || k <= floatProbability)
-            {
-                attackToFloat = true;
-            }
-        }
         Vector3 leftDir = GetMoveDir();
         if (leftDir.x > 0.3f)
         {
@@ -327,8 +331,7 @@ public class Character : MonoBehaviour
         meshRenderer.sortingOrder = order;
     }
 
-    public GameObject cookEffect = null;
-
+    //吃串增加血量上限
     public void HpUp(float value, float larger)
     {
         cookEffect.transform.GetChild(0).gameObject.SetActive(true);
@@ -354,6 +357,7 @@ public class Character : MonoBehaviour
         beLarger = true;
     }
 
+    //体型变大
     public void Enlarge()
     {
         transform.localScale = Vector3.SmoothDamp(transform.localScale, new Vector3(1, 1, 1) * toLargeSize, ref speed, 0.3f);

+ 9 - 5
ActionTowerDefense/Assets/Scripts/MoveCharacter.cs

@@ -84,7 +84,9 @@ public class MoveCharacter : Character
     public MeshRenderer playerMesh;
     public Material[] playerMats;
     public Material[] playerOut;
-    public bool canNotChangeHurt;
+
+
+
     public GameObject soulPrefab;
     public float soulStartSpeed = 1f;
     public bool isInvisible;
@@ -432,9 +434,9 @@ public class MoveCharacter : Character
             uiHp.Show(hp, totalHp);
             if (hp <= 0)
             {
-
                 ChangeState(CharacterState.Die);
-                rb.AddForce(force);
+                if(!canNotAddForce)
+                    rb.AddForce(force);
                 return;
             }
             //if (isSoulUnstable)
@@ -452,14 +454,16 @@ public class MoveCharacter : Character
             beRepelValue -= repelValue;
             if (changeHurt && state == CharacterState.Weak)
             {
-                rb.AddForce(force * weakHitRate);
+                if (!canNotAddForce)
+                    rb.AddForce(force * weakHitRate);
             }
             else
             {
                 if (changeHurt && beRepelValue <= 0)
                 {
                     ChangeState(CharacterState.Weak);
-                    rb.AddForce(force);
+                    if (!canNotAddForce)
+                        rb.AddForce(force);
                 }
             }
 

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

@@ -1845,12 +1845,6 @@ public class PlayerController : MoveCharacter
         }
     }
 
-    public bool canArrowHitFloat;   //可以让弓箭手攻击概率漂浮
-    public float probability;       //攻击的漂浮概率
-    public float gainAbilityProbability;    //弓箭手获得漂浮能力的概率
-    public int abilityTimes;        //弓箭手释放漂浮能力的次数
-    private bool isFirst = true;
-
     public void Summon(int id)
     {
         if (id >= demonicPrefabs.Count)
@@ -1875,22 +1869,6 @@ public class PlayerController : MoveCharacter
         uiMp.Show(mp, totalMp);
         GameObject demonicObj = PoolManager.Instantiate(prefab);
         Demonic demonic = demonicObj.GetComponent<Demonic>();
-        if (canArrowHitFloat && id == 0)
-        {
-            float k = UnityEngine.Random.Range(0, 100);
-            if (isFirst || k <= gainAbilityProbability)
-            {
-                isFirst = false;
-                demonic.attackToFloat = true;
-                demonic.floatProbability = probability;
-                demonic.floatTimes = abilityTimes;
-            }
-        }
-        if (id == 2)
-        {
-            demonic.criticalChance = criticalChance;
-            demonic.criticalMultiplier = criticalMultiplier;
-        }
         demonic.id = id;
         demonic.playerID = playerId;
         if (!demonicDic.ContainsKey(id))

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

@@ -10,8 +10,6 @@ public class Spirits_Float : MonoBehaviour
     private float curHeight;
     private float speed = 1;
     private Vector3 origPos;
-    public float floatProbability;          //漂浮概率
-    public int abilityTimes;                //攻击使漂浮的次数
 
     private void Start()
     {
@@ -20,8 +18,6 @@ public class Spirits_Float : MonoBehaviour
         height = Random.Range(minHeight, maxHeight);
         Demonic dem = GetComponent<Demonic>();
         dem.flyHeight = height;
-        dem.floatProbability = floatProbability;
-        dem.floatTimes = abilityTimes;
     }
 
     private void MoveToHeight()

+ 0 - 3
ActionTowerDefense/Assets/Scripts/Spirits/Trans_Assassin.cs

@@ -37,8 +37,6 @@ public class Trans_Assassin : MonoBehaviour
     {
         player = GetComponentInParent<PlayerController>();
         player.airJumpNumber = 2;
-        player.criticalChance = criticalChance;
-        player.criticalMultiplier = criticalMultiplier;
         distance = rushSpeed * rushTime/2;
     }
     // Update is called once per frame
@@ -154,7 +152,6 @@ public class Trans_Assassin : MonoBehaviour
 
     private void OnDisable()
     {
-        player.criticalChance = 0;
         player.airJumpNumber = 1;
         player.bodyTrans.transform.localScale = transform.GetChild(0).localScale;
         player.isUltimate = false;

+ 0 - 9
ActionTowerDefense/Assets/Scripts/Spirits/Trans_Float.cs

@@ -15,19 +15,10 @@ public class Trans_Float : MonoBehaviour
     private void Start()
     {
         controller = GetComponentInParent<PlayerController>();
-        controller.canArrowHitFloat = true;
-        controller.probability = floatProbability;
-        controller.gainAbilityProbability = gainAbilityProbability;
-        controller.abilityTimes = abilityTimes;
         controller.maxFlyHeight = maxFlyHeight;
         controller.canMove = true;
     }
 
-    private void OnDisable()
-    {
-        controller.canArrowHitFloat = false;
-    }
-
     private void DeMp(int deMP)
     {
         controller.mp -= deMP;

+ 1 - 1
ActionTowerDefense/ProjectSettings/DynamicsManager.asset

@@ -18,7 +18,7 @@ PhysicsManager:
   m_ClothInterCollisionDistance: 0.1
   m_ClothInterCollisionStiffness: 0.2
   m_ContactsGeneration: 1
-  m_LayerCollisionMatrix: ffe7ffffffe7ffffffe7fffffff7ffffffe7ffffffe7ffff3f40ffff3f40ffff3f40ffff3fe0ffff3fe0ffff0090ffff08a8ffff3fb6ffffff87ffff3ffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+  m_LayerCollisionMatrix: ffe7ffffffe7ffffffe7fffffff7ffffffe7ffffffe7ffff3f40feff3f40feff3f40feff3fe0feff3fe0feff0090feff08a8feff3fb6feffff87feff3ffefeff3f00feffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
   m_AutoSimulation: 1
   m_AutoSyncTransforms: 0
   m_ReuseCollisionCallbacks: 1

+ 1 - 1
ActionTowerDefense/ProjectSettings/TagManager.asset

@@ -27,7 +27,7 @@ TagManager:
   - Platform
   - Bullet
   - Portal
-  - 
+  - Boss
   - 
   - 
   -