示例#1
0
 public SingleTagRenderer(BitTag tag)
 {
     Tag          = tag;
     BlendState   = BlendState.AlphaBlend;
     SamplerState = SamplerState.LinearClamp;
     Camera       = new Camera();
 }
示例#2
0
 /// <summary>
 /// Quick access to entire tag lists of Entities. Result will never be null
 /// </summary>
 /// <param name="tag">The tag list to fetch</param>
 /// <returns></returns>
 public List <Entity> this[BitTag tag]
 {
     get
     {
         return(TagLists[tag.ID]);
     }
 }
示例#3
0
文件: Entity.cs 项目: aaronlws95/twog
        public bool CollideDo(BitTag tag, Action <Entity> action, Vector2 at)
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against a tag list when it is not a member of a Scene");
            }
#endif

            bool hit = false;
            var  was = Position;
            Position = at;

            foreach (var other in Scene[tag])
            {
                if (CollideCheck(other))
                {
                    action(other);
                    hit = true;
                }
            }

            Position = was;
            return(hit);
        }
示例#4
0
文件: Entity.cs 项目: aaronlws95/twog
        public List <Entity> CollideAll(BitTag tag)
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against a tag list when it is not a member of a Scene");
            }
#endif
            return(Collide.All(this, Scene[tag]));
        }
示例#5
0
文件: Entity.cs 项目: aaronlws95/twog
        public Entity CollideFirst(BitTag tag, Vector2 at)
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against a tag list when it is not a member of a Scene");
            }
#endif
            return(Collide.First(this, Scene[tag], at));
        }
示例#6
0
文件: Entity.cs 项目: aaronlws95/twog
        public Entity CollideFirstOutside(BitTag tag, Vector2 at)
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against a tag list when it is not a member of a Scene");
            }
#endif

            foreach (var entity in Scene[tag])
            {
                if (!Collide.Check(this, entity) && Collide.Check(this, entity, at))
                {
                    return(entity);
                }
            }
            return(null);
        }
示例#7
0
文件: Entity.cs 项目: aaronlws95/twog
        public Entity Closest(BitTag tag)
        {
            var    list    = Scene[tag];
            Entity closest = null;
            float  dist;

            if (list.Count >= 1)
            {
                closest = list[0];
                dist    = Vector2.DistanceSquared(Position, closest.Position);

                for (int i = 1; i < list.Count; i++)
                {
                    float current = Vector2.DistanceSquared(Position, list[i].Position);
                    if (current < dist)
                    {
                        closest = list[i];
                        dist    = current;
                    }
                }
            }

            return(closest);
        }