private void CheckZBox(XPos xPos, ref CharaPos charaPos, ref CharaLastPos charaLastPos, ref CharaFlag charaFlag, ref CharaQueue charaQueue) { // MapZ移動が無いときはZチェックしない if (charaPos.m_mapZ == charaLastPos.m_mapZ) { return; } int mapX = 0; switch (xPos) { case XPos.Left: mapX = charaPos.m_mapXLeft; break; case XPos.Center: mapX = charaPos.m_mapXCenter; break; case XPos.Right: mapX = charaPos.m_mapXRight; break; } // 手前が壁以外のときのみ壁チェック EnumShapeType frontShape = GetShape(mapX, charaPos.m_mapY, charaPos.m_mapZ - 1); if (frontShape.IsBox()) { return; } // ブロックのみ補正行う、斜め壁は別途 EnumShapeType shape = GetShape(mapX, charaPos.m_mapY, charaPos.m_mapZ); if (!shape.IsBox()) { return; } int newRZ = (charaPos.m_mapZ << PIX_MAP) - 1; Debug.Log($"charaPos.m_mapZ : {charaPos.m_mapZ} charaLastPos.m_mapZ {charaLastPos.m_mapZ}"); charaPos.SetPixZ(newRZ); }
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); } } }