123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- using System;
- using BehaviorDesigner.Runtime.Tasks;
- using ExtensionMethods;
- using UnityEngine;
- public class DahalAIAction
- {
- [TaskDescription("Dahal攻击")]
- [TaskCategory("Enemy/Dahal")]
- public class DahalAttack : BehaviorDesigner.Runtime.Tasks.Action
- {
- private Transform player
- {
- get
- {
- return R.Player.Transform;
- }
- }
- public override void OnAwake()
- {
- this.action = base.GetComponent<DahalAction>();
- }
- public override void OnStart()
- {
- int dir = InputSetting.JudgeDir(this.transform.position, this.player.position);
- switch (this.atkType)
- {
- case DahalAIAction.DahalAttack.AtkType.Atk1:
- this.action.Attack1(dir);
- break;
- case DahalAIAction.DahalAttack.AtkType.Atk2:
- this.action.Attack2(dir);
- break;
- case DahalAIAction.DahalAttack.AtkType.Atk3:
- this.action.Attack3(dir);
- break;
- case DahalAIAction.DahalAttack.AtkType.Atk4:
- this.action.Attack4(dir);
- break;
- case DahalAIAction.DahalAttack.AtkType.Atk5:
- this.action.Attack5(dir);
- break;
- case DahalAIAction.DahalAttack.AtkType.Atk6:
- this.action.Attack6(dir);
- break;
- case DahalAIAction.DahalAttack.AtkType.Atk7:
- this.action.Attack7(dir);
- break;
- }
- }
- public override TaskStatus OnUpdate()
- {
- return TaskStatus.Success;
- }
- public DahalAIAction.DahalAttack.AtkType atkType;
- private DahalAction action;
- public enum AtkType
- {
- Atk1,
- Atk2,
- Atk3,
- Atk4,
- Atk5,
- Atk6,
- Atk7
- }
- }
- [TaskCategory("Enemy/Dahal")]
- [TaskDescription("Dahal攻击方向为面朝方向,二阶段使用")]
- public class DahalAttackFaceDir : BehaviorDesigner.Runtime.Tasks.Action
- {
- public override void OnAwake()
- {
- this._action = base.GetComponent<DahalAction>();
- this._eAttr = base.GetComponent<EnemyAttribute>();
- }
- public override void OnStart()
- {
- this._action.ChangeFace(this._eAttr.faceDir * -1);
- switch (this.atkType)
- {
- case DahalAIAction.DahalAttackFaceDir.AtkType.Atk1:
- this._action.Attack1(this._eAttr.faceDir);
- break;
- case DahalAIAction.DahalAttackFaceDir.AtkType.Atk2:
- this._action.Attack2(this._eAttr.faceDir);
- break;
- case DahalAIAction.DahalAttackFaceDir.AtkType.Atk3:
- this._action.Attack3(this._eAttr.faceDir);
- break;
- case DahalAIAction.DahalAttackFaceDir.AtkType.Atk4:
- this._action.Attack4(this._eAttr.faceDir);
- break;
- case DahalAIAction.DahalAttackFaceDir.AtkType.Atk5:
- this._action.Attack5(this._eAttr.faceDir);
- break;
- case DahalAIAction.DahalAttackFaceDir.AtkType.Atk6:
- this._action.Attack6(this._eAttr.faceDir);
- break;
- case DahalAIAction.DahalAttackFaceDir.AtkType.Atk7:
- this._action.Attack7(this._eAttr.faceDir);
- break;
- }
- }
- public override TaskStatus OnUpdate()
- {
- return TaskStatus.Success;
- }
- public DahalAIAction.DahalAttackFaceDir.AtkType atkType;
- private DahalAction _action;
- private EnemyAttribute _eAttr;
- public enum AtkType
- {
- Atk1,
- Atk2,
- Atk3,
- Atk4,
- Atk5,
- Atk6,
- Atk7
- }
- }
- [TaskCategory("Enemy/Dahal")]
- [TaskDescription("Dahal2阶段翻滚")]
- public class WaitBackToNormal : BehaviorDesigner.Runtime.Tasks.Action
- {
- public override void OnAwake()
- {
- this._action = base.GetComponent<DahalAction>();
- }
- public override TaskStatus OnUpdate()
- {
- if (this._action.stateMachine.currentState.IsInArray(DahalAction.HurtSta))
- {
- return TaskStatus.Failure;
- }
- return (!this._action.stateMachine.currentState.IsInArray(DahalAction.NormalSta)) ? TaskStatus.Running : TaskStatus.Success;
- }
- private DahalAction _action;
- }
- [TaskCategory("Enemy/Dahal")]
- [TaskDescription("Dahal闪避")]
- public class DahalSideStep : BehaviorDesigner.Runtime.Tasks.Action
- {
- public override void OnAwake()
- {
- this._action = base.GetComponent<DahalAction>();
- }
- public override void OnStart()
- {
- this._action.SideStep();
- }
- public override TaskStatus OnUpdate()
- {
- return (!(this._action.stateMachine.currentState == "GroundDodge")) ? TaskStatus.Success : TaskStatus.Running;
- }
- private DahalAction _action;
- }
- [TaskDescription("向前移动一段距离,距离参数在属性里设置")]
- [TaskCategory("Enemy/Dahal")]
- public class DahalMoveSomeDistance : BehaviorDesigner.Runtime.Tasks.Action
- {
- public override void OnAwake()
- {
- this.eAttr = base.GetComponent<EnemyAttribute>();
- this.enemy = base.GetComponent<DahalAction>();
- }
- public override void OnStart()
- {
- if (this.randomDis)
- {
- this.dis = UnityEngine.Random.Range(this.randomMin, this.randomMax);
- }
- this._aimPosX = this.enemy.transform.position.x + (float)this.eAttr.faceDir * this.dis;
- this._aimPosX = Mathf.Clamp(this._aimPosX, GameArea.EnemyRange.min.x + this.eAttr.bounds.size.x, GameArea.EnemyRange.max.x - this.eAttr.bounds.size.x);
- }
- public override TaskStatus OnUpdate()
- {
- if (!this.enemy.DahyalAutoMove(this.moveType))
- {
- return TaskStatus.Failure;
- }
- bool flag = InputSetting.JudgeDir(this.enemy.transform.position.x, this._aimPosX) == this.eAttr.faceDir;
- if (flag)
- {
- return TaskStatus.Running;
- }
- if (this.isArrivedStopAnim)
- {
- return (!this.enemy.StopMoveToIdle()) ? TaskStatus.Failure : TaskStatus.Success;
- }
- return TaskStatus.Success;
- }
- [BehaviorDesigner.Runtime.Tasks.Tooltip("移动距离")]
- public float dis;
- public bool randomDis;
- public float randomMin;
- public float randomMax;
- [BehaviorDesigner.Runtime.Tasks.Tooltip("到达了后是否停止播放移动动画")]
- public bool isArrivedStopAnim = true;
- [BehaviorDesigner.Runtime.Tasks.Tooltip("1普通移动 2快速移动")]
- public int moveType;
- private EnemyAttribute eAttr;
- private DahalAction enemy;
- private float _aimPosX;
- }
- [TaskDescription("移动距离主角的某个位置范围")]
- [TaskCategory("Enemy/Dahal")]
- public class DahalMoveDistanceRange : BehaviorDesigner.Runtime.Tasks.Action
- {
- private Transform player
- {
- get
- {
- return R.Player.Transform;
- }
- }
- public override void OnAwake()
- {
- this.action = base.GetComponent<DahalAction>();
- this.eAttr = base.GetComponent<EnemyAttribute>();
- }
- public override void OnStart()
- {
- this.finalMoveLen = UnityEngine.Random.Range(this.moveRangeMin, this.moveRangeMax);
- int num = (UnityEngine.Random.Range(0, 2) != 0) ? -1 : 1;
- this.aimPos = this.player.transform.position.x + this.finalMoveLen * (float)num;
- int dir = InputSetting.JudgeDir(this.transform.position.x, this.aimPos);
- this.action.TurnRound(dir);
- this.aimPos = Mathf.Clamp(this.aimPos, GameArea.EnemyRange.min.x + this.eAttr.bounds.size.x, GameArea.EnemyRange.max.x - this.eAttr.bounds.size.x);
- }
- public override TaskStatus OnUpdate()
- {
- if (!this.action.DahyalAutoMove(this.moveType))
- {
- return TaskStatus.Failure;
- }
- if (InputSetting.JudgeDir(this.action.transform.position.x, this.aimPos) != this.eAttr.faceDir)
- {
- return (!this.action.StopMoveToIdle()) ? TaskStatus.Failure : TaskStatus.Success;
- }
- float x = Mathf.Abs(this.player.position.x - this.transform.position.x);
- if (!MathfX.isInRange(x, this.moveRangeMin, this.moveRangeMax))
- {
- return TaskStatus.Running;
- }
- this.action.StopMoveToIdle();
- return TaskStatus.Success;
- }
- private DahalAction action;
- private EnemyAttribute eAttr;
- public float moveRangeMin;
- public float moveRangeMax;
- [BehaviorDesigner.Runtime.Tasks.Tooltip("1普通移动 2快速移动")]
- public int moveType;
- private float aimPos;
- private float finalMoveLen;
- }
- }
|