You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9 KiB

5 years ago
5 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /// <summary>
  5. /// Logic block which deals with moving a character in a direction
  6. /// </summary>
  7. [CreateAssetMenu(menuName = "Major Project/Rotate Block")]
  8. [System.Serializable]
  9. public class Rotate : LogicBlock
  10. {
  11. #region Inspector Fields
  12. [SerializeField]
  13. [Header("Rotate Settings")]
  14. [Tooltip("Direction to rotate in")]
  15. protected Direction direction;
  16. #endregion Inspector Fields
  17. #region Class Functions
  18. /// <summary>
  19. /// Rotates the player in the direction specified by this block
  20. /// </summary>
  21. /// <param name="player">Player to rotate</param>
  22. protected override IEnumerator BlockLogic(Character player, float animationTime)
  23. {
  24. //player.Rotate(direction, animationTime);
  25. yield return player.StartCoroutine(player.RotateToDirection(direction, Character.Animation.Jump, animationTime, true));
  26. }
  27. /// <summary>
  28. /// Returns the block that the character will endUp on after they use this logic element
  29. /// </summary>
  30. /// <param name="startBlock">block character is on</param>
  31. /// <param name="layerMask">layers to ignore</param>
  32. /// <returns>block which character will finish on after performing this function </returns>
  33. public override Block GetEndBlock(Block startBlock,Transform transform, LayerMask layerMask)
  34. {
  35. //no movement when rotating
  36. return startBlock;
  37. }
  38. public override void CopyToken(BlockToken token)
  39. {
  40. base.CopyToken(token);
  41. direction = ((DirectionToken)token).direction;
  42. }
  43. public override BlockToken ToToken(BlockToken token = null)
  44. {
  45. if (token == null)
  46. token = new DirectionToken(this);
  47. DirectionToken retVal = (DirectionToken)base.ToToken(token);
  48. retVal.direction = direction;
  49. return retVal;
  50. }
  51. #endregion Class Functions
  52. }