private void AttractSlope(ref CharaPos charaPos, ref CharaLastPos charaLastPos, ref CharaFlag charaFlag, ref CharaQueue charaQueue) { // 浮いている場合は補正しない if (!charaFlag.m_mapFlag.IsFlag(FlagMapCheck.Slope)) { return; } EnumShapeType shape = GetShape(charaPos.m_mapXCenter, charaPos.m_mapY, charaPos.m_mapZ); EnumShapeType bottomShape = GetShape(charaPos.m_mapXCenter, charaPos.m_mapY - 1, charaPos.m_mapZ); // int newY = 0; if (shape.IsSlope()) { // 現チップが坂 newY = (charaPos.m_mapY << PIX_MAP) + GetSlopeBorder(shape, charaPos.m_tipXCenter) + 1; } else if (shape.IsEmpty() && bottomShape.IsSlope()) { // もしくは、現チップが空で、下のチップが坂 newY = ((charaPos.m_mapY - 1) << PIX_MAP) + GetSlopeBorder(bottomShape, charaPos.m_tipXCenter) + 1; } else { return; } charaPos.SetPixY(newY); }
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); }
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); } } }
private void CheckYWall(XPos xPos, ref CharaPos charaPos, ref CharaLastPos charaLastPos, ref CharaFlag charaFlag, ref CharaQueue charaQueue) { // MapX移動が無いときはチェックしない if (charaPos.m_mapY == charaLastPos.m_mapY) { return; } int mapX = 0; int sideMapX = 0; switch (xPos) { case XPos.Left: mapX = charaPos.m_mapXLeft; sideMapX = mapX + 1; break; case XPos.Center: mapX = charaPos.m_mapXCenter; sideMapX = mapX; break; case XPos.Right: mapX = charaPos.m_mapXRight; sideMapX = mapX - 1; break; } EnumShapeType sideShape = GetShape(sideMapX, charaPos.m_mapY, charaPos.m_mapZ); // 横が坂の場合は判定しない if (sideShape.IsSlope()) { return; } EnumShapeType topShape = GetShape(mapX, charaPos.m_mapY + 1, charaPos.m_mapZ); EnumShapeType shape = GetShape(mapX, charaPos.m_mapY, charaPos.m_mapZ); //ひとつ上と同じチップの場合はチェックしない if (shape == topShape) { return; } // Yめり込みチェック bool isHit = false; switch (shape) { case EnumShapeType.Box: isHit = true; break; case EnumShapeType.BSlashWall: isHit = (xPos == XPos.Right) && (charaPos.m_tipXRight >= (TIP_SIZE - 1 - charaPos.m_tipZ)); break; case EnumShapeType.SlashWall: isHit = (xPos == XPos.Left) && (charaPos.m_tipXLeft <= charaPos.m_tipZ); break; } if (isHit) { int newY = (charaPos.m_mapY + 1) << PIX_MAP; charaPos.SetPixY(newY); QueueLand(ref charaFlag, ref charaQueue); } }