/// <summary>
 /// Update which way the player is facing if necessary.
 /// </summary>
 /// <param name="player">The player character.</param>
 /// <param name="pose">The target pose for the player.</param>
 private void UpdateFacing(PlayerCharacter player, PoseInfo pose)
 {
     if (pose.Flipped)
     {
         player.SetFacing(Facing.Left);
     }
     else
     {
         player.SetFacing(Facing.Right);
     }
 }
Example #2
0
        /// <summary>
        /// Have the player respawn at the last checkpoint.
        /// </summary>
        public void Respawn()
        {
            ResetManager.Reset();

            playerSprite.enabled = true;
            player.Physics.Enable();

            try {
                Vector3 position = TransitionManager.GetCurrentSpawnPosition();
                if (position != Vector3.positiveInfinity)
                {
                    player.Physics.Position = position;
                }

                player.Physics.Velocity = Vector2.zero;

                bool   facingRight = TransitionManager.GetCurrentSpawnFacing();
                Facing facing      = facingRight ? Facing.Right : Facing.Left;
                player.SetFacing(facing);
            } catch (UnityException e) {
                Debug.Log(e);
            }

            StartCoroutine(_WaitToEnableControls());
        }
Example #3
0
        /// <summary>
        /// Restore the state the player's state machine was in.
        /// </summary>
        /// <param name="player">The player character.</param>
        public void RestoreState(PlayerCharacter player)
        {
      #if UNITY_EDITOR
            if (Application.isPlaying)
            {
      #endif

            if (driver != null && !driver.IsInState(player.FSM))
            {
                driver.ForceStateChangeOn(player.FSM);
            }

            player.SetFacing(facing);
            player.gameObject.SetActive(active);
            player.Sprite.sprite = sprite;

      #if UNITY_EDITOR
        }
      #endif
        }
Example #4
0
 public void RestoreFacing(PlayerCharacter player)
 {
     player.SetFacing(facing);
 }