//--------------------------------------------------------------------------------------------/ // Methods //--------------------------------------------------------------------------------------------/ /// <summary> /// Interpolates to the specified transformation. /// </summary> public void Apply(Vector3 value) { currentAction = StratusActions.Sequence(this); if (debug) { StratusDebug.Log($"The {eventType} operation was applied on {target.name}", this); } switch (eventType) { case EventType.Translate: transformationType = TransformationType.Translate; if (valueType == ValueType.Static) { if (local) { previousValue = target.localPosition; currentCoroutine = StratusRoutines.Interpolate(previousValue, currentValue, duration, (Vector3 val) => { target.localPosition = val; }, ease); //Actions.Property(currentAction, () => target.localPosition, currentValue, this.duration, this.ease); } else { previousValue = target.position; currentCoroutine = StratusRoutines.Interpolate(previousValue, currentValue, duration, (Vector3 val) => { target.position = val; }, ease); //Actions.Property(currentAction, () => target.position, currentValue, this.duration, this.ease); } } else if (valueType == ValueType.Mirror) { previousValue = target.position; currentCoroutine = StratusRoutines.Interpolate(previousValue, source.position, duration, (Vector3 val) => { target.position = val; }, ease); //Actions.Property(currentAction, () => target.position, source.position, this.duration, this.ease); } target.StartCoroutine(currentCoroutine, transformationType); break; case EventType.Rotate: transformationType = TransformationType.Rotate; previousValue = target.rotation.eulerAngles; currentCoroutine = StratusRoutines.Rotate(target, isMirror ? source.rotation.eulerAngles : currentValue, duration); target.StartCoroutine(currentCoroutine, transformationType); //Actions.Property(currentAction, () => target.rotation.eulerAngles, isMirror ? source.localRotation.eulerAngles : currentValue, this.duration, this.ease); break; case EventType.RotateAround: transformationType = TransformationType.Translate | TransformationType.Rotate; previousValue = target.rotation.eulerAngles; currentCoroutine = StratusRoutines.RotateAround(target, isMirror ? source.position : currentValue, axis, angleAroundTarget, duration); target.StartCoroutine(currentCoroutine, transformationType); break; case EventType.Scale: previousValue = target.localScale; transformationType = TransformationType.Scale; currentCoroutine = StratusRoutines.Interpolate(previousValue, isMirror ? source.localScale : currentValue, duration, (Vector3 val) => { target.localScale = val; }, ease);; //Routines.Scale(target, isMirror ? source.localScale : currentValue, this.duration); target.StartCoroutine(currentCoroutine, transformationType); //Actions.Property(currentAction, () => target.localScale, isMirror ? source.localScale : currentValue, this.duration, this.ease); break; case EventType.Parent: StratusActions.Delay(currentAction, duration); StratusActions.Call(currentAction, () => { target.SetParent(source); }); break; case EventType.Reset: StratusActions.Delay(currentAction, duration); StratusActions.Call(currentAction, () => { target.Reset(); }); break; } }
void RotateAroundWhile() { IEnumerator rotateAround = StratusRoutines.RotateAround(transform, target.position, axis, angleAroundTarget); this.transform.StartCoroutine(rotateAround, TransformationType.Translate | TransformationType.Rotate); }