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; }
protected unsafe IEnumerator MoveToRoutine(Vector2Int[] movementCells) { int movementCellsCount = movementCells.Length; if (movementCellsCount == 0) { yield break; } CellObject cellObj = m_cellObject; IMap parentMap = cellObj.parentMap; Animator2D animator = m_animator2D; AnimatedFightCharacterData.IdleToRunTransitionMode idleToRunTransitionMode = m_characterData.idleToRunTransitionMode; Vector2Int startCell = movementCells[0]; Vector2Int endCell = movementCells[movementCellsCount - 1]; if (cellObj.coords != startCell) { Log.Warning($"Was not on the start cell of a new movement sequence: {cellObj.coords} instead of {startCell} ({this.get_gameObject().get_name()}).", 232, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\FightCharacterObject.cs"); CellObject cellObject = parentMap.GetCellObject(startCell.get_x(), startCell.get_y()); SetCellObject(cellObject); } if (idleToRunTransitionMode.HasFlag(AnimatedFightCharacterData.IdleToRunTransitionMode.IdleToRun)) { Direction direction = (movementCellsCount >= 2) ? startCell.GetDirectionTo(movementCells[1]) : this.direction; CharacterAnimationInfo transitionAnimationInfo2 = new CharacterAnimationInfo(Vector2Int.op_Implicit(startCell), "idle_run", "idle-to-run", loops: false, direction, m_mapRotation); StartFightAnimation(transitionAnimationInfo2); while (!CharacterObjectUtility.HasAnimationEnded(animator, transitionAnimationInfo2)) { yield return(null); } } Vector2Int val = startCell; float cellTraversalDuration = ((movementCellsCount <= 2) ? 5f : 4f) / (float)animator.get_frameRate(); foreach (CharacterAnimationInfo item in CharacterFightMovementSequencer.ComputeMovement(movementCells, m_mapRotation)) { Vector2Int cellCoords = item.position.RoundToInt(); CellObject movementCell = parentMap.GetCellObject(cellCoords.get_x(), cellCoords.get_y()); bool goingUp = ((IntPtr)(void *)movementCell.get_transform().get_position()).y >= ((IntPtr)(void *)cellObj.get_transform().get_position()).y; Vector2 innerPositionStart; Vector2 innerPositionEnd; if (goingUp) { SetCellObject(movementCell); innerPositionStart = Vector2Int.op_Implicit(val - cellCoords); innerPositionEnd = Vector2.get_zero(); } else { innerPositionStart = Vector2.get_zero(); innerPositionEnd = Vector2Int.op_Implicit(cellCoords - val); } StartFightAnimation(item, null, null, restart: false); float animationTime = 0f; do { Vector2 cellObjectInnerPosition = Vector2.Lerp(innerPositionStart, innerPositionEnd, animationTime / cellTraversalDuration); SetCellObjectInnerPosition(cellObjectInnerPosition); yield return(null); animationTime += Time.get_deltaTime(); }while (animationTime < cellTraversalDuration); SetCellObjectInnerPosition(innerPositionEnd); if (!goingUp) { SetCellObject(movementCell); } val = cellCoords; cellObj = movementCell; if (cellCoords != endCell && movementCell.TryGetIsoObject(out IObjectWithActivation isoObject)) { isoObject.PlayDetectionAnimation(); } cellCoords = default(Vector2Int); } if (idleToRunTransitionMode.HasFlag(AnimatedFightCharacterData.IdleToRunTransitionMode.RunToIdle)) { CharacterAnimationInfo transitionAnimationInfo2 = new CharacterAnimationInfo(Vector2Int.op_Implicit(val), "run_idle", "run-to-idle", loops: false, this.direction, m_mapRotation); StartFightAnimation(transitionAnimationInfo2); while (!CharacterObjectUtility.HasAnimationEnded(animator, transitionAnimationInfo2)) { yield return(null); } } }