public override string GetAnimationName() { string animName = ""; AttackStepInfo info = GetAttackStepInfo(); if (null != info) { animName = info.m_animName; } return(animName); }
public AttackStepInfo GetAttackStepInfo() { AttackStepInfo info = null; m_animationNameList.TryGetValue(m_curAttackStep, out info); if (info == null) { IsFinished = true; } return(info); }
void PlaySkillEventAnimation() { AttackStepInfo info = GetAttackStepInfo(); if (info == null || info.m_skillType == m_currentType) { return; } m_currentType = info.m_skillType; StopPlaySkillEventAnimation(); if (info.m_skillType == Actor.ENSkillStepType.enSlash) {//冲锋有动作融合 //计算冲刺的权重 if (m_skillInfo.SlashMotionDistance > 0 && m_skillTarget != null) { Vector3 direction = m_skillTarget.RealPos - CurrentActor.RealPos; direction.y = 0f; float targetWeight = (direction.magnitude + m_skillInfo.SlashTargetPosOffset) / m_skillInfo.SlashMotionDistance; string blendAnimName = m_skillInfo.SlashBlendMotionName; if (targetWeight < 0) { targetWeight = 0; } CurrentActor.PlaySkillEventAnimation(m_skillInfo.ID, (int)info.m_skillType, info.m_animName, Actor.ENAnimType.enBlend, new float[] { (int)AnimationBlendMode.Blend, targetWeight, 0 }); CurrentActor.PlaySkillEventAnimation(m_skillInfo.ID, (int)info.m_skillType + 1, blendAnimName, Actor.ENAnimType.enBlend, new float[] { (int)AnimationBlendMode.Blend, 1 - targetWeight, 0 }); return; } } else if (info.m_skillType == Actor.ENSkillStepType.enRelease) {//释放有动作融合 if (m_skillInfo.ReleaseMotionDistance > 0 && m_skillTarget != null) { Vector3 direction = m_skillTarget.RealPos - CurrentActor.RealPos; direction.y = 0f; float targetWeight = (direction.magnitude + m_skillInfo.ReleaseTargetPosOffset) / m_skillInfo.ReleaseMotionDistance; string blendAnimName = m_skillInfo.ReleaseBlendMotionName; if (!string.IsNullOrEmpty(blendAnimName)) { if (targetWeight < 0) { targetWeight = 0; } CurrentActor.PlaySkillEventAnimation(m_skillInfo.ID, (int)info.m_skillType, info.m_animName, Actor.ENAnimType.enBlend, new float[] { (int)AnimationBlendMode.Blend, targetWeight, 0 }); CurrentActor.PlaySkillEventAnimation(m_skillInfo.ID, (int)info.m_skillType + 1, blendAnimName, Actor.ENAnimType.enBlend, new float[] { (int)AnimationBlendMode.Blend, 1 - targetWeight, 0 }); return; } } } CurrentActor.PlaySkillEventAnimation(m_skillInfo.ID, (int)info.m_skillType, info.m_animName, Actor.ENAnimType.enPlay); }
//private float m_animBeginTimer = 0;//动画开始的时间 //private float m_animDuration = 0;//动画所用时间 public override bool OnUpdate() { if (!IsFinished) { if (Time.time - AnimStartTime > AnimLength) {//当前动画播放完毕 AttackStepInfo info = GetAttackStepInfo(); if (info != null) {//当前有动画在播放 { if (Time.time - AnimStartTime < info.m_animTime) {//播放时间未到,继续播放 RefreshActionRef(); return(false); } ++m_curAttackStep; if (m_animationNameList.Count <= m_curAttackStep) {//所有动作播放完毕 IsFinished = true; } else { // m_animBeginTimer = 0; // m_animDuration = 0; RefreshActionRef(); } } } else { IsFinished = true; } } } return(IsFinished); }
public override bool OnUpdate() { if (m_isSwitchRotation) { float fInterval = RotateForwardTarget(); if (Mathf.Abs(fInterval) <= GameSettings.Singleton.m_attackRotateMinAngle) { m_isPlay = true; m_isSwitchRotation = false; AnimStartTime = Time.time; AnimLength = float.MaxValue; RefreshActionRef(); } else { return(false); } } if (!IsFinished) { PlaySkillEventAnimation(); PlayMissingSound(); //if (m_skillInfo.IsStopAttck) //{//如果目标死亡,且不在主动僵直中,则停止攻击 // if (m_skillTarget != null && m_skillTarget.IsDead) // {//目标死亡 // if (!CurrentActor.ActionControl.IsActionRunning(ActorAction.ENType.enSelfSpasticityAction)) // {//不在主动僵直中 // return true; // } // } //} if (m_skillInfo.IsCanMove) {//移动攻击技能,改为移动攻击action AttackStepInfo info = GetAttackStepInfo(); if (info != null) { if (m_skillInfo.IsConductExist && info.m_animName == m_skillInfo.ConductMotion) {//引导动作 if (CurrentActor.ActionControl.IsActionRunning(AttackingMoveAction.SGetActionType())) { return(false); } int skillID = m_skillID, targetID = m_skillTargetID; AttackingMoveAction action = CurrentActor.ActionControl.AddAction(AttackingMoveAction.SGetActionType()) as AttackingMoveAction; if (action != null) { action.Init(skillID, targetID); return(false); } } } } if (Time.time - AnimStartTime > AnimLength) {//当前动画播放完毕 //回馈位移动画 CurrentActor.ApplyAnimationOffset(); AttackStepInfo info = GetAttackStepInfo(); if (info != null) { //当前有动画在播放 if (m_skillInfo.IsSpellExist && info.m_animName == m_skillInfo.SpellMotion) { //吟唱动作 ActionToSpell(); } //else if (m_skillInfo.IsSlashExist && info.m_animName == m_skillInfo.SlashMotion) //{//冲刺动作 // //ActionToSlash(); //} else if (m_skillInfo.IsConductExist && info.m_animName == m_skillInfo.ConductMotion) { //引导动作 if (m_skillInfo.IsCanMove) { //移动攻击技能,改为移动攻击action int skillID = m_skillID, targetID = m_skillTargetID; AttackingMoveAction action = CurrentActor.ActionControl.AddAction(AttackingMoveAction.SGetActionType()) as AttackingMoveAction; if (action != null) { action.Init(skillID, targetID); return(false); } } else { ActionToConduct(); } } else { if (Time.time - AnimStartTime < info.m_animTime) {//播放时间未到,继续播放 RefreshActionRef(); return(false); } if (info.m_animName == m_skillInfo.ReleaseMotion) { //释放动作 if (m_skillInfo.TargetNumber > 0) { //对多个目标进行释放动作 if (m_skillInfo.TargetNumber > SkillTargetIDList.Count) { m_closestDistance = float.MaxValue; m_closestTargetID = 0; ActorManager.Singleton.ForEach(CheckTarget); if (m_closestTargetID != 0) {//查找到最近的目标 m_skillTargetID = m_closestTargetID; CurrentActor.CurrentTarget = m_skillTarget; RefreshActionRef(); //因为要播放同一技能步骤下的动作,所以把m_currentType重置 m_currentType = Actor.ENSkillStepType.enNone; //加入到技能目标id列表中 SkillTargetIDList.Add(m_skillTargetID); return(false); } } } } ++m_curAttackStep; if (m_animationNameList.Count <= m_curAttackStep) {//所有动作播放完毕 IsFinished = true; } else { m_animBeginTimer = 0; m_animDuration = 0; RefreshActionRef(); } } } else { IsFinished = true; } } } if (!CurrentActor.MainRigidBody.isKinematic) { CurrentActor.MainRigidBody.velocity = Vector3.zero; } return(IsFinished); }