public void EnterFrameTest() { TestAnimation animation = new TestAnimation(); int index = 0; animation.EnterFrame += (o, e) => { System.Diagnostics.Trace.WriteLine(e.Frame); if (index < animation.TotalFrames) { Assert.AreEqual(index, e.Frame); } index++; }; ((IAnimation)animation).OnStarted(); for (int i = 0; i < 20; ++i) { animation.Update(0.25f); } Assert.AreNotEqual <AnimationState>(AnimationState.Playing, animation.State); Assert.AreEqual(6, index); }
public void KeyframeEndingTest() { TestAnimation animation = new TestAnimation(); animation.Repeat = 9999; animation.Ending = KeyframeEnding.Clamp; ((IAnimation)animation).OnStarted(); for (int i = 0; i < 5; ++i) { animation.Update(1); } Assert.AreEqual(0, animation.CurrentFrame); animation.Ending = KeyframeEnding.Discard; ((IAnimation)animation).OnStarted(); for (int i = 0; i < 5; ++i) { animation.Update(1); } Assert.AreEqual(1, animation.CurrentFrame); animation.Ending = KeyframeEnding.Discard; animation.AutoReverse = true; ((IAnimation)animation).OnStarted(); for (int i = 0; i < 50; ++i) { animation.Update(0.5f); System.Diagnostics.Trace.WriteLine(animation.CurrentFrame); } Assert.AreEqual(1, animation.CurrentFrame); }
public void TestDeleteChildrenWithRunningGroup() { // test if children can be activated when their group is stopped var group = new QParallelAnimationGroup(); QVariantAnimation anim1 = new TestAnimation(); anim1.StartValue = new QVariant(0); anim1.EndValue = new QVariant(100); anim1.SetDuration(200); group.AddAnimation(anim1); Assert.AreEqual(anim1.Duration, group.Duration); group.Start(); Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state); System.Threading.Thread.Sleep(80); Assert.Greater(group.CurrentLoopTime, 0); group.RemoveAnimation(anim1); Assert.AreEqual(0, group.AnimationCount); Assert.AreEqual(0, group.Duration); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(0, group.CurrentLoopTime); }
public unsafe void TestDeleteChildrenWithRunningGroup() { // test if children can be activated when their group is stopped var group = new QParallelAnimationGroup(); QVariantAnimation anim1 = new TestAnimation(); anim1.StartValue = new QVariant(0); anim1.EndValue = new QVariant(100); anim1.SetDuration(200); group.AddAnimation(anim1); Assert.AreEqual(anim1.Duration, group.Duration); group.Start(); Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state); System.Threading.Thread.Sleep(80); Assert.Greater(group.CurrentLoopTime, 0); group.RemoveAnimation(anim1); anim1 = null; Assert.AreEqual(0, group.AnimationCount); Assert.AreEqual(0, group.Duration); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(0, group.CurrentLoopTime); }
public void SeekTest() { TestAnimation animation = new TestAnimation(); ((IAnimation)animation).OnStarted(); animation.Seek(TimeSpan.FromSeconds(4.5f)); Assert.AreEqual <AnimationState>(AnimationState.Playing, animation.State); Assert.AreEqual <TimeSpan>(TimeSpan.FromSeconds(4.5), animation.Position); animation.Seek(2); Assert.AreEqual <AnimationState>(AnimationState.Playing, animation.State); Assert.AreEqual <TimeSpan>(TimeSpan.FromSeconds(2), animation.Position); animation.Update(3); Assert.AreNotEqual <AnimationState>(AnimationState.Playing, animation.State); animation.StartupDirection = AnimationDirection.Backward; ((IAnimation)animation).OnStarted(); animation.Seek(1); Assert.AreEqual <AnimationState>(AnimationState.Playing, animation.State); animation.Update(1.001f); Assert.AreNotEqual <AnimationState>(AnimationState.Playing, animation.State); }
public void DirectionTest() { TestAnimation animation = new TestAnimation(); animation.StartupDirection = AnimationDirection.Backward; ((IAnimation)animation).OnStarted(); animation.Update(2); Assert.AreEqual <AnimationState>(AnimationState.Playing, animation.State); Assert.AreEqual <TimeSpan>(TimeSpan.FromSeconds(3), animation.Position); }
public void IsPlayingTest() { TestAnimation animation = new TestAnimation(); Assert.AreNotEqual <AnimationState>(AnimationState.Playing, animation.State); ((IAnimation)animation).OnStarted(); Assert.AreEqual <AnimationState>(AnimationState.Playing, animation.State); animation.Update(5); Assert.AreNotEqual <AnimationState>(AnimationState.Playing, animation.State); }
public void TestGotoFrameBeforeLoaded(int frame) { AddStep("create new animation", () => animation = new TestAnimation(true, fontStore) { Loop = false }); AddStep($"go to frame {frame}", () => animation.GotoFrame(frame)); AddStep("load animation", () => animationContainer.Child = animation); AddAssert($"animation is at frame {frame}", () => animation.CurrentFrameIndex == frame); }
public void RepeatTest() { TestAnimation animation = new TestAnimation(); animation.Repeat = 2.5f; ((IAnimation)animation).OnStarted(); animation.Update(12.4f); Assert.AreEqual <AnimationState>(AnimationState.Playing, animation.State); animation.Update(0.1f); Assert.AreNotEqual <AnimationState>(AnimationState.Playing, animation.State); }
private void loadNewAnimation(bool startFromCurrent = true, Action <TestAnimation> postLoadAction = null) { AddStep("load animation", () => { animationContainer.Child = animation = new TestAnimation(startFromCurrent) { Loop = false, }; postLoadAction?.Invoke(animation); }); AddUntilStep("Wait for animation to load", () => animation.IsLoaded); }
public unsafe void TestPropagateGroupUpdateToChildren() { // this test verifies if group state changes are updating its children correctly var group = new QParallelAnimationGroup(); var o = new QObject(); o.SetProperty("ole", new QVariant(42)); Assert.AreEqual(42, o.Property("ole").ToInt()); var anim1 = new QPropertyAnimation(o, new QByteArray("ole")); anim1.EndValue = new QVariant(42); anim1.SetDuration(100); Assert.IsFalse(anim1.CurrentValue.IsValid); Assert.AreEqual(0, anim1.CurrentValue.ToInt()); Assert.AreEqual(42, o.Property("ole").ToInt()); var anim2 = new TestAnimation(); anim2.StartValue = new QVariant(0); anim2.EndValue = new QVariant(100); anim2.SetDuration(200); Assert.IsTrue(anim2.CurrentValue.IsValid); Assert.AreEqual(0, anim2.CurrentValue.ToInt()); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state); group.AddAnimation(anim1); group.AddAnimation(anim2); group.Start(); Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim2.state); group.Pause(); Assert.AreEqual(QAbstractAnimation.State.Paused, group.state); Assert.AreEqual(QAbstractAnimation.State.Paused, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Paused, anim2.state); group.Stop(); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state); }
public void TestStartGroupWithRunningChild() { var group = new QParallelAnimationGroup(); var anim1 = new TestAnimation(); anim1.StartValue = new QVariant(0); anim1.EndValue = new QVariant(100); anim1.SetDuration(200); var anim2 = new TestAnimation(); anim2.StartValue = new QVariant(0); anim2.EndValue = new QVariant(100); anim2.SetDuration(200); var spy1 = 0; anim1.StateChanged += (arg1, arg2) => { spy1++; }; var spy2 = 0; anim2.StateChanged += (arg1, arg2) => { spy2++; }; Assert.AreEqual(0, spy1); Assert.AreEqual(0, spy2); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state); group.AddAnimation(anim1); group.AddAnimation(anim2); anim1.Start(); anim2.Start(); anim2.Pause(); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Paused, anim2.state); group.Start(); Assert.AreEqual(3, spy1); Assert.AreEqual(4, spy2); Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim2.state); }
public void TestUpdateChildrenWithRunningGroup() { var group = new QParallelAnimationGroup(); var anim = new TestAnimation(); anim.StartValue = new QVariant(0); anim.EndValue = new QVariant(100); anim.SetDuration(200); var groupStateChangedSpy = 0; group.StateChanged += (arg1, arg2) => { groupStateChangedSpy++; }; var childStateChangedSpy = 0; anim.StateChanged += (arg1, arg2) => { childStateChangedSpy++; }; Assert.AreEqual(0, groupStateChangedSpy); Assert.AreEqual(0, childStateChangedSpy); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim.state); group.AddAnimation(anim); group.Start(); Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim.state); Assert.AreEqual(1, groupStateChangedSpy); Assert.AreEqual(1, childStateChangedSpy); anim.Start(); Assert.AreEqual(1, groupStateChangedSpy); Assert.AreEqual(1, childStateChangedSpy); anim.Pause(); Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(QAbstractAnimation.State.Paused, anim.state); // in the animation stops directly, the group will still be running anim.Stop(); Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim.state); }
public void TestStopGroupWithRunningChild() { // test if children can be activated when their group is stopped var group = new QParallelAnimationGroup(); var anim1 = new TestAnimation(); anim1.StartValue = new QVariant(0); anim1.EndValue = new QVariant(100); anim1.SetDuration(200); var anim2 = new TestAnimation(); anim2.StartValue = new QVariant(0); anim2.EndValue = new QVariant(100); anim2.SetDuration(200); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state); group.AddAnimation(anim1); group.AddAnimation(anim2); anim1.Start(); anim2.Start(); anim2.Pause(); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Paused, anim2.state); group.Stop(); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Paused, anim2.state); anim1.Stop(); anim2.Stop(); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state); }
public void TestCrashWhenRemovingUncontrolledAnimation() { var group = new QParallelAnimationGroup(); var anim = new TestAnimation(); anim.LoopCount = -1; var anim2 = new TestAnimation(); anim2.LoopCount = -1; group.AddAnimation(anim); group.AddAnimation(anim2); group.Start(); anim.Dispose(); anim2.Dispose(); }
public void AutoReverseTest() { TestAnimation animation = new TestAnimation(); animation.Repeat = 2.25f; animation.AutoReverse = true; ((IAnimation)animation).OnStarted(); animation.Update(6); Assert.AreEqual <AnimationState>(AnimationState.Playing, animation.State); Assert.AreEqual <TimeSpan>(TimeSpan.FromSeconds(4), animation.Position); animation.Update(5); Assert.AreEqual <TimeSpan>(TimeSpan.FromSeconds(1), animation.Position); Assert.AreEqual <AnimationState>(AnimationState.Playing, animation.State); animation.Update(1.5f); Assert.AreNotEqual <AnimationState>(AnimationState.Playing, animation.State); }
public async void TestAnimationCreateFrames() { //Set DebugMode to debug with Fiddler //Bootstrapper.DebugMode = true; var tests = new ChromaInstanceTests(); var instance = await tests.Instance_ReturnValidInstance(); var testAnimation = new TestAnimation(instance); testAnimation.AnimationState += (devices, frame, result) => { Console.WriteLine($"Devices: {string.Join(",", devices)}, Frame: {frame} of {testAnimation.Frames.Count}, Effects: {string.Join(",", devices.Select(x=>x.EffectId))} Result: {string.Join(",", result)}"); }; testAnimation.CreateFrames(); var playTask = testAnimation.Play(); await Task.Delay(20000); await testAnimation.Stop(); }
[InlineData(true, true, 6560, 2560)] // 56.0% of the way from 2000 to 3000 public void CanTweenKeyframes(bool addZeroFrame, bool addLoop, int time, int expected) { var anim = new TestAnimation() .AddKeyframe(TimeSpan.FromMilliseconds(1000), 1000) .AddKeyframe(TimeSpan.FromMilliseconds(2000), 2000) .AddKeyframe(TimeSpan.FromMilliseconds(3000), 3000); if (addZeroFrame) { anim.AddKeyframe(TimeSpan.Zero, 0); } if (addLoop) { anim.Loop(TimeSpan.FromMilliseconds(1000)); } var frame = anim.GetFrame(TimeSpan.FromMilliseconds(time)); Assert.Equal(expected, frame); }
public bool PlayMec(Vector2 playindex) { TestAnimation t = GetAnimation((int)playindex.x); if (t != null) { t.isPositive = true; t.Play(this.time, this.step, this.distance); t.SetAction(this.actiontime * t.GetAlltime(), delegate { call1 = true; }); } else { return(false); } //can add animation before play inverse animation pauseStartTime = Time.time; pauseAction = delegate { pauseAction = null; TestAnimation tt = GetAnimation((int)playindex.y); if (tt != null) { tt.isPositive = false; Vector3 newTime = new Vector3(this.time.z, this.time.y, this.time.x); Vector3 newStep = new Vector3(this.step.z, this.step.y, this.step.x); Vector2 newDistance = new Vector2(this.distance.y, this.distance.x); tt.Play(newTime, -newStep, newDistance); tt.SetAction(this.actiontime * tt.GetAlltime(), delegate { call2 = true; }); } }; return(true); }
public void BeginFrameEndFrameTest() { TestAnimation animation = new TestAnimation(); animation.BeginFrame = 1; animation.EndFrame = 3; int frameCount = 0; animation.EnterFrame += (o, e) => { frameCount++; }; ((IAnimation)animation).OnStarted(); for (int i = 0; i < 200; ++i) { animation.Update(0.25f); } Assert.AreEqual(AnimationState.Stopped, animation.State); Assert.AreEqual(3, frameCount); }
void UpdateCutterAniamtion() { if (Time.time - zmjLastArmAnimation > CutMineAnimation.singleton.pauseTime.z && CutMineAnimation.singleton.bway3) { CutMineAnimation.singleton.bway3 = false; GameObject cutter = GameObject.Find(CutMineAnimation.singleton.cutterName); Debug.LogError("第四次播放割煤动画"); //SetDT_YJQDTextContent("割底煤"); if (Cutter2DAnimation.singleton.playing) { CastTransfrom.singleton.CutDown(); CastTransfrom.singleton.ToRight(); } CutMineAnimation.singleton.PlayCutterAnimation(CutMineAnimation.singleton.way4, cutter, -1, CutMineAnimation.singleton.speed, 0, () => { Debug.LogError("第四次播放割煤动画结束"); //SetDT_YJQDVisiblity(false); if (Cutter2DAnimation.singleton.playing) { CastTransfrom.singleton.MiddleVisible(false); CastTransfrom.singleton.HintVisible(false); } CutMineAnimation.singleton.bway4 = true; zmjFiveCutterSart = Time.time; //动画播放完毕时执行的函数 }, index => { SetGroup1Particle(-index + 47 + 5 + 2); SetGroup2Particle(-index + 47 + 5 - 8 + 1); }); } if (Time.time - zmjFiveCutterSart > CutMineAnimation.singleton.pauseTime.w && CutMineAnimation.singleton.bway4) { CutMineAnimation.singleton.bway4 = false; GameObject cutter = GameObject.Find(CutMineAnimation.singleton.cutterName); Debug.LogError("第五次播放割煤动画"); if (Cutter2DAnimation.singleton.playing) { CastTransfrom.singleton.ToLeft(); } CutMineAnimation.singleton.PlayCutterAnimation(CutMineAnimation.singleton.way5, cutter, 1, CutMineAnimation.singleton.speed, 0, () => { PlayCutterArm(4); Debug.LogError("第五次播放割煤动画结束"); //SetDT_YJQDVisiblity(false); if (Cutter2DAnimation.singleton.playing) { CastTransfrom.singleton.MiddleVisible(false); CastTransfrom.singleton.HintVisible(false); } //动画播放完毕时执行的函数 }, index => { SetGroup1Particle(index - 3 + 38); SetGroup2Particle(index - 3 + 39 + 8); }); } if (zmjZhijiaend) { if (Time.time - zmjZhijiaendStart > CutMineAnimation.singleton.pauseTime.x && CutMineAnimation.singleton.bway1) { CutMineAnimation.singleton.bway1 = false; zmjZhijiaend = false; GameObject cutter = GameObject.Find(CutMineAnimation.singleton.cutterName); Debug.LogError("第二次播放割煤动画"); //SetDT_YJQDTextContent("切三角煤"); if (Cutter2DAnimation.singleton.playing) { CastTransfrom.singleton.CutTri(); CastTransfrom.singleton.ToRight(); } CutMineAnimation.singleton.PlayCutterAnimation(CutMineAnimation.singleton.way2, cutter, -1, CutMineAnimation.singleton.speed, 0, () => { // if (identification == 1) Debug.LogError("第二次播放割煤动画结束"); //SetDT_YJQDVisiblity(false); PlayCutterArm(2); CutMineAnimation.singleton.speed = 0.54f; if (Cutter2DAnimation.singleton.playing) { CastTransfrom.singleton.MiddleVisible(false); CastTransfrom.singleton.HintVisible(false); Cutter2DAnimation.singleton.StopCutter2ThirdStageAnimation(); } //动画播放完毕时执行的函数 }, index => { SetGroup1Particle(-index + 16 + 6 + 1); SetGroup2Particle(-index + 16 + 6 - 8); Debug.LogError("第二段动画序列号:" + index); if (index == 4) { if (Cutter2DAnimation.singleton.playing) { Cutter2DAnimation.singleton.StartCutter2ThirdStageAnimation(); } //Cutter2DAnimation.singleton.StartCutter1ThirdStageAnimation(); } }); } if (Time.time - zmjZhijiaendStart > CutMineAnimation.singleton.pauseTime.y && CutMineAnimation.singleton.bway2) { CutMineAnimation.singleton.bway2 = false; zmjZhijiaend = false; Debug.LogError("第三次播放割煤动画"); //SetDT_YJQDTextContent("割底煤"); GameObject cutter = GameObject.Find(CutMineAnimation.singleton.cutterName); if (Cutter2DAnimation.singleton.playing) { Cutter2DAnimation.singleton.ShenSuoBi1SecondStage(); Cutter2DAnimation.singleton.TrackSecondStage(); CastTransfrom.singleton.ToLeft(); CastTransfrom.singleton.CutDown(); } CutMineAnimation.singleton.PlayCutterAnimation(CutMineAnimation.singleton.way3, cutter, 1, CutMineAnimation.singleton.speed, 0, () => { Debug.LogError("第三次播放割煤动画结束"); //SetDT_YJQDVisiblity(false); if (Cutter2DAnimation.singleton.playing) { CastTransfrom.singleton.MiddleVisible(false); CastTransfrom.singleton.HintVisible(false); Cutter2DAnimation.singleton.StopCutter1ThirdStageAnimation(); } PlayCutterArm(3); //动画播放完毕时执行的函数 }, index => { SetGroup1Particle(index - 3 - 1); SetGroup2Particle(index - 3 + 8); Debug.LogError("第三次播放割煤动画索引:" + index); if (index == 17) { //SetDT_YJQDTextContent("中部跟机"); if (Cutter2DAnimation.singleton.playing) { CastTransfrom.singleton.FollowMiddle(); Cutter2DAnimation.singleton.StartCutter1ThirdStageAnimation(); } } if (index == 41 && AnimationManager.identification == 3) { TestAnimation.PlayAnimationWhenMax(36, true); } }); } //if (/*Time.time - zmjZhijiaendStart > CutMineAnimation.singleton.pauseTime.z &&*/ CutMineAnimation.singleton.bway3) //{ // CutMineAnimation.singleton.bway3 = false; // zmjZhijiaend = false; // GameObject cutter = GameObject.Find(CutMineAnimation.singleton.cutterName); // CutMineAnimation.singleton.PlayCutterAnimation(CutMineAnimation.singleton.way4, cutter, CutMineAnimation.singleton.speed, 0, () => // { // //动画播放完毕时执行的函数 // }); //} } }
void Update() { if (SOManager.singleton.currSceneName != "ZNCM_G") { try { if (image == null) { image = Cutter2DAnimation.singleton.mineWallsAll.GetComponent <UnityEngine.UI.Image>(); } if (image != null) { image.enabled = false; } } catch { } } if (!playin) { return; } if (firstcutterplay) { if (Time.time - firstcutterplaystarttime > firstcutterplaytime) { if (SOManager.singleton.currSceneName == "ZNCM") { Training.TrainingManager.ExecuteScript("SkipVRCamera,ZNCM_TZ"); } firstcutterplay = false; GameObject cutter = GameObject.Find(CutMineAnimation.singleton.cutterName); try { PlayCutterArm(); if (Cutter2DAnimation.singleton != null) { Cutter2DAnimation.singleton.InitilizeAll(GameObject.Find("CMJ_ZNCM")); } Debug.LogError("第一次播放割煤动画"); //SetDT_YJQDTextContent("斜切进刀"); if (Cutter2DAnimation.singleton.playing) { CastTransfrom.singleton.CutKnife(); CastTransfrom.singleton.ToLeft(); } CutMineAnimation.singleton.PlayCutterAnimation(CutMineAnimation.singleton.way1, cutter, 1, CutMineAnimation.singleton.speed, 0, () => { Debug.LogError("第一次播放割煤动画结束"); //SetDT_YJQDVisiblity(false); if (Cutter2DAnimation.singleton.playing) { CastTransfrom.singleton.MiddleVisible(false); CastTransfrom.singleton.HintVisible(false); Cutter2DAnimation.singleton.StopCutter1SecondStageAnimation(); Cutter2DAnimation.singleton.StopCutter2SecondStageAnimation(); } ZhuAnimation.PlayAnimation(new Vector2(16, 0), 0.5f, new float[] { 0.5f }, ZhuAnimation.ZhuAnimationMode.Mode2); PlayCutterArm(1); //动画播放完毕时执行的函数 }, index => { Debug.LogError("序列号:" + index); SetGroup1Particle(index - 3 - 1); SetGroup2Particle(index - 3 + 8); if (index == 5) { if (Cutter2DAnimation.singleton.playing) { Cutter2DAnimation.singleton.StartCutter1FirstStageAnimation(); } //Cutter2DAnimation.singleton.control1.AbandonRight(); DestroyWall.singleton.control1 = true; if (Cutter2DAnimation.singleton != null) { Cutter2DAnimation.singleton.SetDescending(true, -2.0f); } //if (Cutter2DAnimation.singleton != null) // Cutter2DAnimation.singleton.SetCutter1(true); //AddParticle(0); } if (index == 8) { Cutter2DAnimation.singleton.StartCutter1SecondStageAnimation(); } if (index == 9) { if (Cutter2DAnimation.singleton.playing) { Cutter2DAnimation.singleton.StartCutter2FirstStageAnimation(); } DestroyWall.singleton.control2 = true; if (Cutter2DAnimation.singleton != null) { Cutter2DAnimation.singleton.SetDescending(true, 1.3f); Cutter2DAnimation.singleton.SetCutter1(true); } //AddParticle(1); } if (index == 9) { Cutter2DAnimation.singleton.scalecutterrotation = 1f; //Cutter2DAnimation.singleton.control1.AbandonLeft(); } if (index == 13) { //Cutter2DAnimation.singleton.control1.AbandonRight1(); } if (index == 13) { if (Cutter2DAnimation.singleton.playing) { Cutter2DAnimation.singleton.StartCutter2SecondStageAnimation(); } if (Cutter2DAnimation.singleton != null) { Cutter2DAnimation.singleton.SetCutter2(true); } } if (index == 14) { DestroyWall.singleton.height = 10; } if (index == 16) { SetGroup2Particle(index - 3 + 9); //if (Cutter2DAnimation.singleton != null) // Cutter2DAnimation.singleton.SetCutter2(true); } }); } catch (System.Exception e) { Debug.LogError("播放采煤机动画时出现错误:" + e.StackTrace); } if (SOManager.singleton.minewall != null) { SOManager.singleton.minewall.SetActive(false); } if (minewallorder) { minewallorder = false; IniMineWall(); IniCutterBra(); } } } if (firstplay) { if (Time.time - firstplaysatrttime > firstplaytime) { firstplay = false; Play(); } } if (playing) { UpdateCutterAniamtion(); if (minewalltime > 0 && Time.time - minewalltime > 2) { minewalltime = -1; if (!minewallorder) { IniMineWall(); IniCutterBra(); } } if (allAnimationOvew) { if (allstop1 && Time.time - allstope1timme > 3) { allstop1 = false; Training.TrainingManager.ExecuteScript("SetLenght,0:16,-0.4:0.6:0.01"); allstope1timme = Time.time; } if (!allstop1 && Time.time - allstarttime > 3) { allAnimationOvew = false; Play(rember); minewalltime = Time.time; } } if (call1 && call2) { call1 = false; call2 = false; if (order) { if (currentIndex.y >= targetIndex.y) { result = true; ani1 = GetAnimation((int)currentIndex.x); ani2 = GetAnimation((int)currentIndex.y); startfirstflattime = Time.time; StartTimerForCutterAnimation(); return; } currentIndex = new Vector2(currentIndex.x + 1, currentIndex.y + 1); } else { if (currentIndex.y <= targetIndex.y) { result = true; ani1 = GetAnimation((int)currentIndex.x); ani2 = GetAnimation((int)currentIndex.y); startfirstflattime = Time.time; StartTimerForCutterAnimation(); return; } currentIndex = new Vector2(currentIndex.x - 1, currentIndex.y - 1); } if (identification == 3) { if (currentIndex.y == 33) { ZhuAnimation.PlayAnimation(new Vector2(0, 12), 0.1f, new float[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9f, 0.8f, 0.7f, 0.6f }, ZhuAnimation.ZhuAnimationMode.Mode3); MonoBehaviour.print("SLFirst"); } if (currentIndex.y == 47) { ZhuAnimation.PlayAnimation(new Vector2(10, 25), 0.1f, new float[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f }, ZhuAnimation.ZhuAnimationMode.Mode3); MonoBehaviour.print("SLSecond"); } } if (identification == 5) { if (currentIndex.y == 53) { ZhuAnimation.PlayAnimation(new Vector2(21, 44), 0.1f, new float[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f }, ZhuAnimation.ZhuAnimationMode.Mode3); MonoBehaviour.print("SLTirth"); } } //if (currentIndex.x == 6) //{ // DestroyWall.singleton.control1 = true; //} PlayMec(new Vector2(currentIndex.y, currentIndex.x)); } if (result) { if (ani1 != null && ani2 != null) { if (!ani1.playing && !ani2.playing) { if (SlanimationFirst && Time.time - startfirstflattime > distancetime) { SlanimationFirst = false; } // MonoBehaviour.print("pppppppppppppppp"); if (Time.time - zmj.startTime > zmj.stopTime) { result = false; // print(new Vector2(targetIndex.y, targetIndex.x)); Play(); //Play(time, step, distance, new Vector2(targetIndex.y, targetIndex.x), width, actiontime); } } } } if (pauseAction != null) { if (Time.time - pauseStartTime > pauseTime) { pauseAction(); } } } }
public void TestStateChanged() { //this ensures that the correct animations are started when starting the group var anim1 = new TestAnimation(); var anim2 = new TestAnimation(); var anim3 = new TestAnimation(); var anim4 = new TestAnimation(); anim1.SetDuration(1000); anim2.SetDuration(2000); anim3.SetDuration(3000); anim4.SetDuration(3000); var group = new QParallelAnimationGroup(); group.AddAnimation(anim1); group.AddAnimation(anim2); group.AddAnimation(anim3); group.AddAnimation(anim4); group.Start(); var spy1 = 0; anim1.StateChanged += (arg1, arg2) => { spy1++; }; var spy2 = 0; anim2.StateChanged += (arg1, arg2) => { spy2++; }; var spy3 = 0; anim3.StateChanged += (arg1, arg2) => { spy3++; }; var spy4 = 0; anim4.StateChanged += (arg1, arg2) => { spy4++; }; Assert.AreEqual(1, spy1); Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state); Assert.AreEqual(1, spy2); Assert.AreEqual(QAbstractAnimation.State.Running, anim2.state); Assert.AreEqual(1, spy3); Assert.AreEqual(QAbstractAnimation.State.Running, anim3.state); Assert.AreEqual(1, spy4); Assert.AreEqual(QAbstractAnimation.State.Running, anim4.state); group.CurrentTime = 1500; Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(2, spy1); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state); Assert.AreEqual(1, spy2); Assert.AreEqual(1, spy3); Assert.AreEqual(1, spy4); group.CurrentTime = 2500; Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(2, spy1); Assert.AreEqual(2, spy2); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state); Assert.AreEqual(1, spy3); Assert.AreEqual(1, spy4); group.CurrentTime = 3500; Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(2, spy1); Assert.AreEqual(2, spy2); Assert.AreEqual(2, spy3); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim3.state); Assert.AreEqual(1, spy4); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim4.state); group.direction = QAbstractAnimation.Direction.Backward; group.Start(); spy1 = spy2 = spy3 = spy4 = 0; Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(0, spy1); Assert.AreEqual(0, spy2); Assert.AreEqual(0, spy3); Assert.AreEqual(QAbstractAnimation.State.Running, anim3.state); Assert.AreEqual(1, spy4); Assert.AreEqual(QAbstractAnimation.State.Running, anim4.state); group.CurrentTime = 1500; Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(0, spy1); Assert.AreEqual(1, spy2); Assert.AreEqual(QAbstractAnimation.State.Running, anim2.state); Assert.AreEqual(1, spy3); Assert.AreEqual(1, spy4); group.CurrentTime = 500; Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(1, spy1); Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state); Assert.AreEqual(1, spy2); Assert.AreEqual(1, spy3); Assert.AreEqual(1, spy4); group.CurrentTime = 0; Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(2, spy1); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state); Assert.AreEqual(2, spy2); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state); Assert.AreEqual(1, spy3); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim3.state); Assert.AreEqual(1, spy4); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim4.state); }
public void DurationTest() { TestAnimation animation = new TestAnimation(); Assert.AreEqual <TimeSpan>(TimeSpan.FromSeconds(5), animation.Duration); }
public void TestZeroDurationAnimation() { var group = new QParallelAnimationGroup(); var anim1 = new TestAnimation(); anim1.StartValue = new QVariant(0); anim1.EndValue = new QVariant(100); anim1.SetDuration(0); var anim2 = new TestAnimation(); anim2.StartValue = new QVariant(0); anim2.EndValue = new QVariant(100); anim2.SetDuration(100); var anim3 = new TestAnimation(); anim3.StartValue = new QVariant(0); anim3.EndValue = new QVariant(100); anim3.SetDuration(10); var stateChangedSpy1 = 0; var finishedSpy1 = 0; anim1.StateChanged += (arg1, arg2) => { stateChangedSpy1++; }; anim1.Finished += () => { finishedSpy1++; }; var stateChangedSpy2 = 0; var finishedSpy2 = 0; anim2.StateChanged += (arg1, arg2) => { stateChangedSpy2++; }; anim2.Finished += () => { finishedSpy2++; }; var stateChangedSpy3 = 0; var finishedSpy3 = 0; anim3.StateChanged += (arg1, arg2) => { stateChangedSpy3++; }; anim3.Finished += () => { finishedSpy3++; }; group.AddAnimation(anim1); group.AddAnimation(anim2); group.AddAnimation(anim3); Assert.AreEqual(0, stateChangedSpy1); group.Start(); Assert.AreEqual(2, stateChangedSpy1); Assert.AreEqual(1, finishedSpy1); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state); Assert.AreEqual(1, stateChangedSpy2); Assert.AreEqual(0, finishedSpy2); Assert.AreEqual(1, stateChangedSpy3); Assert.AreEqual(0, finishedSpy3); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim2.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim3.state); Assert.AreEqual(QAbstractAnimation.State.Running, group.state); group.Stop(); group.LoopCount = 4; stateChangedSpy1 = 0; stateChangedSpy2 = 0; stateChangedSpy3 = 0; group.Start(); Assert.AreEqual(2, stateChangedSpy1); Assert.AreEqual(1, stateChangedSpy2); Assert.AreEqual(1, stateChangedSpy3); group.CurrentTime = 50; Assert.AreEqual(2, stateChangedSpy1); Assert.AreEqual(1, stateChangedSpy2); Assert.AreEqual(2, stateChangedSpy3); group.CurrentTime = 150; Assert.AreEqual(4, stateChangedSpy1); Assert.AreEqual(3, stateChangedSpy2); Assert.AreEqual(4, stateChangedSpy3); group.CurrentTime = 50; Assert.AreEqual(6, stateChangedSpy1); Assert.AreEqual(5, stateChangedSpy2); Assert.AreEqual(6, stateChangedSpy3); }