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.

45 lines
1.2 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /// <summary>
  5. /// Logic block which deals with jumping a character in a direction
  6. /// </summary>
  7. [CreateAssetMenu(menuName = "Major Project/Jump Block")]
  8. [System.Serializable]
  9. public class Jump : LogicBlock
  10. {
  11. [SerializeField]
  12. [Tooltip("Direction to Jump")]
  13. protected Direction direction = Direction.Forward;
  14. #region Class Functions
  15. /// <summary>
  16. /// Implementation of BlockLogic, moves the player forward
  17. /// </summary>
  18. /// <param name="player">Player to move</param>
  19. protected override void BlockLogic(Character player, float animationTime)
  20. {
  21. player.Jump(direction, animationTime);
  22. }
  23. public override void CopyToken(BlockToken token)
  24. {
  25. base.CopyToken(token);
  26. direction = ((DirectionToken)token).direction;
  27. }
  28. public override BlockToken ToToken(BlockToken token = null)
  29. {
  30. if (token == null)
  31. token = new DirectionToken(this);
  32. DirectionToken retVal = (DirectionToken)base.ToToken(token);
  33. retVal.direction = direction;
  34. return retVal;
  35. }
  36. #endregion Class Functions
  37. }