📄 maphandler.cpp
字号:
nYGapPos = nYPos-nGap;
bCanMove = GetTileAttribute(nXGapPos, nYGapPos);
}
break;
case _DIRECTION_LIST_3:
{
nXGapPos = nXPos+nGap;
nYGapPos = nYPos;
bCanMove = GetTileAttribute(nXGapPos, nYGapPos);
}
break;
case _DIRECTION_LIST_4:
{
nXGapPos = nXPos+nGap;
nYGapPos = nYPos+nGap;
bCanMove = GetTileAttribute(nXGapPos, nYGapPos);
}
break;
case _DIRECTION_LIST_5:
{
nXGapPos = nXPos;
nYGapPos = nYPos+nGap;
bCanMove = GetTileAttribute(nXGapPos, nYGapPos);
}
break;
case _DIRECTION_LIST_6:
{
nXGapPos = nXPos-nGap;
nYGapPos = nYPos+nGap;
bCanMove = GetTileAttribute(nXGapPos, nYGapPos);
}
break;
case _DIRECTION_LIST_7:
{
nXGapPos = nXPos-nGap;
nYGapPos = nYPos;
bCanMove = GetTileAttribute(nXGapPos, nYGapPos);
}
break;
case _DIRECTION_LIST_8:
{
nXGapPos = nXPos-nGap;
nYGapPos = nYPos-nGap;
bCanMove = GetTileAttribute(nXGapPos, nYGapPos);
}
break;
}
lpptTarget->x = nXGapPos;
lpptTarget->y = nYGapPos;
if ( bCanMove != _CAN_WALK )
return FALSE;
if ( g_xGameProc.m_xActorList.GetCounter() != 0 )
{
g_xGameProc.m_xActorList.MoveCurrentToTop();
CActor* pxActor;
for ( INT nCnt = 0; nCnt < g_xGameProc.m_xActorList.GetCounter(); nCnt++ )
{
pxActor = g_xGameProc.m_xActorList.GetCurrentData();
if ( pxActor->m_wPosX == nXGapPos && pxActor->m_wPosY == nYGapPos && !pxActor->m_bIsDead )
{
return FALSE;
}
g_xGameProc.m_xActorList.MoveNextNode();
}
}
return TRUE;
}
VOID CMapHandler::SetAniTileFrame(INT nLoopTime)
{
INT nCnt;
for ( nCnt = 0; nCnt < 8; nCnt++ )
{
m_dwAniSaveTime[nCnt] += nLoopTime;
}
if ( m_dwAniSaveTime[0] > _TILE_ANI_DELAY_1 )
{
for ( nCnt = 0; nCnt < 16; nCnt++ )
{
m_bAniTileFrame[0][nCnt]++;
if ( m_bAniTileFrame[0][nCnt] >= nCnt )
m_bAniTileFrame[0][nCnt] = 0;
}
m_dwAniSaveTime[0] = 0;
}
if ( m_dwAniSaveTime[1] > _TILE_ANI_DELAY_2 )
{
for ( nCnt = 0; nCnt < 16; nCnt++ )
{
m_bAniTileFrame[1][nCnt]++;
if ( m_bAniTileFrame[1][nCnt] >= nCnt )
m_bAniTileFrame[1][nCnt] = 0;
}
m_dwAniSaveTime[1] = 0;
}
if ( m_dwAniSaveTime[2] > _TILE_ANI_DELAY_3 )
{
for ( nCnt = 0; nCnt < 16; nCnt++ )
{
m_bAniTileFrame[2][nCnt]++;
if ( m_bAniTileFrame[2][nCnt] >= nCnt )
m_bAniTileFrame[2][nCnt] = 0;
}
m_dwAniSaveTime[2] = 0;
}
if ( m_dwAniSaveTime[3] > _TILE_ANI_DELAY_4 )
{
for ( nCnt = 0; nCnt < 16; nCnt++ )
{
m_bAniTileFrame[3][nCnt]++;
if ( m_bAniTileFrame[3][nCnt] >= nCnt )
m_bAniTileFrame[3][nCnt] = 0;
}
m_dwAniSaveTime[3] = 0;
}
if ( m_dwAniSaveTime[4] > _TILE_ANI_DELAY_5 )
{
for ( nCnt = 0; nCnt < 16; nCnt++ )
{
m_bAniTileFrame[4][nCnt]++;
if ( m_bAniTileFrame[4][nCnt] >= nCnt )
m_bAniTileFrame[4][nCnt] = 0;
}
m_dwAniSaveTime[4] = 0;
}
if ( m_dwAniSaveTime[5] > _TILE_ANI_DELAY_6 )
{
for ( nCnt = 0; nCnt < 16; nCnt++ )
{
m_bAniTileFrame[5][nCnt]++;
if ( m_bAniTileFrame[5][nCnt] >= nCnt )
m_bAniTileFrame[5][nCnt] = 0;
}
m_dwAniSaveTime[5] = 0;
}
if ( m_dwAniSaveTime[6] > _TILE_ANI_DELAY_7 )
{
for ( nCnt = 0; nCnt < 16; nCnt++ )
{
m_bAniTileFrame[6][nCnt]++;
if ( m_bAniTileFrame[6][nCnt] >= nCnt )
m_bAniTileFrame[6][nCnt] = 0;
}
m_dwAniSaveTime[6] = 0;
}
if ( m_dwAniSaveTime[7] > _TILE_ANI_DELAY_8 )
{
for ( nCnt = 0; nCnt < 16; nCnt++ )
{
m_bAniTileFrame[7][nCnt]++;
if ( m_bAniTileFrame[7][nCnt] >= nCnt )
m_bAniTileFrame[7][nCnt] = 0;
}
m_dwAniSaveTime[7] = 0;
}
}
VOID CMapHandler::GetScrnPosFromTilePos(SHORT shTileX, SHORT shTileY, SHORT& shScrnX, SHORT& shScrnY)
{
shScrnX = (shTileX - m_shStartViewTileX)*_CELL_WIDTH - m_shViewOffsetX + _VIEW_CELL_X_START;
shScrnY = (shTileY - m_shStartViewTileY)*_CELL_HEIGHT - m_shViewOffsetY + _VIEW_CELL_Y_START;
}
VOID CMapHandler::GetTilePosFromScrnPos(SHORT shScrnX, SHORT shScrnY, SHORT& shTileX, SHORT& shTileY)
{
shTileX = m_shStartViewTileX + (shScrnX - _VIEW_CELL_X_START) / _CELL_WIDTH;
shTileY = m_shStartViewTileY + (shScrnY - _VIEW_CELL_Y_START) / _CELL_HEIGHT;
}
BYTE CMapHandler::CalcDirection16(WORD wFireTileX, WORD wFireTileY, WORD wDestTileX, WORD wDestTileY)
{
INT nWidth = wDestTileX - wFireTileX;
INT nHeight = wDestTileY - wFireTileY;
FLOAT rLineLength, rBottomInTriangle;
INT nDimension;
BYTE bDir;
rLineLength = (FLOAT)sqrt(nWidth*nWidth+nHeight*nHeight);
// 扁夯.
// 7 0 1
// 6 2
// 5 4 3
// 老窜篮 4俺狼 盒搁(90档扁霖)栏肺 唱穿绊 盒搁俊 措茄 cos蔼阑 利侩茄促.
( nWidth >= 0 ) ?
( nHeight < 0 ? (rBottomInTriangle=(FLOAT)-nHeight, nDimension=0) : (rBottomInTriangle=(FLOAT) nWidth, nDimension=4) ):
( nHeight >= 0 ? (rBottomInTriangle=(FLOAT) nHeight, nDimension=8) : (rBottomInTriangle=(FLOAT)-nWidth, nDimension=12) );
// 6(cos45) 0(cos 0) 0(cos45)
// 4(cos90) 2(cos 0) 2(cos 0)
// 4(cos45) 2(cos90) 2(cos45)
FLOAT rCosVal = rBottomInTriangle/rLineLength;
CONST FLOAT rCosVal16[8] = { 1.0f, 0.980785f, 0.923880f, 0.831470f, 0.707107f, 0.555570f, 0.382683f, 0.195090f };
// 阿盒搁阑 3俺狼 康开栏肺 唱穿绢辑 康开阑 犁炼沥茄促.
bDir = 0;
for ( INT nCnt = 0; nCnt < 8; nCnt++ )
{
if( rCosVal <= rCosVal16[nCnt] )
bDir = nDimension+(nCnt+1)/2;
else break;
}
if( bDir >= 16 ) bDir = 0;
return bDir;
}
BYTE CMapHandler::CalcDirection8(WORD wFireTileX, WORD wFireTileY, WORD wDestTileX, WORD wDestTileY)
{
INT nWidth = wDestTileX - wFireTileX;
INT nHeight = wDestTileY - wFireTileY;
FLOAT rLineLength, rBottomInTriangle;
INT nDimension;
BYTE bDir;
rLineLength = (FLOAT)sqrt(nWidth*nWidth+nHeight*nHeight);
// 扁夯.
// 7 0 1
// 6 2
// 5 4 3
// 老窜篮 4俺狼 盒搁(90档扁霖)栏肺 唱穿绊 盒搁俊 措茄 cos蔼阑 利侩茄促.
( nWidth >= 0 ) ?
( nHeight < 0 ? (rBottomInTriangle=(FLOAT)-nHeight, nDimension=0) : (rBottomInTriangle=(FLOAT) nWidth, nDimension=2) ):
( nHeight >= 0 ? (rBottomInTriangle=(FLOAT) nHeight, nDimension=4) : (rBottomInTriangle=(FLOAT)-nWidth, nDimension=6) );
// 6(cos45) 0(cos 0) 0(cos45)
// 4(cos90) 2(cos 0) 2(cos 0)
// 4(cos45) 2(cos90) 2(cos45)
FLOAT rCosVal = rBottomInTriangle/rLineLength;
// cos(0), cos(pi/8), cos(pi/4), cos(pi/2)
CONST FLOAT rCosVal8[4] = { 1.0f, 0.923880f, 0.707107f, 0.382683f };
// 阿盒搁阑 3俺狼 康开栏肺 唱穿绢辑 康开阑 犁炼沥茄促.
bDir = 0;
for ( INT nCnt = 0; nCnt < 4; nCnt++ )
{
if( rCosVal <= rCosVal8[nCnt] )
bDir = nDimension+(nCnt+1)/2;
else break;
}
if( bDir >= 8 ) bDir = 0;
return bDir;
}
/*
VOID CMapHandler::DrawOneCellObjTile(INT nX, INT nY)
{
if ( nY >= m_stMapFileHeader.shHeight )
return;
INT nObjFileIdx, nImgIdx;
// 坷宏璃飘啊 乐阑锭.
if ( m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].cFileIdx != -1 )
{
// 坷宏璃飘1捞 乐阑锭.
if ( m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].shObj1 != -1 )
{
nObjFileIdx = (m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].cFileIdx & 0XF0) >> 4;
nImgIdx = m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].shObj1;
m_pxTileImg[nObjFileIdx]->NewSetIndex(nImgIdx);
if ( m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shWidth == 48 &&
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight == 32 )
{
g_xMainWnd.DrawWithImageForCompClipRgn(
(nX-m_shStartViewTileX)*_CELL_WIDTH +_VIEW_CELL_X_START-m_shViewOffsetX,
(nY-m_shStartViewTileY)*_CELL_HEIGHT+_VIEW_CELL_Y_START-m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight+_CELL_HEIGHT-m_shViewOffsetY,
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shWidth,
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight,
(WORD*)m_pxTileImg[nObjFileIdx]->m_pbCurrImage,
_CLIP_WIDTH, _CLIP_HEIGHT);
}
}
// 坷宏璃飘2啊 乐阑锭.
if ( m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].shObj2 != -1 )
{
nObjFileIdx = (m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].cFileIdx & 0X0F);
nImgIdx = m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].shObj2;
m_pxTileImg[nObjFileIdx]->NewSetIndex(nImgIdx);
if ( m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shWidth == 48 &&
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight == 32 )
{
g_xMainWnd.DrawWithImageForCompClipRgn(
(nX-m_shStartViewTileX)*_CELL_WIDTH +_VIEW_CELL_X_START-m_shViewOffsetX,
(nY-m_shStartViewTileY)*_CELL_HEIGHT+_VIEW_CELL_Y_START-m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight+_CELL_HEIGHT-m_shViewOffsetY,
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shWidth,
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight,
(WORD*)m_pxTileImg[nObjFileIdx]->m_pbCurrImage,
_CLIP_WIDTH, _CLIP_HEIGHT);
}
}
}
}
BOOL CMapHandler::DrawOneCellOverObjTile(INT nX, INT nY)
{
if ( nY >= m_stMapFileHeader.shHeight )
return FALSE;
INT nObjFileIdx, nImgIdx;
// 坷宏璃飘啊 乐阑锭.
if ( m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].cFileIdx != -1 )
{
// 坷宏璃飘1捞 乐阑锭.
if ( m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].shObj1 != -1 )
{
nObjFileIdx = (m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].cFileIdx & 0XF0) >> 4;
nImgIdx = m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].shObj1;
m_pxTileImg[nObjFileIdx]->NewSetIndex(nImgIdx);
if ( m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shWidth != 48 ||
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight != 32 )
{
g_xMainWnd.DrawWithImageForCompClipRgn(
(nX-m_shStartViewTileX)*_CELL_WIDTH +_VIEW_CELL_X_START-m_shViewOffsetX,
(nY-m_shStartViewTileY)*_CELL_HEIGHT+_VIEW_CELL_Y_START-m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight+_CELL_HEIGHT-m_shViewOffsetY,
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shWidth,
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight,
(WORD*)m_pxTileImg[nObjFileIdx]->m_pbCurrImage,
_CLIP_WIDTH, _CLIP_HEIGHT);
return TRUE;
}
}
// 坷宏璃飘2啊 乐阑锭.
if ( m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].shObj2 != -1 )
{
nObjFileIdx = (m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].cFileIdx & 0X0F);
nImgIdx = m_pstCellInfo[nY + nX*m_stMapFileHeader.shHeight].shObj2;
m_pxTileImg[nObjFileIdx]->NewSetIndex(nImgIdx);
if ( m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shWidth != 48 ||
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight != 32 )
{
g_xMainWnd.DrawWithImageForCompClipRgn(
(nX-m_shStartViewTileX)*_CELL_WIDTH +_VIEW_CELL_X_START-m_shViewOffsetX,
(nY-m_shStartViewTileY)*_CELL_HEIGHT+_VIEW_CELL_Y_START-m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight+_CELL_HEIGHT-m_shViewOffsetY,
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shWidth,
m_pxTileImg[nObjFileIdx]->m_lpstNewCurrWilImageInfo->shHeight,
(WORD*)m_pxTileImg[nObjFileIdx]->m_pbCurrImage,
_CLIP_WIDTH, _CLIP_HEIGHT);
return TRUE;
}
}
}
return FALSE;
}
*/
/******************************************************************************************************************
窃荐疙 : CMapHandler::DrawSMTile()
累己磊 :
累己老 :
格利 :
涝仿 : INT nX
INT nY
免仿 : VOID
[老磊][荐沥磊] : 荐沥郴侩
*******************************************************************************************************************/
/*
VOID CMapHandler::DrawSMTile(INT nX, INT nY)
{
INT nObjImgIdx, nMidImgIdx;
if ( nX >= m_stMapFileHeader.wWidth || nY >= m_stMapFileHeader.wHeight || nX < 0 || nY < 0 )
return;
nObjImgIdx = (m_lpstCellInfo[nY + nX*m_stMapFileHeader.wHeight].bArea * 10000) + (m_lpstCellInfo[nY + nX*m_stMapFileHeader.wHeight].wFrImgIdx & 0x7FFF) - 1;
if (m_lpstCellInfo[nY + nX*m_stMapFileHeader.wHeight].bArea < 8 )//<---------------??????????3锅甘俊 救静搁 俊矾巢
{
nMidImgIdx = m_lpstCellInfo[nY + nX*m_stMapFileHeader.wHeight].wMidImgIdx - 1;
if ( nMidImgIdx >= 0 && nMidImgIdx < 938 && nY < m_shStartViewTileY+_VIEW_CELL_Y_COUNT )
{
m_xSMTileImg.SetIndex(nMidImgIdx);
g_xMainWnd.DrawWithImageForCompMemToMem(
(nX-m_shStartViewTileX)*_CELL_WIDTH ,
(nY-m_shStartViewTileY)*_CELL_HEIGHT,
m_xSMTileImg.m_lpstCurrWilImageInfo->shWidth,
m_xSMTileImg.m_lpstCurrWilImageInfo->shHeight,
(WORD*)m_xSMTileImg.m_pbCurrImage,
_VIEW_CELL_X_COUNT*_CELL_WIDTH, _VIEW_CELL_Y_COUNT*_CELL_HEIGHT, m_wSavedMapBuffer);
}
}
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -