Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ORKEditorHelp("Change Scale Float", "Sets or fades the scale of a game object.", "")]
- [ORKEventStep(typeof(BaseEvent))]
- [ORKNodeInfo("Movement/Movement")]
- public class ChangeScaleFloatStep : BaseEventStep
- {
- // scaling object
- [ORKEditorInfo(labelText="Scaling Object")]
- public EventObjectSetting scaleObject = new EventObjectSetting();
- [ORKEditorHelp("Time Between (s)", "The time in seconds between scaling two objects.\n" +
- "Only used if greater than 0 and more than one object will be scaled.", "")]
- [ORKEditorLimit(0.0f, false)]
- public float timeBetween = 0;
- [ORKEditorHelp("Wait Between", "Wait for all objects to start scaling before executing the next step.\n" +
- "If disabled, the next step will execute immediately while this step continues.", "")]
- public bool waitBetween = true;
- [ORKEditorInfo(separator=true, labelText="ScaleX")]
- public EventFloat scaleX = new EventFloat();
- [ORKEditorInfo(separator = true, labelText = "ScaleY")]
- public EventFloat scaleY = new EventFloat();
- [ORKEditorInfo(separator = true, labelText = "ScaleZ")]
- public EventFloat scaleZ = new EventFloat();
- Vector3 scale(BaseEvent baseEvent)
- {
- return new Vector3(scaleX.GetValue(baseEvent), scaleY.GetValue(baseEvent), scaleZ.GetValue(baseEvent));
- }
- // fade
- [ORKEditorHelp("Fade Scale", "The scale is changed over time to the new scale.\n" +
- "If disabled, the object's scale is set to the new scale immediately.", "")]
- [ORKEditorInfo(separator=true, labelText="Fade Settings")]
- public bool fade = false;
- [ORKEditorInfo(separator=true, labelText="Time (s)", label=new string[] {
- "The time in seconds used to scale."
- })]
- [ORKEditorLayout("fade", true, autoInit=true)]
- public EventFloat time;
- [ORKEditorHelp("Wait", "Wait until the scaling has finished before the next step is executed.", "")]
- [ORKEditorLayout("waitBetween", true, endCheckGroup=true)]
- public bool wait = false;
- // interpolate
- [ORKEditorHelp("Interpolation", "The interpolation used for fading the scale.", "")]
- [ORKEditorLayout(endCheckGroup=true)]
- public EaseType interpolation = EaseType.Linear;
- // ingame
- private List<GameObject> list;
- private int index = 0;
- private float tmpTime = 0;
- public ChangeScaleFloatStep()
- {
- }
- public override void SetData(DataObject data)
- {
- base.SetData(data);
- if(data.Contains<float>("time"))
- {
- this.time = new EventFloat();
- this.time.type = NumberValueType.Value;
- data.Get("time", ref this.time.value);
- }
- }
- public override void Execute(BaseEvent baseEvent)
- {
- this.list = this.scaleObject.GetObject(baseEvent);
- this.index = 0;
- if(this.list.Count > 0)
- {
- this.tmpTime = this.time != null ? this.time.GetValue(baseEvent) : 0;
- this.Continue(baseEvent);
- if(!this.waitBetween)
- {
- baseEvent.StepFinished(this.next);
- }
- }
- else
- {
- baseEvent.StepFinished(this.next);
- }
- }
- public override void Continue(BaseEvent baseEvent)
- {
- if(this.list[this.index] != null)
- {
- if(this.fade)
- {
- ActorEventScaler scaler = ComponentHelper.Get<ActorEventScaler>(this.list[this.index]);
- scaler.Scale(this.list[this.index].transform, this.tmpTime, this.scale(baseEvent), this.interpolation);
- }
- else
- {
- this.list[this.index].transform.localScale = this.scale(baseEvent);
- }
- }
- this.index++;
- // execute next
- if(this.index < this.list.Count)
- {
- if(this.timeBetween > 0)
- {
- baseEvent.StartContinue(this.timeBetween, this);
- }
- else
- {
- this.Continue(baseEvent);
- }
- }
- // finish
- else
- {
- if(this.waitBetween)
- {
- if(this.fade && this.wait)
- {
- baseEvent.StartTime(this.tmpTime, this.next);
- }
- else
- {
- baseEvent.StepFinished(this.next);
- }
- }
- // clear data
- this.list = null;
- this.index = 0;
- }
- }
- /*
- ============================================================================
- Node name functions
- ============================================================================
- */
- public override string GetNodeDetails()
- {
- return (this.fade ?
- "Fade scale, " + this.time.GetInfoText() + "s " + (this.wait ? "(wait)" : "") :
- "Set scale");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement