|
|
@@ -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);
|