Пример #1
0
        public bool Add(IGameComponent gc)
        {
            if (isClear)
            {
                return(false);
            }
            gc.Initialize();
            bool result = CollectionUtils.Add(collections, gc);

            if (gc != null && Added != null)
            {
                Added.Invoke(gc);
            }
            if (gc  is  DrawableGameComponent)
            {
                if (((DrawableGameComponent)gc).GetDrawOrder() != 0)
                {
                    SortDraw();
                }
            }
            return(result);
        }
Пример #2
0
        public bool Add(IGameComponent gc, int index)
        {
            if (isClear)
            {
                return(false);
            }
            gc.Initialize();
            bool result = CollectionUtils.Add(collections, gc);

            for (int i = 0; i < collections.Count; i++)
            {
                if (collections[i]   is  DrawableGameComponent)
                {
                    if (i == index)
                    {
                        ((DrawableGameComponent)collections[i])
                        .SetEnabled(true);
                    }
                    else
                    {
                        ((DrawableGameComponent)collections[i])
                        .SetEnabled(false);
                    }
                }
            }
            if (gc != null && Added != null)
            {
                Added.Invoke(gc);
            }
            if (gc  is  DrawableGameComponent)
            {
                if (((DrawableGameComponent)gc).GetDrawOrder() != 0)
                {
                    SortDraw();
                }
            }
            return(result);
        }
Пример #3
0
 /// <summary>
 /// Registers the given GameComponent as a global GameComponent.
 /// </summary>
 public void RegisterGlobalComponent(IGameComponent Component)
 {
     Component.Initialize();
     _Game.Components.Add(Component);
 }
Пример #4
0
 public void AddGameComponent(IGameComponent component)
 {
     Components.Add(new GameComponentWrapper(component, this));
     component.Initialize();
 }