using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[CreateAssetMenu(menuName = "Major Project/Combined Block")]
|
|
[System.Serializable]
|
|
public class CombinedBlock : LogicBlock
|
|
{
|
|
#region Inspector Variables
|
|
[SerializeField]
|
|
[Tooltip("Blocks this will run through")]
|
|
protected BlockReader blockReader;
|
|
#endregion Inspector Variables
|
|
|
|
#region Private Variables
|
|
|
|
#endregion Private Variables
|
|
|
|
|
|
public override bool Run(Character player, float animationTime)
|
|
{
|
|
BlockLogic(player,animationTime);
|
|
|
|
if (blockReader.Finished)
|
|
{
|
|
blockReader.Reset();
|
|
RepeatCount++;
|
|
}
|
|
|
|
return isFinished();
|
|
}
|
|
|
|
protected override void BlockLogic(Character player, float animationTime)
|
|
{
|
|
blockReader.Read(player,animationTime);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resets the block to be ready to used again
|
|
/// </summary>
|
|
public override void Reset()
|
|
{
|
|
base.Reset();
|
|
blockReader.Reset();
|
|
}
|
|
|
|
public override void CopyToken(BlockToken token)
|
|
{
|
|
base.CopyToken(token);
|
|
|
|
blockReader = new BlockReader();
|
|
|
|
foreach (BlockToken subToken in ((CombinedToken)token).subBlocks)
|
|
blockReader.Add(subToken.ToLogicBlock());
|
|
}
|
|
|
|
public override BlockToken ToToken(BlockToken token = null)
|
|
{
|
|
if (token == null)
|
|
token = new CombinedToken(this);
|
|
|
|
CombinedToken retVal = (CombinedToken)base.ToToken(token);
|
|
retVal.subBlocks = new BlockToken[blockReader.LogicChain.Count];
|
|
|
|
for (int i = 0; i < retVal.subBlocks.Length; i++)
|
|
retVal.subBlocks[i] = blockReader.LogicChain[i].ToToken();
|
|
|
|
return retVal;
|
|
}
|
|
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class CombinedToken : BlockToken
|
|
{
|
|
public BlockToken[] subBlocks;
|
|
|
|
public CombinedToken(LogicBlock block) : base(block)
|
|
{
|
|
}
|
|
}
|