示例#1
0
文件: Npc.cs 项目: steynh/GamingMinor
        private bool seesWall()
        {
            List<PhysicalObject2D> visionCollisions = World._mainCollisionDictionary.CalculateCollisions(VisionRectangle);

            foreach (PhysicalObject2D s in visionCollisions)
            {
                CollisionRectangle futureNpc = new CollisionRectangle(new Vector2(s.Position.X, Position.Y), new Vector2(Bounds.Width, Bounds.Height));
                CollisionRectangle platformRectangle = s.Bounds;
                if (futureNpc.Intersects(platformRectangle) && (s.Position.Y < Bounds.Bottom))
                    {
                        if (s is IColored && (((IColored)s).Color == Color || ((IColored)s).Color == Color.White))
                            if (s is Platform && s.Collidable == true)
                            {
                                return true;
                            }
                    }
                }

            return false;
        }
示例#2
0
        protected override void UpdateBounds()
        {
            List<VectorRectangle> childrenBounds = new List<VectorRectangle>();

            foreach (PhysicalObject2D child in Children) {
                childrenBounds.Add(child.Bounds);
            }

            _bounds = new CollisionRectangle(VectorRectangle.GetUnion(childrenBounds));
            _bounds.Object = this;

            _boundsChanged = false;
            // TODO shit
        }
示例#3
0
        public void Add(CollisionRectangle rectangle)
        {
            if (rectangle == null)
                throw new ArgumentException("Rectangle can't be null");

            _allRectangles.Add(rectangle);
        }