public ActorAction AddAction(ActorAction.ENType newType) { if (!IsDisable(newType)) { bool isValidateActionState = false; for (int index = m_actionList.Count - 1; index >= 0; --index) { ActorAction item = m_actionList[index]; if (!item.IsEnable) { continue; } if (ActorAction.ENRelation.enReplace == CheckRelation(newType, item.GetActionType())) { m_actionList.RemoveAt(index); isValidateActionState = true; item.OnInterupt(); RemoveDisableCount(item.GetActionType()); item.IsEnable = false; ReleaseObj(item); } } ActorAction obj = CreateObj(newType); obj.CurrentActor = CurrentActor; if (null != CurrentActor.mActorBlendAnim) { CurrentActor.mActorBlendAnim.CurActionType = newType; } ActioningObjArray[(int)newType] = obj; m_actionList.Add(obj); AddDisableCount(obj.GetActionType()); if (isValidateActionState) { for (int i = 0; i < ActioningArray.Length; i++) { ActioningArray[i] = 0; ActioningObjArray[i] = null; } for (int i = 0; i < m_actionList.Count; i++) { ActorAction ac = m_actionList[i]; ActioningObjArray[(int)ac.GetActionType()] = ac; ActioningArray[(int)ac.GetActionType()]++; } } return(obj); } else { string currentActions = CurrentActor.GetType() + ":" + newType.ToString() + " Current Actions:"; foreach (ActorAction action in m_actionList) { currentActions += action.GetActionType().ToString() + ", "; } //Debug.LogWarning("Add action failed:" + newType.ToString()+" actor type:"+CurrentActor.Type.ToString()); return(null); } }
public void AddDisableCount(ActorAction.ENType type) { ActioningArray[(int)type]++; for (int index = 0; index < m_disableCount.Length; ++index) { if (ActorAction.ENRelation.enUnable == CheckRelation((ActorAction.ENType)index, type)) { ++m_disableCount[index]; } } }
public bool InterruptAction(ActorAction.ENType actionType) { ActorAction item = LookupAction(actionType); if (item != null) { item.OnInterupt(); item.IsEnable = false; return(true); } return(false); }
public void RemoveAction(ActorAction.ENType type) { foreach (var action in m_actionList) { if (action.GetActionType() == type) { action.OnInterupt(); RemoveDisableCount(type); } } m_curRemoveType_Temp = type; m_actionList.RemoveAll(Temp_Remove_Action); ActioningObjArray[(int)type] = null; ActioningArray[(int)type] = 0; }
private void RemoveDisableCount(ActorAction.ENType type) { ActioningObjArray[(int)type] = null; ActioningArray[(int)type]--; if (ActioningArray[(int)type] < 0) { ActioningArray[(int)type] = 0; } for (int index = 0; index < m_disableCount.Length; ++index) { if (ActorAction.ENRelation.enUnable == CheckRelation((ActorAction.ENType)index, type)) { --m_disableCount[index]; } } }
bool IsNewAction(ActorAction.ENType actionType) { ActorAction action = mActor.ActionControl.LookupAction(actionType); if (null == action) { return(true); } uint curRefCount = mActor.mActionRefCountDict[(int)action.GetActionType()]; //mActor.mActionRefCountDict.TryGetValue(action.GetActionType(), out curRefCount); uint lastRefCount = mLastActionRefCountDict[(int)action.GetActionType()]; mLastActionRefCountDict[(int)action.GetActionType()] = curRefCount; // if (mLastActionRefCountDict.TryGetValue(action.GetActionType(), out lastRefCount)) // { // mLastActionRefCountDict[action.GetActionType()] = curRefCount; // } // else // { // mLastActionRefCountDict.Add(action.GetActionType(), curRefCount); // } return(curRefCount != lastRefCount); }
//!tick public void LateUpdate() { if (GameSettings.Singleton.m_closeActorBlendAnim) { return; } if (CurrentActor.Type == ActorType.enMain && CurrentActor.IsActorExit) { return; } if (CurrentActor.MainPlayerConfig == null || CurrentActor.MainPlayerConfig.m_headTransform == null) { return; } ActorAction.ENType actionType = LastActionType; LastActionType = CurActionType; if (CurActionType != ActorAction.ENType.enStandAction && CurActionType != ActorAction.ENType.enMoveAction) { Reset(); return; } if (CurrentActor.IsDead) { Reset(); return; } if (actionType == ActorAction.ENType.enRollAction && CurActionType == ActorAction.ENType.enStandAction) { m_isRotateUpbody = false; Reset(); return; } else { if (CurActionType != ActorAction.ENType.enStandAction) { m_isRotateUpbody = true; } } bool isHaveTarget = (null != CurrentActor.TargetManager.CurrentTarget); if (isHaveTarget && IsRawRotation()) { MoveAction action = CurrentActor.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction; if (null != action) { action.AnimName = "run"; } return; } if (isHaveTarget) { RotateMainBody(); if (m_isRotateUpbody) { RotateUpBody(); } } else { if (mIsRotateUpBodyWithoutTarget) { RotateUpBodyWithoutTarget(); } } }
public ActorAction.ENRelation Lookup(ActorAction.ENType newType, ActorAction.ENType oldType) { return((ActorAction.ENRelation)m_relationArray[(int)oldType * (int)ActorAction.ENType.Count + (int)newType]); }
public bool IsDisable(ActorAction.ENType type) { return(m_disableCount[(int)type] > 0); }
private ActorAction.ENRelation CheckRelation(ActorAction.ENType newAction, ActorAction.ENType oldAction) { return(GameTable.ActionRelationTableAsset.Lookup(newAction, oldAction)); }
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 ActorAction LookupAction(ActorAction.ENType type) { return(ActioningObjArray[(int)type]); //return m_actionList.Find(action => action.GetActionType() == type); }
public bool IsActionRunning(ActorAction.ENType acType) { return(ActioningArray[(int)acType] > 0); }
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; } } } }