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.

61 lines
1.8 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. #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 void BlockLogic(Character player, float animationTime)
  23. {
  24. player.Rotate(direction, animationTime);
  25. }
  26. /// <summary>
  27. /// Returns the block that the character will endUp on after they use this logic element
  28. /// </summary>
  29. /// <param name="startBlock">block character is on</param>
  30. /// <param name="layerMask">layers to ignore</param>
  31. /// <returns>block which character will finish on after performing this function </returns>
  32. public override Block GetEndBlock(Block startBlock,Transform transform, LayerMask layerMask)
  33. {
  34. //no movement when rotating
  35. return startBlock;
  36. }
  37. public override void CopyToken(BlockToken token)
  38. {
  39. base.CopyToken(token);
  40. direction = ((DirectionToken)token).direction;
  41. }
  42. public override BlockToken ToToken(BlockToken token = null)
  43. {
  44. if (token == null)
  45. token = new DirectionToken(this);
  46. DirectionToken retVal = (DirectionToken)base.ToToken(token);
  47. retVal.direction = direction;
  48. return retVal;
  49. }
  50. #endregion Class Functions
  51. }