Exemplo n.º 1
0
        private void Remove(IComponentContainer container)
        {
            var drawable = container.GetComponent <Component <IDrawable> >();

            if (!ReferenceEquals(null, drawable))
            {
                renderer.DeleteDrawable(drawable.Value);
            }
            registry.Unregister(container);
        }
        public static IDataContext CreateDataContext(IComponentContainer componentContainer, ISolution solution, ITextControl control)
        {
            var actionManager = componentContainer.GetComponent <IActionManager>();

            var dataRules = DataRules
                            .AddRule("Test", ProjectModelDataConstants.SOLUTION, x => solution)
                            .AddRule("Test", TextControlDataConstants.TEXT_CONTROL, x => control)
                            .AddRule("Test", DocumentModelDataConstants.DOCUMENT, x => control.Document)
#if WAVE07
                            .AddRule("Test", DocumentModelDataConstants.EDITOR_CONTEXT, x => new DocumentEditorContext(new DocumentOffset(control.Document, control.Caret.Position.Value.ToDocOffset())));
Exemplo n.º 3
0
        public static IDataContext CreateDataContext(IComponentContainer componentContainer, ISolution solution, ITextControl control)
        {
            var actionManager = componentContainer.GetComponent<IActionManager>();

            var dataRules = DataRules
                .AddRule("Test", ProjectModelDataConstants.SOLUTION, x => solution)
                .AddRule("Test", TextControlDataConstants.TEXT_CONTROL, x => control)
                .AddRule("Test", DocumentModelDataConstants.DOCUMENT, x => control.Document)
                .AddRule("Test", DocumentModelDataConstants.EDITOR_CONTEXT, x => new DocumentEditorContext(new DocumentOffset(control.Document, control.Caret.Position.Value.ToDocOffset())));
            return actionManager.DataContexts.CreateWithDataRules(control.Lifetime, dataRules);
        }
        private static IDataContext CreateDataContext(IComponentContainer componentContainer, ISolution solution, ITextControl control)
        {
            var actionManager = componentContainer.GetComponent <IActionManager>();

            var dataRules = DataRules
                            .AddRule("Test", ProjectModelDataConstants.SOLUTION, x => solution)
                            .AddRule("Test", TextControlDataConstants.TEXT_CONTROL, x => control)
                            .AddRule("Test", DocumentModelDataConstants.DOCUMENT, x => control.Document)
                            .AddRule("Test", DocumentModelDataConstants.EDITOR_CONTEXT, x => new DocumentEditorContext(new DocumentOffset(control.Document, control.Caret.Offset())));

            return(actionManager.DataContexts.CreateWithDataRules(control.Lifetime, dataRules));
        }
Exemplo n.º 5
0
        public void TestGetComponent13()
        {
            AutoComponentContainerBuilder builder = new AutoComponentContainerBuilder();

            builder.ComponentCategory = "Test";
            builder.AddAssemblyFile(Assembly.GetExecutingAssembly().Location);
            IComponentContainer container = builder.Build();

            try
            {
                Console.WriteLine("Test13 Start");
                TestClass3 test = (TestClass3)container.GetComponent(typeof(TestClass3));
                test.Print();
                Console.WriteLine("Test13 End");
            }
            catch (Exception e)
            {
                Assert.Fail(e.StackTrace);
            }
        }
Exemplo n.º 6
0
        private void HandleCollisions(float absoluteTime, IComponentContainer containerPlayer)
        {
            var player = containerPlayer.GetComponent <Component <Box2D> >().Value;

            foreach (IComponentContainer enemy in registry.GetAllContainerWithComponent <Enemy>().ToList())
            {
                Box2D enemyFrame = enemy.GetComponent <Component <Box2D> >().Value;
                //intersections enemy <-> player
                if (player.Intersects(enemyFrame))
                {
                    //game lost
                    Lost = true;
                    //remove player
                    Remove(containerPlayer);
                    CreateExplosion(absoluteTime, player);
                    //remove enemy
                    Remove(enemy);
                    CreateExplosion(absoluteTime, enemyFrame);
                    return;
                }
                //intersections enemy <-> playerBullet
                foreach (IComponentContainer bullet in registry.GetAllContainerWithComponent <PlayerBullet>().ToList())
                {
                    Box2D bulletFrame = bullet.GetComponent <Component <Box2D> >().Value;
                    if (bulletFrame.Intersects(enemyFrame))
                    {
                        Points += 20;
                        //delete bullet and enemy
                        Remove(bullet);
                        Remove(enemy);
                        CreateExplosion(absoluteTime, enemyFrame);
                    }
                }
            }
            //intersections enemyBullet <-> player
            foreach (IComponentContainer enemyBullet in registry.GetAllContainerWithComponent <EnemyBullet>().ToList())
            {
                Box2D enemyFrame = enemyBullet.GetComponent <Component <Box2D> >().Value;
                if (player.Intersects(enemyFrame))
                {
                    //game lost
                    Lost = true;
                    //remove player
                    Remove(containerPlayer);
                    CreateExplosion(absoluteTime, player);
                    //remove enemyBullet
                    Remove(enemyBullet);
                    return;
                }
                //bullet <-> bullet
                foreach (IComponentContainer bullet in registry.GetAllContainerWithComponent <PlayerBullet>().ToList())
                {
                    Box2D bulletFrame = bullet.GetComponent <Component <Box2D> >().Value;
                    if (bulletFrame.Intersects(enemyFrame))
                    {
                        Points += 2;
                        Remove(bullet);
                        Remove(enemyBullet);
                        CreateExplosion(absoluteTime, bulletFrame);
                    }
                }
            }
        }
 /// <summary>
 /// BindFunctor#Invokeが呼び出されたときにIComponentContainer#GetComponentし、バインドされた引数とする
 /// </summary>
 /// <returns>コンテナから取得したコンポーネントのインスタンス</returns>
 public object Provide()
 {
     return(componentContainer.GetComponent(componentType));
 }
Exemplo n.º 8
0
 private void Remove(IComponentContainer container)
 {
     var drawable = container.GetComponent<Component<IDrawable>>();
     if (null != drawable)
     {
         renderer.DeleteDrawable(drawable.Value);
     }
     registry.Unregister(container);
 }
Exemplo n.º 9
0
 private void HandleCollisions(float absoluteTime, IComponentContainer containerPlayer)
 {
     var player = containerPlayer.GetComponent<Component<Box2D>>().Value;
     foreach (IComponentContainer enemy in registry.GetAllContainerWithComponent<Enemy>().ToList())
     {
         Box2D enemyFrame = enemy.GetComponent<Component<Box2D>>().Value;
         //intersections enemy <-> player
         if (player.Intersects(enemyFrame))
         {
             //game lost
             Lost = true;
             //remove player
             Remove(containerPlayer);
             CreateExplosion(absoluteTime, player);
             //remove enemy
             Remove(enemy);
             CreateExplosion(absoluteTime, enemyFrame);
             return;
         }
         //intersections enemy <-> playerBullet
         foreach (IComponentContainer bullet in registry.GetAllContainerWithComponent<PlayerBullet>().ToList())
         {
             Box2D bulletFrame = bullet.GetComponent<Component<Box2D>>().Value;
             if (bulletFrame.Intersects(enemyFrame))
             {
                 Points += 20;
                 //delete bullet and enemy
                 Remove(bullet);
                 Remove(enemy);
                 CreateExplosion(absoluteTime, enemyFrame);
             }
         }
     }
     //intersections enemyBullet <-> player
     foreach (IComponentContainer enemyBullet in registry.GetAllContainerWithComponent<EnemyBullet>().ToList())
     {
         Box2D enemyFrame = enemyBullet.GetComponent<Component<Box2D>>().Value;
         if (player.Intersects(enemyFrame))
         {
             //game lost
             Lost = true;
             //remove player
             Remove(containerPlayer);
             CreateExplosion(absoluteTime, player);
             //remove enemyBullet
             Remove(enemyBullet);
             return;
         }
         //bullet <-> bullet
         foreach (IComponentContainer bullet in registry.GetAllContainerWithComponent<PlayerBullet>().ToList())
         {
             Box2D bulletFrame = bullet.GetComponent<Component<Box2D>>().Value;
             if (bulletFrame.Intersects(enemyFrame))
             {
                 Points += 2;
                 Remove(bullet);
                 Remove(enemyBullet);
                 CreateExplosion(absoluteTime, bulletFrame);
             }
         }
     }
 }