new actions:

ActionFadeIn.cs
ActionFadeOut.cs
ActionFadeTo.cs
This commit is contained in:
2014-06-17 02:05:43 +04:00
committed by Ivan "KaiSD" Korystin
parent 0fb99b3747
commit db81d59756
6 changed files with 85 additions and 12 deletions

View File

@@ -22,11 +22,6 @@ class ActionFadeBy : ActionInterval
return new ActionFadeBy(-delta, duration);
}
public override void start()
{
base.start();
}
public override void stepInterval(float dt)
{
float d = dt / duration;

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using UnityEngine;
class ActionFadeIn : ActionFadeTo
{
public ActionFadeIn(float tgtDuration)
: base(1, tgtDuration)
{
}
public override Action clone()
{
return new ActionFadeIn(duration);
}
public override Action reverse()
{
return new ActionFadeIn(duration);
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using UnityEngine;
class ActionFadeOut : ActionFadeTo
{
public ActionFadeOut(float tgtDuration)
: base(0, tgtDuration)
{
}
public override Action clone()
{
return new ActionFadeOut(duration);
}
public override Action reverse()
{
return new ActionFadeOut(duration);
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using UnityEngine;
class ActionFadeTo : ActionInterval
{
public float value;
public float delta;
public ActionFadeTo(float tgtValue, float tgtDuration)
: base(tgtDuration)
{
value = tgtValue;
}
public override Action clone()
{
return new ActionFadeTo(value, duration);
}
public override void start()
{
base.start();
delta = value - target.gameObject.renderer.material.color.a;
}
public override void stepInterval(float dt)
{
float d = dt / duration;
Color tgtColor = target.gameObject.renderer.material.color;
tgtColor[3] += delta * d;
target.gameObject.renderer.material.color = tgtColor;
}
}