public void Test_Indexer() { var anim = new AnimationController (); var clip = new AnimationClip (100, "Clip"); anim.AddClip (clip); Assert.AreEqual (clip, anim["Clip"]); }
public void Test_AddClip() { var anim = new AnimationController (); var clip1 = new AnimationClip (100, "Name"); var clip2 = new AnimationClip (100, "Name"); anim.AddClip (clip1); anim.AddClip (clip2); Assert.AreEqual (2, anim.ClipCount); Assert.AreEqual (2, anim.Clips.Count ()); anim.RemoveClip (clip1); anim.RemoveClip (clip2); Assert.AreEqual (0, anim.ClipCount); Assert.AreEqual (0, anim.Clips.Count ()); }
public static Node Create(Vector3 pos) { var cmp = new MyFireExplosion (); var spr = new Sprite (100, 100); spr.AddTexture (new Texture ("media/FireExplosion.png")); var track = new AnimationTrack ("TextureOffset", InterpolationType.Step); track.AddKeyframe (0, new Vector2 (0, 0)); track.AddKeyframe (100, new Vector2 (100, 0)); track.AddKeyframe (200, new Vector2 (200, 0)); track.AddKeyframe (300, new Vector2 (300, 0)); track.AddKeyframe (400, new Vector2 (400, 0)); track.AddKeyframe (500, new Vector2 (500, 0)); track.AddKeyframe (600, new Vector2 (600, 0)); track.AddKeyframe (700, new Vector2 (700, 0)); track.AddKeyframe (800, new Vector2 (800, 0)); track.AddKeyframe (900, new Vector2 (900, 0)); track.AddKeyframe (1000, new Vector2 (0, 100)); track.AddKeyframe (1100, new Vector2 (100, 100)); track.AddKeyframe (1200, new Vector2 (200, 100)); track.AddKeyframe (1300, new Vector2 (300, 100)); track.AddKeyframe (1400, new Vector2 (400, 100)); track.AddKeyframe (1500, new Vector2 (500, 100)); track.AddKeyframe (1600, new Vector2 (600, 100)); track.AddKeyframe (1700, new Vector2 (700, 100)); track.AddKeyframe (1800, new Vector2 (800, 100)); track.AddKeyframe (1900, new Vector2 (900, 100)); track.AddKeyframe (2000, new Vector2 (0, 200)); track.AddKeyframe (2100, new Vector2 (100, 200)); track.AddKeyframe (2200, new Vector2 (200, 200)); track.AddKeyframe (2300, new Vector2 (300, 200)); track.AddKeyframe (2400, new Vector2 (400, 200)); track.AddKeyframe (2500, new Vector2 (500, 200)); track.AddKeyframe (2600, new Vector2 (600, 200)); track.AddKeyframe (2700, new Vector2 (700, 200)); track.AddKeyframe (2800, new Vector2 (800, 200)); track.AddKeyframe (2900, new Vector2 (900, 200)); var clip = new AnimationClip (3000, "FireExplosion"); clip.AddTrack (spr, track); clip.WrapMode = WrapMode.Loop; var anim = new AnimationController (); anim.AddClip (clip); var node = new Node (); node.Attach (cmp); node.Attach (spr); node.Attach (anim); node.Translation = pos; return node; }
public void Test_OnAnimate_Event_2() { var clip = new AnimationClip (100, "TestClip"); clip.WrapMode = WrapMode.Once; clip.Play (); var args1 = new MyEventArgs (1); var args2 = new MyEventArgs (2); var args3 = new MyEventArgs (3); var count = 0; clip.AddEvent (0, (sender, args) => count = 1, null); clip.AddEvent (50, (sender, args) => count = 2, null); clip.AddEvent (100, (sender, args) => count += 1, null); clip.AddEvent (100, (sender, args) => count += 1, null); var anim = new AnimationController (); anim.AddClip (clip); // 停止中のクリップはイベントを発火しない clip.Stop (); anim.OnAnimate (0, 0); Assert.AreEqual (0, count); clip.Play (); // 逆再生中の dtime は逆方向 // clip.SetSpeed (-1, 50); // anim.OnAnimate (40, 10); // Assert.AreEqual (2, count); count = 0; clip.Speed = 1; // 同じポジションで重複したイベントは両方発火 anim.OnAnimate (100, 0); Assert.AreEqual (2, count); }
public void Test_WeakReferenceTrack() { var target = new MyTarget (); var track = new AnimationTrack ("Speed", InterpolationType.Linear); track.AddKeyframe (0, 100.0f); track.AddKeyframe (100, 100.0f); var clip = new AnimationClip (100, "Clip"); clip.AddTrack (target, track); var anim = new AnimationController (); anim.AddClip (clip); // ターゲットの解放 target = null; GC.Collect (); Assert.AreEqual (1, clip.TrackCount); Assert.AreEqual (false, clip.GetTrack (0).Item1.IsAlive); // 解放済みのターゲットを含むアニメーションの実行。 // エラーが起きてはならない anim.OnAnimate (0, 0); }
public void Test_OnAnimate_Point_Once() { var clip = new AnimationClip (3, "TestClip"); clip.WrapMode = WrapMode.Once; clip.Duration = 3; clip.Play (); var track = new AnimationTrack ("Point", InterpolationType.Step); track.AddKeyframe (1, new Vector3 (1, 2, 0)); track.AddKeyframe (2, new Vector3 (2, 3, 0)); var target = new MyTarget (); clip.AddTrack (target, track); var anim = new AnimationController (); anim.AddClip (clip); Assert.AreEqual (0f, target.Point.X, 0.0001f); Assert.AreEqual (0f, target.Point.Y, 0.0001f); anim.OnAnimate (1, 0); Assert.AreEqual (1.0f, target.Point.X, 0.0001f); Assert.AreEqual (2.0f, target.Point.Y, 0.0001f); anim.OnAnimate (2, 0); Assert.AreEqual (2.0f, target.Point.X, 0.0001f); Assert.AreEqual (3.0f, target.Point.Y, 0.0001f); anim.OnAnimate (3, 0); Assert.AreEqual (2.0f, target.Point.X, 0.0001f); Assert.AreEqual (3.0f, target.Point.Y, 0.0001f); }
public void Test_OnAnimate_Float_Once() { var track = new AnimationTrack ("Speed", InterpolationType.Step); track.AddKeyframe (1, 1.0f); track.AddKeyframe (2, 2.0f); var clip = new AnimationClip (3, "TestClip"); clip.WrapMode = WrapMode.Once; clip.Duration = 3; clip.Play (); var target = new MyTarget (); clip.AddTrack (target, track); var anim = new AnimationController (); anim.AddClip (clip); Assert.AreEqual (0.0f, target.Speed); anim.OnAnimate (1, 0); Assert.AreEqual (1.0f, target.Speed); anim.OnAnimate (2, 0); Assert.AreEqual (2.0f, target.Speed); anim.OnAnimate (3, 0); Assert.AreEqual (2.0f, target.Speed); }
public void Test_OnAnimate_Event_Handler() { var clip = new AnimationClip (100, "TestClip"); clip.WrapMode = WrapMode.Once; clip.Play (); var count = 0; clip.AddEvent (0, (x, y) => count = 1, null); clip.AddEvent (50, (x, y) => count = 2, null); clip.AddEvent (100, (x, y) => count = 3, null); var anim = new AnimationController (); anim.AddClip (clip); anim.OnAnimate (0, 0); Assert.AreEqual (1, count); anim.OnAnimate (50, 0); Assert.AreEqual (2, count); anim.OnAnimate (100, 0); Assert.AreEqual (3, count); }
public void Test_OnAnimate_Event_Args() { var clip = new AnimationClip (100, "TestClip"); clip.WrapMode = WrapMode.Once; clip.Play (); var args1 = new MyEventArgs (1); var args2 = new MyEventArgs (2); var args3 = new MyEventArgs (3); var count = 0; clip.AddEvent (0, (sender, args) => count = ((MyEventArgs)args).Value, args1); clip.AddEvent (50, (sender, args) => count = ((MyEventArgs)args).Value, args2); clip.AddEvent (100, (sender, args) => count = ((MyEventArgs)args).Value, args3); var anim = new AnimationController (); anim.AddClip (clip); anim.OnAnimate (0, 0); Assert.AreEqual (1, count); anim.OnAnimate (50, 0); Assert.AreEqual (2, count); anim.OnAnimate (100, 0); Assert.AreEqual (3, count); }