当前位置: 首页>>代码示例>>C#>>正文


C# World.Update方法代码示例

本文整理汇总了C#中World.Update方法的典型用法代码示例。如果您正苦于以下问题:C# World.Update方法的具体用法?C# World.Update怎么用?C# World.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World的用法示例。


在下文中一共展示了World.Update方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main(string[] args)
        {
            var g2d = DD.Graphics2D.GetInstance ();
            g2d.CreateWindow (800, 600, "こんにちは、世界");

            // ----------------------------------------

            var wld = new World ();

            var node1 = MySender.Create ("Recver1", new Vector3 (100, 250, 0));
            var node2 = MyRecver.Create ("Recver1", new Vector3 (600, 150, 0));
            var node3 = MyRecver.Create ("Recver2", new Vector3 (600, 250, 0));
            var node4 = MyRecver.Create ("Recver3", new Vector3 (600, 350, 0));
            var node5 = MyRecver.Create ("All", new Vector3 (600, 500, 0));
            var node6 = MyButton.Create ("1", "Recver1", new Vector3 (50, 350, 0));
            var node7 = MyButton.Create ("2", "Recver2", new Vector3 (100, 350, 0));
            var node8 = MyButton.Create ("3", "Recver3", new Vector3 (150, 350, 0));
            var node9 = MyButton.Create ("All", "All", new Vector3 (200, 350, 0));

            wld.AddChild (node1);
            wld.AddChild (node2);
            wld.AddChild (node3);
            wld.AddChild (node4);
            wld.AddChild (node5);
            wld.AddChild (node6);
            wld.AddChild (node7);
            wld.AddChild (node8);
            wld.AddChild (node9);

            // ----------------------------------------
            var active = true;

            g2d.OnClosed += delegate (object sender, EventArgs eventArgs) {
                active = false;
            };

            Console.WriteLine ("Start of Main Loop");

            g2d.SetFrameRateLimit (60);

            var watch = new Stopwatch ();
            watch.Start ();

            while (active) {
                var msec = watch.ElapsedMilliseconds;

                g2d.Dispatch (wld);
                wld.Animate (msec, 33);
                wld.CollisionUpdate ();
                wld.Update (msec);
                wld.Deliver ();
                g2d.Draw (wld);
            }

            Console.WriteLine ("End of Game");
        }
开发者ID:weimingtom,项目名称:erica,代码行数:56,代码来源:Program.cs

示例2: Test_ClearRecords

        public void Test_ClearRecords()
        {
            var node = new Node ("Node");
            var mbox = new MailBox ("Address");
            node.Attach (mbox);

            var wld = new World ();
            wld.AddChild (node);

            wld.Update (16);
            wld.PostOffice.Post (node, "Address", "Hello World");
            wld.Update (33);
            wld.PostOffice.Deliver ();

            var po = wld.PostOffice;
            Assert.AreEqual (1, po.DeliveryRecordCount);

            po.ClearRecords ();
            Assert.AreEqual (0, po.DeliveryRecordCount);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:20,代码来源:TestPostOffice.cs

示例3: Main

        public static void Main(string[] args)
        {
            var g2d = DD.Graphics2D.GetInstance ();
            g2d.CreateWindow (800, 600, "こんにちは、世界");

            Resource.SetTextureDirectory ("DatabaseSample/Textures/");

            // ----------------------------------------
            var node1 = MyCharacterHolder.Create ();
            var node2 = MyCharacterViewer.Create (new Vector3 (0, 0, 0));
            var node3 = MyCharacterSelector.Create (new Vector3 (0,0,0));

            var wld = new World ();
            wld.AddChild (node1);
            wld.AddChild (node2);
            wld.AddChild (node3);

            // ----------------------------------------
            var active = true;

            g2d.OnClosed += delegate (object sender, EventArgs eventArgs) {
                active = false;
            };

            Console.WriteLine ("Start of Main Loop");

            g2d.SetFrameRateLimit (60);

            var watch = new Stopwatch ();
            watch.Start ();

            while (active) {
                var msec = watch.ElapsedMilliseconds;

                g2d.Dispatch (wld);
                wld.Animate (msec, 33);
                wld.Deliver ();
                wld.CollisionUpdate ();
                wld.Update (msec);
                wld.Purge ();
                g2d.Draw (wld);
            }

            Console.WriteLine ("End of Game");
            wld.Destroy ();
        }
开发者ID:weimingtom,项目名称:erica,代码行数:46,代码来源:Program2.cs

示例4: Test_Destroy_and_Purge

        public void Test_Destroy_and_Purge()
        {
            var node1 = new Node ("DeadSoul(PurgeTime=1)");  // パージされる
            var node2 = new Node ("DeadSoul(PurgeTime=2)");  // パージされない

            var wld = new World ();
            wld.AddChild (node1);
            wld.AddChild (node2);

            // 遅延ファイナライズ
            node1.Destroy (1);
            node2.Destroy (2);

            // そしてパージ (time=1まで)
            wld.Update (1);
            wld.Purge ();

            Assert.AreEqual (true, node1.IsDestroyed);
            Assert.AreEqual (true, node2.IsDestroyed);
            Assert.AreEqual (true, node1.IsFinalized);
            Assert.AreEqual (false, node2.IsFinalized);
            Assert.AreEqual (1, wld.NodeDestroyer.ReservationCount);
            Assert.AreEqual (1, wld.ChildCount);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:24,代码来源:TestNodeDestroyer.cs

示例5: Test_UpdateInit

        public void Test_UpdateInit()
        {
            var wld = new World ();
            var nod = new Node ();
            wld.AddChild (nod);

            var cmp1 = new MyComponent ();
            var cmp2 = new MyComponent ();
            wld.Attach (cmp1);
            nod.Attach (cmp2);

            wld.Update (0);
            Assert.AreEqual (1, cmp1.OnUpdateInited);
            Assert.AreEqual (1, cmp2.OnUpdateInited);

            wld.Update (0);
            Assert.AreEqual (1, cmp1.OnUpdateInited);
            Assert.AreEqual (1, cmp2.OnUpdateInited);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:19,代码来源:TestWorld.cs

示例6: Test_Find_by_Predicate

        public void Test_Find_by_Predicate()
        {
            var node1 = new Node ("Node1");
            var node2 = new Node ("Node2");
            var node3 = new Node ("Node3");
            var node4 = new Node ("Node4");
            node1.AddChild (node2);
            node1.AddChild (node3);

            var wld = new World ();
            wld.AddChild (node1);

            Assert.AreEqual (node1, wld.Find (x => x.Name == "Node1"));
            Assert.AreEqual (node2, wld.Find (x => x.Name == "Node2"));
            Assert.AreEqual (node3, wld.Find (x => x.Name == "Node3"));
            Assert.AreEqual (null, wld.Find (x => x.Name == "Node4"));

            // Update()を呼ぶまで更新されない
            wld.AddChild (node4);
            Assert.AreEqual (null, wld.Find (x => x.Name == "Node4"));

            wld.Update (0);
            Assert.AreEqual (node4, wld.Find (x => x.Name == "Node4"));
        }
开发者ID:weimingtom,项目名称:erica,代码行数:24,代码来源:TestWorld.cs

示例7: Test_Finds_by_Predicate

        public void Test_Finds_by_Predicate()
        {
            var node1 = new Node ("Node1");
            var node2 = new Node ("Node2");
            var node3 = new Node ("Node3");
            var node4 = new Node ("Node1");
            var node5 = new Node ("Node1");
            var node6 = new Node ("Node6");
            node1.AddChild (node2);
            node1.AddChild (node3);
            node2.AddChild (node4);
            node3.AddChild (node5);

            var wld = new World ();
            wld.AddChild (node1);

            Assert.AreEqual (3, wld.Finds (x => x.Name == "Node1").Count());
            Assert.AreEqual (1, wld.Finds (x => x.Name == "Node2").Count ());
            Assert.AreEqual (1, wld.Finds (x => x.Name == "Node3").Count ());
            Assert.AreEqual (0, wld.Finds (x => x.Name == "Node4").Count ());

            // Update()を呼ぶまで更新されない
            wld.AddChild (node6);
            Assert.AreEqual (0, wld.Finds (x => x.Name == "Node6").Count ());

            wld.Update (0);
            Assert.AreEqual (1, wld.Finds (x => x.Name == "Node6").Count ());
        }
开发者ID:weimingtom,项目名称:erica,代码行数:28,代码来源:TestWorld.cs

示例8: Test_Downloads

        public void Test_Downloads()
        {
            var node1 = new Node ("Node1");
            var node2 = new Node ("Node2");
            var node3 = new Node ("Node3");
            var node4 = new Node ("Node4");

            var wld = new World ();

            wld.AddChild (node1);
            wld.AddChild (node2);
            wld.AddChild (node3);
            Assert.AreEqual (4, wld.Downwards.Count ());

            // Update()するまでは反映されない
            wld.AddChild (node4);
            Assert.AreEqual (4, wld.Downwards.Count ());

            wld.Update (0);
            Assert.AreEqual (5, wld.Downwards.Count ());
        }
开发者ID:weimingtom,项目名称:erica,代码行数:21,代码来源:TestWorld.cs

示例9: Test_DeliveryRecord

        public void Test_DeliveryRecord()
        {
            var node = new Node ("Node");
            var mbox = new MailBox ("Address");
            node.Attach (mbox);

            var wld = new World ();
            wld.AddChild (node);

            wld.Update (16);
            wld.PostOffice.Post (node, "Address", "Hello World");
            wld.Update (33);
            wld.PostOffice.Deliver ();

            var po = wld.PostOffice;

            Assert.AreEqual (1, po.DeliveryRecordCount);
            Assert.AreEqual (1, po.DeliveryRecords.Count());

            var rec = po.DeliveryRecords.ElementAt (0);

            Assert.AreEqual (33, rec.Time);
            Assert.AreEqual ("Node", rec.From);
            Assert.AreEqual ("Address", rec.Address);
            Assert.AreEqual ("Hello World", rec.LetterType);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:26,代码来源:TestPostOffice.cs


注:本文中的World.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。