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.
 
 
 
 
 
 

80 lines
2.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/Rotate Block")]
[System.Serializable]
public class Rotate : LogicBlock
{
#region Inspector Fields
[SerializeField]
[Header("Rotate Settings")]
[Tooltip("Direction to rotate in")]
protected Direction direction;
[SerializeField]
[Tooltip("Angle in Degrees")]
protected int Angle = 90;
#endregion Inspector Fields
#region Class Functions
/// <summary>
/// Rotates the player in the direction specified by this block
/// </summary>
/// <param name="player">Player to rotate</param>
protected override IEnumerator BlockLogic(Character player, float animationTime, bool useBlockDirection = false)
{
//player.Rotate(direction, animationTime);
//Debug.Log("Rotating by: " + Angle);
yield return player.StartCoroutine(player.RotateInDirection(direction,Angle, Character.Animation.Jump, animationTime));
}
/// <summary>
/// Returns the block that the character will endUp on after they use this logic element
/// </summary>
/// <param name="startBlock">block character is on</param>
/// <param name="layerMask">layers to ignore</param>
/// <returns>block which character will finish on after performing this function </returns>
public override Block GetEndBlock(Block startBlock,Transform transform, LayerMask layerMask)
{
//no movement when rotating
return startBlock;
}
public override void CopyToken(BlockToken token)
{
base.CopyToken(token);
direction = ((RotateToken)token).direction;
Angle = ((RotateToken)token).angle;
}
public override BlockToken ToToken(BlockToken token = null)
{
if (token == null)
token = new RotateToken(this);
RotateToken retVal = (RotateToken)base.ToToken(token);
retVal.direction = direction;
retVal.angle = Angle;
return retVal;
}
#endregion Class Functions
}
[System.Serializable]
public class RotateToken : BlockToken
{
public Direction direction;
public int angle;
public RotateToken(LogicBlock block) : base(block) { }
}