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

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Logic block which deals with moving a character in a direction
/// </summary>
[CreateAssetMenu(menuName = "Major Project/Move Block")]
[System.Serializable]
public class Move : LogicBlock
{
[SerializeField]
protected Direction direction = Direction.Forward;
#region Class Functions
/// <summary>
/// Implementation of BlockLogic, moves the player forward
/// </summary>
/// <param name="player">Player to move</param>
protected override void BlockLogic(Character player, float animationTime)
{
player.Move(direction, animationTime);
}
public override void CopyToken(BlockToken token)
{
base.CopyToken(token);
direction = ((DirectionToken)token).direction;
}
public override BlockToken ToToken(BlockToken token = null)
{
if (token == null)
token = new DirectionToken(this);
DirectionToken retVal = (DirectionToken) base.ToToken(token);
retVal.direction = direction;
return retVal;
}
#endregion Class Functions
}
[System.Serializable]
public class DirectionToken : BlockToken
{
public Direction direction;
public DirectionToken(LogicBlock block) : base(block) { }
}