/// <summary> /// Checks if this behavior is following an specified entity. /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool IsFollowingEntity(Base.Entity entity) { var beh = this; while (beh != null && beh.Following != null && beh.Following != entity) { beh = beh.Following.GetBehavior <ChainBehavior <T> >(); } return(beh != null && beh.Following != null && beh.Following == entity); }
private void Drop(Levels.Level level, Base.Entity dropEntity) { var enemyPosition = Entity.CenterPosition; var dropDistance = VectorHelper.AngleToV2((float)(Random.NextDouble() * Math.PI - Math.PI / 2), 32); var dropPosition = enemyPosition + dropDistance; dropEntity.Parent = null; dropEntity.OverlapEntities = true; dropEntity.Position = dropPosition; if (level.Map.Collides(dropEntity.CollisionRect)) { dropEntity.Position = enemyPosition; } level.AddEntity(dropEntity); }
/// <summary> /// 对象转换 /// </summary> /// <typeparam name="TProjection">对象类型</typeparam> /// <returns></returns> public static TProjection ProjectedAs <TProjection>(this Base.Entity item) where TProjection : class, new() { return(Mapper.Map <TProjection>(item)); }