Пример #1
0
        protected override void OnComponentRemoved(GameComponentEventArgs <GameScreen> e)
        {
            base.OnComponentRemoved(e);

            e.GameComponent.StateChanged -= this.Screen_StateChanged;

            if (this.m_ScreensStack.Count == 0)
            {
                this.Game.Exit();
            }
        }
Пример #2
0
        protected virtual void OnComponentAdded(GameComponentEventArgs <ComponentType> e)
        {
            if (this.m_IsInitialized)
            {
                this.InitializeComponent(e.GameComponent);
            }
            else
            {
                this.m_UninitializedComponents.Add(e.GameComponent);
            }

            // If the new component implements IUpdateable:
            // 1. find a spot for it on the updateable list
            // 2. hook it's UpdateOrderChanged event
            IUpdateable updatable = e.GameComponent as IUpdateable;

            if (updatable != null)
            {
                this.insertSorted(updatable);
                updatable.UpdateOrderChanged += new EventHandler <EventArgs>(this.childUpdateOrder_Changed);
            }

            // If the new component implements IDrawable:
            // 1. find a spot for it on the drawable lists (IDrawble/Sprite)
            // 2. hook it's DrawOrderChanged event
            IDrawable drawable = e.GameComponent as IDrawable;

            if (drawable != null)
            {
                this.insertSorted(drawable);
                drawable.DrawOrderChanged += new EventHandler <EventArgs>(this.childDrawOrder_Changed);
            }

            // raise the Added event:
            if (this.ComponentAdded != null)
            {
                this.ComponentAdded(this, e);
            }
        }
Пример #3
0
        protected virtual void OnComponentRemoved(GameComponentEventArgs <ComponentType> e)
        {
            if (!this.m_IsInitialized)
            {
                this.m_UninitializedComponents.Remove(e.GameComponent);
            }

            IUpdateable updatable = e.GameComponent as IUpdateable;

            if (updatable != null)
            {
                this.m_UpdateableComponents.Remove(updatable);
                updatable.UpdateOrderChanged -= this.childUpdateOrder_Changed;
            }

            Sprite sprite = e.GameComponent as Sprite;

            if (sprite != null)
            {
                this.m_Sprites.Remove(sprite);
                sprite.DrawOrderChanged -= this.childDrawOrder_Changed;
            }
            else
            {
                IDrawable drawable = e.GameComponent as IDrawable;
                if (drawable != null)
                {
                    this.m_DrawableComponents.Remove(drawable);
                    drawable.DrawOrderChanged -= this.childDrawOrder_Changed;
                }
            }

            // raise the Removed event:
            if (this.ComponentRemoved != null)
            {
                this.ComponentRemoved(this, e);
            }
        }