Browse Source

Documented classes a bit.

Renamed some methods to comply with the C# naming convention.
master
38 changed files with 451 additions and 580 deletions
  1. +7
    -7
      Assets/scripts/coa4u/ActionsBase/Action.cs
  2. +15
    -15
      Assets/scripts/coa4u/ActionsBase/ActionInterval.cs
  3. +14
    -26
      Assets/scripts/coa4u/ActionsBase/ActionParallel.cs
  4. +14
    -26
      Assets/scripts/coa4u/ActionsBase/ActionRandom.cs
  5. +18
    -30
      Assets/scripts/coa4u/ActionsBase/ActionRepeat.cs
  6. +19
    -31
      Assets/scripts/coa4u/ActionsBase/ActionSequence.cs
  7. +3
    -9
      Assets/scripts/coa4u/ActionsBase/ActionStop.cs
  8. +4
    -13
      Assets/scripts/coa4u/ActionsInstant/ActionHide.cs
  9. +6
    -12
      Assets/scripts/coa4u/ActionsInstant/ActionLog.cs
  10. +13
    -22
      Assets/scripts/coa4u/ActionsInstant/ActionSendMessage.cs
  11. +9
    -15
      Assets/scripts/coa4u/ActionsInstant/ActionSetDirection.cs
  12. +8
    -14
      Assets/scripts/coa4u/ActionsInstant/ActionSetPlace.cs
  13. +6
    -12
      Assets/scripts/coa4u/ActionsInstant/ActionSetRotation.cs
  14. +5
    -11
      Assets/scripts/coa4u/ActionsInstant/ActionSetTint.cs
  15. +4
    -13
      Assets/scripts/coa4u/ActionsInstant/ActionShow.cs
  16. +4
    -13
      Assets/scripts/coa4u/ActionsInstant/ActionToggleVisibility.cs
  17. +17
    -29
      Assets/scripts/coa4u/ActionsInterval/ActionBezierAbs.cs
  18. +12
    -24
      Assets/scripts/coa4u/ActionsInterval/ActionBezierRel.cs
  19. +12
    -18
      Assets/scripts/coa4u/ActionsInterval/ActionBlink.cs
  20. +10
    -13
      Assets/scripts/coa4u/ActionsInterval/ActionDelay.cs
  21. +9
    -18
      Assets/scripts/coa4u/ActionsInterval/ActionFadeBy.cs
  22. +4
    -10
      Assets/scripts/coa4u/ActionsInterval/ActionFadeIn.cs
  23. +4
    -10
      Assets/scripts/coa4u/ActionsInterval/ActionFadeOut.cs
  24. +10
    -19
      Assets/scripts/coa4u/ActionsInterval/ActionFadeTo.cs
  25. +15
    -12
      Assets/scripts/coa4u/ActionsInterval/ActionJumpBy.cs
  26. +15
    -12
      Assets/scripts/coa4u/ActionsInterval/ActionJumpTo.cs
  27. +29
    -10
      Assets/scripts/coa4u/ActionsInterval/ActionMoveBy.cs
  28. +15
    -12
      Assets/scripts/coa4u/ActionsInterval/ActionMoveTo.cs
  29. +13
    -10
      Assets/scripts/coa4u/ActionsInterval/ActionRotateBy.cs
  30. +15
    -12
      Assets/scripts/coa4u/ActionsInterval/ActionRotateTo.cs
  31. +17
    -14
      Assets/scripts/coa4u/ActionsInterval/ActionScaleBy.cs
  32. +15
    -12
      Assets/scripts/coa4u/ActionsInterval/ActionScaleTo.cs
  33. +16
    -13
      Assets/scripts/coa4u/ActionsInterval/ActionSkewBy.cs
  34. +18
    -15
      Assets/scripts/coa4u/ActionsInterval/ActionTintBy.cs
  35. +24
    -21
      Assets/scripts/coa4u/ActionsInterval/ActionTintTo.cs
  36. +14
    -8
      Assets/scripts/coa4u/CoreClasses/MethodHolder.cs
  37. +12
    -13
      Assets/scripts/coa4u/UnityComponents/Actor.cs
  38. +6
    -6
      Assets/scripts/coa4u/UnityComponents/ActorSampleActions.cs

+ 7
- 7
Assets/scripts/coa4u/ActionsBase/Action.cs View File

@@ -37,7 +37,7 @@ namespace coa4u
/// <summary> /// <summary>
/// Returns a copy of the action. /// Returns a copy of the action.
/// </summary> /// </summary>
public virtual ActionInstant clone()
public virtual ActionInstant Clone()
{ {
return new ActionInstant(); return new ActionInstant();
} }
@@ -45,7 +45,7 @@ namespace coa4u
/// <summary> /// <summary>
/// Returns the reversed version of the action, if it is possible. /// Returns the reversed version of the action, if it is possible.
/// </summary> /// </summary>
public virtual ActionInstant reverse()
public virtual ActionInstant Reverse()
{ {
throw new Exception("Can reverse only the reversable interval actions"); throw new Exception("Can reverse only the reversable interval actions");
} }
@@ -53,7 +53,7 @@ namespace coa4u
/// <summary> /// <summary>
/// This method is called at the action start. Usable for instant and interval actions. /// This method is called at the action start. Usable for instant and interval actions.
/// </summary> /// </summary>
public virtual void start()
public virtual void Start()
{ {
if (target == null) if (target == null)
throw new Exception("Can start the action only after it's atached to the actor"); throw new Exception("Can start the action only after it's atached to the actor");
@@ -64,7 +64,7 @@ namespace coa4u
/// <summary> /// <summary>
/// This method is called at every frame update. Not usable for instant actions. /// This method is called at every frame update. Not usable for instant actions.
/// </summary> /// </summary>
public virtual void step(float dt)
public virtual void StepTimer(float dt)
{ {
if (target == null) if (target == null)
throw new Exception("Can update the action only after it's atached to the actor"); throw new Exception("Can update the action only after it's atached to the actor");
@@ -73,7 +73,7 @@ namespace coa4u
/// <summary> /// <summary>
/// This method is called after the interval action is stopped. Not usable for instant actions. /// This method is called after the interval action is stopped. Not usable for instant actions.
/// </summary> /// </summary>
public virtual void stop()
public virtual void Stop()
{ {
if (target == null) if (target == null)
throw new Exception("Can stop the action only after it's atached to the actor"); throw new Exception("Can stop the action only after it's atached to the actor");
@@ -82,7 +82,7 @@ namespace coa4u
/// <summary> /// <summary>
/// This method sets the actor for the action. /// This method sets the actor for the action.
/// </summary> /// </summary>
public void setActor(Actor actor)
public void SetActor(Actor actor)
{ {
target = actor; target = actor;
} }
@@ -90,7 +90,7 @@ namespace coa4u
/// <summary> /// <summary>
/// This method modifies the given vector to keep the locked axises untouched. /// This method modifies the given vector to keep the locked axises untouched.
/// </summary> /// </summary>
protected void lockAxises(ref Vector3 point)
protected void LockAxises(ref Vector3 point)
{ {
{ {
if (target == null) if (target == null)


+ 15
- 15
Assets/scripts/coa4u/ActionsBase/ActionInterval.cs View File

@@ -13,10 +13,10 @@ namespace coa4u
protected float timeScale; protected float timeScale;
private float dtrdata; private float dtrdata;


public ActionInterval(float tgtDuration)
public ActionInterval(float targetDuration)
: base() : base()
{ {
duration = tgtDuration;
duration = targetDuration;
timeScale = 1F; timeScale = 1F;
dtr = 0; dtr = 0;
} }
@@ -24,7 +24,7 @@ namespace coa4u
/// <summary> /// <summary>
/// Returns a copy of the action. /// Returns a copy of the action.
/// </summary> /// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionInterval(duration); return new ActionInterval(duration);
} }
@@ -32,7 +32,7 @@ namespace coa4u
/// <summary> /// <summary>
/// Returns the reversed version of the action, if it is possible. /// Returns the reversed version of the action, if it is possible.
/// </summary> /// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
throw new Exception("Can reverse only the reversable interval actions"); throw new Exception("Can reverse only the reversable interval actions");
} }
@@ -40,9 +40,9 @@ namespace coa4u
/// <summary> /// <summary>
/// This method is called at the action start. /// This method is called at the action start.
/// </summary> /// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
running = true; running = true;
timer = 0F; timer = 0F;
} }
@@ -50,19 +50,19 @@ namespace coa4u
/// <summary> /// <summary>
/// This method is called after the interval action is stopped. /// This method is called after the interval action is stopped.
/// </summary> /// </summary>
public override void stop()
public override void Stop()
{ {
base.stop();
base.Stop();
running = false; running = false;
} }


/// <summary> /// <summary>
/// This method is called every frame update. Don't override this method, when inheriting, put your code in stepInterval instead.
/// This method is called every frame update. Don't override this method, when inheriting, put your code in Step() instead.
/// </summary> /// </summary>
public override void step(float dt)
public override void StepTimer(float dt)
{ {
dt *= timeScale; dt *= timeScale;
base.step(dt);
base.StepTimer(dt);
if (timer + dt > duration) if (timer + dt > duration)
{ {
float odt = dt; float odt = dt;
@@ -73,10 +73,10 @@ namespace coa4u
{ {
timer += dt; timer += dt;
} }
stepInterval(dt);
Step(dt);
if (timer > duration) if (timer > duration)
{ {
stop();
Stop();
dtr = timer - duration; dtr = timer - duration;
} }
} }
@@ -84,14 +84,14 @@ namespace coa4u
/// <summary> /// <summary>
/// This method is called every frame update. Put your code here. /// This method is called every frame update. Put your code here.
/// </summary> /// </summary>
public virtual void stepInterval(float dt)
public virtual void Step(float dt)
{ {
} }


/// <summary> /// <summary>
/// Immediately changes the time scale for this action and all nested ones. /// Immediately changes the time scale for this action and all nested ones.
/// </summary> /// </summary>
public void setTimeScale(float ts)
public void SetTimeScale(float ts)
{ {
timeScale = ts; timeScale = ts;
} }


+ 14
- 26
Assets/scripts/coa4u/ActionsBase/ActionParallel.cs View File

@@ -24,55 +24,43 @@ namespace coa4u


} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
ActionInstant[] aList = new ActionInstant[actions.Length]; ActionInstant[] aList = new ActionInstant[actions.Length];
for (int i = 0; i < actions.Length; i++) for (int i = 0; i < actions.Length; i++)
{ {
aList[i] = actions[i].clone();
aList[i] = actions[i].Clone();
} }
return new ActionSequence(aList); return new ActionSequence(aList);
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
ActionInstant[] aList = new ActionInstant[actions.Length]; ActionInstant[] aList = new ActionInstant[actions.Length];
for (int i = 0; i < actions.Length; i++) for (int i = 0; i < actions.Length; i++)
{ {
aList[i] = actions[i].reverse();
aList[i] = actions[i].Reverse();
} }
return new ActionSequence(aList); return new ActionSequence(aList);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
for (int i = 0; i < actions.Length; i++) for (int i = 0; i < actions.Length; i++)
{ {
actions[i].setActor(target);
actions[i].start();
actions[i].SetActor(target);
actions[i].Start();
} }
} }


/// <summary>
/// This method is called every frame update.
/// </summary>
public override void step(float dt)
public override void StepTimer(float dt)
{ {
dt *= timeScale; dt *= timeScale;
for (int i = 0; i < actions.Length; i++) for (int i = 0; i < actions.Length; i++)
{ {
if (actions[i].running) if (actions[i].running)
actions[i].step(dt);
actions[i].StepTimer(dt);
} }
bool canStopNow = true; bool canStopNow = true;
float dtrdata = 0; float dtrdata = 0;
@@ -86,7 +74,7 @@ namespace coa4u
} }
if (canStopNow) if (canStopNow)
{ {
stop();
Stop();
dtr = dtrdata; dtr = dtrdata;
} }
} }
@@ -94,12 +82,12 @@ namespace coa4u
/// <summary> /// <summary>
/// This method is called after the interval action is stopped. /// This method is called after the interval action is stopped.
/// </summary> /// </summary>
public override void stop()
public override void Stop()
{ {
base.stop();
base.Stop();
for (int i = 0; i < actions.Length; i++) for (int i = 0; i < actions.Length; i++)
{ {
actions[i].stop();
actions[i].Stop();
} }
} }
} }

+ 14
- 26
Assets/scripts/coa4u/ActionsBase/ActionRandom.cs View File

@@ -26,54 +26,42 @@ namespace coa4u


} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
ActionInstant[] aList = new ActionInstant[actions.Length]; ActionInstant[] aList = new ActionInstant[actions.Length];
for (int i = 0; i < actions.Length; i++) for (int i = 0; i < actions.Length; i++)
{ {
aList[i] = actions[i].clone();
aList[i] = actions[i].Clone();
} }
return new ActionRandom(aList); return new ActionRandom(aList);
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
ActionInstant[] aList = new ActionInstant[actions.Length]; ActionInstant[] aList = new ActionInstant[actions.Length];
for (int i = 0; i < actions.Length; i++) for (int i = 0; i < actions.Length; i++)
{ {
aList[i] = actions[i].reverse();
aList[i] = actions[i].Reverse();
} }
return new ActionRandom(aList); return new ActionRandom(aList);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
index = UnityEngine.Random.Range(0, actions.Length); index = UnityEngine.Random.Range(0, actions.Length);
actions[index].setActor(target);
actions[index].start();
actions[index].SetActor(target);
actions[index].Start();
} }


/// <summary>
/// This method is called every frame update.
/// </summary>
public override void step(float dt)
public override void StepTimer(float dt)
{ {
dt *= timeScale; dt *= timeScale;
if (actions[index].running) if (actions[index].running)
actions[index].step(dt);
actions[index].StepTimer(dt);
if (!actions[index].running) if (!actions[index].running)
{ {
stop();
Stop();
dtr = actions[index].dtr; dtr = actions[index].dtr;
} }
} }
@@ -81,10 +69,10 @@ namespace coa4u
/// <summary> /// <summary>
/// This method is called after the interval action is stopped. /// This method is called after the interval action is stopped.
/// </summary> /// </summary>
public override void stop()
public override void Stop()
{ {
base.stop();
actions[index].stop();
base.Stop();
actions[index].Stop();
} }
} }
} }

+ 18
- 30
Assets/scripts/coa4u/ActionsBase/ActionRepeat.cs View File

@@ -14,73 +14,61 @@ namespace coa4u
protected int counter; protected int counter;
protected bool forever; protected bool forever;


public ActionRepeat(ActionInterval tgtAction, int tgtCount)
public ActionRepeat(ActionInterval targetAction, int targetCount)
: base(0) : base(0)
{ {
action = tgtAction;
count = tgtCount;
action = targetAction;
count = targetCount;
counter = 0; counter = 0;
forever = false; forever = false;
} }


public ActionRepeat(ActionInterval tgtAction)
public ActionRepeat(ActionInterval targetAction)
: base(0) : base(0)
{ {
action = tgtAction;
action = targetAction;
count = 0; count = 0;
counter = 0; counter = 0;
forever = true; forever = true;
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionRepeat((ActionInterval)action.clone(), count);
return new ActionRepeat((ActionInterval)action.Clone(), count);
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionRepeat((ActionInterval)action.reverse(), count);
return new ActionRepeat((ActionInterval)action.Reverse(), count);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
action.setActor(target);
action.start();
base.Start();
action.SetActor(target);
action.Start();
counter = 0; counter = 0;
} }


/// <summary>
/// This method is called every frame update.
/// </summary>
public override void step(float dt)
public override void StepTimer(float dt)
{ {
dt *= timeScale; dt *= timeScale;
if (action.running) if (action.running)
{ {
action.step(dt);
action.StepTimer(dt);
} }
if (!action.running && (forever || counter < count - 1)) if (!action.running && (forever || counter < count - 1))
{ {
float dtrdata = action.dtr; float dtrdata = action.dtr;
action.start();
action.Start();
if (dtrdata > 0) if (dtrdata > 0)
action.step(dtrdata);
action.StepTimer(dtrdata);
counter += 1; counter += 1;
} }
else if (!action.running && counter >= count - 1) else if (!action.running && counter >= count - 1)
{ {
dtr = action.dtr; dtr = action.dtr;
stop();
Stop();
} }
} }
} }

+ 19
- 31
Assets/scripts/coa4u/ActionsBase/ActionSequence.cs View File

@@ -25,73 +25,61 @@ namespace coa4u


} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
ActionInstant[] aList = new ActionInstant[actions.Length]; ActionInstant[] aList = new ActionInstant[actions.Length];
for (int i = 0; i < actions.Length; i++) for (int i = 0; i < actions.Length; i++)
{ {
aList[i] = actions[i].clone();
aList[i] = actions[i].Clone();
} }
return new ActionSequence(aList); return new ActionSequence(aList);
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
ActionInstant[] aList = new ActionInstant[actions.Length]; ActionInstant[] aList = new ActionInstant[actions.Length];
for (int i = 0; i < actions.Length; i++) for (int i = 0; i < actions.Length; i++)
{ {
aList[actions.Length - 1 - i] = actions[i].reverse();
aList[actions.Length - 1 - i] = actions[i].Reverse();
} }
return new ActionSequence(aList); return new ActionSequence(aList);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
index = 0; index = 0;
actions[0].setActor(target);
actions[0].start();
actions[0].SetActor(target);
actions[0].Start();
while (!actions[index].running && index < actions.Length) while (!actions[index].running && index < actions.Length)
{ {
index += 1; index += 1;
actions[index].setActor(target);
actions[index].start();
actions[index].SetActor(target);
actions[index].Start();
} }
} }


/// <summary>
/// This method is called every frame update.
/// </summary>
public override void step(float dt)
public override void StepTimer(float dt)
{ {
dt *= timeScale; dt *= timeScale;
float dtrdata = 0; float dtrdata = 0;
if (actions[index].running) if (actions[index].running)
{ {
actions[index].step(dt);
actions[index].StepTimer(dt);
if (!actions[index].running) if (!actions[index].running)
dtrdata = actions[index].dtr; dtrdata = actions[index].dtr;
} }
while (!actions[index].running && index < actions.Length - 1) while (!actions[index].running && index < actions.Length - 1)
{ {
index += 1; index += 1;
actions[index].setActor(target);
actions[index].start();
actions[index].SetActor(target);
actions[index].Start();
if (actions[index].running && dtrdata > 0) if (actions[index].running && dtrdata > 0)
actions[index].step(dtrdata);
actions[index].StepTimer(dtrdata);
} }
if (!actions[index].running) if (!actions[index].running)
{ {
stop();
Stop();
dtr = dtrdata; dtr = dtrdata;
} }
} }
@@ -99,12 +87,12 @@ namespace coa4u
/// <summary> /// <summary>
/// This method is called after the interval action is stopped. /// This method is called after the interval action is stopped.
/// </summary> /// </summary>
public override void stop()
public override void Stop()
{ {
base.stop();
base.Stop();
for (int i = 0; i < actions.Length; i++) for (int i = 0; i < actions.Length; i++)
{ {
actions[i].stop();
actions[i].Stop();
} }
} }
} }

+ 3
- 9
Assets/scripts/coa4u/ActionsBase/ActionStop.cs View File

@@ -14,20 +14,14 @@ namespace coa4u
{ {
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionStop(); return new ActionStop();
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
target.StopAction(); target.StopAction();
} }
} }

+ 4
- 13
Assets/scripts/coa4u/ActionsInstant/ActionHide.cs View File

@@ -15,28 +15,19 @@ namespace coa4u
{ {
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionHide(); return new ActionHide();
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionShow(); return new ActionShow();
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
renderer.enabled = false; renderer.enabled = false;
} }
} }

+ 6
- 12
Assets/scripts/coa4u/ActionsInstant/ActionLog.cs View File

@@ -11,16 +11,13 @@ namespace coa4u
{ {
string message; string message;


public ActionLog(string tgtMessage)
public ActionLog(string targetMessage)
: base() : base()
{ {
message = tgtMessage;
message = targetMessage;
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionLog(message); return new ActionLog(message);
} }
@@ -28,17 +25,14 @@ namespace coa4u
/// <summary> /// <summary>
/// Returns the reversed version of the action, if it is possible. /// Returns the reversed version of the action, if it is possible.
/// </summary> /// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionLog(message); return new ActionLog(message);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
Debug.Log(message); Debug.Log(message);
} }
} }

+ 13
- 22
Assets/scripts/coa4u/ActionsInstant/ActionSendMessage.cs View File

@@ -15,49 +15,40 @@ namespace coa4u
protected object param; protected object param;
protected SendMessageOptions options = SendMessageOptions.DontRequireReceiver; protected SendMessageOptions options = SendMessageOptions.DontRequireReceiver;


public ActionSendMessage(string tgtMessage)
public ActionSendMessage(string targetMessage)
: base() : base()
{ {
message = tgtMessage;
message = targetMessage;
} }


public ActionSendMessage(string tgtMessage, object tgtParam)
public ActionSendMessage(string targetMessage, object targetParam)
: base() : base()
{ {
message = tgtMessage;
param = tgtParam;
message = targetMessage;
param = targetParam;
} }


public ActionSendMessage(string tgtMessage, object tgtParam, SendMessageOptions tgtOptions)
public ActionSendMessage(string targetMessage, object targetParam, SendMessageOptions targetOptions)
: base() : base()
{ {
message = tgtMessage;
param = tgtParam;
options = tgtOptions;
message = targetMessage;
param = targetParam;
options = targetOptions;
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionSendMessage(message, param, options); return new ActionSendMessage(message, param, options);
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionSendMessage(message, param, options); return new ActionSendMessage(message, param, options);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
if (param != null) if (param != null)
{ {
target.ReceiveMessage(message, param, options); target.ReceiveMessage(message, param, options);


+ 9
- 15
Assets/scripts/coa4u/ActionsInstant/ActionSetDirection.cs View File

@@ -12,38 +12,32 @@ namespace coa4u
protected Vector3 value; protected Vector3 value;
protected Actor other; protected Actor other;


public ActionSetDirection(Vector3 tgtValue)
public ActionSetDirection(Vector3 targetValue)
: base() : base()
{ {
value = tgtValue;
value = targetValue;
} }


public ActionSetDirection(Vector2 tgtValue)
: this((Vector3)tgtValue)
public ActionSetDirection(Vector2 targetValue)
: this((Vector3)targetValue)
{ {
locks = Axises.z; locks = Axises.z;
} }


public ActionSetDirection(Actor tgtActor)
public ActionSetDirection(Actor targetActor)
: base() : base()
{ {
other = tgtActor;
other = targetActor;
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionSetDirection(value); return new ActionSetDirection(value);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
if (other != null) if (other != null)
{ {
value = other.transform.position; value = other.transform.position;


+ 8
- 14
Assets/scripts/coa4u/ActionsInstant/ActionSetPlace.cs View File

@@ -11,34 +11,28 @@ namespace coa4u
{ {
protected Vector3 value; protected Vector3 value;


public ActionSetPlace(Vector3 tgtPlace)
public ActionSetPlace(Vector3 targetPlace)
: base() : base()
{ {
value = tgtPlace;
value = targetPlace;
} }


public ActionSetPlace(Vector2 tgtPlace)
: this((Vector3)tgtPlace)
public ActionSetPlace(Vector2 targetPlace)
: this((Vector3)targetPlace)
{ {
locks = Axises.z; locks = Axises.z;
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionSetPlace(value); return new ActionSetPlace(value);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
if (locks != Axises.none) if (locks != Axises.none)
lockAxises(ref value);
LockAxises(ref value);
transform.position = value; transform.position = value;
} }
} }

+ 6
- 12
Assets/scripts/coa4u/ActionsInstant/ActionSetRotation.cs View File

@@ -11,10 +11,10 @@ namespace coa4u
{ {
protected Vector3 value; protected Vector3 value;


public ActionSetRotation(Vector3 tgtValue)
public ActionSetRotation(Vector3 targetValue)
: base() : base()
{ {
value = tgtValue;
value = targetValue;
} }


public ActionSetRotation(float angle) public ActionSetRotation(float angle)
@@ -23,22 +23,16 @@ namespace coa4u
locks = Axises.xy; locks = Axises.xy;
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionSetRotation(value); return new ActionSetRotation(value);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
if (locks != Axises.none) if (locks != Axises.none)
lockAxises(ref value);
LockAxises(ref value);
transform.rotation = Quaternion.Euler(value); transform.rotation = Quaternion.Euler(value);
} }
} }

+ 5
- 11
Assets/scripts/coa4u/ActionsInstant/ActionSetTint.cs View File

@@ -12,26 +12,20 @@ namespace coa4u
public Vector4 color; public Vector4 color;
protected const float coeff = 1F / 255F; protected const float coeff = 1F / 255F;


public ActionSetTint(Vector4 tgtColor)
public ActionSetTint(Vector4 targetColor)
: base() : base()
{ {
color = tgtColor * coeff;
color = targetColor * coeff;
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionSetTint(color * 255F); return new ActionSetTint(color * 255F);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
renderer.material.color = new Color(color[0], color[1], color[2], color[3]); renderer.material.color = new Color(color[0], color[1], color[2], color[3]);
} }
} }

+ 4
- 13
Assets/scripts/coa4u/ActionsInstant/ActionShow.cs View File

@@ -15,28 +15,19 @@ namespace coa4u
{ {
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionShow(); return new ActionShow();
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionHide(); return new ActionHide();
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
renderer.enabled = true; renderer.enabled = true;
} }
} }

+ 4
- 13
Assets/scripts/coa4u/ActionsInstant/ActionToggleVisibility.cs View File

@@ -15,28 +15,19 @@ namespace coa4u
{ {
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionToggleVisibility(); return new ActionToggleVisibility();
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionToggleVisibility(); return new ActionToggleVisibility();
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
renderer.enabled = !renderer.enabled; renderer.enabled = !renderer.enabled;
} }
} }

+ 17
- 29
Assets/scripts/coa4u/ActionsInterval/ActionBezierAbs.cs View File

@@ -14,57 +14,45 @@ namespace coa4u
protected Vector3 startControlPoint; protected Vector3 startControlPoint;
protected Vector3 endControlPoint; protected Vector3 endControlPoint;


public ActionBezierAbs(Vector3 tgtStart, Vector3 tgtSCP, Vector3 tgtECP, Vector3 tgtEnd, float tgtDuration)
: base(tgtDuration)
public ActionBezierAbs(Vector3 targetStart, Vector3 targetSCP, Vector3 targetECP, Vector3 targetEnd, float targetDuration)
: base(targetDuration)
{ {
startPoint = tgtStart;
endPoint = tgtEnd;
startControlPoint = tgtSCP;
endControlPoint = tgtECP;
startPoint = targetStart;
endPoint = targetEnd;
startControlPoint = targetSCP;
endControlPoint = targetECP;
} }


public ActionBezierAbs(Vector2 tgtStart, Vector2 tgtSCP, Vector2 tgtECP, Vector2 tgtEnd, float tgtDuration)
: this((Vector3)tgtStart, (Vector3)tgtSCP, (Vector3)tgtECP, (Vector3)tgtEnd, tgtDuration)
public ActionBezierAbs(Vector2 targetStart, Vector2 targetSCP, Vector2 targetECP, Vector2 targetEnd, float targetDuration)
: this((Vector3)targetStart, (Vector3)targetSCP, (Vector3)targetECP, (Vector3)targetEnd, targetDuration)
{ {
locks = Axises.z; locks = Axises.z;
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionBezierAbs(startPoint, startControlPoint, endControlPoint, endPoint, duration); return new ActionBezierAbs(startPoint, startControlPoint, endControlPoint, endPoint, duration);
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionBezierAbs(endPoint, endControlPoint, startControlPoint, startPoint, duration); return new ActionBezierAbs(endPoint, endControlPoint, startControlPoint, startPoint, duration);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
float z = transform.position.z; float z = transform.position.z;
if (locks != Axises.none) if (locks != Axises.none)
{ {
lockAxises(ref startPoint);
lockAxises(ref endPoint);
lockAxises(ref startControlPoint);
lockAxises(ref endControlPoint);
LockAxises(ref startPoint);
LockAxises(ref endPoint);
LockAxises(ref startControlPoint);
LockAxises(ref endControlPoint);
} }
} }


/// <summary>
/// This method is called every frame update.
/// </summary>
public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float t = timer / duration; float t = timer / duration;
Vector3 newPosition = (((-startPoint Vector3 newPosition = (((-startPoint


+ 12
- 24
Assets/scripts/coa4u/ActionsInterval/ActionBezierRel.cs View File

@@ -17,51 +17,39 @@ namespace coa4u
protected Vector3 startControlPoint; protected Vector3 startControlPoint;
protected Vector3 endControlPoint; protected Vector3 endControlPoint;


public ActionBezierRel(Vector3 tgtSCP, Vector3 tgtECP, Vector3 tgtEnd, float tgtDuration)
: base(tgtDuration)
public ActionBezierRel(Vector3 targetSCP, Vector3 targetECP, Vector3 targetEnd, float targetDuration)
: base(targetDuration)
{ {
ep = tgtEnd;
cp1 = tgtSCP;
cp2 = tgtECP;
ep = targetEnd;
cp1 = targetSCP;
cp2 = targetECP;
} }


public ActionBezierRel(Vector2 tgtSCP, Vector2 tgtECP, Vector2 tgtEnd, float tgtDuration)
: this((Vector3)tgtSCP, (Vector3)tgtECP, (Vector3)tgtEnd, tgtDuration)
public ActionBezierRel(Vector2 targetSCP, Vector2 targetECP, Vector2 targetEnd, float targetDuration)
: this((Vector3)targetSCP, (Vector3)targetECP, (Vector3)targetEnd, targetDuration)
{ {
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionBezierRel(startControlPoint, endControlPoint, endPoint, duration); return new ActionBezierRel(startControlPoint, endControlPoint, endPoint, duration);
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionBezierRel(-startControlPoint, -endControlPoint, -endPoint, duration); return new ActionBezierRel(-startControlPoint, -endControlPoint, -endPoint, duration);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
startPoint = target.transform.position; startPoint = target.transform.position;
endPoint = startPoint + ep; endPoint = startPoint + ep;
startControlPoint = startPoint + cp1; startControlPoint = startPoint + cp1;
endControlPoint = startControlPoint + cp2; endControlPoint = startControlPoint + cp2;
} }


/// <summary>
/// This method is called every frame update.
/// </summary>
public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float t = timer / duration; float t = timer / duration;
Vector3 newPosition = (((-startPoint Vector3 newPosition = (((-startPoint


+ 12
- 18
Assets/scripts/coa4u/ActionsInterval/ActionBlink.cs View File

@@ -15,46 +15,40 @@ namespace coa4u
protected float durationMin; protected float durationMin;
protected float durationMax; protected float durationMax;


public ActionBlink(int tgtBlinks, float tgtDuration)
public ActionBlink(int targetBlinks, float targetDuration)
: base(null, 0) : base(null, 0)
{ {
durationMin = tgtDuration;
durationMax = tgtDuration;
count = (tgtBlinks) * 2;
durationMin = targetDuration;
durationMax = targetDuration;
count = (targetBlinks) * 2;
blinkSeq = new ActionInstant[] blinkSeq = new ActionInstant[]
{ {
new ActionToggleVisibility(), new ActionToggleVisibility(),
new ActionDelay(tgtDuration / tgtBlinks)
new ActionDelay(targetDuration / targetBlinks)
}; };
action = new ActionSequence(blinkSeq); action = new ActionSequence(blinkSeq);
} }


public ActionBlink(int tgtBlinks, float tgtDurationMin, float tgtDurationMax)
public ActionBlink(int targetBlinks, float targetDurationMin, float targetDurationMax)
: base(null, 0) : base(null, 0)
{ {
durationMin = tgtDurationMin;
durationMax = tgtDurationMax;
count = (tgtBlinks) * 2;
durationMin = targetDurationMin;
durationMax = targetDurationMax;
count = (targetBlinks) * 2;
blinkSeq = new ActionInstant[] blinkSeq = new ActionInstant[]
{ {
new ActionToggleVisibility(), new ActionToggleVisibility(),
new ActionDelay(tgtDurationMin / tgtBlinks, tgtDurationMax / tgtBlinks)
new ActionDelay(targetDurationMin / targetBlinks, targetDurationMax / targetBlinks)
}; };
action = new ActionSequence(blinkSeq); action = new ActionSequence(blinkSeq);
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionBlink(count / 2 - 1, durationMin, durationMax); return new ActionBlink(count / 2 - 1, durationMin, durationMax);
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionBlink(count / 2 - 1, durationMin, durationMax); return new ActionBlink(count / 2 - 1, durationMin, durationMax);
} }


+ 10
- 13
Assets/scripts/coa4u/ActionsInterval/ActionDelay.cs View File

@@ -12,26 +12,23 @@ namespace coa4u
protected float durationMin; protected float durationMin;
protected float durationMax; protected float durationMax;


public ActionDelay(float tgtDuration)
: base(tgtDuration)
public ActionDelay(float targetDuration)
: base(targetDuration)
{ {
durationMin = tgtDuration;
durationMax = tgtDuration;
durationMin = targetDuration;
durationMax = targetDuration;
} }


public ActionDelay(float tgtDuration, float tgtDurationMax)
: base(tgtDuration)
public ActionDelay(float targetDuration, float targetDurationMax)
: base(targetDuration)
{ {
durationMin = tgtDuration;
durationMax = tgtDurationMax;
durationMin = targetDuration;
durationMax = targetDurationMax;
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
if (durationMax != null) if (durationMax != null)
{ {
duration = UnityEngine.Random.Range(durationMin, durationMax); duration = UnityEngine.Random.Range(durationMin, durationMax);


+ 9
- 18
Assets/scripts/coa4u/ActionsInterval/ActionFadeBy.cs View File

@@ -11,37 +11,28 @@ namespace coa4u
{ {
protected float delta; protected float delta;


public ActionFadeBy(float tgtDelta, float tgtDuration)
: base(tgtDuration)
public ActionFadeBy(float targetDelta, float targetDuration)
: base(targetDuration)
{ {
delta = tgtDelta;
delta = targetDelta;
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionFadeBy(delta, duration); return new ActionFadeBy(delta, duration);
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionFadeBy(-delta, duration); return new ActionFadeBy(-delta, duration);
} }


/// <summary>
/// This method is called every frame update.
/// </summary>
public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float d = dt / duration; float d = dt / duration;
Color tgtColor = renderer.material.color;
tgtColor[3] += delta * d;
renderer.material.color = tgtColor;
Color targetColor = renderer.material.color;
targetColor[3] += delta * d;
renderer.material.color = targetColor;
} }
} }
} }

+ 4
- 10
Assets/scripts/coa4u/ActionsInterval/ActionFadeIn.cs View File

@@ -10,23 +10,17 @@ namespace coa4u
class ActionFadeIn : ActionFadeTo class ActionFadeIn : ActionFadeTo
{ {


public ActionFadeIn(float tgtDuration)
: base(1, tgtDuration)
public ActionFadeIn(float targetDuration)
: base(1, targetDuration)
{ {
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionFadeIn(duration); return new ActionFadeIn(duration);
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionFadeOut(duration); return new ActionFadeOut(duration);
} }


+ 4
- 10
Assets/scripts/coa4u/ActionsInterval/ActionFadeOut.cs View File

@@ -10,23 +10,17 @@ namespace coa4u
class ActionFadeOut : ActionFadeTo class ActionFadeOut : ActionFadeTo
{ {


public ActionFadeOut(float tgtDuration)
: base(0, tgtDuration)
public ActionFadeOut(float targetDuration)
: base(0, targetDuration)
{ {
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionFadeOut(duration); return new ActionFadeOut(duration);
} }


/// <summary>
/// Returns the reversed version of the action, if it is possible.
/// </summary>
public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionFadeIn(duration); return new ActionFadeIn(duration);
} }


+ 10
- 19
Assets/scripts/coa4u/ActionsInterval/ActionFadeTo.cs View File

@@ -12,38 +12,29 @@ namespace coa4u
protected float value; protected float value;
protected float delta; protected float delta;


public ActionFadeTo(float tgtValue, float tgtDuration)
: base(tgtDuration)
public ActionFadeTo(float targetValue, float targetDuration)
: base(targetDuration)
{ {
value = tgtValue;
value = targetValue;
} }


/// <summary>
/// Returns a copy of the action.
/// </summary>
public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionFadeTo(value, duration); return new ActionFadeTo(value, duration);
} }


/// <summary>
/// This method is called at the action start.
/// </summary>
public override void start()
public override void Start()
{ {
base.start();
base.Start();
delta = value - renderer.material.color.a; delta = value - renderer.material.color.a;
} }


/// <summary>
/// This method is called every frame update.
/// </summary>
public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float d = dt / duration; float d = dt / duration;
Color tgtColor = renderer.material.color;
tgtColor[3] += delta * d;
renderer.material.color = tgtColor;
Color targetColor = renderer.material.color;
targetColor[3] += delta * d;
renderer.material.color = targetColor;
} }
} }
} }

+ 15
- 12
Assets/scripts/coa4u/ActionsInterval/ActionJumpBy.cs View File

@@ -4,37 +4,40 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// Jumps given number of times in the given direction for the given amount of seconds.
/// </summary>
class ActionJumpBy : ActionSequence class ActionJumpBy : ActionSequence
{ {
protected Vector3 point; protected Vector3 point;
float height; float height;
int jumps; int jumps;


public ActionJumpBy(Vector3 tgtPoint, float tgtHeight, int tgtJumps, float tgtDuration)
: base(new ActionInstant[tgtJumps])
public ActionJumpBy(Vector3 targetPoint, float targetHeight, int targetJumps, float targetDuration)
: base(new ActionInstant[targetJumps])
{ {
point = tgtPoint;
jumps = tgtJumps;
height = tgtHeight;
duration = tgtDuration;
point = targetPoint;
jumps = targetJumps;
height = targetHeight;
duration = targetDuration;
} }


public ActionJumpBy(Vector2 tgtPoint, float tgtHeight, int tgtJumps, float tgtDuration)
: this((Vector3)tgtPoint, tgtHeight, tgtJumps, tgtDuration)
public ActionJumpBy(Vector2 targetPoint, float targetHeight, int targetJumps, float targetDuration)
: this((Vector3)targetPoint, targetHeight, targetJumps, targetDuration)
{ {
} }


public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionJumpBy(point, height, jumps, duration); return new ActionJumpBy(point, height, jumps, duration);
} }


public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionJumpBy(-point, height, jumps, duration); return new ActionJumpBy(-point, height, jumps, duration);
} }


public override void start()
public override void Start()
{ {
float coeff = 1F / jumps; float coeff = 1F / jumps;
Vector3 end = point * coeff; Vector3 end = point * coeff;
@@ -45,7 +48,7 @@ namespace coa4u
{ {
actions[i] = singleJump; actions[i] = singleJump;
} }
base.start();
base.Start();
} }
} }
} }

+ 15
- 12
Assets/scripts/coa4u/ActionsInterval/ActionJumpTo.cs View File

@@ -4,37 +4,40 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// Jumps to the given point for the given amount of seconds in the given amounts of jumps.
/// </summary>
class ActionJumpTo : ActionSequence class ActionJumpTo : ActionSequence
{ {
protected Vector3 point; protected Vector3 point;
float height; float height;
int jumps; int jumps;


public ActionJumpTo(Vector3 tgtPoint, float tgtHeight, int tgtJumps, float tgtDuration)
: base(new ActionInstant[tgtJumps])
public ActionJumpTo(Vector3 targetPoint, float targetHeight, int targetJumps, float targetDuration)
: base(new ActionInstant[targetJumps])
{ {
point = tgtPoint;
jumps = tgtJumps;
height = tgtHeight;
duration = tgtDuration;
point = targetPoint;
jumps = targetJumps;
height = targetHeight;
duration = targetDuration;
} }


public ActionJumpTo(Vector2 tgtPoint, float tgtHeight, int tgtJumps, float tgtDuration)
: this((Vector3)tgtPoint, tgtHeight, tgtJumps, tgtDuration)
public ActionJumpTo(Vector2 targetPoint, float targetHeight, int targetJumps, float targetDuration)
: this((Vector3)targetPoint, targetHeight, targetJumps, targetDuration)
{ {
locks = Axises.z; locks = Axises.z;
} }


public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionJumpTo(point, height, jumps, duration); return new ActionJumpTo(point, height, jumps, duration);
} }


public override void start()
public override void Start()
{ {
float coeff = 1F / jumps; float coeff = 1F / jumps;
if (locks != Axises.none) if (locks != Axises.none)
lockAxises(ref point);
LockAxises(ref point);
Vector3 start = target.gameObject.transform.position; Vector3 start = target.gameObject.transform.position;
Vector3 end = (point - start) * coeff; Vector3 end = (point - start) * coeff;
Vector3 cp1 = Vector3.up * height; Vector3 cp1 = Vector3.up * height;
@@ -44,7 +47,7 @@ namespace coa4u
{ {
actions[i] = singleJump; actions[i] = singleJump;
} }
base.start();
base.Start();
} }
} }
} }

+ 29
- 10
Assets/scripts/coa4u/ActionsInterval/ActionMoveBy.cs View File

@@ -4,36 +4,55 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// Moves in the given direction for the given amount of seconds.
/// </summary>
class ActionMoveBy : ActionInterval class ActionMoveBy : ActionInterval
{ {
protected Vector3 delta; protected Vector3 delta;
protected Vector3 referencePoint;


public ActionMoveBy(Vector3 tgtDelta, float tgtDuration)
: base(tgtDuration)
public ActionMoveBy(Vector3 targetDelta, float targetDuration)
: base(targetDuration)
{ {
delta = tgtDelta;
delta = targetDelta;
} }


public ActionMoveBy(Vector2 tgtValue, float tgtDuration)
: this((Vector3)tgtValue, tgtDuration)
public ActionMoveBy(Vector2 targetValue, float targetDuration)
: this((Vector3)targetValue, targetDuration)
{ {
} }


public override ActionInstant clone()
public ActionMoveBy(ref Vector3 refPoint, float targetDuration)
: this(Vector3.zero, targetDuration)
{
referencePoint = refPoint;
}

public override ActionInstant Clone()
{ {
return new ActionMoveBy(delta, duration); return new ActionMoveBy(delta, duration);
} }


public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionMoveBy(delta * -1F, duration); return new ActionMoveBy(delta * -1F, duration);
} }


public override void stepInterval(float dt)
public override void Start()
{
base.Start();
if (referencePoint != null)
{
delta = referencePoint;
}
}

public override void Step(float dt)
{ {
float d = dt / duration; float d = dt / duration;
Vector3 tgt = delta * d;
transform.Translate(tgt, Space.World);
Vector3 target = delta * d;
transform.Translate(target, Space.World);
} }
} }
} }

+ 15
- 12
Assets/scripts/coa4u/ActionsInterval/ActionMoveTo.cs View File

@@ -4,41 +4,44 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// Moves to the given point for the given amount of seconds.
/// </summary>
class ActionMoveTo : ActionInterval class ActionMoveTo : ActionInterval
{ {
protected Vector3 value; protected Vector3 value;
protected Vector3 path; protected Vector3 path;


public ActionMoveTo(Vector3 tgtValue, float tgtDuration)
: base(tgtDuration)
public ActionMoveTo(Vector3 targetValue, float targetDuration)
: base(targetDuration)
{ {
value = tgtValue;
value = targetValue;
} }


public ActionMoveTo(Vector2 tgtValue, float tgtDuration)
: this((Vector3)tgtValue, tgtDuration)
public ActionMoveTo(Vector2 targetValue, float targetDuration)
: this((Vector3)targetValue, targetDuration)
{ {
locks = Axises.z; locks = Axises.z;
} }


public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionMoveBy(value, duration); return new ActionMoveBy(value, duration);
} }


public override void start()
public override void Start()
{ {
base.start();
base.Start();
if (locks != Axises.none) if (locks != Axises.none)
lockAxises(ref value);
LockAxises(ref value);
path = value - transform.position; path = value - transform.position;
} }


public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float d = dt / duration; float d = dt / duration;
Vector3 tgt = path * d;
transform.Translate(tgt, Space.World);
Vector3 target = path * d;
transform.Translate(target, Space.World);
} }
} }
} }

+ 13
- 10
Assets/scripts/coa4u/ActionsInterval/ActionRotateBy.cs View File

@@ -4,36 +4,39 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// Rotates by the given euler angles.
/// </summary>
class ActionRotateBy : ActionInterval class ActionRotateBy : ActionInterval
{ {
protected Vector3 delta; protected Vector3 delta;


public ActionRotateBy(Vector3 tgtDelta, float tgtDuration)
: base(tgtDuration)
public ActionRotateBy(Vector3 targetDelta, float targetDuration)
: base(targetDuration)
{ {
delta = tgtDelta;
delta = targetDelta;
} }


public ActionRotateBy(float angle, float tgtDuration)
: this(new Vector3(0, 0, angle), tgtDuration)
public ActionRotateBy(float angle, float targetDuration)
: this(new Vector3(0, 0, angle), targetDuration)
{ {
} }


public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionRotateBy(delta, duration); return new ActionRotateBy(delta, duration);
} }


public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionRotateBy(delta * -1F, duration); return new ActionRotateBy(delta * -1F, duration);
} }


public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float d = dt / duration; float d = dt / duration;
Vector3 tgt = delta * d;
transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + tgt);
Vector3 target = delta * d;
transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + target);
} }
} }
} }

+ 15
- 12
Assets/scripts/coa4u/ActionsInterval/ActionRotateTo.cs View File

@@ -4,31 +4,34 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// Rotates to the given euler angles.
/// </summary>
class ActionRotateTo : ActionInterval class ActionRotateTo : ActionInterval
{ {
protected Vector3 value; protected Vector3 value;
protected Vector3 path; protected Vector3 path;


public ActionRotateTo(Vector3 tgtValue, float tgtDuration)
: base(tgtDuration)
public ActionRotateTo(Vector3 targetValue, float targetDuration)
: base(targetDuration)
{ {
value = tgtValue;
value = targetValue;
} }


public ActionRotateTo(float angle, float tgtDuration)
: this(new Vector3(0, 0, angle), tgtDuration)
public ActionRotateTo(float angle, float targetDuration)
: this(new Vector3(0, 0, angle), targetDuration)
{ {
locks = Axises.xy; locks = Axises.xy;
} }


public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionRotateTo(value, duration); return new ActionRotateTo(value, duration);
} }


public override void start()
public override void Start()
{ {
base.start();
base.Start();
path = new Vector3(); path = new Vector3();
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
@@ -40,13 +43,13 @@ namespace coa4u
path[i] = t + 360 - f; path[i] = t + 360 - f;
} }
if (locks != Axises.none) if (locks != Axises.none)
lockAxises(ref path);
LockAxises(ref path);
} }
public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float d = dt / duration; float d = dt / duration;
Vector3 tgt = path * d;
transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + tgt);
Vector3 target = path * d;
transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + target);
} }
} }
} }

+ 17
- 14
Assets/scripts/coa4u/ActionsInterval/ActionScaleBy.cs View File

@@ -4,35 +4,38 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// Scales the object by the given multiplier.
/// </summary>
class ActionScaleBy : ActionInterval class ActionScaleBy : ActionInterval
{ {
protected Vector3 delta; protected Vector3 delta;
protected Vector3 path; protected Vector3 path;


public ActionScaleBy(Vector3 tgtDelta, float tgtDuration)
: base(tgtDuration)
public ActionScaleBy(Vector3 targetDelta, float targetDuration)
: base(targetDuration)
{ {
delta = tgtDelta;
delta = targetDelta;
} }


public ActionScaleBy(Vector2 tgtValue, float tgtDuration)
: this((Vector3)tgtValue, tgtDuration)
public ActionScaleBy(Vector2 targetValue, float targetDuration)
: this((Vector3)targetValue, targetDuration)
{ {
} }


public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionScaleBy(delta, duration); return new ActionScaleBy(delta, duration);
} }


public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionScaleBy(delta * -1F, duration); return new ActionScaleBy(delta * -1F, duration);
} }


public override void start()
public override void Start()
{ {
base.start();
base.Start();
Vector3 scale = transform.localScale; Vector3 scale = transform.localScale;
scale.x *= delta.x; scale.x *= delta.x;
scale.y *= delta.y; scale.y *= delta.y;
@@ -40,16 +43,16 @@ namespace coa4u
path = scale - transform.localScale; path = scale - transform.localScale;
} }


public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float d = dt / duration; float d = dt / duration;
Vector3 tgt = path * d;
transform.localScale += tgt;
Vector3 target = path * d;
transform.localScale += target;
} }


public override void stop()
public override void Stop()
{ {
base.stop();
base.Stop();
} }
} }
} }

+ 15
- 12
Assets/scripts/coa4u/ActionsInterval/ActionScaleTo.cs View File

@@ -4,41 +4,44 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// Rotates to the given value.
/// </summary>
class ActionScaleTo : ActionInterval class ActionScaleTo : ActionInterval
{ {
protected Vector3 value; protected Vector3 value;
protected Vector3 path; protected Vector3 path;


public ActionScaleTo(Vector3 tgtValue, float tgtDuration)
: base(tgtDuration)
public ActionScaleTo(Vector3 targetValue, float targetDuration)
: base(targetDuration)
{ {
value = tgtValue;
value = targetValue;
} }


public ActionScaleTo(Vector2 tgtValue, float tgtDuration)
: this((Vector3)tgtValue, tgtDuration)
public ActionScaleTo(Vector2 targetValue, float targetDuration)
: this((Vector3)targetValue, targetDuration)
{ {
locks = Axises.z; locks = Axises.z;
} }


public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionScaleTo(value, duration); return new ActionScaleTo(value, duration);
} }


public override void start()
public override void Start()
{ {
base.start();
base.Start();
if (locks != Axises.none) if (locks != Axises.none)
lockAxises(ref value);
LockAxises(ref value);
path = value - transform.localScale; path = value - transform.localScale;
} }


public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float d = dt / duration; float d = dt / duration;
Vector3 tgt = path * d;
transform.localScale += tgt;
Vector3 target = path * d;
transform.localScale += target;
} }
} }
} }

+ 16
- 13
Assets/scripts/coa4u/ActionsInterval/ActionSkewBy.cs View File

@@ -4,45 +4,48 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// Skews the object by the given angles.
/// </summary>
class ActionSkewBy : ActionInterval class ActionSkewBy : ActionInterval
{ {
protected Vector3 skewAngles1; protected Vector3 skewAngles1;
protected Vector3 skewAngles2; protected Vector3 skewAngles2;
protected Mesh mesh; protected Mesh mesh;


public ActionSkewBy(Vector3 tgtAngles1, Vector3 tgtAngles2, float tgtDuration)
: base(tgtDuration)
public ActionSkewBy(Vector3 targetAngles1, Vector3 targetAngles2, float targetDuration)
: base(targetDuration)
{ {
skewAngles1 = tgtAngles1;
skewAngles2 = tgtAngles2;
skewAngles1 = targetAngles1;
skewAngles2 = targetAngles2;
} }


public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionSkewBy(skewAngles1, skewAngles2, duration); return new ActionSkewBy(skewAngles1, skewAngles2, duration);
} }


public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionSkewBy(-skewAngles1, -skewAngles2, duration); return new ActionSkewBy(-skewAngles1, -skewAngles2, duration);
} }


public override void start()
public override void Start()
{ {
base.start();
base.Start();
if (!(target is Actor)) if (!(target is Actor))
{ {
throw new Exception("You should use Actor class instead of Actor, if you want to skew your object."); throw new Exception("You should use Actor class instead of Actor, if you want to skew your object.");
} }
} }


public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float d = dt / duration; float d = dt / duration;
Vector3 tgt = skewAngles1 * d;
((Actor)target).skewAngles1 += tgt;
tgt = skewAngles2 * d;
((Actor)target).skewAngles2 += tgt;
Vector3 target = skewAngles1 * d;
((Actor)target).skewAngles1 += target;
target = skewAngles2 * d;
((Actor)target).skewAngles2 += target;
} }
} }
} }

+ 18
- 15
Assets/scripts/coa4u/ActionsInterval/ActionTintBy.cs View File

@@ -4,42 +4,45 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// Tints the target by the given color value. If you're going to change alpha, target shaders should support transparency.
/// </summary>
class ActionTintBy : ActionInterval class ActionTintBy : ActionInterval
{ {
protected Vector4 color; protected Vector4 color;
protected const float coeff = 1F / 255F; protected const float coeff = 1F / 255F;


public ActionTintBy(Vector4 tgtColor, float tgtDuration)
: base(tgtDuration)
public ActionTintBy(Vector4 targetColor, float targetDuration)
: base(targetDuration)
{ {
color = tgtColor * coeff;
color = targetColor * coeff;
} }


public ActionTintBy(Vector3 tgtColor, float tgtDuration)
: this(new Vector4(tgtColor.x, tgtColor.y, tgtColor.z), tgtDuration)
public ActionTintBy(Vector3 targetColor, float targetDuration)
: this(new Vector4(targetColor.x, targetColor.y, targetColor.z), targetDuration)
{ {
} }


public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionTintBy(color / coeff, duration); return new ActionTintBy(color / coeff, duration);
} }


public override ActionInstant reverse()
public override ActionInstant Reverse()
{ {
return new ActionTintBy(-color / coeff, duration); return new ActionTintBy(-color / coeff, duration);
} }


public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float d = dt / duration; float d = dt / duration;
Vector4 tgt = color * d;
Color tgtColor = renderer.material.color;
tgtColor[0] += tgt[0];
tgtColor[1] += tgt[1];
tgtColor[2] += tgt[2];
tgtColor[3] += tgt[3];
renderer.material.color = tgtColor;
Vector4 target = color * d;
Color targetColor = renderer.material.color;
targetColor[0] += target[0];
targetColor[1] += target[1];
targetColor[2] += target[2];
targetColor[3] += target[3];
renderer.material.color = targetColor;
} }
} }
} }

+ 24
- 21
Assets/scripts/coa4u/ActionsInterval/ActionTintTo.cs View File

@@ -4,49 +4,52 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// Tints the target to the given color value. If you're going to change alpha, target shaders should support transparency.
/// </summary>
class ActionTintTo : ActionInterval class ActionTintTo : ActionInterval
{ {
protected Vector4 color; protected Vector4 color;
protected Vector4 path; protected Vector4 path;
protected const float coeff = 1F / 255F; protected const float coeff = 1F / 255F;


public ActionTintTo(Vector4 tgtColor, float tgtDuration)
: base(tgtDuration)
public ActionTintTo(Vector4 targetColor, float targetDuration)
: base(targetDuration)
{ {
color = tgtColor * coeff;
color = targetColor * coeff;
path = Vector4.zero; path = Vector4.zero;
} }


public ActionTintTo(Vector3 tgtColor, float tgtDuration)
: this(new Vector4(tgtColor.x, tgtColor.y, tgtColor.z), tgtDuration)
public ActionTintTo(Vector3 targetColor, float targetDuration)
: this(new Vector4(targetColor.x, targetColor.y, targetColor.z), targetDuration)
{ {
} }


public override ActionInstant clone()
public override ActionInstant Clone()
{ {
return new ActionTintTo(color / coeff, duration); return new ActionTintTo(color / coeff, duration);
} }


public override void start()
public override void Start()
{ {
base.start();
Color tgtColor = renderer.material.color;
path[0] = color[0] - tgtColor[0];
path[1] = color[1] - tgtColor[1];
path[2] = color[2] - tgtColor[2];
path[3] = color[3] - tgtColor[3];
base.Start();
Color targetColor = renderer.material.color;
path[0] = color[0] - targetColor[0];
path[1] = color[1] - targetColor[1];
path[2] = color[2] - targetColor[2];
path[3] = color[3] - targetColor[3];
} }


public override void stepInterval(float dt)
public override void Step(float dt)
{ {
float d = dt / duration; float d = dt / duration;
Vector4 tgt = path * d;
Color tgtColor = renderer.material.color;
tgtColor[0] += tgt[0];
tgtColor[1] += tgt[1];
tgtColor[2] += tgt[2];
tgtColor[3] += tgt[3];
renderer.material.color = tgtColor;
Vector4 target = path * d;
Color targetColor = renderer.material.color;
targetColor[0] += target[0];
targetColor[1] += target[1];
targetColor[2] += target[2];
targetColor[3] += target[3];
renderer.material.color = targetColor;
} }
} }
} }

+ 14
- 8
Assets/scripts/coa4u/CoreClasses/MethodHolder.cs View File

@@ -4,6 +4,9 @@ using UnityEngine;


namespace coa4u namespace coa4u
{ {
/// <summary>
/// The holder class for the Methods Caching. Use MethodHolder<T> if your method requires the argument of type T.
/// </summary>
public class MethodHolder public class MethodHolder
{ {
protected Action method; protected Action method;
@@ -13,13 +16,13 @@ namespace coa4u
{ {
} }


public MethodHolder(Action tgtMethod)
public MethodHolder(Action targetMethod)
{ {
method = tgtMethod;
methodName = tgtMethod.Method.Name;
method = targetMethod;
methodName = targetMethod.Method.Name;
} }


public virtual void run(object param = null)
public virtual void Run(object param = null)
{ {
if (method != null) if (method != null)
method.Invoke(); method.Invoke();
@@ -34,17 +37,20 @@ namespace coa4u
} }
} }


/// <summary>
/// The holder class for the Methods Caching. Use MethodHolder<T> if your method requires the argument of type T.
/// </summary>
public class MethodHolder<T> : MethodHolder public class MethodHolder<T> : MethodHolder
{ {
protected Action<T> methodParam; protected Action<T> methodParam;


public MethodHolder(Action<T> tgtMethod)
public MethodHolder(Action<T> targetMethod)
{ {
methodParam = tgtMethod;
methodName = tgtMethod.Method.Name;
methodParam = targetMethod;
methodName = targetMethod.Method.Name;
} }


public override void run(object param)
public override void Run(object param)
{ {
if (methodParam != null) if (methodParam != null)
methodParam.Invoke((T)param); methodParam.Invoke((T)param);


+ 12
- 13
Assets/scripts/coa4u/UnityComponents/Actor.cs View File

@@ -51,15 +51,15 @@ public class Actor : MonoBehaviour
if (paused || action == null) if (paused || action == null)
return; return;
if (action.running) if (action.running)
action.step(Time.deltaTime);
action.StepTimer(Time.deltaTime);
if (skewAngles1 != angles1prev || skewAngles2 != angles2prev) if (skewAngles1 != angles1prev || skewAngles2 != angles2prev)
updateSkew();
UpdateSkew();
} }


/// <summary> /// <summary>
/// Updates the skew for the mesh. /// Updates the skew for the mesh.
/// </summary> /// </summary>
void updateSkew()
void UpdateSkew()
{ {
if (meshCached == null) if (meshCached == null)
return; return;
@@ -92,15 +92,15 @@ public class Actor : MonoBehaviour
/// <summary> /// <summary>
/// Attaches and starts the action. /// Attaches and starts the action.
/// </summary> /// </summary>
public void AttachAction(ActionInstant tgtAction)
public void AttachAction(ActionInstant targetAction)
{ {
if (action != null) if (action != null)
{ {
action.stop();
action.Stop();
} }
action = tgtAction;
action.setActor(this);
action.start();
action = targetAction;
action.SetActor(this);
action.Start();
} }


/// <summary> /// <summary>
@@ -111,7 +111,7 @@ public class Actor : MonoBehaviour
if (action == null) if (action == null)
return; return;
if (action.running) if (action.running)
action.stop();
action.Stop();
action = null; action = null;
} }


@@ -138,7 +138,7 @@ public class Actor : MonoBehaviour
{ {
if (action is ActionInterval) if (action is ActionInterval)
{ {
((ActionInterval)action).setTimeScale(ts);
((ActionInterval)action).SetTimeScale(ts);
} }
} }


@@ -170,15 +170,14 @@ public class Actor : MonoBehaviour
} }
} }



public void ReceiveMessage(string key, object param = null, SendMessageOptions options = SendMessageOptions.DontRequireReceiver) public void ReceiveMessage(string key, object param = null, SendMessageOptions options = SendMessageOptions.DontRequireReceiver)
{ {
if (methodsCache.ContainsKey(key)) if (methodsCache.ContainsKey(key))
{ {
if (param == null) if (param == null)
methodsCache[key].run();
methodsCache[key].Run();
else else
methodsCache[key].run(param);
methodsCache[key].Run(param);
} }
else else
{ {


+ 6
- 6
Assets/scripts/coa4u/UnityComponents/ActorSampleActions.cs View File

@@ -34,21 +34,21 @@ public class ActorSampleActions : Actor
new ActionRotateTo(new Vector3(0, 0, 0), 1), new ActionRotateTo(new Vector3(0, 0, 0), 1),
new ActionFadeOut(2), new ActionFadeOut(2),
new ActionSetTint(new Vector4(67, 105, 181)), new ActionSetTint(new Vector4(67, 105, 181)),
new ActionSendMessage("msgHello"),
new ActionSendMessage("msgHelloTo", "world"),
new ActionSendMessage("MessageHello"),
new ActionSendMessage("MessageHelloTo", "world"),
}), 5); }), 5);
this.AttachAction(seq); this.AttachAction(seq);


AddMethodToCache(msgHello);
AddMethodToCache<string>(msgHelloTo);
AddMethodToCache(MessageHello);
AddMethodToCache<string>(MessageHelloTo);
} }


void msgHello()
void MessageHello()
{ {
Debug.Log("Hello!"); Debug.Log("Hello!");
} }


void msgHelloTo(string who)
void MessageHelloTo(string who)
{ {
Debug.Log("Hello " + who.ToString() + "!"); Debug.Log("Hello " + who.ToString() + "!");
} }