private void OnDamageApplied(Damaging sender, IFlyEntity e) { // ToDo: Add bounce support! Behave.This(this) .BlendOut(forSeconds: 1) .Despawn(); }
private void HookOnDestroyed(IFlyEntity entity) { var destroyable = entity.Components.Find <LifeStatusComponent>(); if (destroyable != null) { destroyable.Destroyed += sender => this.RemoveFromScene(); } }
private void OnCollided(ICollideable sender, IFlyEntity other) { var damageEntity = other as IDamageEntity; if (damageEntity != null) { this.OnHit(damageEntity.Damaging); } }
public bool ApplyEffectTo(IFlyEntity entity) { var empireOwned = entity.Components.Get <EmpireOwned>(); if (empireOwned != null && empireOwned.Empire != null) { empireOwned.Empire.AddMinerals(this.Count); return(true); } else { return(false); } }
public bool Untrack(IFlyEntity entity) { LifeTrackedEntity trackedEntity = this.entities.Find(te => te.FlyEntity == entity); if (this.entities.Remove(trackedEntity)) { this.OnUntracked(trackedEntity); return(true); } else { return(false); } }
public void Track(IFlyEntity entity) { var lifeBar = new LifeBar() { Entity = entity }; var trackedEntity = new LifeTrackedEntity() { FlyEntity = entity, LifeBar = lifeBar }; this.entities.Add(trackedEntity); this.OnTracked(trackedEntity); }
//public IPhysicsEntity GetPhysicsEntityIn( RectangleF area ) //{ // AABB aabb = new AABB( new XnaF.Vector2( area.Width, area.Height ), area.Position.ToXna() ); // IFlyComponent component = null; // Console.WriteLine( "query" ); // this.physicsWorld.QueryAABB( fixture => { // component = fixture.Body.UserData as ICollideable; // if( component != null ) // { // var bounds = component.Owner.Bounds; // if( bounds.Rectangle.Intersects( area ) ) // { // return false; // } // } // return true; // }, // ref aabb // ); // return component != null ? (component.Owner as IPhysicsEntity) : null; //} public void Draw(IFlyDrawContext drawContext) { HiddenEntities = 0; RectangleF area = drawContext.Camera.Area; for (int i = 0; i < this.entities.Count; ++i) { IFlyEntity entity = this.entities[i]; if (!entity.Bounds.HasBounds || entity.Bounds.Intersects(ref area)) { entity.Draw(drawContext); } else { ++HiddenEntities; } } }
public void RemoveEntity(IFlyEntity entity) { if (this.entities.Remove(entity)) { entity.Scene = null; var gravityEmitting = entity as IGravityEmittingEntity; var gravityReceiving = entity as IGravityReceivingEntity; if (gravityEmitting != null) { this.gravityEmittingEntities.Remove(gravityEmitting); } if (gravityReceiving != null) { this.gravityReceivingEntities.Remove(gravityReceiving); } } }
private static string GetText(IFlyEntity entity) { var described = entity as IDescribed; string text; if (described != null) { text = described.Description; } else { text = entity.Name; } if (text == null) { text = entity.ToString(); } return(text); }
public void AddEntity(IFlyEntity entity) { if (entity != null) { entity.Scene = this; this.entities.Add(entity); var gravityEmitting = entity as IGravityEmittingEntity; var gravityReceiving = entity as IGravityReceivingEntity; if (gravityEmitting != null) { this.gravityEmittingEntities.Add(gravityEmitting); } if (gravityReceiving != null) { this.gravityReceivingEntities.Add(gravityReceiving); } entity.Bounds.RefreshIt(); } }
private void OnSelectedEntityRemoved(IFlyEntity sender, FlyScene e) { this.Unselect(); }
public void AddEntity(IFlyEntity entity) { this.scene.AddEntity(entity); }
public void RemoveEntity(IFlyEntity entity) { this.scene.RemoveEntity(entity); }
public void OnDamaged(IFlyEntity entity) { this.DamagedOther.Raise(this, entity); }
public void TrackEntity(IFlyEntity entity) { this.trackedEntities.Track(entity); }