예제 #1
0
        public RoomExit NearestExit(Vector2 location)
        {
            RoomExit nearest     = null;
            double   nearestDist = double.PositiveInfinity;

            for (int i = 0; i < exitPoints.Count; i++)
            {
                if (exitPoints[i].next != null)
                {
                    if (Util.Distance(location, exitPoints[i].location.vec) < nearestDist)
                    {
                        nearest     = exitPoints[i];
                        nearestDist = Util.Distance(location, exitPoints[i].location.vec);
                    }
                }
            }
            return(nearest);
        }
예제 #2
0
        private void RenderOneExit(SpriteBatch sb, RoomExit e, Direction d, Vector2 offset)
        {
            Texture2D bgtex    = AssMan.Get(backgroundAsset);
            Rectangle lowRect  = new Rectangle(0, WALLH, EXITW, (int)(e.location.vec.Y - (EXITH >> 1) - WALLH));
            Rectangle highRect = new Rectangle(0, lowRect.Y + lowRect.Height + EXITH, EXITW, bgtex.Height - (lowRect.Height + lowRect.Y + EXITH));

            if (d == Direction.E)
            {
                highRect.X = lowRect.X = bgtex.Width - EXITW;
            }
            else if (d == Direction.S)
            {
                lowRect  = new Rectangle(0, bgtex.Height - EXITW, (int)e.location.vec.X - (EXITH >> 1), EXITW);
                highRect = new Rectangle(lowRect.X + lowRect.Width + EXITH, lowRect.Y, bgtex.Width - (EXITH >> 1) - (int)e.location.vec.X, EXITW);
            }
            lowRect  = Util.AddOffset(lowRect, backgroundOrigin);
            highRect = Util.AddOffset(highRect, backgroundOrigin);

            sb.Draw(AssMan.Get(IAsset.Mask), Util.AddOffset(lowRect, offset), Color.Black);
            sb.Draw(AssMan.Get(IAsset.Mask), Util.AddOffset(highRect, offset), Color.Black);
        }