public IEnumerator PlayLethalHitAnimation() { Animator2D animator = m_animator2D; string animationNameBackup = animator.get_animationName(); yield return(null); if (string.Equals(animator.get_animationName(), animationNameBackup)) { CharacterAnimationInfo animationInfo = new CharacterAnimationInfo(Vector2Int.op_Implicit(m_cellObject.coords), "hit", "hit", loops: false, direction, m_mapRotation); StartFightAnimation(animationInfo, (Action)((CharacterObject)this).PlayIdleAnimation, (Action)null, restart: true, async: false); } }
public void PlayAnimation(string animationName, Action onComplete = null, bool loop = false, bool restart = true, bool async = false) { TimelineAsset value; bool flag = ((Dictionary <string, TimelineAsset>)m_timelineAssetDictionary).TryGetValue(animationName, out value); if (flag && null != value) { m_playableDirector.set_extrapolationMode(0); if (value != m_playableDirector.get_playableAsset()) { m_playableDirector.Play(value); } else { if (restart || !m_animator2D.get_animationName().Equals(animationName)) { m_playableDirector.set_time(0.0); } m_playableDirector.Resume(); } m_hasTimeline = true; } else { if (flag) { Log.Warning("Boss named '" + this.get_gameObject().get_name() + "' has a timeline setup for key '" + animationName + "' but the actual asset is null.", 202, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\BossObject.cs"); } m_playableDirector.set_time(0.0); m_playableDirector.Pause(); m_hasTimeline = false; } m_animationCallback.Setup(animationName, restart, onComplete); m_animator2D.SetAnimation(animationName, loop, async, restart); }
public static bool HasAnimationReachedLabel([NotNull] Animator2D animator2D, CharacterAnimationInfo animationInfo, [NotNull] string label) { if (!animator2D.get_reachedEndOfAnimation() && !label.Equals(animator2D.get_currentLabel(), StringComparison.OrdinalIgnoreCase)) { return(!animationInfo.animationName.Equals(animator2D.get_animationName())); } return(true); }
public static bool HasAnimationEnded([NotNull] Animator2D animator2D, CharacterAnimationInfo animationInfo) { if (!animator2D.get_reachedEndOfAnimation()) { return(!animationInfo.animationName.Equals(animator2D.get_animationName())); } return(true); }
protected void StartFightAnimation(CharacterAnimationInfo animationInfo, Action onComplete = null, Action onCancel = null, bool restart = true, bool async = false) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) string animationName = animationInfo.animationName; string timelineKey = animationInfo.timelineKey; m_animator2D.get_transform().set_localRotation(animationInfo.flipX ? Quaternion.Euler(0f, -135f, 0f) : Quaternion.Euler(0f, 45f, 0f)); direction = animationInfo.direction; ITimelineAssetProvider animatedCharacterData = GetAnimatedCharacterData(); if (animatedCharacterData != null) { TimelineAsset timelineAsset; bool flag = animatedCharacterData.TryGetTimelineAsset(timelineKey, out timelineAsset); if (flag && null != timelineAsset) { if (timelineAsset != m_playableDirector.get_playableAsset()) { m_playableDirector.Play(timelineAsset); } else { if (restart || !m_animator2D.get_animationName().Equals(animationName)) { m_playableDirector.set_time(0.0); } m_playableDirector.Resume(); } m_hasTimeline = true; } else { if (flag) { Log.Warning("Character named '" + GetAnimatedCharacterData().get_name() + "' has a timeline setup for key '" + timelineKey + "' but the actual asset is null.", 171, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\BoardCharacterObject.cs"); } m_playableDirector.set_time(0.0); m_playableDirector.Pause(); m_hasTimeline = false; } } m_animationCallback.Setup(animationName, restart, onComplete, onCancel); m_animator2D.SetAnimation(animationName, animationInfo.loops, async, restart); m_animationParameters = animationInfo.parameters; }
private IEnumerator MoveToRoutine(List <Vector3> path, Vector3 endLookAt) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) int movementCellsCount = path.Count; if (movementCellsCount <= 1) { yield break; } Animator2D animator = m_animator2D; AnimatedFightCharacterData.IdleToRunTransitionMode idleToRunTransitionMode = m_characterData.idleToRunTransitionMode; Vector3 startCell = path[0]; if (!m_isRunning && idleToRunTransitionMode.HasFlag(AnimatedFightCharacterData.IdleToRunTransitionMode.IdleToRun)) { Direction direction = (movementCellsCount >= 2) ? GetDirection(startCell, path[1]) : this.direction; CharacterAnimationInfo transitionAnimationInfo2 = new CharacterAnimationInfo(new Vector2(startCell.x, startCell.z), "idle_run", "idle-to-run", loops: false, direction, m_mapRotation); if (!transitionAnimationInfo2.animationName.Equals(m_animator2D.get_animationName())) { StartAnimation(transitionAnimationInfo2); } while (!CharacterObjectUtility.HasAnimationEnded(animator, transitionAnimationInfo2)) { yield return(null); } } m_isRunning = true; Vector3 previousCoords = startCell; int num; for (int i = 1; i < movementCellsCount; i = num) { Vector3 coords = path[i]; Vector3 direction2 = coords - previousCoords; float magnitude = direction2.get_magnitude(); Direction direction3 = GetDirection(direction2); CharacterAnimationInfo animationInfo = new CharacterAnimationInfo(new Vector2(coords.x, coords.z), "run", "run", loops: true, direction3, m_mapRotation); StartAnimation(animationInfo, null, null, restart: false); float cellTraversalDuration = magnitude * 5f * (1f / m_speedFactor) / (float)animator.get_frameRate(); float animationTime = 0f; do { Vector3 val = Vector3.Lerp(previousCoords, coords, animationTime / cellTraversalDuration); this.get_transform().set_position(val + Vector3.get_up() * m_heightOffest); yield return(null); animationTime += Time.get_deltaTime(); }while (animationTime < cellTraversalDuration); this.get_transform().set_position(coords + Vector3.get_up() * m_heightOffest); previousCoords = coords; num = i + 1; } m_isRunning = false; if (idleToRunTransitionMode.HasFlag(AnimatedFightCharacterData.IdleToRunTransitionMode.RunToIdle)) { CharacterAnimationInfo transitionAnimationInfo2 = new CharacterAnimationInfo(new Vector2(previousCoords.x, previousCoords.z), "run_idle", "run-to-idle", loops: false, this.direction, m_mapRotation); StartAnimation(transitionAnimationInfo2); while (!CharacterObjectUtility.HasAnimationEnded(animator, transitionAnimationInfo2)) { yield return(null); } } if (endLookAt != Vector3.get_zero()) { m_direction = GetDirection(endLookAt); } PlayIdleAnimation(); m_movementCoroutine = null; }