using System; using System.Collections.Generic; using UnityEngine; public class Action { protected Actor target; public float duration = 0; protected Transform transform; protected Renderer renderer; public Action() { } public virtual Action clone() { return new Action(); } public virtual bool isRunning() { return false; } /// /// This method is called at the action start. Usable for instant and interval actions. /// public virtual Action reverse() { throw new Exception("Can reverse only the reversable interval actions"); } /// /// This method is called at the action start. Usable for instant and interval actions. /// public virtual void start() { if (target == null) throw new Exception("Can start the action only after it's atached to the actor"); transform = target.gameObject.transform; renderer = target.gameObject.renderer; } /// /// This method is called at every frame update. Not usable for instant actions. /// public virtual void step(float dt) { if (target == null) throw new Exception("Can update the action only after it's atached to the actor"); } /// /// This method is called after the interval action is stopped. Not usable for instant actions. /// public virtual void stop() { if (target == null) throw new Exception("Can stop the action only after it's atached to the actor"); } public void setActor(Actor actor) { target = actor; } public virtual float dtr { get { return 0; } protected set { } } }