void ChangeResultID(AnimationEvent animEvent) { ActorProp selfProp = transform.parent.GetComponent <ActorProp>(); if (null == selfProp) { return; } AttackAction action = selfProp.ActorLogicObj.ActionControl.LookupAction(ActorAction.ENType.enAttackAction) as AttackAction; if (null != action) { //action.m_triggerSkillResultID = animEvent.intParameter; ++action.m_skillResultIDIndex; action.m_firstTarget = null; } else { AttackingMoveAction amAction = selfProp.ActorLogicObj.ActionControl.LookupAction(AttackingMoveAction.SGetActionType()) as AttackingMoveAction; if (amAction != null) { //amAction.m_triggerSkillResultID = animEvent.intParameter; ++amAction.m_skillResultIDIndex; amAction.m_firstTarget = null; } } }
/*void OnTriggerEnter(Collider other) * { * if (!ActorTargetManager.IsTrigger(other)) * { * return; * } * //Debug.LogWarning(gameObject.name + " trigger with " + other); * ActorProp selfProp = transform.parent.GetComponent<ActorProp>(); * if (null == selfProp) * { * Debug.LogWarning("trigger return, actorProp get failed"); * return; * } * GlobalEnvironment.Singleton.IsInCallbackOrTrigger = true; * try * { * Actor self = selfProp.ActorLogicObj; * if (null != self && !self.IsDead) * { * AttackAction action = self.ActionControl.LookupAction(ActorAction.ENType.enAttackAction) as AttackAction; * if (null != action) * { * action.OnTriggerEnter(gameObject, other); * } * else * { * AttackingMoveAction amAction = self.ActionControl.LookupAction(AttackingMoveAction.SGetActionType()) as AttackingMoveAction; * if (amAction != null) * { * amAction.OnTriggerEnter(gameObject, other); * } * } * } * } * catch (Exception e) * { * Debug.LogError("Error On OnTriggerEnter" + e.Message + ",,,,Stack:" + e.StackTrace.ToString()); * DebugLog.Singleton.OnShowLog("[AttackActionCallback Error On OnTriggerEnter] " + e.Message + " " + e.StackTrace.ToString()); * } * GlobalEnvironment.Singleton.IsInCallbackOrTrigger = false; * }*/ void ChangeInstantResultID(AnimationEvent animEvent) { ActorProp selfProp = transform.parent.GetComponent <ActorProp>(); if (null == selfProp) { return; } Actor self = selfProp.ActorLogicObj; if (null != self && !self.IsDead) { AttackAction action = self.ActionControl.LookupAction(ActorAction.ENType.enAttackAction) as AttackAction; if (null != action) { ++action.m_skillResultIDIndex; action.CreateSkillResult(); } else { AttackingMoveAction amAction = self.ActionControl.LookupAction(AttackingMoveAction.SGetActionType()) as AttackingMoveAction; if (amAction != null) { ++amAction.m_skillResultIDIndex; amAction.CreateSkillResult(); } } } }
public override void Update() { Actor.Cmd cmd = Owner.CurrentCmd; if (cmd != null) { switch (cmd.m_type) { case Actor.ENCmdType.enMove: { if (ActionMoveTo(cmd.m_moveTargetPos, true, false, cmd.IsSyncPosValidate, cmd.m_syncPos)) { Owner.CurrentCmd = null; } } break; case Actor.ENCmdType.enSkill: { Owner.CurrentTarget = ActorManager.Singleton.Lookup(cmd.m_targetID); //ActionForwardTo(cmd.m_targetID); if (ActionTryAttack(cmd.m_skillID, Owner.CurrentTarget, cmd.IsSyncPosValidate, cmd.m_syncPos)) { Owner.CurrentCmd = null; } else { ActionForwardTo(cmd.m_targetID); } } break; case Actor.ENCmdType.enRoll: { RollAction rollAction = Owner.ActionControl.AddAction(ActorAction.ENType.enRollAction) as RollAction; if (rollAction != null) { rollAction.Init(Owner.CurrentCmd.m_syncPos, cmd.m_moveTargetPos); Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enActorEnter: { Player player = Owner as Player; if (player != null) { if (player.SwitchActorEnter(cmd.m_syncPos, cmd.m_forward)) { Owner.CurrentCmd = null; } } else { Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enActorExit: { Owner.IsActorExit = true; ActorExitAction actorExitAction = Owner.ActionControl.AddAction(ActorAction.ENType.enActorExitAction) as ActorExitAction; if (actorExitAction != null) { Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enInteruptAction: { Owner.ActionControl.InterruptAction((ActorAction.ENType)cmd.m_interruptedActionType); Owner.CurrentCmd = null; break; } case Actor.ENCmdType.enBeHitAction: { BeAttackAction beAttackAction = Owner.ActionControl.AddAction(ActorAction.ENType.enBeAttackAction) as BeAttackAction; if (beAttackAction != null) { Actor srcActor = ActorManager.Singleton.Lookup(cmd.m_srcActorID); beAttackAction.Init(srcActor, cmd.m_isBack, cmd.m_isFly); Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enJumpInAction: { Owner.CurrentTarget = ActorManager.Singleton.Lookup(cmd.m_targetID); JumpinAction jumpInAction = Owner.ActionControl.AddAction(ActorAction.ENType.enJumpinAction) as JumpinAction; if (jumpInAction != null) { Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enJumpOutAction: { JumpoutAction jumpOutAction = Owner.ActionControl.AddAction(ActorAction.ENType.enJumpoutAction) as JumpoutAction; if (jumpOutAction != null) { Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enAttackingMoveAction: { AttackingMoveAction action = Owner.ActionControl.AddAction(ActorAction.ENType.enAttackingMoveAction) as AttackingMoveAction; if (action != null) { action.InitImpl(Owner.CurrentCmd.m_skillID, Owner.CurrentCmd.m_targetID, cmd.IsSyncPosValidate, cmd.m_syncPos); Owner.CurrentCmd = null; } } break; } } }
private ActorAction CreateObj(ActorAction.ENType newType) { ActorAction action = m_pool.GetObjectFromPool(newType) as ActorAction; if (action != null) { return(action); } switch (newType) { case ActorAction.ENType.enStandAction: action = new StandAction(); break; //站立 case ActorAction.ENType.enMoveAction: action = new MoveAction(); break; //移动 case ActorAction.ENType.enAttackAction: action = new AttackAction(); break; //攻击 case ActorAction.ENType.enSpasticityAction: action = new SpasticityAction(); break; //被动僵直 case ActorAction.ENType.enBeAttackAction: action = new BeAttackAction(); break; //受击 case ActorAction.ENType.enUndownAction: action = new UndownAction(); break; //霸体 case ActorAction.ENType.enDeadAction: action = new DeadAction(); break; //死亡 case ActorAction.ENType.enReliveAction: action = new ReliveAction(); break; //复活 case ActorAction.ENType.enPlayEffectAction: action = new PlayEffectAction(); break; //播放特效 case ActorAction.ENType.enSearchEnemyAction: //action = new SearchEnemyAction(); break; //搜索敌人 case ActorAction.ENType.enTeleportAction: action = new TeleportAction(); break; //瞬移 case ActorAction.ENType.enControlMoveAction: action = new ControlMoveAction(); break; //控制技能定身 case ActorAction.ENType.enHoldDownAction: action = new HoldDownAction(); break; //按下状态 case ActorAction.ENType.enSelfSpasticityAction: action = new SelfSpasticityAction(); break; //主动僵直 case ActorAction.ENType.enAlertAction: action = new AlertAction(); break; //警戒 case ActorAction.ENType.enJumpinAction: action = new JumpinAction(); break; //入场 case ActorAction.ENType.enJumpoutAction: action = new JumpoutAction(); break; //退场 case ActorAction.ENType.enRollAction: action = new RollAction(); break; //翻滚 case ActorAction.ENType.enFakeBeAttackAction: action = new FakeBeAttackAction(); break; //假受击 case ActorAction.ENType.enActorExitAction: action = new ActorExitAction(); break; //主控角色退场 case ActorAction.ENType.enActorEnterAction: action = new ActorEnterAction(); break; //主控角色入场 case ActorAction.ENType.enControlAttackAction: action = new ControlAttackAction(); break; //不能攻击 case ActorAction.ENType.enControlBeAttackAction: action = new ControlBeAttackAction(); break; //不能受击 case ActorAction.ENType.enAttackingMoveAction: action = new AttackingMoveAction(); break;//攻击时移动 case ActorAction.ENType.enDragMoveAction: action = new DragMoveAction(); break;//拖拽 default: throw new Exception("Miss Action Create for" + newType.ToString()); } return(action); }
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); }
public void Tick() { string strAnim = "standby"; ActorAction.ENType curActionType = ActorAction.ENType.enNone; Vector3 mDirection = Vector3.zero; Vector3 syncPos = Vector3.zero; if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enBeAttackAction)) { BeAttackAction action = mActor.ActionControl.LookupAction(ActorAction.ENType.enBeAttackAction) as BeAttackAction; bool isNewAction = IsNewAction(ActorAction.ENType.enBeAttackAction); if (action.mStrAnim != mLastAnimName || isNewAction) { bool isHitedFly = false; if (action.m_isBack) { isHitedFly = action.m_isFly; } mLastAnimName = action.mStrAnim; string animFullName = ""; float animLength = mActor.PlayAnimation(action.mStrAnim, mDirection, out animFullName, syncPos); if (action.fBlendFactor > 0f) { mActor.BlendAnimation(action.mAniBlend, action.fBlendFactor); } if (isHitedFly) { mActor.BlendAnimation("knock", 1.0f); } if (isNewAction) { action.AnimStartTime = Time.time; action.AnimLength = animLength; action.AnimFullName = animFullName; } } return; } else if (mActor.ActionControl.IsActionRunning(AttackingMoveAction.SGetActionType())) { AttackingMoveAction action = mActor.ActionControl.LookupAction(AttackingMoveAction.SGetActionType()) as AttackingMoveAction; strAnim = action.AnimName; curActionType = AttackingMoveAction.SGetActionType(); } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enAttackAction)) { AttackAction action = mActor.ActionControl.LookupAction(ActorAction.ENType.enAttackAction) as AttackAction; bool isNewAction = IsNewAction(ActorAction.ENType.enAttackAction); if (isNewAction) { if (!action.m_isPlay) { strAnim = "standby"; } else { if (null != action.m_skillTarget) { mDirection = action.m_skillTarget.RealPos - mActor.RealPos; } strAnim = action.GetAnimationName(); } if (strAnim == "standby") { // if (mActor.IsState_ReadyToFight) // { // strAnim = "readytofight"; // } } mLastAnimName = strAnim; string animFullName = ""; if (action.IsSyncPosition) { syncPos = action.SyncPosition; } float animLength = mActor.PlayAnimation(strAnim, mDirection, out animFullName, syncPos); if (isNewAction) { action.AnimStartTime = Time.time; action.AnimLength = animLength; action.AnimFullName = animFullName; } AttackAction aAction = action as AttackAction;// mActor.ActionControl.LookupAction(curActionType) as AttackAction; // AttackAction.AttackStepInfo info = aAction.GetAttackStepInfo(); if (aAction.m_isPlay) { //攻击中 if (aAction.m_skillTarget != null) { //有技能目标 float targetWeight = 0; string blendAnimName = ""; Vector3 direction = aAction.m_skillTarget.RealPos - mActor.RealPos; direction.y = 0f; if (aAction.m_skillInfo.SlashMotion == strAnim) {//计算冲刺的权重 if (aAction.m_skillInfo.SlashMotionDistance > 0) { targetWeight = (direction.magnitude + aAction.m_skillInfo.SlashTargetPosOffset) / aAction.m_skillInfo.SlashMotionDistance; blendAnimName = aAction.m_skillInfo.SlashBlendMotionName; } } else if (aAction.m_skillInfo.ReleaseMotion == strAnim) {//计算释放的权重 if (aAction.m_skillInfo.ReleaseMotionDistance > 0) { targetWeight = (direction.magnitude + aAction.m_skillInfo.ReleaseTargetPosOffset) / aAction.m_skillInfo.ReleaseMotionDistance; blendAnimName = aAction.m_skillInfo.ReleaseBlendMotionName; } } if (!string.IsNullOrEmpty(blendAnimName)) {//动作融合 if (targetWeight < 0) { targetWeight = 0; } mActor.BlendAnimation(strAnim, targetWeight, 0); mActor.BlendAnimation(blendAnimName, 1 - targetWeight, 0); } } } SelfSpasticityAction spAction = mActor.ActionControl.AddAction(ActorAction.ENType.enSelfSpasticityAction) as SelfSpasticityAction; if (null != spAction) { spAction.AnimLength = animLength; } } FakeBeAttackAction beFakeAction = mActor.ActionControl.LookupAction(ActorAction.ENType.enFakeBeAttackAction) as FakeBeAttackAction; if (null != beFakeAction && IsNewAction(ActorAction.ENType.enFakeBeAttackAction)) { if ((action.IsNormalAttack())) { mActor.BlendAnimation(beFakeAction.mStrAnim, GameSettings.Singleton.m_fakeBlendWeightValue, GameSettings.Singleton.m_fakeBlendFadeTime, AnimationBlendMode.Additive); } } return; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enFakeBeAttackAction)) { FakeBeAttackAction action = mActor.ActionControl.LookupAction(ActorAction.ENType.enFakeBeAttackAction) as FakeBeAttackAction; bool isNewAction = IsNewAction(ActorAction.ENType.enFakeBeAttackAction); if (action.mStrAnim != mLastAnimName || isNewAction) { mLastAnimName = action.mStrAnim; if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enMoveAction)) { mActor.BlendAnimation(action.mStrAnim, GameSettings.Singleton.m_fakeBlendWeightValue, GameSettings.Singleton.m_fakeBlendFadeTime, AnimationBlendMode.Additive); } else { string animFullName = ""; float animLength = mActor.PlayAnimation(action.mStrAnim, mDirection, out animFullName, syncPos); if (action.fBlendFactor > 0f) { mActor.BlendAnimation(action.mAniBlend, action.fBlendFactor); } action.AnimStartTime = Time.time; action.AnimLength = animLength; action.AnimFullName = animFullName; } } return; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enMoveAction)) { MoveAction action = mActor.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction; strAnim = action.AnimName; float fDiff = action.mRealSpeed / action.m_currentSpeed; if (action.mIsRotating) { //strAnim = "standby"; } else if ((fDiff <= 0.1f || action.m_currentSpeed == 0)) { strAnim = "standby"; } bool isNewAction = IsNewAction(ActorAction.ENType.enMoveAction); if (strAnim != mLastAnimName || isNewAction) { // if (strAnim == "run") // { // float fBase = mActor.PropConfig.RunBaseSpeed - mActor.PropConfig.WalkBaseSpeed; // float fPercent = (mActor.MoveSpeed - mActor.PropConfig.WalkBaseSpeed) / fBase; // if (fPercent <= 0.0f || fPercent <= 1 / fBase) // { // strAnim = "walk"; // } // } // if (strAnim == "standby") // { // if (mActor.IsState_ReadyToFight) // { // strAnim = "readytofight"; // } // } mLastAnimName = strAnim; string animFullName = ""; float animLength = mActor.PlayAnimation(strAnim, mDirection, out animFullName, syncPos); if (isNewAction) { action.AnimStartTime = Time.time; action.AnimLength = animLength; action.AnimFullName = animFullName; } } return; //Debug.Log("strAnim=" + strAnim + " realSpeed=" + action.mRealSpeed + " action.m_currentSpeed=" + action.m_currentSpeed); } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enStandAction)) { StandAction action = mActor.ActionControl.LookupAction(StandAction.SGetActionType()) as StandAction; strAnim = action.AnimName; curActionType = ActorAction.ENType.enStandAction; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enDeadAction)) { strAnim = "dead"; curActionType = ActorAction.ENType.enDeadAction; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enReliveAction)) { strAnim = "reborn"; curActionType = ActorAction.ENType.enReliveAction; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enAlertAction)) { strAnim = "alert"; curActionType = ActorAction.ENType.enAlertAction; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enControlMoveAction)) {//控制移动 ControlMoveAction action = mActor.ActionControl.LookupAction(ControlMoveAction.SGetActionType()) as ControlMoveAction; strAnim = action.AnimName; curActionType = ActorAction.ENType.enControlMoveAction; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enJumpinAction)) { strAnim = "jumpin"; curActionType = ActorAction.ENType.enJumpinAction; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enJumpoutAction)) { strAnim = "jumpout"; curActionType = ActorAction.ENType.enJumpoutAction; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enRollAction)) { strAnim = "rolling"; curActionType = ActorAction.ENType.enRollAction; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enActorExitAction)) { strAnim = "jumpout"; curActionType = ActorAction.ENType.enActorExitAction; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enActorEnterAction)) { strAnim = "jumpin"; curActionType = ActorAction.ENType.enActorEnterAction; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enControlAttackAction)) {//控制攻击 strAnim = "standby"; curActionType = ActorAction.ENType.enControlAttackAction; } else if (mActor.ActionControl.IsActionRunning(ActorAction.ENType.enControlBeAttackAction)) {//控制受击 strAnim = "standby"; curActionType = ActorAction.ENType.enControlBeAttackAction; } if (strAnim == "") { return; } if (strAnim == "standby") { // if (mActor.IsState_ReadyToFight) // { // strAnim = "readytofight"; // } } bool isNewAction1 = IsNewAction(curActionType); if (strAnim != mLastAnimName || isNewAction1) { mLastAnimName = strAnim; ActorAction action = mActor.ActionControl.LookupAction(curActionType); if (action != null) { if (action.IsSyncPosition) { syncPos = action.SyncPosition; } } string animFullName = ""; float animLength = mActor.PlayAnimation(strAnim, mDirection, out animFullName, syncPos); if (action != null) {//设置animation播放的时间 if (isNewAction1) { action.AnimStartTime = Time.time; action.AnimLength = animLength; action.AnimFullName = animFullName; } } } }