1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using BehaviorDesigner.Runtime;
- using BehaviorDesigner.Runtime.Tasks;
- /// <summary>
- /// 行为 使用技能
- /// </summary>
- public class ActionSkill : Action
- {
- /// <summary>
- /// 技能索引
- /// </summary>
- public int skillIndex = 0;
- /// <summary>
- /// 攻击动作
- /// </summary>
- public string attackAnimation = "UniqueSkill";
- /// <summary>
- /// 角色
- /// </summary>
- private Role role = null;
- /// <summary>
- /// 目标
- /// </summary>
- private Role target = null;
- private float aniTime = 0;
- private bool getInfo = false;
- private float checkTime = 0.1f;
- public override void OnAwake()
- {
- role = GetComponent<Role>();
- }
- public override void OnStart()
- {
- Transform tran = role.mBehaviorTree.GetVariable("target").GetValue() as Transform;
- target = tran.GetComponent<Role>();
- role.mSkillEvent.PlayerSkill = SkillEvent;
- role.PlayAnimation(attackAnimation);
- checkTime = 0.1f;
- getInfo = false;
- }
- /// <summary>
- /// 攻击帧事件
- /// </summary>
- private void SkillEvent()
- {
- X2Battle.X2BattleManager.Instance.mBulletModel.OnCastSkill(
- role.mData.UID, role.mData.GetSkillBisha(), false, X2Battle.EBulletCastPoint.ECAST_POINT_DEFLUAT,target.mData.UID, false);
- }
- public override TaskStatus OnUpdate()
- {
- // 获取争取的信息
- if (getInfo == false)
- {
- checkTime -= Time.deltaTime;
- if (checkTime < 0)
- {
- return TaskStatus.Success;
- }
- // 获取动画层 0 指Base Layer.
- AnimatorStateInfo stateinfo = role.mAnimator.GetCurrentAnimatorStateInfo(0);
- if (stateinfo.IsName(attackAnimation) == false)
- {
- return TaskStatus.Running;
- }
- aniTime = role.mAnimator.GetCurrentAnimatorClipInfo(0)[0].clip.length;
- getInfo = true;
- }
- // 开始计时
- aniTime -= Time.deltaTime * role.mAnimator.speed;
- if (aniTime > 0)
- {
- return TaskStatus.Running;
- }
- return TaskStatus.Success;
- }
- }
|