📄 gameproc.cpp
字号:
(FLOAT)100/255.0f);
mtrl.diffuse.a = 125/255.0f;
g_xMainWnd.Get3DDevice()->SetMaterial(&mtrl);
g_xMainWnd.Get3DDevice()->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, TRUE );
g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, TRUE);
g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
g_xMainWnd.Get3DDevice()->SetTexture(0, NULL);
g_xMainWnd.Get3DDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX, m_avBillboard, 4, NULL);
// 盔惑汗蓖.
ZeroMemory(&mtrl, sizeof(mtrl));
mtrl.diffuse.r = mtrl.diffuse.g = mtrl.diffuse.b = 0.1f;
mtrl.ambient.r = mtrl.ambient.g = mtrl.ambient.b = 1.0f;
g_xMainWnd.Get3DDevice()->SetMaterial(&mtrl);
g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, FALSE);
g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_SRCBLEND , D3DBLEND_ONE);
g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
g_xMainWnd.Get3DDevice()->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal);
g_xMainWnd.Get3DDevice()->EndScene();
}
}
g_xMainWnd.PutsHan(g_xMainWnd.GetBackBuffer(), nCenterX-sizeLen.cx/2-1, nCenterY-7, RGB( 0, 0, 0), RGB(0, 0, 0), pstItem->szItemName);
g_xMainWnd.PutsHan(g_xMainWnd.GetBackBuffer(), nCenterX-sizeLen.cx/2 , nCenterY-8, RGB(255, 255, 125), RGB(0, 0, 0), pstItem->szItemName);
break;
}
m_stMapItemList.MoveNextNode();
}
}
}
VOID CGameProcess::RenderScene(INT nLoopTime)
{
BOOL bIsMoveTime = FALSE;
static WORD wMoveTime = 0;
static DWORD dwReceiveTime = 0;
wMoveTime += nLoopTime;
m_wCurrInputDelayTime += nLoopTime;
if ( nLoopTime < 10000 ) dwReceiveTime += nLoopTime;
if ( m_wCurrInputDelayTime >= m_wInputDelayTime )
{
m_wCurrInputDelayTime = 0;
m_wInputDelayTime = 0;
}
if ( wMoveTime > 100 )
{
bIsMoveTime = TRUE;
wMoveTime = 0;
}
if ( !m_bRender && dwReceiveTime > 100000 )
{
MessageBox(g_xMainWnd.GetSafehWnd(), "肺弊柯 沥焊甫 罐绰单 角菩沁嚼聪促. 橇肺弊伐阑 辆丰钦聪促.", "", MB_OK);
PostQuitMessage(NULL);
dwReceiveTime = 0;
}
if ( m_bRender )
{
m_xLightFog.ClearSavedLightColor();
m_xMyHero.UpdateMotionState(nLoopTime, bIsMoveTime);
// 甘阑 弊赴促.
// Clear(0);
g_xMainWnd.DrawWithImagePerLineClipRgn(
m_xMap.m_rcView.left+_VIEW_CELL_X_START-m_xMap.m_shViewOffsetX,
m_xMap.m_rcView.top+_VIEW_CELL_Y_START-m_xMap.m_shViewOffsetY,
m_xMap.m_rcView.right-m_xMap.m_rcView.left,
m_xMap.m_rcView.bottom-m_xMap.m_rcView.top,
m_xMap.m_wSavedMapBuffer, _CLIP_WIDTH, _CLIP_HEIGHT);
m_pxMouseTargetActor = NULL;
CheckMappedData(nLoopTime, bIsMoveTime);
AutoTargeting();
RenderObject(nLoopTime);
RenderMapTileGrid(); //For Debug
CMagic* pxMagic;
m_xMagicList.MoveCurrentToTop();
for ( INT nCnt = 0; nCnt < m_xMagicList.GetCounter(); )
{
pxMagic = m_xMagicList.GetCurrentData();
if ( pxMagic->m_bMagicNum == _SKILL_SHOOTLIGHTEN )
{
CElecMagic* pxElecMagic = (CElecMagic*)pxMagic;;
pxElecMagic->UpdateMagic(nLoopTime);
if ( pxElecMagic->m_bActiveState == _MAGIC_FINISH )
{
m_xMagicList.DeleteCurrentNodeEx();
delete((CElecMagic*)pxElecMagic);
pxElecMagic = NULL;
}
else
{
m_xMagicList.MoveNextNode();
nCnt++;
}
}
else
{
pxMagic->UpdateMagic(nLoopTime);
if ( pxMagic->m_bActiveState == _MAGIC_FINISH )
{
m_xMagicList.DeleteCurrentNodeEx();
delete((CMagic*)pxMagic);
pxMagic = NULL;
}
else
{
m_xMagicList.MoveNextNode();
nCnt++;
}
}
}
if ( m_bShowMist ) m_xMist.ProgressMist();
if ( m_bShowSnow )
{
m_xSnow.UpdateSystem(nLoopTime);
m_xSnow.RenderSystem(g_xMainWnd.Get3DDevice());
}
if ( m_bShowRain )
{
m_xRain.UpdateSystem(nLoopTime);
m_xRain.RenderSystem(g_xMainWnd.Get3DDevice());
}
m_xFlyingTail.UpdateSystem(nLoopTime);
m_xFlyingTail.RenderSystem(g_xMainWnd.Get3DDevice());
m_xSmoke.UpdateSystem(nLoopTime);
m_xSmoke.RenderSystem(g_xMainWnd.Get3DDevice());
// m_xElec.UpdateElec(400, 300, 0, 0);
// m_xElec.RenderElec(g_xMainWnd.Get3DDevice());
m_xLightFog.ShowLightFog();
m_xMyHero.ShowMessage(nLoopTime);
m_xMyHero.DrawHPBar();
if ( m_xActorList.GetCounter() != 0 )
{
m_xActorList.MoveCurrentToTop();
CActor* pxActor;
for ( INT nCnt = 0; nCnt < m_xActorList.GetCounter(); nCnt++ )
{
pxActor = m_xActorList.GetCurrentData();
switch ( pxActor->m_stFeature.bGender )
{
case _GENDER_MAN:
case _GENDER_WOMAN:
{
CHero* pxHero;
pxHero = (CHero*)pxActor;
pxHero->ShowMessage(nLoopTime);
pxHero->DrawHPBar();
}
break;
case _GENDER_NPC:
case _GENDER_MON:
{
// pxActor->ShowMessage(nLoopTime);
pxActor->DrawHPBar();
}
break;
}
m_xActorList.MoveNextNode();
}
}
DropItemShow();
// RenderShine(nLoopTime);
if ( m_xMagicList.GetCounter() != 0 )
{
m_xMagicList.MoveCurrentToTop();
CMagic* pxMagic;
for ( INT nCnt = 0; nCnt < m_xMagicList.GetCounter(); nCnt++ )
{
pxMagic = m_xMagicList.GetCurrentData();
if ( pxMagic->m_bMagicNum == _SKILL_SHOOTLIGHTEN )
{
CElecMagic* pxElecMagic = (CElecMagic*)pxMagic;
pxElecMagic->DrawMagic();
}
else
pxMagic->DrawMagic();
m_xMagicList.MoveNextNode();
}
}
if ( m_pxMouseTargetActor )
{
if ( m_pxMouseOldTargetActor != m_pxMouseTargetActor )
{
if ( !m_pxMouseTargetActor->m_szName[0] )
g_xClientSocket.SendQueryName(m_pxMouseTargetActor->m_dwIdentity, m_pxMouseTargetActor->m_wPosX, m_pxMouseTargetActor->m_wPosY);
}
m_pxMouseOldTargetActor = m_pxMouseTargetActor;
m_pxMouseTargetActor->DrawName();
//m_pxMouseTargetActor->DrawHPBar();
}
if ( m_wNPCWndPosX && m_wNPCWndPosY && ( abs(m_wNPCWndPosX-m_xMyHero.m_wPosX) > 5 || abs(m_wNPCWndPosY-m_xMyHero.m_wPosY) > 5) )
{
CloseNPCWindow();
}
m_xInterface.RenderInterface(nLoopTime, m_ptMousePos);
ShowStatus(0, 0);
}
else
Clear(0);
//g_xMainWnd.DrawWithGrayBackBuffer();
m_xNotice.RenderMessageBox(nLoopTime);
}
VOID CGameProcess::CloseNPCWindow()
{
if ( m_xInterface.m_xNPCWnd.GetGameWndActive() )
{
m_xInterface.DeleteWindowToList(_WND_ID_NPCCHAT);
m_xInterface.m_xNPCWnd.SetGameWndActive(FALSE);
m_wNPCWndPosX = m_wNPCWndPosY = 0;
}
}
BOOL CGameProcess::RenderShine(INT nLoopTime)
{
DWORD dwCurrTick = timeGetTime();
if ( dwCurrTick - m_dwLastShineTick > 5000 )
{
m_bShowShine = TRUE;
m_dwLastShineTick = dwCurrTick;
m_wShineCurrDelay = 0;
m_bCurrShineFrame = 0;
}
m_wShineCurrDelay += nLoopTime;
if ( m_wShineCurrDelay > 120 )
{
m_bCurrShineFrame++;
m_wShineCurrDelay = 0;
if ( m_bCurrShineFrame > 9 )
{
m_bCurrShineFrame = 0;
m_bShowShine = FALSE;
}
}
if ( g_xMainWnd.Get3DDevice() && m_bShowShine )
{
if( SUCCEEDED(g_xMainWnd.Get3DDevice()->BeginScene()) )
{
D3DVECTOR vTrans;
D3DMATRIX matTrans;
D3DMATRIX matScale;
D3DMATRIX matRot;
D3DMATRIX matWorld;
D3DMATRIX matTempWorld;
D3DMATRIX matWorldOriginal;
g_xMainWnd.Get3DDevice()->GetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal);
D3DMATERIAL7 mtrl;
CWHWilImageData* pxShineImg = &m_xImage.m_xImageList[_IMAGE_PROGUSE];
if ( pxShineImg->NewSetIndex(m_bCurrShineFrame+40) )
{
if ( m_stMapItemList.GetCounter() != 0 )
{
m_stMapItemList.MoveCurrentToTop();
LPGROUNDITEM pstItem;
for ( INT nCnt = 0; nCnt < m_stMapItemList.GetCounter(); nCnt++ )
{
pstItem = m_stMapItemList.GetCurrentData();
/* INT nCenterX = (pstItem->shTileX-m_xMap.m_shStartViewTileX)*_CELL_WIDTH +_VIEW_CELL_X_START-m_xMap.m_shViewOffsetX;
INT nCenterY = (pstItem->shTileY-m_xMap.m_shStartViewTileY)*_CELL_HEIGHT+_VIEW_CELL_Y_START-m_xMap.m_shViewOffsetY;
*/ INT nCenterX = (pstItem->shTileX-m_xMap.m_shStartViewTileX)*_CELL_WIDTH +_VIEW_CELL_X_START-m_xMap.m_shViewOffsetX+_CELL_WIDTH /2;
INT nCenterY = (pstItem->shTileY-m_xMap.m_shStartViewTileY)*_CELL_HEIGHT+_VIEW_CELL_Y_START-m_xMap.m_shViewOffsetY+_CELL_HEIGHT/2;
g_xMainWnd.Get3DDevice()->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal);
vTrans.x = (FLOAT) nCenterX-400;
vTrans.y = (FLOAT)-nCenterY+300;
vTrans.z = 0;
D3DUtil_SetTranslateMatrix(matTrans, vTrans);
D3DUtil_SetScaleMatrix(matScale, (FLOAT)pxShineImg->m_lpstNewCurrWilImageInfo->shWidth, (FLOAT)pxShineImg->m_lpstNewCurrWilImageInfo->shHeight, 0.0f);
D3DMath_MatrixMultiply(matWorld, matScale, matTrans);
g_xMainWnd.Get3DDevice()->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld);
if ( m_lpddsShineTextr[m_bCurrShineFrame] )
g_xMainWnd.Get3DDevice()->SetTexture(0, m_lpddsShineTextr[m_bCurrShineFrame]);
D3DUtil_InitMaterial(mtrl, (FLOAT)255/255.0f, (FLOAT)255/255.0f, (FLOAT)255/255.0f);
mtrl.diffuse.a = 1/255.0f;
g_xMainWnd.Get3DDevice()->SetMaterial(&mtrl);
SetBlendRenderState(g_xMainWnd.Get3DDevice(), _BLEND_LIGHTINV, mtrl);
g_xMainWnd.Get3DDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX, m_avBillboard, 4, NULL);
// 盔惑汗蓖.
ZeroMemory(&mtrl, sizeof(mtrl));
mtrl.diffuse.r = mtrl.diffuse.g = mtrl.diffuse.b = 0.1f;
mtrl.ambient.r = mtrl.ambient.g = mtrl.ambient.b = 1.0f;
g_xMainWnd.Get3DDevice()->SetMaterial(&mtrl);
ResetBlendenderState(g_xMainWnd.Get3DDevice());
g_xMainWnd.Get3DDevice()->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal);
m_stMapItemList.MoveNextNode();
}
}
}
g_xMainWnd.Get3DDevice()->EndScene();
return S_OK;
}
}
return E_FAIL;
}
VOID CGameProcess::RenderObject(INT nLoopTime)
{
INT nStartX, nStartY, nObjFileIdx, nImgIdx, nArrayNum, nObjCnt;
BOOL bFocused = FALSE;
BOOL bLongObj = FALSE;
BOOL bBlend = FALSE;
BOOL bDrawShadow = TRUE;
m_xMap.SetAniTileFrame(nLoopTime);
// 48*32 鸥老屈 坷宏璃飘 弊府扁.
for ( INT nYCnt = m_xMap.m_shStartViewTileY-4; nYCnt < m_xMap.m_shStartViewTileY+_VIEW_CELL_Y_COUNT+6; nYCnt++ )
{
for ( INT nXCnt = m_xMap.m_shStartViewTileX-4; nXCnt < m_xMap.m_shStartViewTileX+_VIEW_CELL_X_COUNT+6; nXCnt++ )
{
if ( nYCnt >= m_xMap.m_stMapFileHeader.shHeight )
break;
if ( nXCnt >= m_xMap.m_stMapFileHeader.shWidth || nXCnt < 0 || nYCnt < 0 )
continue;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Test : 堡盔阑 困秦辑 -4何磐 +5鳖瘤狼 康开阑 歹 棱绰促.
LIGHTINFO stLight = m_xMap.GetTileLightInfo(nXCnt, nYCnt);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -