GetMegaSet() 공개 정적인 메소드

Gets the n'th mega set specified by a megaSet from a Compact object.
public static GetMegaSet ( Compact cpt ) : MegaSet
cpt Compact Compact object.
리턴 MegaSet
예제 #1
0
        private bool GetGridValues(Compact cpt, out byte resGrid, out int resBitNum, out uint resWidth)
        {
            var width = SkyCompact.GetMegaSet(cpt).gridWidth;

            return(GetGridValues(cpt.Core.xcood, cpt.Core.ycood, width, cpt, out resGrid, out resBitNum, out resWidth));
        }
예제 #2
0
        private bool Collide(Compact cpt)
        {
            MegaSet m1 = SkyCompact.GetMegaSet(_compact);
            MegaSet m2 = SkyCompact.GetMegaSet(cpt);

            // target's base coordinates
            ushort x = (ushort)(cpt.Core.xcood & 0xfff8);
            ushort y = (ushort)(cpt.Core.ycood & 0xfff8);

            // The collision is direction dependent
            switch (_compact.Core.dir)
            {
            case 0:                // looking up
                x -= m1.colOffset; // compensate for inner x offsets
                x += m2.colOffset;

                if (x + m2.colWidth < _compact.Core.xcood)     // their rightmost
                {
                    return(false);
                }

                x -= m1.colWidth;     // our left, their right
                if (x >= _compact.Core.xcood)
                {
                    return(false);
                }

                y += 8;     // bring them down a line
                if (y == _compact.Core.ycood)
                {
                    return(true);
                }

                y += 8;     // bring them down a line
                if (y == _compact.Core.ycood)
                {
                    return(true);
                }

                return(false);

            case 1:                // looking down
                x -= m1.colOffset; // compensate for inner x offsets
                x += m2.colOffset;

                if (x + m2.colWidth < _compact.Core.xcood)     // their rightmoast
                {
                    return(false);
                }

                x -= m1.colWidth;     // our left, their right
                if (x >= _compact.Core.xcood)
                {
                    return(false);
                }

                y -= 8;     // bring them up a line
                if (y == _compact.Core.ycood)
                {
                    return(true);
                }

                y -= 8;     // bring them up a line
                if (y == _compact.Core.ycood)
                {
                    return(true);
                }

                return(false);

            case 2:     // looking left

                if (y != _compact.Core.ycood)
                {
                    return(false);
                }

                x += m2.lastChr;
                if (x == _compact.Core.xcood)
                {
                    return(true);
                }

                x -= 8;     // out another one
                if (x == _compact.Core.xcood)
                {
                    return(true);
                }

                return(false);

            case 3:     // looking right
            case 4:     // talking (not sure if this makes sense...)

                if (y != _compact.Core.ycood)
                {
                    return(false);
                }

                x -= m1.lastChr;     // last block
                if (x == _compact.Core.xcood)
                {
                    return(true);
                }

                x -= 8;     // out another block
                if (x != _compact.Core.xcood)
                {
                    return(false);
                }

                return(true);

            default:
                throw new InvalidOperationException(string.Format("Unknown Direction: {0}", _compact.Core.dir));
            }
        }
예제 #3
0
        public ushort DoAutoRoute(Compact cpt)
        {
            var cptScreen = (byte)cpt.Core.screen;
            var cptWidth  = (byte)SkyCompact.GetMegaSet(cpt).gridWidth;

            InitWalkGrid(cptScreen, cptWidth);

            byte  startX, startY, destX, destY;
            short initStaX, initStaY, initDestX, initDestY;

            ClipCoordX(cpt.Core.xcood, out startX, out initStaX);
            ClipCoordY(cpt.Core.ycood, out startY, out initStaY);
            ClipCoordX(cpt.Core.arTargetX, out destX, out initDestX);
            ClipCoordY(cpt.Core.arTargetY, out destY, out initDestY);

            var raw = _skyCompact.FetchCptRaw(cpt.Core.animScratchId);

            Array.Clear(raw, 0, 64);
            var routeDest = new UShortAccess(raw, 0);

            if ((startX == destX) && (startY == destY))
            {
                return(2);
            }

            var routeGrid = new UShortAccess(_routeGrid, 0);

            if (routeGrid[(destY + 1) * RouteGridWidth + destX + 1] != 0)
            {
                //if ((cpt == &Sky::SkyCompact::foster) && (cptScreen == 12) && (destX == 2) && (destY == 14)) {
                if (_skyCompact.CptIsId(cpt, (ushort)CptIds.Foster) && (cptScreen == 12) && (destX == 2) &&
                    (destY == 14))
                {
                    /* workaround for Scriptbug #1043047
                     * In screen 12 (the pipe factory) Joey can block Foster's target
                     * coordinates (2/14). This is normally not too tragic, but in the
                     * scene when foster gets thrown out by Lamb (first time you enter
                     * the pipe factory), the game would enter an infinite loop. */
                    routeGrid[(destY + 1) * RouteGridWidth + destX + 1] = 0;
                    // hide this part joey from the grid
                }
                else
                {
                    return(1); // AR destination is an unaccessible block
                }
            }

            if (!CalcWalkGrid(startX, startY, destX, destY))
            {
                return(1); // can't find route to block
            }
            var routeData = MakeRouteData(destX, destY);

            // the route is done.
            // if there was an initial x movement (due to clipping) tag it onto the start
            routeData = CheckInitMove(routeData, initStaX);

            byte cnt = 0;

            do
            {
                routeDest[cnt]     = routeData[cnt];
                routeDest[cnt + 1] = routeData[cnt + 1];
                cnt += 2;
            } while (routeData[cnt - 2] != 0);
            return(0);
        }