This commit is contained in:
2014-06-16 00:25:35 +04:00
committed by Ivan "KaiSD" Korystin
parent bb1b24e947
commit 441fa25a19
25 changed files with 1110 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using UnityEngine;
class ActionDelay : ActionInterval
{
protected float durationMin;
protected float durationMax;
public ActionDelay(float tgtDuration)
: base(tgtDuration)
{
durationMin = tgtDuration;
durationMax = tgtDuration;
}
public ActionDelay(float tgtDuration, float tgtDurationMax)
: base(tgtDuration)
{
durationMin = tgtDuration;
durationMax = tgtDurationMax;
}
public override void start()
{
base.start();
if (durationMax != null)
{
duration = UnityEngine.Random.Range(durationMin, durationMax);
}
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using UnityEngine;
class ActionMoveBy : ActionInterval
{
protected Vector3 delta;
public ActionMoveBy(Vector3 tgtDelta, float tgtDuration)
: base(tgtDuration)
{
delta = tgtDelta;
}
public override Action clone()
{
return new ActionMoveBy(delta, duration);
}
public override Action reverse()
{
return new ActionMoveBy(delta * -1F, duration);
}
public override void stepInterval(float dt)
{
float d = dt / duration;
Vector3 tgt = delta * d;
target.gameObject.transform.Translate(tgt, Space.World);
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using UnityEngine;
class ActionMoveTo : ActionInterval
{
protected Vector3 value;
protected Vector3 path;
public ActionMoveTo(Vector3 tgtValue, float tgtDuration)
: base(tgtDuration)
{
value = tgtValue;
}
public override Action clone()
{
return new ActionMoveBy(value, duration);
}
public override void start()
{
base.start();
path = value - target.gameObject.transform.position;
}
public override void stepInterval(float dt)
{
float d = dt / duration;
Vector3 tgt = path * d;
target.gameObject.transform.Translate(tgt, Space.World);
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using UnityEngine;
class ActionRotateBy : ActionInterval
{
protected Vector3 delta;
public ActionRotateBy(Vector3 tgtDelta, float tgtDuration)
: base(tgtDuration)
{
delta = tgtDelta;
}
public override Action clone()
{
return new ActionRotateBy(delta, duration);
}
public override Action reverse()
{
return new ActionRotateBy(delta * -1F, duration);
}
public override void stepInterval(float dt)
{
float d = dt / duration;
Vector3 tgt = delta * d;
target.gameObject.transform.Rotate(Vector3.up, tgt.y);
target.gameObject.transform.Rotate(Vector3.right, tgt.x);
target.gameObject.transform.Rotate(Vector3.forward, tgt.z);
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using UnityEngine;
class ActionRotateTo : ActionInterval
{
protected Vector3 value;
protected Vector3 path;
public ActionRotateTo(Vector3 tgtValue, float tgtDuration)
: base(tgtDuration)
{
value = tgtValue;
}
public override Action clone()
{
return new ActionRotateTo(value, duration);
}
public override void start()
{
base.start();
path = new Vector3();
for (int i = 0; i < 3; i++)
{
float t = value[i];
float f = target.gameObject.transform.rotation.eulerAngles[i];
if (Math.Abs(t - f) < Math.Abs(t + 360 - f))
path[i] = t - f;
else
path[i] = t + 360 - f;
}
}
public override void stepInterval(float dt)
{
float d = dt / duration;
Vector3 tgt = path * d;
target.gameObject.transform.Rotate(Vector3.up, tgt.y);
target.gameObject.transform.Rotate(Vector3.right, tgt.x);
target.gameObject.transform.Rotate(Vector3.forward, tgt.z);
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using UnityEngine;
class ActionScaleBy : ActionInterval
{
protected Vector3 delta;
protected Vector3 path;
public ActionScaleBy(Vector3 tgtDelta, float tgtDuration)
: base(tgtDuration)
{
delta = tgtDelta;
}
public override Action clone()
{
return new ActionScaleBy(delta, duration);
}
public override Action reverse()
{
return new ActionScaleBy(delta * -1F, duration);
}
public override void start()
{
base.start();
Vector3 scale = target.gameObject.transform.localScale;
scale.x *= delta.x;
scale.y *= delta.y;
scale.z *= delta.z;
path = scale - target.gameObject.transform.localScale;
}
public override void stepInterval(float dt)
{
float d = dt / duration;
Vector3 tgt = path * d;
target.gameObject.transform.localScale += tgt;
}
public override void stop()
{
base.stop();
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using UnityEngine;
class ActionScaleTo : ActionInterval
{
protected Vector3 value;
protected Vector3 path;
public ActionScaleTo(Vector3 tgtValue, float tgtDuration)
: base(tgtDuration)
{
value = tgtValue;
}
public override Action clone()
{
return new ActionScaleTo(value, duration);
}
public override void start()
{
base.start();
path = value - target.gameObject.transform.localScale;
}
public override void stepInterval(float dt)
{
float d = dt / duration;
Vector3 tgt = path * d;
target.gameObject.transform.localScale += tgt;
}
public override void stop()
{
base.stop();
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using UnityEngine;
class ActionTintBy : ActionInterval
{
public Vector4 color;
protected const float coeff = 1F / 255F;
public ActionTintBy(Vector4 tgtColor, float tgtDuration)
: base(tgtDuration)
{
color = tgtColor * coeff;
}
public override Action clone()
{
return new ActionTintBy(color / coeff, duration);
}
public override Action reverse()
{
return new ActionTintBy(-color / coeff, duration);
}
public override void stepInterval(float dt)
{
float d = dt / duration;
Vector4 tgt = color * d;
Color tgtColor = target.gameObject.renderer.material.color;
tgtColor[0] += tgt[0];
tgtColor[1] += tgt[1];
tgtColor[2] += tgt[2];
tgtColor[3] += tgt[3];
target.gameObject.renderer.material.color = tgtColor;
}
}