Exemplo n.º 1
0
Arquivo: Bullet.cs Projeto: tivtag/Fly
        private void OnDamageApplied(Damaging sender, IFlyEntity e)
        {
            // ToDo: Add bounce support!

            Behave.This(this)
            .BlendOut(forSeconds: 1)
            .Despawn();
        }
Exemplo n.º 2
0
        private void HookOnDestroyed(IFlyEntity entity)
        {
            var destroyable = entity.Components.Find <LifeStatusComponent>();

            if (destroyable != null)
            {
                destroyable.Destroyed += sender => this.RemoveFromScene();
            }
        }
Exemplo n.º 3
0
        private void OnCollided(ICollideable sender, IFlyEntity other)
        {
            var damageEntity = other as IDamageEntity;

            if (damageEntity != null)
            {
                this.OnHit(damageEntity.Damaging);
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        //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;
                }
            }
        }
Exemplo n.º 8
0
        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);
                }
            }
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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();
            }
        }
Exemplo n.º 11
0
 private void OnSelectedEntityRemoved(IFlyEntity sender, FlyScene e)
 {
     this.Unselect();
 }
Exemplo n.º 12
0
 public void AddEntity(IFlyEntity entity)
 {
     this.scene.AddEntity(entity);
 }
Exemplo n.º 13
0
 public void RemoveEntity(IFlyEntity entity)
 {
     this.scene.RemoveEntity(entity);
 }
Exemplo n.º 14
0
 public void OnDamaged(IFlyEntity entity)
 {
     this.DamagedOther.Raise(this, entity);
 }
Exemplo n.º 15
0
 public void TrackEntity(IFlyEntity entity)
 {
     this.trackedEntities.Track(entity);
 }