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.
 
 
 
 
 
 

81 lines
2.1 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Base class all logic blocks are derived from
/// </summary>
[System.Serializable]
public abstract class LogicBlock : ScriptableObject
{
#region Inspector Fields
[SerializeField]
[Header("Base Settings")]
[Tooltip("Wait until this block is resolved before moving to next")]
public bool WaitUntilFinished = false;
[SerializeField]
[Tooltip("Amount of times to run this Block before moving to next")]
protected int RepeatAmount = 1;
#endregion Inspector Fields
#region private variables
/// <summary>
/// Amount of times this block has run
/// </summary>
protected int RepeatCount = 0;
#endregion private variables
#region Class Functions
/// <summary>
/// Runs the block
/// </summary>
/// <param name="player">Player which will be affected by the block</param>
/// <returns>returns true if block is finished</returns>
public virtual bool Run(Character player)
{
RepeatCount++;
BlockLogic(player);
return isFinished();
}
/// <summary>
/// Returns the amount of space this logic block takes up
/// </summary>
/// <returns>Int which controlls how much space this takes up</returns>
public virtual int Size()
{
return 1;
}
/// <summary>
/// Where derived callses should implement the logic for their classes
/// </summary>
/// <param name="player">Player which will be affected by the block</param>
/// <returns>returns true if block is finished</returns>
protected abstract void BlockLogic(Character player);
/// <summary>
/// Resets the block to be ready to used again
/// </summary>
public virtual void Reset()
{
RepeatCount = 0;
}
/// <summary>
/// False if this block needs to be run again
/// </summary>
/// <returns>bool false if block needs to be run again</returns>
public virtual bool isFinished()
{
return (RepeatCount == RepeatAmount);
}
#endregion Class Functions
}