コード例 #1
0
ファイル: Game.cs プロジェクト: FakeDomi/FNA-Threaded
        private void OnComponentRemoved(
            object sender,
            GameComponentCollectionEventArgs e
            )
        {
            IUpdateable updateable = e.GameComponent as IUpdateable;

            if (updateable != null)
            {
                lock (updateableComponents)
                {
                    updateableComponents.Remove(updateable);
                }
                updateable.UpdateOrderChanged -= OnUpdateOrderChanged;
            }

            IDrawable drawable = e.GameComponent as IDrawable;

            if (drawable != null)
            {
                lock (drawableComponents)
                {
                    drawableComponents.Remove(drawable);
                }
                drawable.DrawOrderChanged -= OnDrawOrderChanged;
            }
        }
コード例 #2
0
 private void OnComponentRemoved(GameComponentCollectionEventArgs eventArgs)
 {
     if (this.ComponentRemoved != null)
     {
         this.ComponentRemoved(this, eventArgs);
     }
 }
コード例 #3
0
ファイル: GameObject.cs プロジェクト: rpwjanzen/2HourGame
 void Components_ComponentRemoved(object sender, GameComponentCollectionEventArgs e)
 {
     if (e.GameComponent == this)
     {
         RaiseGameObjectRemovedEvent();
     }
 }
コード例 #4
0
 void OnComponentAdded(GameComponentCollectionEventArgs eventArgs)
 {
     if (ComponentAdded != null)
     {
         ComponentAdded(this, eventArgs);
     }
 }
コード例 #5
0
ファイル: Game.cs プロジェクト: Crystallinqq/osu-2005
        private void GameComponentAdded(object sender, GameComponentCollectionEventArgs e)
        {
            if (this.inRun)
            {
                e.GameComponent.Initialize();
            }
            IUpdateable gameComponent = e.GameComponent as IUpdateable;

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

            if (item != null)
            {
                int num2 = this.drawableComponents.BinarySearch(item, DrawOrderComparer.Default);
                if (num2 < 0)
                {
                    this.drawableComponents.Insert(~num2, item);
                    item.DrawOrderChanged += new EventHandler(this.DrawableDrawOrderChanged);
                }
            }
        }
コード例 #6
0
        void GameComponentRemoved(object sender, GameComponentCollectionEventArgs e)
        {
            IDrawable d = e.GameComponent as IDrawable;

            if (d != null)
            {
                d.DrawOrderChanged -= DrawableDrawOrderChanged;
                d.VisibleChanged   -= DrawableVisibleChanged;

                if (d.Visible)
                {
                    visibleDrawable.Remove(d);
                }
            }

            IUpdateable u = e.GameComponent as IUpdateable;

            if (u != null)
            {
                u.UpdateOrderChanged -= UpdatableUpdateOrderChanged;
                u.EnabledChanged     -= UpdatableEnabledChanged;

                if (u.Enabled)
                {
                    enabledUpdateable.Remove(u);
                }
            }
        }
コード例 #7
0
 private void Components_ComponentRemoved(
     object sender,
     GameComponentCollectionEventArgs e
     )
 {
     DecategorizeComponent(e.GameComponent);
 }
コード例 #8
0
 private void OnComponentRemoved(GameComponentCollectionEventArgs eventArgs)
 {
     if (this.ComponentRemoved == null)
     {
         return;
     }
     this.ComponentRemoved((object)this, eventArgs);
 }
コード例 #9
0
ファイル: Game.cs プロジェクト: XthemeCore/FSOMonoGame
 private void Components_ComponentAdded(
     object sender, GameComponentCollectionEventArgs e)
 {
     // Since we only subscribe to ComponentAdded after the graphics
     // devices are set up, it is safe to just blindly call Initialize.
     e.GameComponent.Initialize();
     CategorizeComponent(e.GameComponent);
 }
コード例 #10
0
ファイル: Game.cs プロジェクト: jfernandezrodriguez/MonoGame
 void Handle_gameComponentCollectionComponentAdded(object sender, GameComponentCollectionEventArgs e)
 {
     if (!_initialized && !_initializing)
     {
         e.GameComponent.Initialize();
     }
     else
     {
         _gameComponentsToInitialize.Add(e.GameComponent);
     }
 }
コード例 #11
0
 void Handle_gameComponentCollectionComponentAdded(object sender, GameComponentCollectionEventArgs e)
 {
     if (!_initialized && !_initializing)
     {
         //Console.WriteLine("here");
         //e.GameComponent.Initialize();
     }
     else
     {
         e.GameComponent.Initialize();
         //_gameComponentsToInitialize.Add(e.GameComponent);
     }
 }
コード例 #12
0
        public static void SortCollidable(object sender, GameComponentCollectionEventArgs e)
        {
            var gc = e.GameComponent;
            IEnemy item = gc as IEnemy;
            if (item != null) EnemyList.Add(item);

            IBlock block = gc as Block;
            if (block != null && block.BlockState.HasCollision) blockList.Add(block);

            ICollectible collectible = gc as ICollectible;
            if (collectible != null) itemList.Add(collectible);

            IProjectile proj = gc as IProjectile;
            if (proj != null) projList.Add(proj);
        }
コード例 #13
0
        public static void RemoveCollidable(object sender, GameComponentCollectionEventArgs e)
        {
            var gc = e.GameComponent;
            IEnemy item = gc as IEnemy;
            if (item != null) ToRemoveE.Add(item);

            Block block = gc as Block;
            if (block != null) toRemoveB.Add(block);

            ICollectible collectible = gc as ICollectible;
            if (collectible != null) toRemoveC.Add(collectible);

            IProjectile proj = gc as IProjectile;
            if (proj != null) toRemoveP.Add(proj);
        }
コード例 #14
0
ファイル: Game.cs プロジェクト: Crystallinqq/osu-2005
        private void GameComponentRemoved(object sender, GameComponentCollectionEventArgs e)
        {
            IUpdateable gameComponent = e.GameComponent as IUpdateable;

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

            if (item != null)
            {
                this.drawableComponents.Remove(item);
                item.DrawOrderChanged -= new EventHandler(this.DrawableDrawOrderChanged);
            }
        }
コード例 #15
0
		void ComponentAdded( object sender, GameComponentCollectionEventArgs e ) {
		    if( e.GameComponent is Player ) {
		        if( m_Player != null ) {
		            m_Player.Dispose();
		        }

		        m_Bullets.Clear();
		        m_Asteroids.Clear();
		        m_Player = e.GameComponent as Player;
		    } else if( e.GameComponent is Bullet ) {
#if Audio
				Pew.Play();
#endif
				m_Bullets.Add( e.GameComponent as Bullet );
			} else if( e.GameComponent is Xbox360IndieGameDesign.Asteroid ) {
				m_Asteroids.Add( e.GameComponent as Xbox360IndieGameDesign.Asteroid );
			}
		}
コード例 #16
0
ファイル: Game.cs プロジェクト: BibleUs/FNA
        private void Components_ComponentRemoved(
            object sender,
            GameComponentCollectionEventArgs e
            )
        {
            IUpdateable updateable = e.GameComponent as IUpdateable;

            if (updateable != null)
            {
                _updateables.Remove(updateable);
            }

            IDrawable drawable = e.GameComponent as IDrawable;

            if (drawable != null)
            {
                _drawables.Remove(drawable);
            }
        }
コード例 #17
0
ファイル: Game.cs プロジェクト: Hayaweh/AudioPipe
 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);
     }
 }
コード例 #18
0
 private void Components_ComponentAdded(object sender, GameComponentCollectionEventArgs e)
 {
     e.GameComponent.Initialize();
     this.CategorizeComponent(e.GameComponent);
 }
コード例 #19
0
        private void componentAdded(object sender, GameComponentCollectionEventArgs e)
        {
            IUpdateable u = e.GameComponent as IUpdateable;
            IDrawable d = e.GameComponent as IDrawable;

            if (u != null)
            {
                updateable.Add(u);
                updateable.Sort(updateOrderComparer);
                u.UpdateOrderChanged += componentUpdateOrderChanged;
            }

            if (d != null)
            {
                drawable.Add(d);
                drawable.Sort(drawOrderComparer);
                d.DrawOrderChanged += componentDrawOrderChanged;
            }

            if (loaded)
                e.GameComponent.Initialize();
        }
コード例 #20
0
 private void OnComponentRemoved(GameComponentCollectionEventArgs eventArgs)
 {
     EventHelpers.Raise(this, ComponentRemoved, eventArgs);
 }
コード例 #21
0
		void ComponentRemoved( object sender, GameComponentCollectionEventArgs e ) {
			if( e.GameComponent is Bullet ) {
				m_Bullets.Remove( e.GameComponent as Bullet );
			} else if( e.GameComponent is Xbox360IndieGameDesign.Asteroid ) {
				m_Asteroids.Remove( e.GameComponent as Xbox360IndieGameDesign.Asteroid );
			}
		}
コード例 #22
0
 /// <summary>
 /// 自分自身が GameComponent としての登録から解除される時に、
 /// 自分自身が現在有効な IDebugMap ではなくなるように設定します。
 /// </summary>
 /// <param name="sender">イベントのソース。</param>
 /// <param name="e">イベント データ。</param>
 void OnComponentRemoved(object sender, GameComponentCollectionEventArgs e)
 {
     if (e.GameComponent == this)
     {
         DebugMap.Instance = null;
     }
 }
コード例 #23
0
 /// <summary>
 /// 自分自身が GameComponent として登録される時に、自分自身を現在有効な ITimeRuler として設定します。
 /// </summary>
 /// <param name="sender">イベントのソース。</param>
 /// <param name="e">イベント データ。</param>
 void OnComponentAdded(object sender, GameComponentCollectionEventArgs e)
 {
     if (e.GameComponent == this)
     {
         TimeRuler.Instance = this;
     }
 }
コード例 #24
0
 /// <summary>
 /// 削除された GameComponent が DebugComponent ならば DebugContext プロパティをクリアします。
 /// </summary>
 /// <param name="sender">イベントのソース。</param>
 /// <param name="e">イベント データ。</param>
 void OnComponentRemoved(object sender, GameComponentCollectionEventArgs e)
 {
     var debugComponent = e.GameComponent as DebugComponent;
     if (debugComponent != null)
     {
         debugComponent.DebugContext = null;
     }
 }
コード例 #25
0
ファイル: Game.cs プロジェクト: sergios1234/monoxna
        void GameComponentRemoved(object sender, GameComponentCollectionEventArgs e)
        {
            IDrawable d = e.GameComponent as IDrawable;
            if (d != null)
            {
                d.DrawOrderChanged -= DrawableDrawOrderChanged;
                d.VisibleChanged -= DrawableVisibleChanged;

                if (d.Visible)
                    visibleDrawable.Remove(d);
            }

            IUpdateable u = e.GameComponent as IUpdateable;
            if (u != null)
            {
                u.UpdateOrderChanged -= UpdatableUpdateOrderChanged;
                u.EnabledChanged -= UpdatableEnabledChanged;

                if (u.Enabled)
                    enabledUpdateable.Remove(u);
            }
        }
コード例 #26
0
 private void GameComponentRemoved( object sender, GameComponentCollectionEventArgs e )
 {
     IUpdateable item = e.GameComponent as IUpdateable;
     if ( item != null )
     {
         this._updateableComponents.Remove( item );
         item.UpdateOrderChanged -= this.UpdateableUpdateOrderChanged;
     }
     IDrawable drawable = e.GameComponent as IDrawable;
     if ( drawable != null )
     {
         this._drawableComponents.Remove( drawable );
         drawable.DrawOrderChanged -= this.DrawableDrawOrderChanged;
     }
     IUnitializable unitializable = e.GameComponent as IUnitializable;
     if ( unitializable != null )
     {
         unitializable.Unitialize();
     }
 }
コード例 #27
0
        /// <summary>
        /// Removes the component in the appropriate order
        /// </summary>
        /// <param name="sender">The object that triggered this event</param>
        /// <param name="e">Information pertaining to the state of the event</param>
        private void ComponentRemoved(object sender, GameComponentCollectionEventArgs e)
        {
            this.components.Remove(e.GameComponent);

            // check to see if its drawable
            IDrawable drawableComponent = e.GameComponent as IDrawable;

            if (drawableComponent != null)
            {
                // remove from our drawing components and unhook the event
                this.drawingComponents.Remove(drawableComponent);
                drawableComponent.DrawOrderChanged -= new EventHandler(this.ComponentDrawOrderChanged);
            }

            // check to see if it is just a component
            IUpdateable component = e.GameComponent as IUpdateable;

            if (component != null)
            {
                // remove from the updating components and unhook the event
                this.updatingComponents.Remove(component);
                component.UpdateOrderChanged -= new EventHandler(this.ComponentUpdateOrderChanged);
            }
        }
コード例 #28
0
ファイル: Game.cs プロジェクト: JesterScribble/MonoGame
 void Handle_gameComponentCollectionComponentAdded(object sender, GameComponentCollectionEventArgs e)
 {
     if (!_initialized && !_initializing) {
         e.GameComponent.Initialize();
     }
     else {
         _gameComponentsToInitialize.Add(e.GameComponent);
     }
 }
コード例 #29
0
 public void Constructors()
 {
     GameComponentCollectionEventArgs args = new GameComponentCollectionEventArgs(null);
     Assert.IsNotNull(args, "Failed to create type");
 }
コード例 #30
0
        /// <summary>
        /// Adds the component in the appropriate order
        /// </summary>
        /// <param name="sender">The object that triggered this event</param>
        /// <param name="e">Information pertaining to the state of the event</param>
        private void ComponentAdded(object sender, GameComponentCollectionEventArgs e)
        {
            if (this.isInitialized)
            {
                e.GameComponent.Initialize();
            }

            // e.GameComponent is an IGameComponent, but we need the events in the IDrawable
            IDrawable drawableComponent = e.GameComponent as IDrawable;

            if (drawableComponent != null)
            {
                // subscribe to the order changing events
                drawableComponent.DrawOrderChanged += new EventHandler(this.ComponentDrawOrderChanged);

                // find where this drawing component belongs
                int index = this.drawingComponents.BinarySearch(drawableComponent, Utility.DrawOrderComparer.Default);
                if (index < 0)
                {
                    index = ~index;
                    while (index < this.drawingComponents.Count && this.drawingComponents[index].DrawOrder == drawableComponent.DrawOrder)
                    {
                        index++;
                    }
                    // insert it at the calculated index
                    this.drawingComponents.Insert(index, drawableComponent);
                }
            }

            // check to see if it is just a component
            IUpdateable component = e.GameComponent as IUpdateable;

            if (component != null)
            {
                // subscribe to the update order change event
                component.UpdateOrderChanged += new EventHandler(ComponentUpdateOrderChanged);

                // find where this drawing component belongs
                int index = this.updatingComponents.BinarySearch(component, Utility.UpdateOrderComparer.Default);
                if (index < 0)
                {
                    index = ~index;
                    // calculate the index
                    while (index < this.updatingComponents.Count && this.updatingComponents[index].UpdateOrder == component.UpdateOrder)
                    {
                        index++;
                    }

                    // insert at the calculated index
                    this.updatingComponents.Insert(index, component);
                }
            }
        }
コード例 #31
0
        private void componentRemoved(object sender, GameComponentCollectionEventArgs e)
        {
            IUpdateable u = e.GameComponent as IUpdateable;
            IDrawable d = e.GameComponent as IDrawable;

            if (u != null)
            {
                updateable.Remove(u);
                u.UpdateOrderChanged -= componentUpdateOrderChanged;
            }

            if (d != null)
            {
                drawable.Remove(d);
                d.DrawOrderChanged -= componentDrawOrderChanged;
            }
        }
コード例 #32
0
ファイル: Game.cs プロジェクト: rash-pro/MonoGame
        void Handle_gameComponentCollectionComponentAdded(object sender, GameComponentCollectionEventArgs e)
        {
            if (!_initialized && !_initializing) {
                //Console.WriteLine("here");
                //e.GameComponent.Initialize();
            }
            else {
                e.GameComponent.Initialize();
                //_gameComponentsToInitialize.Add(e.GameComponent);
            }
コード例 #33
0
ファイル: Sand.cs プロジェクト: hortont424/sand
        private void ComponentRemoved(object sender, GameComponentCollectionEventArgs e)
        {
            var actor = e.GameComponent as Actor;

            if(actor != null)
            {
                foreach(var child in actor.Children)
                {
                    Components.Remove(child);
                }
            }
        }
コード例 #34
0
 public void GameComponent()
 {
     MyComponent c = new MyComponent(new TestGame());
     GameComponentCollectionEventArgs args = new GameComponentCollectionEventArgs(c);
     Assert.AreSame(c, args.GameComponent);
 }
コード例 #35
0
ファイル: Game.cs プロジェクト: Hayaweh/AudioPipe
 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);
         }
     }
 }
コード例 #36
0
ファイル: GameScreen.cs プロジェクト: Prismik/TDPlatformer
 void ComponentRemoved(object sender, GameComponentCollectionEventArgs e)
 {
     updateOrdered.Remove((GameComponent)e.GameComponent);
     DrawableGameComponent drawable = e.GameComponent as DrawableGameComponent;
     if (drawable != null)
         drawOrdered.Remove(drawable);
 }
コード例 #37
0
 /// <summary>
 /// Handles the ComponentRemoved event of the Components control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The 
 /// <see cref="Microsoft.Xna.Framework.GameComponentCollectionEventArgs"/> 
 /// instance containing the event data.</param>
 void Components_ComponentRemoved(object sender, GameComponentCollectionEventArgs e)
 {
     if (e.GameComponent == this)
     {
         Dispose();
     }
 }
コード例 #38
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());
        }
コード例 #39
0
 /// <summary>
 /// 自分自身が GameComponent として登録される時に、自分自身を現在有効な IDebugConsole として設定します。
 /// </summary>
 /// <param name="sender">イベントのソース。</param>
 /// <param name="e">イベント データ。</param>
 void OnComponentAdded(object sender, GameComponentCollectionEventArgs e)
 {
     if (e.GameComponent == this)
     {
         DebugConsole.Instance = this;
     }
 }
コード例 #40
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());
        }
コード例 #41
0
ファイル: GameScreen.cs プロジェクト: Prismik/TDPlatformer
 void ComponentAdded(object sender, GameComponentCollectionEventArgs e)
 {
     // TODO: Insert components according to UpdateOrder and DrawOrder
     //       Currently we can use Sort, however for performance we
     //       should use BinarySearch.
     updateOrdered.Add((GameComponent)e.GameComponent);
     DrawableGameComponent drawable = e.GameComponent as DrawableGameComponent;
     if (drawable != null)
         drawOrdered.Add(drawable);
 }