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.

80 lines
2.3 KiB

  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. [SerializeField]
  17. [Tooltip("Angle in Degrees")]
  18. protected int Angle = 90;
  19. #endregion Inspector Fields
  20. #region Class Functions
  21. /// <summary>
  22. /// Rotates the player in the direction specified by this block
  23. /// </summary>
  24. /// <param name="player">Player to rotate</param>
  25. protected override IEnumerator BlockLogic(Character player, float animationTime, bool useBlockDirection = false)
  26. {
  27. //player.Rotate(direction, animationTime);
  28. //Debug.Log("Rotating by: " + Angle);
  29. yield return player.StartCoroutine(player.RotateInDirection(direction,Angle, Character.Animation.Jump, animationTime));
  30. }
  31. /// <summary>
  32. /// Returns the block that the character will endUp on after they use this logic element
  33. /// </summary>
  34. /// <param name="startBlock">block character is on</param>
  35. /// <param name="layerMask">layers to ignore</param>
  36. /// <returns>block which character will finish on after performing this function </returns>
  37. public override Block GetEndBlock(Block startBlock,Transform transform, LayerMask layerMask)
  38. {
  39. //no movement when rotating
  40. return startBlock;
  41. }
  42. public override void CopyToken(BlockToken token)
  43. {
  44. base.CopyToken(token);
  45. direction = ((RotateToken)token).direction;
  46. Angle = ((RotateToken)token).angle;
  47. }
  48. public override BlockToken ToToken(BlockToken token = null)
  49. {
  50. if (token == null)
  51. token = new RotateToken(this);
  52. RotateToken retVal = (RotateToken)base.ToToken(token);
  53. retVal.direction = direction;
  54. retVal.angle = Angle;
  55. return retVal;
  56. }
  57. #endregion Class Functions
  58. }
  59. [System.Serializable]
  60. public class RotateToken : BlockToken
  61. {
  62. public Direction direction;
  63. public int angle;
  64. public RotateToken(LogicBlock block) : base(block) { }
  65. }