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.

49 lines
1.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. #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. public override void CopyToken(BlockToken token)
  27. {
  28. base.CopyToken(token);
  29. direction = ((DirectionToken)token).direction;
  30. }
  31. public override BlockToken ToToken(BlockToken token = null)
  32. {
  33. if (token == null)
  34. token = new DirectionToken(this);
  35. DirectionToken retVal = (DirectionToken)base.ToToken(token);
  36. retVal.direction = direction;
  37. return retVal;
  38. }
  39. #endregion Class Functions
  40. }