예제 #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();
 }