示例#1
0
 /// <summary>
 /// ゲーム コンポーネントとしての登録が解除される時に、
 /// 静的シングルトン フィールドから自身を削除します。
 /// </summary>
 /// <param name="sender">イベントのソース。</param>
 /// <param name="e">イベント データ。</param>
 void OnComponentRemoved(object sender, GameComponentCollectionEventArgs e)
 {
     if (e.GameComponent == this)
     {
         instance = null;
     }
 }
示例#2
0
        private void GameComponentAdded(object sender, GameComponentCollectionEventArgs e)
        {
            if (this._inRun)
            {
                e.GameComponent.Initialize();
            }
            IUpdateable item = e.GameComponent as IUpdateable;

            if (item != null)
            {
                int num = this._updateableComponents.BinarySearch(item, UpdateOrderComparer.Default);
                if (num < 0)
                {
                    this._updateableComponents.Insert(~num, item);
                    item.UpdateOrderChanged += new EventHandler(this.UpdateableUpdateOrderChanged);
                }
            }
            IDrawable drawable = e.GameComponent as IDrawable;

            if (drawable != null)
            {
                int num2 = this._drawableComponents.BinarySearch(drawable, DrawOrderComparer.Default);
                if (num2 < 0)
                {
                    this._drawableComponents.Insert(~num2, drawable);
                    drawable.DrawOrderChanged += new EventHandler(this.DrawableDrawOrderChanged);
                }
            }
        }
示例#3
0
        public void GameComponent()
        {
            MyComponent c = new MyComponent(new TestGame());
            GameComponentCollectionEventArgs args = new GameComponentCollectionEventArgs(c);

            Assert.AreSame(c, args.GameComponent);
        }
示例#4
0
        private void OnComponentRemoved(GameComponentCollectionEventArgs args)
        {
            if (!isInitialized)
            {
                myUninitializedComponents.Remove(args.GameComponent);
            }

            IUpdateable uComponent = args.GameComponent as IUpdateable;

            if (uComponent != null)
            {
                myUpdateableComponents.Remove(uComponent);
                uComponent.UpdateOrderChanged -= new EventHandler <EventArgs>(ChildUpdateOrderChanged);
            }

            IDrawable dComponent = args.GameComponent as IDrawable;

            if (dComponent != null)
            {
                myDrawableComponents.Remove(dComponent);
                dComponent.DrawOrderChanged -= new EventHandler <EventArgs>(ChildDrawOrderChanged);
            }

            EventHandler <GameComponentCollectionEventArgs> componentRemoved = ComponentRemoved;

            if (componentRemoved != null)
            {
                componentRemoved(this, args);
            }
        }
示例#5
0
 /// <summary>
 /// ゲーム コンポーネントとしてインスタンスが登録される時に、
 /// 静的シングルトン フィールドへ自身を設定します。
 /// </summary>
 /// <param name="sender">イベントのソース。</param>
 /// <param name="e">イベント データ。</param>
 void OnComponentAdded(object sender, GameComponentCollectionEventArgs e)
 {
     if (e.GameComponent == this)
     {
         instance = this;
     }
 }
 void Components_ComponentRemoved(object sender, GameComponentCollectionEventArgs e)
 {
     if (e.GameComponent == this)
     {
         Dispose();
     }
 }
 private void BabyShapes_BashingComponentRemoved(object sender, GameComponentCollectionEventArgs e)
 {
     // Clean up the bashing shape once it's lifespan is over.
     if (Object.ReferenceEquals(this._BashingShape, e.GameComponent))
     {
         this._BashingShape = null;
         this._BabyShapes.Components.ComponentRemoved -= new EventHandler <GameComponentCollectionEventArgs>(BabyShapes_BashingComponentRemoved);
     }
 }
示例#8
0
 private static void CheckForForceRemove(object sender, GameComponentCollectionEventArgs e)
 {
     if (e.GameComponent is KeyboardComponent && Loaded)
     {
         Loaded   = false;
         Instance = null;
         ((GameComponent)e.GameComponent).Game.Components.ComponentRemoved -= CheckForForceRemove;
     }
 }
        private void ComponentRemoved(object sender, GameComponentCollectionEventArgs e)
        {
            var ssb = e.GameComponent as ISharedSpriteBatchAndLifeCycle;

            if (ssb != null)
            {
                ssb.SpriteBatch = null;
            }
        }
示例#10
0
        private void OnComponentAdded(GameComponentCollectionEventArgs args)
        {
            if (isInitialized)
            {
                args.GameComponent.Initialize();
            }
            else
            {
                myUninitializedComponents.Add(args.GameComponent);
            }

            // If the new component impliments IUpdateable find a spot for it on the updateable list
            //  and hook it's UpdateOrderChanged event
            IUpdateable uComponent = args.GameComponent as IUpdateable;

            if (uComponent != null)
            {
                int index = myUpdateableComponents.BinarySearch(uComponent, IUpdateableComparer.Default);
                if (index < 0)
                {
                    index = ~index;
                    while (index < myUpdateableComponents.Count && myUpdateableComponents[index].UpdateOrder == uComponent.UpdateOrder)
                    {
                        index++;
                    }
                    myUpdateableComponents.Insert(index, uComponent);
                    uComponent.UpdateOrderChanged += new EventHandler <EventArgs>(ChildUpdateOrderChanged);
                }
            }

            // If the new component impliments IDrawable find a spot for it on the drawable list
            //  and hook it's DrawOrderChanged event
            IDrawable dComponent = args.GameComponent as IDrawable;

            if (dComponent != null)
            {
                int index = myDrawableComponents.BinarySearch(dComponent, IDrawableComparer.Default);
                if (index < 0)
                {
                    index = ~index;
                    while (index < myDrawableComponents.Count && myDrawableComponents[index].DrawOrder == dComponent.DrawOrder)
                    {
                        index++;
                    }
                    myDrawableComponents.Insert(index, dComponent);
                    dComponent.DrawOrderChanged += new EventHandler <EventArgs>(ChildDrawOrderChanged);
                }
            }

            EventHandler <GameComponentCollectionEventArgs> componentAdded = ComponentAdded;

            if (componentAdded != null)
            {
                componentAdded(this, args);
            }
        }
示例#11
0
        void GameComponents_ComponentAdded(object sender, GameComponentCollectionEventArgs e)
        {
            IDebugInfo debugInfoComp = e.GameComponent as IDebugInfo;

            if (debugInfoComp == null)
            {
                return;
            }
            AddComponants(debugInfoComp);
        }
示例#12
0
 private void Components_ComponentRemoved(object sender, GameComponentCollectionEventArgs e)
 {
     if (e.GameComponent is IUpdateable updateable)
     {
         _updateables.Remove(updateable);
     }
     if (e.GameComponent is IDrawable drawable)
     {
         _drawables.Remove(drawable);
     }
 }
示例#13
0
        /// <summary>
        /// Handle the ComponentRemoved event raise by the GameComponentCollection
        /// </summary>
        /// <param name="sender">The GameComponent collection</param>
        /// <param name="eventArgs">Arguments of the ComponentRemoved event.</param>
        protected override void GameComponentRemoved(object sender, GameComponentCollectionEventArgs eventArgs)
        {
            base.GameComponentRemoved(sender, eventArgs);

            if (eventArgs.Component is IDrawable)
            {
                IDrawable drawable = (IDrawable)eventArgs.Component;
                this.DrawableComponents.Remove(drawable);
                drawable.DrawOrderChanged -= new EventHandler <EventArgs>(DrawOrderChanged);
            }
        }
        private void BabyShapes_HelpTextComponentRemoved(object sender, GameComponentCollectionEventArgs e)
        {
            // Clean up the helptext shape once it's lifespan is over.
            if (Object.ReferenceEquals(this._HelpText, e.GameComponent))
            {
                this._HelpText = null;
                this._BabyShapes.Components.ComponentRemoved -= new EventHandler <GameComponentCollectionEventArgs>(BabyShapes_HelpTextComponentRemoved);
            }

            // And add a message about the babypackage.
            var packageMessage = this.CreatePackageDetailsMessage(this.Game.Services.GetService <IBabyPackageProvider>());

            if (packageMessage != null)
            {
                this._BabyShapes.Components.Add(packageMessage);
            }
        }
示例#15
0
        private void GameComponentRemoved(object sender, GameComponentCollectionEventArgs e)
        {
            IUpdateable item = e.GameComponent as IUpdateable;

            if (item != null)
            {
                this._updateableComponents.Remove(item);
                item.UpdateOrderChanged -= new EventHandler(this.UpdateableUpdateOrderChanged);
            }
            IDrawable drawable = e.GameComponent as IDrawable;

            if (drawable != null)
            {
                this._drawableComponents.Remove(drawable);
                drawable.DrawOrderChanged -= new EventHandler(this.DrawableDrawOrderChanged);
            }
        }
示例#16
0
        private void ComponentRemoved(object sender, GameComponentCollectionEventArgs args)
        {
            var update = args.GameComponent as IUpdateable;

            if (update != null)
            {
                update.UpdateOrderChanged -= UpdateOrderChanged;
                _sortedUpdateables.Remove(update);
            }
            var draw = args.GameComponent as IDrawable;

            if (draw != null)
            {
                draw.DrawOrderChanged -= DrawOrderChanged;
                _sortedDrawables.Remove(draw);
            }
        }
示例#17
0
        void components_ComponentRemoved(object sender, GameComponentCollectionEventArgs e)
        {
            SortComponentsByStackOrder();
            if (e.GameComponent is VisualComponent)
            {
                neededDrawOrders -= ((VisualComponent)e.GameComponent).NeededDrawOrders;
            }
            else
            {
                if (e.GameComponent is IDrawable)
                {
                    neededDrawOrders--;
                }
            }

            OnStackChanged(this, new EventArgs());
        }
示例#18
0
        private void ComponentAdded(object sender, GameComponentCollectionEventArgs args)
        {
            // monogame also calls initialize
            // I would have assumed that there'd be some property IsInitialized to prevent multiple calls to Initialize, but there isn't
            args.GameComponent.Initialize();
            var update = args.GameComponent as IUpdateable;

            if (update != null)
            {
                _sortedUpdateables.Add(update);
                update.UpdateOrderChanged += UpdateOrderChanged;
                SortUpdatables();
            }
            var draw = args.GameComponent as IDrawable;

            if (draw != null)
            {
                _sortedDrawables.Add(draw);
                draw.DrawOrderChanged += DrawOrderChanged;
                SortDrawables();
            }
        }
示例#19
0
        /// <summary>
        /// When a componenet removed from the game, it will be also removed from the screen.
        /// </summary>
        /// <param name="i_Sender">Sender object.</param>
        /// <param name="i_ArgsHolder">Arguments holder.</param>
        private void components_ComponentRemoved(object i_Sender, GameComponentCollectionEventArgs i_ArgsHolder)
        {
            IGameComponent component = i_ArgsHolder.GameComponent;

            if (!m_constGameComponentCollection.Contains(component))
            {
                if (m_gameComponentCollection.Contains(component))
                {
                    m_gameComponentCollection.Remove(component);
                }

                if (m_gameDrawableComponentCollection.Contains(component))
                {
                    m_gameDrawableComponentCollection.Remove(component);
                }

                if (ComponentRemoved != null)
                {
                    ComponentRemoved.Invoke(component);
                }
            }
        }
示例#20
0
        void components_ComponentAdded(object sender, GameComponentCollectionEventArgs e)
        {
            UpdateComponentsX();
            UpdateComponentsY();

            SortComponentsByStackOrder();
            if (e.GameComponent is VisualComponent)
            {
                neededDrawOrders += ((VisualComponent)e.GameComponent).NeededDrawOrders;
                ((VisualComponent)e.GameComponent).OnStackOrderChanged       += new EventHandler(VisualComponent_OnStackOrderChanged);
                ((VisualComponent)e.GameComponent).OnStackChanged            += new EventHandler(VisualComponent_OnStackChanged);
                ((VisualComponent)e.GameComponent).OnRelativePositionChanged += new EventHandler(VisualComponent_OnRelativePositionChanged);
            }
            else
            {
                if (e.GameComponent is IDrawable)
                {
                    neededDrawOrders++;
                }
            }

            OnStackChanged(this, new EventArgs());
        }
示例#21
0
 private void OnGameComponentAdded(object sender, GameComponentCollectionEventArgs eventArgs)
 {
     _updateText = true;
 }
示例#22
0
 void GameComponents_Changed(object sender, GameComponentCollectionEventArgs e)
 {
     RefreshDataGrid();
 }
示例#23
0
        public void Constructors()
        {
            GameComponentCollectionEventArgs args = new GameComponentCollectionEventArgs(null);

            Assert.IsNotNull(args, "Failed to create type");
        }