public override void ChangeDirection(Direction newDirection)
 {
     //IL_0010: Unknown result type (might be due to invalid IL or missing references)
     //IL_0015: Unknown result type (might be due to invalid IL or missing references)
     //IL_001a: Unknown result type (might be due to invalid IL or missing references)
     //IL_0038: Unknown result type (might be due to invalid IL or missing references)
     //IL_0078: Unknown result type (might be due to invalid IL or missing references)
     //IL_00b6: Unknown result type (might be due to invalid IL or missing references)
     //IL_00cc: Unknown result type (might be due to invalid IL or missing references)
     if (newDirection != m_direction)
     {
         Vector2    position   = Vector2Int.op_Implicit(m_cellObject.coords);
         Animator2D animator2D = m_animator2D;
         CharacterAnimationParameters animationParameters    = m_animationParameters;
         CharacterAnimationInfo       characterAnimationInfo = (m_animationParameters.secondDirection == Direction.None) ? new CharacterAnimationInfo(position, animationParameters.animationName, animationParameters.timelineKey, animationParameters.loops, newDirection, m_mapRotation) : new CharacterAnimationInfo(previousDirection: DirectionExtensions.Rotate(angle: m_direction.DirectionAngleTo(newDirection), value: animationParameters.firstDirection), position: position, animationName: animationParameters.animationName, timelineKey: animationParameters.timelineKey, loops: animationParameters.loops, direction: newDirection, mapRotation: m_mapRotation);
         animator2D.get_transform().set_localRotation(characterAnimationInfo.flipX ? Quaternion.Euler(0f, -135f, 0f) : Quaternion.Euler(0f, 45f, 0f));
         direction = newDirection;
         string animationName = characterAnimationInfo.animationName;
         int    currentFrame  = animator2D.get_currentFrame();
         m_animationCallback.ChangeAnimationName(animationName);
         animator2D.SetAnimation(animationName, characterAnimationInfo.loops, false, true);
         animator2D.set_currentFrame(currentFrame);
         m_animationParameters = characterAnimationInfo.parameters;
     }
 }
Exemplo n.º 2
0
 public void PlayAnim(string animName, bool loop, bool randomStartFrame = false)
 {
     if (!(m_animator2D == null) && !string.IsNullOrEmpty(animName))
     {
         m_animator2D.SetAnimation(animName, loop, false, true);
         if (randomStartFrame)
         {
             int currentFrame = Random.Range(0, Mathf.Min(15, m_animator2D.get_animationFrameCount()));
             m_animator2D.set_currentFrame(currentFrame);
         }
     }
 }
        protected override void OnMapRotationChanged(DirectionAngle previousMapRotation, DirectionAngle newMapRotation)
        {
            //IL_0010: Unknown result type (might be due to invalid IL or missing references)
            //IL_0016: Invalid comparison between Unknown and I4
            //IL_0021: Unknown result type (might be due to invalid IL or missing references)
            //IL_0026: Unknown result type (might be due to invalid IL or missing references)
            //IL_002b: Unknown result type (might be due to invalid IL or missing references)
            //IL_0043: Unknown result type (might be due to invalid IL or missing references)
            //IL_007e: Unknown result type (might be due to invalid IL or missing references)
            //IL_00bc: Unknown result type (might be due to invalid IL or missing references)
            //IL_00d2: Unknown result type (might be due to invalid IL or missing references)
            base.OnMapRotationChanged(previousMapRotation, newMapRotation);
            Animator2D animator2D = m_animator2D;

            if ((int)animator2D.GetInitialisationState() == 3)
            {
                Vector2 position = Vector2Int.op_Implicit(m_cellObject.coords);
                CharacterAnimationParameters animationParameters = m_animationParameters;
                CharacterAnimationInfo       characterAnimationInfo;
                if (m_animationParameters.secondDirection == Direction.None)
                {
                    characterAnimationInfo = new CharacterAnimationInfo(position, animationParameters.animationName, animationParameters.timelineKey, animationParameters.loops, direction, newMapRotation);
                }
                else
                {
                    DirectionAngle angle             = newMapRotation.Substract(previousMapRotation);
                    Direction      previousDirection = animationParameters.firstDirection.Rotate(angle);
                    characterAnimationInfo = new CharacterAnimationInfo(position, animationParameters.animationName, animationParameters.timelineKey, animationParameters.loops, previousDirection, direction, newMapRotation);
                }
                animator2D.get_transform().set_localRotation(characterAnimationInfo.flipX ? Quaternion.Euler(0f, -135f, 0f) : Quaternion.Euler(0f, 45f, 0f));
                string animationName = characterAnimationInfo.animationName;
                int    currentFrame  = animator2D.get_currentFrame();
                m_animationCallback.ChangeAnimationName(animationName);
                animator2D.SetAnimation(animationName, characterAnimationInfo.loops, false, true);
                animator2D.set_currentFrame(currentFrame);
                m_animationParameters = characterAnimationInfo.parameters;
            }
        }