public void Test_EventDriven_SimpleAnimation_2() { // Define animation parameters / objects DummyAnimatableObject animateableObject = new DummyAnimatableObject(); int dummyInt = 0; // Define animation sequence // .. nothing special, just step by step animateableObject.BuildAnimationSequence() .ChangeFloatBy( () => animateableObject.DummyValue, (givenValue) => animateableObject.DummyValue = givenValue, 10f, TimeSpan.FromMilliseconds(500.0)) .WaitFinished() .CallAction(() => { dummyInt = 10; }) .ChangeFloatBy( () => animateableObject.DummyValue, (givenValue) => animateableObject.DummyValue = givenValue, 20f, TimeSpan.FromMilliseconds(500.0)) .Apply(); // Perform animation in an event-driven way EventDrivenPassInfo passInfo = animateableObject.AnimationHandler.CalculateEventDriven(); // Check results Assert.True(passInfo.CountSteps == 2); Assert.True(dummyInt == 10); Assert.True(animateableObject.DummyValue == 30f); Assert.True(passInfo.TotalTime == TimeSpan.FromSeconds(1.0)); }
public void Test_EventDriven_SimpleAnimation_8() { // Define animation parameters / objects GenericObject genObject = new GenericObject(NamedOrGenericKey.Empty); // Define animation sequence // Same as above, just with a wait-finished event here (dynamic wait step) genObject.BuildAnimationSequence() .Move3DTo(new Vector3(6f, 0f, 0f), new MovementSpeed(0.3f)) // 20,0 Secs .Scale3DTo(new Vector3(2f, 2f, 2f), TimeSpan.FromSeconds(2.0)) // 02,0 Secs .WaitFinished() .Move3DTo(new Vector3(9f, 0f, 0f), new MovementSpeed(0.3f)) // 10,0 Secs .RotateEulerAnglesBy(new Vector3(2f, 0f, 0f), TimeSpan.FromSeconds(12.0)) // 12,0 Secs .WaitFinished() .Apply(); genObject.BuildAnimationSequence() .Move3DTo(new Vector3(10f, 0f, 0f), new MovementSpeed(0.4f)) // 25,0 Secs .Scale3DTo(new Vector3(2f, 2f, 2f), TimeSpan.FromSeconds(30.0)) // 30,0 Secs .WaitFinished() .Move3DTo(new Vector3(11f, 0f, 0f), new MovementSpeed(0.4f)) // 2,5 Secs .RotateEulerAnglesBy(new Vector3(2f, 0f, 0f), TimeSpan.FromSeconds(1.0)) // 1,0 Secs .WaitFinished() .ApplyAsSecondary(); // Perform animation in an event-driven way EventDrivenPassInfo passInfo = genObject.AnimationHandler.CalculateEventDriven(); // Check results Assert.True(passInfo.CountSteps == 4); Assert.True(passInfo.Steps[0].UpdateTime == TimeSpan.FromSeconds(20.0)); Assert.True(passInfo.Steps[1].UpdateTime == TimeSpan.FromSeconds(10.0)); Assert.True(passInfo.Steps[2].UpdateTime == TimeSpan.FromSeconds(2.0)); Assert.True(passInfo.Steps[3].UpdateTime == TimeSpan.FromSeconds(0.5)); Assert.True(Math.Round(passInfo.TotalTime.TotalSeconds, 1) == 32.5); }
public void Test_EventDriven_SimpleAnimation_7() { // Define animation parameters / objects GenericObject genObject = new GenericObject(NamedOrGenericKey.Empty); // Define animation sequence // Same as above, just with a wait-finished event here (dynamic wait step) genObject.BuildAnimationSequence() .Move3DBy(new Vector3(5f, 0f, 0f), TimeSpan.FromMilliseconds(500.0)) .Scale3DTo(new Vector3(2f, 2f, 2f), TimeSpan.FromMilliseconds(1750.0)) .WaitFinished() .RotateEulerAnglesBy(new Vector3(2f, 0f, 0f), TimeSpan.FromMilliseconds(500.0)) .WaitFinished() .Apply(); genObject.BuildAnimationSequence() .Move3DBy(new Vector3(5f, 0f, 0f), TimeSpan.FromMilliseconds(400.0)) .Scale3DTo(new Vector3(2f, 2f, 2f), TimeSpan.FromMilliseconds(1850.0)) .WaitFinished() .RotateEulerAnglesBy(new Vector3(2f, 0f, 0f), TimeSpan.FromMilliseconds(300.0)) .WaitFinished() .ApplyAsSecondary(); // Perform animation in an event-driven way EventDrivenPassInfo passInfo = genObject.AnimationHandler.CalculateEventDriven(); // Check results Assert.True(passInfo.CountSteps == 4); Assert.True(passInfo.Steps[0].UpdateTime == TimeSpan.FromMilliseconds(1750.0)); Assert.True(passInfo.Steps[1].UpdateTime == TimeSpan.FromMilliseconds(100.0)); Assert.True(passInfo.Steps[2].UpdateTime == TimeSpan.FromMilliseconds(300.0)); Assert.True(passInfo.Steps[3].UpdateTime == TimeSpan.FromMilliseconds(100.0)); }
public void Test_EventDriven_SimpleAnimation_EmptyStates() { // Define animation parameters / objects GenericObject genObject = new GenericObject(NamedOrGenericKey.Empty); Assert.True(genObject.AnimationHandler.TimeTillCurrentAnimationStepFinished == new TimeSpan(0, 0, 0, 0, int.MaxValue)); // Perform animation in an event-driven way EventDrivenPassInfo passInfo = genObject.AnimationHandler.CalculateEventDriven(); // Check results Assert.True(passInfo.CountSteps == 0); Assert.True(genObject.AnimationHandler.TimeTillCurrentAnimationStepFinished == new TimeSpan(0, 0, 0, 0, int.MaxValue)); }
public void Test_EventDriven_SimpleAnimation_3() { // Define animation parameters / objects GenericObject genObject = new GenericObject(NamedOrGenericKey.Empty); // Define animation sequence // .. use 3D-Engine GenericObject (animated just like simulation objects) genObject.BuildAnimationSequence() .Move3DBy(new Vector3(5f, 0f, 0f), TimeSpan.FromMilliseconds(500.0)) .Scale3DTo(new Vector3(2f, 2f, 2f), TimeSpan.FromMilliseconds(750.0)) .WaitFinished() .Apply(); // Main-Test: Perform animation in an event-driven way EventDrivenPassInfo passInfo = genObject.AnimationHandler.CalculateEventDriven(); // Check results Assert.True(passInfo.CountSteps == 1); Assert.True(passInfo.Steps[0].UpdateTime == TimeSpan.FromMilliseconds(750.0)); }
public void Test_EventDriven_SimpleAnimation_5() { // Define animation parameters / objects GenericObject genObject = new GenericObject(NamedOrGenericKey.Empty); // Define animation sequence // .. A bit more complicated.. this method uses a fixed wait timer in between. Not all animations before it would be finished // More complicated here: The step "Scale3DTo" is the longest and controls the duration of the second event genObject.BuildAnimationSequence() .Move3DBy(new Vector3(5f, 0f, 0f), TimeSpan.FromMilliseconds(500.0)) .Scale3DTo(new Vector3(2f, 2f, 2f), TimeSpan.FromMilliseconds(1750.0)) .WaitUntilTimePassed(TimeSpan.FromMilliseconds(600.0)) .RotateEulerAnglesBy(new Vector3(2f, 0f, 0f), TimeSpan.FromMilliseconds(500.0)) .WaitFinished() .Apply(); // Perform animation in an event-driven way EventDrivenPassInfo passInfo = genObject.AnimationHandler.CalculateEventDriven(); // Check results Assert.True(passInfo.CountSteps == 2); Assert.True(passInfo.Steps[0].UpdateTime == TimeSpan.FromMilliseconds(600.0)); Assert.True(passInfo.Steps[1].UpdateTime == TimeSpan.FromMilliseconds(1150.0)); }