Exemple #1
0
        private Rectangle GetSidePassageSrcRect(int distance, bool rightSide, SideWallType type)
        {
            Rectangle result = new Rectangle();

            result.Width = sideWidth[distance];

            switch (type)
            {
            case SideWallType.Corner:
            case SideWallType.Corridor:
            case SideWallType.Parallel:
                result.Width += sideWidth[distance + 1];
                break;
            }

            for (int i = 0; i < distance; i++)
            {
                result.X += sideWidth[i];
            }

            result.X      *= 16;
            result.Y      *= 16;
            result.Width  *= 16;
            result.Height *= 16;

            result.Y     += imageSize.Height * (int)type;
            result.Height = imageSize.Height;

            if (rightSide)
            {
                result.X = imageSize.Width - result.X - result.Width;
            }

            if (distance % 2 == 1)
            {
                result.X += imageSize.Width;
            }

            return(result);
        }
Exemple #2
0
        private void DrawSidePassages(SpriteBatch spriteBatch,
                                      Point loc,
                                      Point lookDir,
                                      Point leftDir,
                                      Point rightDir,
                                      int distance,
                                      Rectangle maindestRect)
        {
            Point forwardPt      = new Point(loc.X + lookDir.X, loc.Y + lookDir.Y);
            Point leftPt         = new Point(loc.X + leftDir.X, loc.Y + leftDir.Y);
            Point rightPt        = new Point(loc.X + rightDir.X, loc.Y + rightDir.Y);
            Point leftForwardPt  = new Point(leftPt.X + lookDir.X, leftPt.Y + lookDir.Y);
            Point rightForwardPt = new Point(rightPt.X + lookDir.X, rightPt.Y + lookDir.Y);

            int forwardValue      = MapValueAt(forwardPt);
            int leftValue         = MapValueAt(leftPt);
            int rightValue        = MapValueAt(rightPt);
            int leftForwardValue  = MapValueAt(leftForwardPt);
            int rightForwardValue = MapValueAt(rightForwardPt);

            SideWallType leftType  = GetSideWallType(distance, leftValue, leftForwardValue, forwardValue);
            SideWallType rightType = GetSideWallType(distance, rightValue, rightForwardValue, forwardValue);

            Rectangle srcRect, destRect;

            srcRect  = GetSidePassageSrcRect(distance, false, leftType);
            destRect = GetSidePassageDestRect(distance, false, leftType, maindestRect);
            //Surfaces.Walls.Draw(srcRect, destRect);
            spriteBatch.Draw(Surfaces.Walls, destRect, srcRect, Color.White);

            if (leftType == SideWallType.Exhibit && AnimateExhibits)
            {
                Color clr = Color.White;

                if (distance % 2 == 0)
                {
                    srcRect.X += imageSize.Width;
                }

                if (distance <= 2)
                {
                    clr = ExhibitColor(leftValue);
                }

                srcRect.X += imageSize.Width * (1 + exhibitFrame);
                //Surfaces.Walls.Draw(srcRect, destRect);
                spriteBatch.Draw(Surfaces.Walls, destRect, srcRect, clr);
            }

            srcRect  = GetSidePassageSrcRect(distance, true, rightType);
            destRect = GetSidePassageDestRect(distance, true, rightType, maindestRect);
            // Surfaces.Walls.Draw(srcRect, destRect);
            spriteBatch.Draw(Surfaces.Walls, destRect, srcRect, Color.White);


            if (rightType == SideWallType.Exhibit && AnimateExhibits)
            {
                if (distance % 2 == 0)
                {
                    srcRect.X += imageSize.Width;
                }

                Color clr = Color.White;

                if (distance <= 2)
                {
                    clr = ExhibitColor(rightValue);
                }

                srcRect.X += imageSize.Width * (1 + exhibitFrame);
                //Surfaces.Walls.Draw(srcRect, destRect);
                spriteBatch.Draw(Surfaces.Walls, destRect, srcRect, clr);
            }
        }