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