diff --git a/Assets/scripts/coa4u/ActionsBase/Action.cs b/Assets/scripts/coa4u/ActionsBase/Action.cs index 997157f..47adcff 100644 --- a/Assets/scripts/coa4u/ActionsBase/Action.cs +++ b/Assets/scripts/coa4u/ActionsBase/Action.cs @@ -37,7 +37,7 @@ namespace coa4u /// /// Returns a copy of the action. /// - public virtual ActionInstant clone() + public virtual ActionInstant Clone() { return new ActionInstant(); } @@ -45,7 +45,7 @@ namespace coa4u /// /// Returns the reversed version of the action, if it is possible. /// - public virtual ActionInstant reverse() + public virtual ActionInstant Reverse() { throw new Exception("Can reverse only the reversable interval actions"); } @@ -53,7 +53,7 @@ namespace coa4u /// /// This method is called at the action start. Usable for instant and interval actions. /// - public virtual void start() + public virtual void Start() { if (target == null) throw new Exception("Can start the action only after it's atached to the actor"); @@ -64,7 +64,7 @@ namespace coa4u /// /// This method is called at every frame update. Not usable for instant actions. /// - public virtual void step(float dt) + public virtual void StepTimer(float dt) { if (target == null) throw new Exception("Can update the action only after it's atached to the actor"); @@ -73,7 +73,7 @@ namespace coa4u /// /// This method is called after the interval action is stopped. Not usable for instant actions. /// - public virtual void stop() + public virtual void Stop() { if (target == null) throw new Exception("Can stop the action only after it's atached to the actor"); @@ -82,7 +82,7 @@ namespace coa4u /// /// This method sets the actor for the action. /// - public void setActor(Actor actor) + public void SetActor(Actor actor) { target = actor; } @@ -90,7 +90,7 @@ namespace coa4u /// /// This method modifies the given vector to keep the locked axises untouched. /// - protected void lockAxises(ref Vector3 point) + protected void LockAxises(ref Vector3 point) { { if (target == null) diff --git a/Assets/scripts/coa4u/ActionsBase/ActionInterval.cs b/Assets/scripts/coa4u/ActionsBase/ActionInterval.cs index 0c03791..d4e5c91 100644 --- a/Assets/scripts/coa4u/ActionsBase/ActionInterval.cs +++ b/Assets/scripts/coa4u/ActionsBase/ActionInterval.cs @@ -13,10 +13,10 @@ namespace coa4u protected float timeScale; private float dtrdata; - public ActionInterval(float tgtDuration) + public ActionInterval(float targetDuration) : base() { - duration = tgtDuration; + duration = targetDuration; timeScale = 1F; dtr = 0; } @@ -24,7 +24,7 @@ namespace coa4u /// /// Returns a copy of the action. /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionInterval(duration); } @@ -32,7 +32,7 @@ namespace coa4u /// /// Returns the reversed version of the action, if it is possible. /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { throw new Exception("Can reverse only the reversable interval actions"); } @@ -40,9 +40,9 @@ namespace coa4u /// /// This method is called at the action start. /// - public override void start() + public override void Start() { - base.start(); + base.Start(); running = true; timer = 0F; } @@ -50,19 +50,19 @@ namespace coa4u /// /// This method is called after the interval action is stopped. /// - public override void stop() + public override void Stop() { - base.stop(); + base.Stop(); running = false; } /// - /// 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. /// - public override void step(float dt) + public override void StepTimer(float dt) { dt *= timeScale; - base.step(dt); + base.StepTimer(dt); if (timer + dt > duration) { float odt = dt; @@ -73,10 +73,10 @@ namespace coa4u { timer += dt; } - stepInterval(dt); + Step(dt); if (timer > duration) { - stop(); + Stop(); dtr = timer - duration; } } @@ -84,14 +84,14 @@ namespace coa4u /// /// This method is called every frame update. Put your code here. /// - public virtual void stepInterval(float dt) + public virtual void Step(float dt) { } /// /// Immediately changes the time scale for this action and all nested ones. /// - public void setTimeScale(float ts) + public void SetTimeScale(float ts) { timeScale = ts; } diff --git a/Assets/scripts/coa4u/ActionsBase/ActionParallel.cs b/Assets/scripts/coa4u/ActionsBase/ActionParallel.cs index fda09d8..309144e 100644 --- a/Assets/scripts/coa4u/ActionsBase/ActionParallel.cs +++ b/Assets/scripts/coa4u/ActionsBase/ActionParallel.cs @@ -24,55 +24,43 @@ namespace coa4u } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { ActionInstant[] aList = new ActionInstant[actions.Length]; for (int i = 0; i < actions.Length; i++) { - aList[i] = actions[i].clone(); + aList[i] = actions[i].Clone(); } return new ActionSequence(aList); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { ActionInstant[] aList = new ActionInstant[actions.Length]; for (int i = 0; i < actions.Length; i++) { - aList[i] = actions[i].reverse(); + aList[i] = actions[i].Reverse(); } return new ActionSequence(aList); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); for (int i = 0; i < actions.Length; i++) { - actions[i].setActor(target); - actions[i].start(); + actions[i].SetActor(target); + actions[i].Start(); } } - /// - /// This method is called every frame update. - /// - public override void step(float dt) + public override void StepTimer(float dt) { dt *= timeScale; for (int i = 0; i < actions.Length; i++) { if (actions[i].running) - actions[i].step(dt); + actions[i].StepTimer(dt); } bool canStopNow = true; float dtrdata = 0; @@ -86,7 +74,7 @@ namespace coa4u } if (canStopNow) { - stop(); + Stop(); dtr = dtrdata; } } @@ -94,12 +82,12 @@ namespace coa4u /// /// This method is called after the interval action is stopped. /// - public override void stop() + public override void Stop() { - base.stop(); + base.Stop(); for (int i = 0; i < actions.Length; i++) { - actions[i].stop(); + actions[i].Stop(); } } } diff --git a/Assets/scripts/coa4u/ActionsBase/ActionRandom.cs b/Assets/scripts/coa4u/ActionsBase/ActionRandom.cs index f8fa8b6..4534d34 100644 --- a/Assets/scripts/coa4u/ActionsBase/ActionRandom.cs +++ b/Assets/scripts/coa4u/ActionsBase/ActionRandom.cs @@ -26,54 +26,42 @@ namespace coa4u } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { ActionInstant[] aList = new ActionInstant[actions.Length]; for (int i = 0; i < actions.Length; i++) { - aList[i] = actions[i].clone(); + aList[i] = actions[i].Clone(); } return new ActionRandom(aList); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { ActionInstant[] aList = new ActionInstant[actions.Length]; for (int i = 0; i < actions.Length; i++) { - aList[i] = actions[i].reverse(); + aList[i] = actions[i].Reverse(); } return new ActionRandom(aList); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); index = UnityEngine.Random.Range(0, actions.Length); - actions[index].setActor(target); - actions[index].start(); + actions[index].SetActor(target); + actions[index].Start(); } - /// - /// This method is called every frame update. - /// - public override void step(float dt) + public override void StepTimer(float dt) { dt *= timeScale; if (actions[index].running) - actions[index].step(dt); + actions[index].StepTimer(dt); if (!actions[index].running) { - stop(); + Stop(); dtr = actions[index].dtr; } } @@ -81,10 +69,10 @@ namespace coa4u /// /// This method is called after the interval action is stopped. /// - public override void stop() + public override void Stop() { - base.stop(); - actions[index].stop(); + base.Stop(); + actions[index].Stop(); } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsBase/ActionRepeat.cs b/Assets/scripts/coa4u/ActionsBase/ActionRepeat.cs index 2fe321a..383ba00 100644 --- a/Assets/scripts/coa4u/ActionsBase/ActionRepeat.cs +++ b/Assets/scripts/coa4u/ActionsBase/ActionRepeat.cs @@ -14,73 +14,61 @@ namespace coa4u protected int counter; protected bool forever; - public ActionRepeat(ActionInterval tgtAction, int tgtCount) + public ActionRepeat(ActionInterval targetAction, int targetCount) : base(0) { - action = tgtAction; - count = tgtCount; + action = targetAction; + count = targetCount; counter = 0; forever = false; } - public ActionRepeat(ActionInterval tgtAction) + public ActionRepeat(ActionInterval targetAction) : base(0) { - action = tgtAction; + action = targetAction; count = 0; counter = 0; forever = true; } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { - return new ActionRepeat((ActionInterval)action.clone(), count); + return new ActionRepeat((ActionInterval)action.Clone(), count); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { - return new ActionRepeat((ActionInterval)action.reverse(), count); + return new ActionRepeat((ActionInterval)action.Reverse(), count); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); - action.setActor(target); - action.start(); + base.Start(); + action.SetActor(target); + action.Start(); counter = 0; } - /// - /// This method is called every frame update. - /// - public override void step(float dt) + public override void StepTimer(float dt) { dt *= timeScale; if (action.running) { - action.step(dt); + action.StepTimer(dt); } if (!action.running && (forever || counter < count - 1)) { float dtrdata = action.dtr; - action.start(); + action.Start(); if (dtrdata > 0) - action.step(dtrdata); + action.StepTimer(dtrdata); counter += 1; } else if (!action.running && counter >= count - 1) { dtr = action.dtr; - stop(); + Stop(); } } } diff --git a/Assets/scripts/coa4u/ActionsBase/ActionSequence.cs b/Assets/scripts/coa4u/ActionsBase/ActionSequence.cs index 2d361a7..1c1e766 100644 --- a/Assets/scripts/coa4u/ActionsBase/ActionSequence.cs +++ b/Assets/scripts/coa4u/ActionsBase/ActionSequence.cs @@ -25,73 +25,61 @@ namespace coa4u } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { ActionInstant[] aList = new ActionInstant[actions.Length]; for (int i = 0; i < actions.Length; i++) { - aList[i] = actions[i].clone(); + aList[i] = actions[i].Clone(); } return new ActionSequence(aList); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { ActionInstant[] aList = new ActionInstant[actions.Length]; 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); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); index = 0; - actions[0].setActor(target); - actions[0].start(); + actions[0].SetActor(target); + actions[0].Start(); while (!actions[index].running && index < actions.Length) { index += 1; - actions[index].setActor(target); - actions[index].start(); + actions[index].SetActor(target); + actions[index].Start(); } } - /// - /// This method is called every frame update. - /// - public override void step(float dt) + public override void StepTimer(float dt) { dt *= timeScale; float dtrdata = 0; if (actions[index].running) { - actions[index].step(dt); + actions[index].StepTimer(dt); if (!actions[index].running) dtrdata = actions[index].dtr; } while (!actions[index].running && index < actions.Length - 1) { index += 1; - actions[index].setActor(target); - actions[index].start(); + actions[index].SetActor(target); + actions[index].Start(); if (actions[index].running && dtrdata > 0) - actions[index].step(dtrdata); + actions[index].StepTimer(dtrdata); } if (!actions[index].running) { - stop(); + Stop(); dtr = dtrdata; } } @@ -99,12 +87,12 @@ namespace coa4u /// /// This method is called after the interval action is stopped. /// - public override void stop() + public override void Stop() { - base.stop(); + base.Stop(); for (int i = 0; i < actions.Length; i++) { - actions[i].stop(); + actions[i].Stop(); } } } diff --git a/Assets/scripts/coa4u/ActionsBase/ActionStop.cs b/Assets/scripts/coa4u/ActionsBase/ActionStop.cs index 2e1b770..9a8cc36 100644 --- a/Assets/scripts/coa4u/ActionsBase/ActionStop.cs +++ b/Assets/scripts/coa4u/ActionsBase/ActionStop.cs @@ -14,20 +14,14 @@ namespace coa4u { } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionStop(); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); target.StopAction(); } } diff --git a/Assets/scripts/coa4u/ActionsInstant/ActionHide.cs b/Assets/scripts/coa4u/ActionsInstant/ActionHide.cs index 662265f..e2896e4 100644 --- a/Assets/scripts/coa4u/ActionsInstant/ActionHide.cs +++ b/Assets/scripts/coa4u/ActionsInstant/ActionHide.cs @@ -15,28 +15,19 @@ namespace coa4u { } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionHide(); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionShow(); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); renderer.enabled = false; } } diff --git a/Assets/scripts/coa4u/ActionsInstant/ActionLog.cs b/Assets/scripts/coa4u/ActionsInstant/ActionLog.cs index 61cef4f..a76e69d 100644 --- a/Assets/scripts/coa4u/ActionsInstant/ActionLog.cs +++ b/Assets/scripts/coa4u/ActionsInstant/ActionLog.cs @@ -11,16 +11,13 @@ namespace coa4u { string message; - public ActionLog(string tgtMessage) + public ActionLog(string targetMessage) : base() { - message = tgtMessage; + message = targetMessage; } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionLog(message); } @@ -28,17 +25,14 @@ namespace coa4u /// /// Returns the reversed version of the action, if it is possible. /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionLog(message); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); Debug.Log(message); } } diff --git a/Assets/scripts/coa4u/ActionsInstant/ActionSendMessage.cs b/Assets/scripts/coa4u/ActionsInstant/ActionSendMessage.cs index e09ed61..bb94c72 100644 --- a/Assets/scripts/coa4u/ActionsInstant/ActionSendMessage.cs +++ b/Assets/scripts/coa4u/ActionsInstant/ActionSendMessage.cs @@ -15,49 +15,40 @@ namespace coa4u protected object param; protected SendMessageOptions options = SendMessageOptions.DontRequireReceiver; - public ActionSendMessage(string tgtMessage) + public ActionSendMessage(string targetMessage) : base() { - message = tgtMessage; + message = targetMessage; } - public ActionSendMessage(string tgtMessage, object tgtParam) + public ActionSendMessage(string targetMessage, object targetParam) : 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() { - message = tgtMessage; - param = tgtParam; - options = tgtOptions; + message = targetMessage; + param = targetParam; + options = targetOptions; } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionSendMessage(message, param, options); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionSendMessage(message, param, options); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); if (param != null) { target.ReceiveMessage(message, param, options); diff --git a/Assets/scripts/coa4u/ActionsInstant/ActionSetDirection.cs b/Assets/scripts/coa4u/ActionsInstant/ActionSetDirection.cs index 8a1f75b..814f8f3 100644 --- a/Assets/scripts/coa4u/ActionsInstant/ActionSetDirection.cs +++ b/Assets/scripts/coa4u/ActionsInstant/ActionSetDirection.cs @@ -12,38 +12,32 @@ namespace coa4u protected Vector3 value; protected Actor other; - public ActionSetDirection(Vector3 tgtValue) + public ActionSetDirection(Vector3 targetValue) : base() { - value = tgtValue; + value = targetValue; } - public ActionSetDirection(Vector2 tgtValue) - : this((Vector3)tgtValue) + public ActionSetDirection(Vector2 targetValue) + : this((Vector3)targetValue) { locks = Axises.z; } - public ActionSetDirection(Actor tgtActor) + public ActionSetDirection(Actor targetActor) : base() { - other = tgtActor; + other = targetActor; } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionSetDirection(value); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); if (other != null) { value = other.transform.position; diff --git a/Assets/scripts/coa4u/ActionsInstant/ActionSetPlace.cs b/Assets/scripts/coa4u/ActionsInstant/ActionSetPlace.cs index d84ddc4..822ac18 100644 --- a/Assets/scripts/coa4u/ActionsInstant/ActionSetPlace.cs +++ b/Assets/scripts/coa4u/ActionsInstant/ActionSetPlace.cs @@ -11,34 +11,28 @@ namespace coa4u { protected Vector3 value; - public ActionSetPlace(Vector3 tgtPlace) + public ActionSetPlace(Vector3 targetPlace) : base() { - value = tgtPlace; + value = targetPlace; } - public ActionSetPlace(Vector2 tgtPlace) - : this((Vector3)tgtPlace) + public ActionSetPlace(Vector2 targetPlace) + : this((Vector3)targetPlace) { locks = Axises.z; } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionSetPlace(value); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); if (locks != Axises.none) - lockAxises(ref value); + LockAxises(ref value); transform.position = value; } } diff --git a/Assets/scripts/coa4u/ActionsInstant/ActionSetRotation.cs b/Assets/scripts/coa4u/ActionsInstant/ActionSetRotation.cs index 49e6c64..a11a7f6 100644 --- a/Assets/scripts/coa4u/ActionsInstant/ActionSetRotation.cs +++ b/Assets/scripts/coa4u/ActionsInstant/ActionSetRotation.cs @@ -11,10 +11,10 @@ namespace coa4u { protected Vector3 value; - public ActionSetRotation(Vector3 tgtValue) + public ActionSetRotation(Vector3 targetValue) : base() { - value = tgtValue; + value = targetValue; } public ActionSetRotation(float angle) @@ -23,22 +23,16 @@ namespace coa4u locks = Axises.xy; } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionSetRotation(value); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); if (locks != Axises.none) - lockAxises(ref value); + LockAxises(ref value); transform.rotation = Quaternion.Euler(value); } } diff --git a/Assets/scripts/coa4u/ActionsInstant/ActionSetTint.cs b/Assets/scripts/coa4u/ActionsInstant/ActionSetTint.cs index d9160b1..613516d 100644 --- a/Assets/scripts/coa4u/ActionsInstant/ActionSetTint.cs +++ b/Assets/scripts/coa4u/ActionsInstant/ActionSetTint.cs @@ -12,26 +12,20 @@ namespace coa4u public Vector4 color; protected const float coeff = 1F / 255F; - public ActionSetTint(Vector4 tgtColor) + public ActionSetTint(Vector4 targetColor) : base() { - color = tgtColor * coeff; + color = targetColor * coeff; } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionSetTint(color * 255F); } - /// - /// This method is called at the action start. - /// - 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]); } } diff --git a/Assets/scripts/coa4u/ActionsInstant/ActionShow.cs b/Assets/scripts/coa4u/ActionsInstant/ActionShow.cs index e5285b7..7123989 100644 --- a/Assets/scripts/coa4u/ActionsInstant/ActionShow.cs +++ b/Assets/scripts/coa4u/ActionsInstant/ActionShow.cs @@ -15,28 +15,19 @@ namespace coa4u { } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionShow(); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionHide(); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); renderer.enabled = true; } } diff --git a/Assets/scripts/coa4u/ActionsInstant/ActionToggleVisibility.cs b/Assets/scripts/coa4u/ActionsInstant/ActionToggleVisibility.cs index 5c283a3..c05af9e 100644 --- a/Assets/scripts/coa4u/ActionsInstant/ActionToggleVisibility.cs +++ b/Assets/scripts/coa4u/ActionsInstant/ActionToggleVisibility.cs @@ -15,28 +15,19 @@ namespace coa4u { } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionToggleVisibility(); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionToggleVisibility(); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); renderer.enabled = !renderer.enabled; } } diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionBezierAbs.cs b/Assets/scripts/coa4u/ActionsInterval/ActionBezierAbs.cs index 4253b4c..31f2e97 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionBezierAbs.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionBezierAbs.cs @@ -14,57 +14,45 @@ namespace coa4u protected Vector3 startControlPoint; 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; } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionBezierAbs(startPoint, startControlPoint, endControlPoint, endPoint, duration); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionBezierAbs(endPoint, endControlPoint, startControlPoint, startPoint, duration); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); float z = transform.position.z; 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); } } - /// - /// This method is called every frame update. - /// - public override void stepInterval(float dt) + public override void Step(float dt) { float t = timer / duration; Vector3 newPosition = (((-startPoint diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionBezierRel.cs b/Assets/scripts/coa4u/ActionsInterval/ActionBezierRel.cs index 140d245..2b6eaba 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionBezierRel.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionBezierRel.cs @@ -17,51 +17,39 @@ namespace coa4u protected Vector3 startControlPoint; 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) { } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionBezierRel(startControlPoint, endControlPoint, endPoint, duration); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionBezierRel(-startControlPoint, -endControlPoint, -endPoint, duration); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); startPoint = target.transform.position; endPoint = startPoint + ep; startControlPoint = startPoint + cp1; endControlPoint = startControlPoint + cp2; } - /// - /// This method is called every frame update. - /// - public override void stepInterval(float dt) + public override void Step(float dt) { float t = timer / duration; Vector3 newPosition = (((-startPoint diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionBlink.cs b/Assets/scripts/coa4u/ActionsInterval/ActionBlink.cs index e8310b6..bb8822d 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionBlink.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionBlink.cs @@ -15,46 +15,40 @@ namespace coa4u protected float durationMin; protected float durationMax; - public ActionBlink(int tgtBlinks, float tgtDuration) + public ActionBlink(int targetBlinks, float targetDuration) : base(null, 0) { - durationMin = tgtDuration; - durationMax = tgtDuration; - count = (tgtBlinks) * 2; + durationMin = targetDuration; + durationMax = targetDuration; + count = (targetBlinks) * 2; blinkSeq = new ActionInstant[] { new ActionToggleVisibility(), - new ActionDelay(tgtDuration / tgtBlinks) + new ActionDelay(targetDuration / targetBlinks) }; action = new ActionSequence(blinkSeq); } - public ActionBlink(int tgtBlinks, float tgtDurationMin, float tgtDurationMax) + public ActionBlink(int targetBlinks, float targetDurationMin, float targetDurationMax) : base(null, 0) { - durationMin = tgtDurationMin; - durationMax = tgtDurationMax; - count = (tgtBlinks) * 2; + durationMin = targetDurationMin; + durationMax = targetDurationMax; + count = (targetBlinks) * 2; blinkSeq = new ActionInstant[] { new ActionToggleVisibility(), - new ActionDelay(tgtDurationMin / tgtBlinks, tgtDurationMax / tgtBlinks) + new ActionDelay(targetDurationMin / targetBlinks, targetDurationMax / targetBlinks) }; action = new ActionSequence(blinkSeq); } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionBlink(count / 2 - 1, durationMin, durationMax); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionBlink(count / 2 - 1, durationMin, durationMax); } diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionDelay.cs b/Assets/scripts/coa4u/ActionsInterval/ActionDelay.cs index ec2d09f..0acf462 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionDelay.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionDelay.cs @@ -12,26 +12,23 @@ namespace coa4u protected float durationMin; 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; } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); if (durationMax != null) { duration = UnityEngine.Random.Range(durationMin, durationMax); diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionFadeBy.cs b/Assets/scripts/coa4u/ActionsInterval/ActionFadeBy.cs index 77611b4..83ff49c 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionFadeBy.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionFadeBy.cs @@ -11,37 +11,28 @@ namespace coa4u { protected float delta; - public ActionFadeBy(float tgtDelta, float tgtDuration) - : base(tgtDuration) + public ActionFadeBy(float targetDelta, float targetDuration) + : base(targetDuration) { - delta = tgtDelta; + delta = targetDelta; } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionFadeBy(delta, duration); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionFadeBy(-delta, duration); } - /// - /// This method is called every frame update. - /// - public override void stepInterval(float dt) + public override void Step(float dt) { 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; } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionFadeIn.cs b/Assets/scripts/coa4u/ActionsInterval/ActionFadeIn.cs index 8ec09d4..8469234 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionFadeIn.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionFadeIn.cs @@ -10,23 +10,17 @@ namespace coa4u class ActionFadeIn : ActionFadeTo { - public ActionFadeIn(float tgtDuration) - : base(1, tgtDuration) + public ActionFadeIn(float targetDuration) + : base(1, targetDuration) { } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionFadeIn(duration); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionFadeOut(duration); } diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionFadeOut.cs b/Assets/scripts/coa4u/ActionsInterval/ActionFadeOut.cs index 5b3adcd..677544c 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionFadeOut.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionFadeOut.cs @@ -10,23 +10,17 @@ namespace coa4u class ActionFadeOut : ActionFadeTo { - public ActionFadeOut(float tgtDuration) - : base(0, tgtDuration) + public ActionFadeOut(float targetDuration) + : base(0, targetDuration) { } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionFadeOut(duration); } - /// - /// Returns the reversed version of the action, if it is possible. - /// - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionFadeIn(duration); } diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionFadeTo.cs b/Assets/scripts/coa4u/ActionsInterval/ActionFadeTo.cs index 320f70b..ed69306 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionFadeTo.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionFadeTo.cs @@ -12,38 +12,29 @@ namespace coa4u protected float value; protected float delta; - public ActionFadeTo(float tgtValue, float tgtDuration) - : base(tgtDuration) + public ActionFadeTo(float targetValue, float targetDuration) + : base(targetDuration) { - value = tgtValue; + value = targetValue; } - /// - /// Returns a copy of the action. - /// - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionFadeTo(value, duration); } - /// - /// This method is called at the action start. - /// - public override void start() + public override void Start() { - base.start(); + base.Start(); delta = value - renderer.material.color.a; } - /// - /// This method is called every frame update. - /// - public override void stepInterval(float dt) + public override void Step(float dt) { 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; } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionJumpBy.cs b/Assets/scripts/coa4u/ActionsInterval/ActionJumpBy.cs index 64e2cfc..177b6d6 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionJumpBy.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionJumpBy.cs @@ -4,37 +4,40 @@ using UnityEngine; namespace coa4u { + /// + /// Jumps given number of times in the given direction for the given amount of seconds. + /// class ActionJumpBy : ActionSequence { protected Vector3 point; float height; 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); } - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionJumpBy(-point, height, jumps, duration); } - public override void start() + public override void Start() { float coeff = 1F / jumps; Vector3 end = point * coeff; @@ -45,7 +48,7 @@ namespace coa4u { actions[i] = singleJump; } - base.start(); + base.Start(); } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionJumpTo.cs b/Assets/scripts/coa4u/ActionsInterval/ActionJumpTo.cs index 8531089..af17d5f 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionJumpTo.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionJumpTo.cs @@ -4,37 +4,40 @@ using UnityEngine; namespace coa4u { + /// + /// Jumps to the given point for the given amount of seconds in the given amounts of jumps. + /// class ActionJumpTo : ActionSequence { protected Vector3 point; float height; 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; } - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionJumpTo(point, height, jumps, duration); } - public override void start() + public override void Start() { float coeff = 1F / jumps; if (locks != Axises.none) - lockAxises(ref point); + LockAxises(ref point); Vector3 start = target.gameObject.transform.position; Vector3 end = (point - start) * coeff; Vector3 cp1 = Vector3.up * height; @@ -44,7 +47,7 @@ namespace coa4u { actions[i] = singleJump; } - base.start(); + base.Start(); } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionMoveBy.cs b/Assets/scripts/coa4u/ActionsInterval/ActionMoveBy.cs index 0f63512..5f8855b 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionMoveBy.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionMoveBy.cs @@ -4,36 +4,55 @@ using UnityEngine; namespace coa4u { + /// + /// Moves in the given direction for the given amount of seconds. + /// class ActionMoveBy : ActionInterval { 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); } - public override ActionInstant reverse() + public override ActionInstant Reverse() { 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; - Vector3 tgt = delta * d; - transform.Translate(tgt, Space.World); + Vector3 target = delta * d; + transform.Translate(target, Space.World); } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionMoveTo.cs b/Assets/scripts/coa4u/ActionsInterval/ActionMoveTo.cs index bf42ad4..959c49c 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionMoveTo.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionMoveTo.cs @@ -4,41 +4,44 @@ using UnityEngine; namespace coa4u { + /// + /// Moves to the given point for the given amount of seconds. + /// class ActionMoveTo : ActionInterval { protected Vector3 value; 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; } - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionMoveBy(value, duration); } - public override void start() + public override void Start() { - base.start(); + base.Start(); if (locks != Axises.none) - lockAxises(ref value); + LockAxises(ref value); path = value - transform.position; } - public override void stepInterval(float dt) + public override void Step(float dt) { float d = dt / duration; - Vector3 tgt = path * d; - transform.Translate(tgt, Space.World); + Vector3 target = path * d; + transform.Translate(target, Space.World); } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionRotateBy.cs b/Assets/scripts/coa4u/ActionsInterval/ActionRotateBy.cs index f75e177..a8793f8 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionRotateBy.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionRotateBy.cs @@ -4,36 +4,39 @@ using UnityEngine; namespace coa4u { + /// + /// Rotates by the given euler angles. + /// class ActionRotateBy : ActionInterval { 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); } - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionRotateBy(delta * -1F, duration); } - public override void stepInterval(float dt) + public override void Step(float dt) { 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); } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionRotateTo.cs b/Assets/scripts/coa4u/ActionsInterval/ActionRotateTo.cs index 9667e61..18d8fa9 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionRotateTo.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionRotateTo.cs @@ -4,31 +4,34 @@ using UnityEngine; namespace coa4u { + /// + /// Rotates to the given euler angles. + /// class ActionRotateTo : ActionInterval { protected Vector3 value; 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; } - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionRotateTo(value, duration); } - public override void start() + public override void Start() { - base.start(); + base.Start(); path = new Vector3(); for (int i = 0; i < 3; i++) { @@ -40,13 +43,13 @@ namespace coa4u path[i] = t + 360 - f; } 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; - Vector3 tgt = path * d; - transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + tgt); + Vector3 target = path * d; + transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + target); } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionScaleBy.cs b/Assets/scripts/coa4u/ActionsInterval/ActionScaleBy.cs index 90d573f..b4811f7 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionScaleBy.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionScaleBy.cs @@ -4,35 +4,38 @@ using UnityEngine; namespace coa4u { + /// + /// Scales the object by the given multiplier. + /// class ActionScaleBy : ActionInterval { protected Vector3 delta; 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); } - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionScaleBy(delta * -1F, duration); } - public override void start() + public override void Start() { - base.start(); + base.Start(); Vector3 scale = transform.localScale; scale.x *= delta.x; scale.y *= delta.y; @@ -40,16 +43,16 @@ namespace coa4u path = scale - transform.localScale; } - public override void stepInterval(float dt) + public override void Step(float dt) { 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(); } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionScaleTo.cs b/Assets/scripts/coa4u/ActionsInterval/ActionScaleTo.cs index de8140c..dd07121 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionScaleTo.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionScaleTo.cs @@ -4,41 +4,44 @@ using UnityEngine; namespace coa4u { + /// + /// Rotates to the given value. + /// class ActionScaleTo : ActionInterval { protected Vector3 value; 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; } - public override ActionInstant clone() + public override ActionInstant Clone() { return new ActionScaleTo(value, duration); } - public override void start() + public override void Start() { - base.start(); + base.Start(); if (locks != Axises.none) - lockAxises(ref value); + LockAxises(ref value); path = value - transform.localScale; } - public override void stepInterval(float dt) + public override void Step(float dt) { float d = dt / duration; - Vector3 tgt = path * d; - transform.localScale += tgt; + Vector3 target = path * d; + transform.localScale += target; } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionSkewBy.cs b/Assets/scripts/coa4u/ActionsInterval/ActionSkewBy.cs index 2dd6e8d..d78a3f9 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionSkewBy.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionSkewBy.cs @@ -4,45 +4,48 @@ using UnityEngine; namespace coa4u { + /// + /// Skews the object by the given angles. + /// class ActionSkewBy : ActionInterval { protected Vector3 skewAngles1; protected Vector3 skewAngles2; 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); } - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionSkewBy(-skewAngles1, -skewAngles2, duration); } - public override void start() + public override void Start() { - base.start(); + base.Start(); if (!(target is Actor)) { 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; - 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; } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionTintBy.cs b/Assets/scripts/coa4u/ActionsInterval/ActionTintBy.cs index 954e8ab..74060ea 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionTintBy.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionTintBy.cs @@ -4,42 +4,45 @@ using UnityEngine; namespace coa4u { + /// + /// Tints the target by the given color value. If you're going to change alpha, target shaders should support transparency. + /// class ActionTintBy : ActionInterval { protected Vector4 color; 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); } - public override ActionInstant reverse() + public override ActionInstant Reverse() { return new ActionTintBy(-color / coeff, duration); } - public override void stepInterval(float dt) + public override void Step(float dt) { 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; } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/ActionsInterval/ActionTintTo.cs b/Assets/scripts/coa4u/ActionsInterval/ActionTintTo.cs index c7cf1ad..39a5991 100644 --- a/Assets/scripts/coa4u/ActionsInterval/ActionTintTo.cs +++ b/Assets/scripts/coa4u/ActionsInterval/ActionTintTo.cs @@ -4,49 +4,52 @@ using UnityEngine; namespace coa4u { + /// + /// Tints the target to the given color value. If you're going to change alpha, target shaders should support transparency. + /// class ActionTintTo : ActionInterval { protected Vector4 color; protected Vector4 path; 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; } - 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); } - 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; - 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; } } } \ No newline at end of file diff --git a/Assets/scripts/coa4u/CoreClasses/MethodHolder.cs b/Assets/scripts/coa4u/CoreClasses/MethodHolder.cs index 0c48716..7bb1e76 100644 --- a/Assets/scripts/coa4u/CoreClasses/MethodHolder.cs +++ b/Assets/scripts/coa4u/CoreClasses/MethodHolder.cs @@ -4,6 +4,9 @@ using UnityEngine; namespace coa4u { + /// + /// The holder class for the Methods Caching. Use MethodHolder if your method requires the argument of type T. + /// public class MethodHolder { 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) method.Invoke(); @@ -34,17 +37,20 @@ namespace coa4u } } + /// + /// The holder class for the Methods Caching. Use MethodHolder if your method requires the argument of type T. + /// public class MethodHolder : MethodHolder { protected Action methodParam; - public MethodHolder(Action tgtMethod) + public MethodHolder(Action 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) methodParam.Invoke((T)param); diff --git a/Assets/scripts/coa4u/UnityComponents/Actor.cs b/Assets/scripts/coa4u/UnityComponents/Actor.cs index 3fbeb3d..6dc305a 100644 --- a/Assets/scripts/coa4u/UnityComponents/Actor.cs +++ b/Assets/scripts/coa4u/UnityComponents/Actor.cs @@ -51,15 +51,15 @@ public class Actor : MonoBehaviour if (paused || action == null) return; if (action.running) - action.step(Time.deltaTime); + action.StepTimer(Time.deltaTime); if (skewAngles1 != angles1prev || skewAngles2 != angles2prev) - updateSkew(); + UpdateSkew(); } /// /// Updates the skew for the mesh. /// - void updateSkew() + void UpdateSkew() { if (meshCached == null) return; @@ -92,15 +92,15 @@ public class Actor : MonoBehaviour /// /// Attaches and starts the action. /// - public void AttachAction(ActionInstant tgtAction) + public void AttachAction(ActionInstant targetAction) { if (action != null) { - action.stop(); + action.Stop(); } - action = tgtAction; - action.setActor(this); - action.start(); + action = targetAction; + action.SetActor(this); + action.Start(); } /// @@ -111,7 +111,7 @@ public class Actor : MonoBehaviour if (action == null) return; if (action.running) - action.stop(); + action.Stop(); action = null; } @@ -138,7 +138,7 @@ public class Actor : MonoBehaviour { 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) { if (methodsCache.ContainsKey(key)) { if (param == null) - methodsCache[key].run(); + methodsCache[key].Run(); else - methodsCache[key].run(param); + methodsCache[key].Run(param); } else { diff --git a/Assets/scripts/coa4u/UnityComponents/ActorSampleActions.cs b/Assets/scripts/coa4u/UnityComponents/ActorSampleActions.cs index 001a940..cc84611 100644 --- a/Assets/scripts/coa4u/UnityComponents/ActorSampleActions.cs +++ b/Assets/scripts/coa4u/UnityComponents/ActorSampleActions.cs @@ -34,21 +34,21 @@ public class ActorSampleActions : Actor new ActionRotateTo(new Vector3(0, 0, 0), 1), new ActionFadeOut(2), new ActionSetTint(new Vector4(67, 105, 181)), - new ActionSendMessage("msgHello"), - new ActionSendMessage("msgHelloTo", "world"), + new ActionSendMessage("MessageHello"), + new ActionSendMessage("MessageHelloTo", "world"), }), 5); this.AttachAction(seq); - AddMethodToCache(msgHello); - AddMethodToCache(msgHelloTo); + AddMethodToCache(MessageHello); + AddMethodToCache(MessageHelloTo); } - void msgHello() + void MessageHello() { Debug.Log("Hello!"); } - void msgHelloTo(string who) + void MessageHelloTo(string who) { Debug.Log("Hello " + who.ToString() + "!"); }