Ejemplo n.º 1
0
            private void CheckXBox(XPos xPos, ref CharaPos charaPos, ref CharaLastPos charaLastPos,
                                   ref CharaFlag charaFlag, ref CharaQueue charaQueue)
            {
                int mapX     = 0;
                int lastMapX = 0;
                int sideMapX = 0;
                int offsetX  = 0;

                switch (xPos)
                {
                case XPos.Left:
                    mapX     = charaPos.m_mapXLeft;
                    lastMapX = charaLastPos.m_mapXLeft;
                    sideMapX = mapX + 1;
                    offsetX  = TIP_SIZE + SIDE_OFFSET;
                    break;

                case XPos.Center:
                    mapX     = charaPos.m_mapXCenter;
                    lastMapX = charaLastPos.m_mapXCenter;
                    break;

                case XPos.Right:
                    mapX     = charaPos.m_mapXRight;
                    lastMapX = charaLastPos.m_mapXRight;
                    sideMapX = mapX - 1;
                    offsetX  = -1 - SIDE_OFFSET;
                    break;
                }

                // MapX移動が無いときはチェックしない
                if (mapX == lastMapX)
                {
                    return;
                }

                // 横が空の時のみ、壁チェック
                EnumShapeType sideShape = GetShape(sideMapX, charaPos.m_mapY, charaPos.m_mapZ);

                if (!sideShape.IsEmpty())
                {
                    return;
                }

                // ブロックのみ補正行う、斜め壁は別途
                EnumShapeType shape = GetShape(mapX, charaPos.m_mapY, charaPos.m_mapZ);

                if (!shape.IsBox())
                {
                    return;
                }

                // 中心位置への補正SIDE_OFFSET
                int newX = (mapX << PIX_MAP) + offsetX;

                charaPos.SetPixX(newX);
                QueueCrash(ref charaFlag, ref charaQueue);
            }
Ejemplo n.º 2
0
            private void CheckXZSlashWall(XPos xPos, ref CharaPos charaPos, ref CharaLastPos charaLastPos,
                                          ref CharaFlag charaFlag, ref CharaQueue charaQueue)
            {
                int mapX    = 0;
                int tipX    = 0;
                int offsetX = 0;

                switch (xPos)
                {
                case XPos.Left:
                    mapX    = charaPos.m_mapXLeft;
                    tipX    = charaPos.m_tipXLeft;
                    offsetX = +1 + SIDE_OFFSET;
                    break;

                case XPos.Center:
                    mapX = charaPos.m_mapXCenter;
                    tipX = charaPos.m_tipXCenter;
                    break;

                case XPos.Right:
                    mapX    = charaPos.m_mapXRight;
                    tipX    = charaPos.m_tipXRight;
                    offsetX = -1 - SIDE_OFFSET;
                    break;
                }

                EnumShapeType shape = GetShape(mapX, charaPos.m_mapY, charaPos.m_mapZ);

                if (!shape.IsSlashWall())
                {
                    return;
                }


                int  moveX    = math.abs(charaPos.m_posX - charaLastPos.m_posX);
                int  moveZ    = math.abs(charaPos.m_posZ - charaLastPos.m_posZ);
                bool isZSlide = (moveX > moveZ);

                if (isZSlide)
                {
                    // 斜め壁座標
                    int  borderX = 0;
                    int  shiftZ  = 0;
                    bool isHit   = false;
                    switch (shape)
                    {
                    case EnumShapeType.SlashWall:
                        borderX = charaPos.m_tipZ;
                        shiftZ  = -(tipX + 1);
                        isHit   = tipX <= borderX;
                        break;

                    case EnumShapeType.BSlashWall:
                        borderX = TIP_SIZE - 1 - charaPos.m_tipZ;
                        shiftZ  = -(TIP_SIZE - tipX);
                        isHit   = tipX >= borderX;
                        break;
                    }

                    if (isHit)
                    {
                        int newZ = ((charaPos.m_mapZ + 1) << PIX_MAP) + shiftZ;
                        charaPos.SetPixZ(newZ);
                    }
                }
                else
                {
                    int borderZ = 0;
                    int shiftX  = 0;
                    switch (shape)
                    {
                    case EnumShapeType.SlashWall:
                        borderZ = tipX;
                        shiftX  = charaPos.m_tipZ + 1;
                        break;

                    case EnumShapeType.BSlashWall:
                        borderZ = TIP_SIZE - 1 - tipX;
                        shiftX  = -(TIP_SIZE - charaPos.m_tipZ);
                        break;
                    }

                    if (charaPos.m_tipZ >= borderZ)
                    {
                        int newX = (mapX << PIX_MAP) + shiftX + offsetX;
                        charaPos.SetPixX(newX);
                    }
                }
            }