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; } }
private void OnComponentRemoved(GameComponentCollectionEventArgs eventArgs) { if (this.ComponentRemoved != null) { this.ComponentRemoved(this, eventArgs); } }
void Components_ComponentRemoved(object sender, GameComponentCollectionEventArgs e) { if (e.GameComponent == this) { RaiseGameObjectRemovedEvent(); } }
void OnComponentAdded(GameComponentCollectionEventArgs eventArgs) { if (ComponentAdded != null) { ComponentAdded(this, eventArgs); } }
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); } } }
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); } } }
private void Components_ComponentRemoved( object sender, GameComponentCollectionEventArgs e ) { DecategorizeComponent(e.GameComponent); }
private void OnComponentRemoved(GameComponentCollectionEventArgs eventArgs) { if (this.ComponentRemoved == null) { return; } this.ComponentRemoved((object)this, eventArgs); }
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); }
void Handle_gameComponentCollectionComponentAdded(object sender, GameComponentCollectionEventArgs e) { if (!_initialized && !_initializing) { e.GameComponent.Initialize(); } else { _gameComponentsToInitialize.Add(e.GameComponent); } }
void Handle_gameComponentCollectionComponentAdded(object sender, GameComponentCollectionEventArgs e) { if (!_initialized && !_initializing) { //Console.WriteLine("here"); //e.GameComponent.Initialize(); } else { e.GameComponent.Initialize(); //_gameComponentsToInitialize.Add(e.GameComponent); } }
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); }
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); }
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); } }
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 ); } }
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); } }
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); } }
private void Components_ComponentAdded(object sender, GameComponentCollectionEventArgs e) { e.GameComponent.Initialize(); this.CategorizeComponent(e.GameComponent); }
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(); }
private void OnComponentRemoved(GameComponentCollectionEventArgs eventArgs) { EventHelpers.Raise(this, ComponentRemoved, eventArgs); }
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 ); } }
/// <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; } }
/// <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; } }
/// <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; } }
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); } }
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(); } }
/// <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); } }
public void Constructors() { GameComponentCollectionEventArgs args = new GameComponentCollectionEventArgs(null); Assert.IsNotNull(args, "Failed to create type"); }
/// <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); } } }
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; } }
void Handle_gameComponentCollectionComponentAdded(object sender, GameComponentCollectionEventArgs e) { if (!_initialized && !_initializing) { //Console.WriteLine("here"); //e.GameComponent.Initialize(); } else { e.GameComponent.Initialize(); //_gameComponentsToInitialize.Add(e.GameComponent); }
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); } } }
public void GameComponent() { MyComponent c = new MyComponent(new TestGame()); GameComponentCollectionEventArgs args = new GameComponentCollectionEventArgs(c); Assert.AreSame(c, args.GameComponent); }
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); } } }
void ComponentRemoved(object sender, GameComponentCollectionEventArgs e) { updateOrdered.Remove((GameComponent)e.GameComponent); DrawableGameComponent drawable = e.GameComponent as DrawableGameComponent; if (drawable != null) drawOrdered.Remove(drawable); }
/// <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(); } }
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()); }
/// <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; } }
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()); }
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); }