public virtual bool PlayAction(int actionId, bool replayActionId = false) { if (Avatar != null && Avatar.AvatarAnimation != null && Avatar.AvatarAnimation.PlayingAnimation != null && Avatar.AvatarAnimation.PlayingAnimation.animationName.Contains("Die")) { return(false); } // Stop last action. if (replayActionId == false && curActID == actionId) { return(true); } StopAction(); // Play the animation of this action. AvatarAction action = ConfigDatabase.DefaultCfg.ActionConfig.GetActionById(actionId); if (action == null) { return(false); } if (action.GetAnimationName(avatarAssetId) == "") { Debug.LogError(string.Format("Animation name is empty in action({0})", action.id.ToString("X8"))); return(false); } if (!Avatar.PlayAnim(action.GetAnimationName(avatarAssetId))) { return(false); } // Set animation finish callback. Avatar.SetAnimationFinishDeletage(OnAnimationFinished, null, null); // Save the current action ID. curActID = actionId; // Log action. if (LogAction) { LogMsg(String.Format("PlayAction actionId:{0:X} actType:{1:X} animation:{2}", actionId, AvatarAction._Type.GetNameByType(action.actionType), action.GetAnimationName(avatarAssetId))); } return(true); }
public virtual void PreLoadAnimation(int actionId) { AvatarAction action = ConfigDatabase.DefaultCfg.ActionConfig.GetActionById(actionId); if (action == null) { return; } Avatar.PreLoadAnimation(action.GetAnimationName(avatarAssetId)); }
/// <summary> /// 非战斗中使用 /// </summary> public void PlayAnimationByActionType(int actionType, int weaponType, int combatStateType) { int actionCount = ConfigDatabase.DefaultCfg.ActionConfig.GetActionCountInType(weaponType, combatStateType, actionType); if (actionCount == 0) { AvatarAnimation.PlayDefaultAnim(AvatarAssetConfig.ComponentIdToAvatarTypeId(AvatarAssetId)); return; } AvatarAction animAction = ConfigDatabase.DefaultCfg.ActionConfig.GetActionInTypeByIndex(weaponType, combatStateType, actionType, 0); if (animAction.GetAnimationName(AvatarAssetId) == "") { Debug.LogError(string.Format("Animation name is empty in action({0})", animAction.id.ToString("X"))); return; } PlayAnim(animAction.GetAnimationName(AvatarAssetId)); }