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.

54 lines
1.3 KiB

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/Move Block")]
  8. [System.Serializable]
  9. public class Move : LogicBlock
  10. {
  11. [SerializeField]
  12. protected Direction direction = Direction.Forward;
  13. #region Class Functions
  14. /// <summary>
  15. /// Implementation of BlockLogic, moves the player forward
  16. /// </summary>
  17. /// <param name="player">Player to move</param>
  18. protected override void BlockLogic(Character player, float animationTime)
  19. {
  20. player.Move(direction, animationTime);
  21. }
  22. public override void CopyToken(BlockToken token)
  23. {
  24. base.CopyToken(token);
  25. direction = ((DirectionToken)token).direction;
  26. }
  27. public override BlockToken ToToken(BlockToken token = null)
  28. {
  29. if (token == null)
  30. token = new DirectionToken(this);
  31. DirectionToken retVal = (DirectionToken) base.ToToken(token);
  32. retVal.direction = direction;
  33. return retVal;
  34. }
  35. #endregion Class Functions
  36. }
  37. [System.Serializable]
  38. public class DirectionToken : BlockToken
  39. {
  40. public Direction direction;
  41. public DirectionToken(LogicBlock block) : base(block) { }
  42. }