📄 datamanager.cpp
字号:
}
// story mode
m_StoryModeCount=pData.ReadShort();
if(m_StoryModeCount!=0)
{
//m_StoryModes=new StoryMode[m_StoryModeCount];
m_StoryModes = (StoryMode *)pEngine->GetMem()->GlobalMalloc(m_StoryModeCount*sizeof(StoryMode));
for(i=0;i<m_StoryModeCount;i++)
{
m_StoryModes[i].characterId=pData.ReadShort();
m_StoryModes[i].count=pData.ReadShort();
if(m_StoryModes[i].count>0)
{
//m_StoryModes[i].storyStages=new StoryStage[m_StoryModes[i].count];
m_StoryModes[i].storyStages = (StoryStage *)pEngine->GetMem()->GlobalMalloc(m_StoryModes[i].count*sizeof(StoryStage));
for(int j=0;j<m_StoryModes[i].count;j++)
{
m_StoryModes[i].storyStages[j].info=pData.ReadShort();
m_StoryModes[i].storyStages[j].competitor=pData.ReadShort();
m_StoryModes[i].storyStages[j].place=pData.ReadShort();
count=pData.ReadShort();
m_StoryModes[i].storyStages[j].words_count=count;
//m_StoryModes[i].storyStages[j].words=new Words[m_StoryModes[i].storyStages[j].words_count];
m_StoryModes[i].storyStages[j].words = (Words *)pEngine->GetMem()->GlobalMalloc(m_StoryModes[i].storyStages[j].words_count*sizeof(Words));
for(k=0;k<count;k++)
{
Words* pWrd=&(m_StoryModes[i].storyStages[j].words[k]);
pWrd->person=pData.ReadShort();
pWrd->stringId=pData.ReadShort();
}
}
}
}
}
m_StringCount=pData.ReadShort();
//Qiu Li, 2005-1-31
//m_pStringItem=new char[m_StringCount][200];
//m_pStringItem = new char*[m_StringCount];
m_pStringItem = (char **)pEngine->GetMem()->GlobalMalloc(m_StringCount*sizeof(char*));
m_StringLength = pData.ReadShort()+1;
//m_pStringBuffer = new char[m_StringLength];
m_pStringBuffer = (char *)pEngine->GetMem()->GlobalMalloc(m_StringLength*sizeof(char));
pData.ReadBlock(m_pStringBuffer, m_StringLength-1);
char *pCur = m_pStringBuffer;
for(i=0;i<m_StringCount;i++)
{
// pData.ReadString(m_pStringItem[i]);
int count = (unsigned char)*pCur;
*pCur = 0;
pCur++;
m_pStringItem[i] = pCur;
pCur += count;
}
*pCur = 0;
//Qiu Li end
//Qiu Li, 2005/1/25
SPRINTF(m_pStringItem[ID_ABOUT7], "%s", VERSION);
//Qiu Li end
pFile = NULL;
pEngine->GetMem()->StackFree(0);
// debug /////////////////
///Test();
/////////////////////////
return true;
}
int CDataManager::LoadBallRes(int index)
{
if(index<0 || index>=m_iBallCount)
return 0;
return m_pRender->GetG3d()->LoadTexture(m_pBallTexture[index], 0);
}
int CDataManager::LoadPlayerRes(int index, int clothIndex)
{
if(index<0 || index>=m_iPlayerCount)
return -1;
m_pRender->LoadModel(m_pModelFile[m_pPlayer[index].modelIndex], m_pPlayer[index].modelIndex);
return m_pRender->GetG3d()->LoadTexture(m_pPlayer[index].cloths[clothIndex]);
}
void CDataManager::LoadPlayerInfo(int index, CPlayer *pPlayer)
{
int i;
if(index<0 || index>=m_iPlayerCount)
return;
if(pPlayer==NULL)return;
//if (pPlayer->m_ballTracePos != NULL) delete [] pPlayer->m_ballTracePos;
//if (pPlayer->m_ballTraceRot != NULL) delete [] pPlayer->m_ballTraceRot;
CSimpleMemory::strcpy(pPlayer->m_name, m_pPlayer[index].name);
pPlayer->m_strength=m_pPlayer[index].power;
pPlayer->m_precision=m_pPlayer[index].precision;
pPlayer->m_rotation=m_pPlayer[index].rotation;
pPlayer->m_mentation=m_pPlayer[index].mentation;
pPlayer->m_ballIndex=m_pPlayer[index].ballIndex;
pPlayer->SetModelID(m_pPlayer[index].modelIndex);
for(i=0;i<PLAYER_ANI_COUNT;i++)
{
pPlayer->m_actionTable[i].actionStart=m_pPlayer[index].actionstart[i];
pPlayer->m_actionTable[i].actionEnd=m_pPlayer[index].actionend[i];
pPlayer->m_actionTable[i].actionInterval=m_pPlayer[index].actioninterval[i];
pPlayer->m_actionTable[i].stopFrame=m_pPlayer[index].actionkeep[i];
}
pPlayer->m_ballTraceCount=m_pPlayer[index].ballStepsCount;
//pPlayer->m_ballTracePos=new int [pPlayer->m_ballTraceCount][3];
//pPlayer->m_ballTraceRot=new int [pPlayer->m_ballTraceCount][3];
int j;
for(i=0;i<pPlayer->m_ballTraceCount;i++)
{
for(j=0;j<3;j++)
pPlayer->m_ballTracePos[i][j]=m_pPlayer[index].pballTrace[i*6+j];
for(j=0;j<3;j++)
pPlayer->m_ballTraceRot[i][j]=m_pPlayer[index].pballTrace[i*6+3+j];
}
// for(i=0;i<pPlayer->m_ballTraceCount;i++)
// DBGPRINTF("pos:%d, %d, %d",pPlayer->m_ballTracePos[i][0],pPlayer->m_ballTracePos[i][1],pPlayer->m_ballTracePos[i][2]);
//Qiu Li modify to draw decoration, 2005/2/2
//pPlayer->m_decor = new short[m_pPlayer[index].clothsCount];
for( i=0; i<m_pPlayer[index].clothsCount; i++ )
{
pPlayer->m_decor[i] = (short)m_pPlayer[index].decor[i];
}
//Qiu Li end
}
void CDataManager::LoadBallInfo(CEngine* pEngine,int index, CBall *pBall)
{
if(index<0 || index>=m_iBallCount)
return;
if(pBall==NULL)
return;
pBall->m_weight=m_pBallWeight[index];
pBall->SetTexid(m_pRender->GetG3d(), LoadBallRes(index));
if (pBall->m_Texture.m_pData == NULL)
pBall->m_Texture.m_pData = (unsigned char*)pEngine->GetMem()->HeapMalloc(pBall->m_Texture.m_w * pBall->m_Texture.m_h *2);
MEMCPY(pBall->m_Texture.m_pData, m_pRender->GetG3d()->m_pTextures[pBall->m_texid].m_pData, pBall->m_Texture.m_w * pBall->m_Texture.m_h *2);
}
int CDataManager::LoadBgRes(int index)
{
if(index<0 || index>=m_iBgCount)
return -1;
for (int i=0; i<m_pBgs[index].lightTypeCount; i++)
m_pBgs[index].lightid[i] = m_pRender->GetG3d()->LoadTexture(m_pBgs[index].lightTexName[i]);
// m_pRender->LoadModel(m_pModelFile[m_pBgs[index].skyboxModelIndex], m_pBgs[index].skyboxModelIndex);
m_pRender->LoadModel(m_pModelFile[m_pBgs[index].floorModelIndex], m_pBgs[index].floorModelIndex);
m_pRender->LoadModel(m_pModelFile[m_pBgs[index].modelIndex], m_pBgs[index].modelIndex);
if (m_pBgs[index].audienceIndex >= 0)
m_pRender->LoadModel(m_pModelFile[m_pBgs[index].audienceIndex], m_pBgs[index].audienceIndex);
if (m_pBgs[index].furnitureIndex >= 0)
m_pRender->LoadModel(m_pModelFile[m_pBgs[index].furnitureIndex], m_pBgs[index].furnitureIndex);
char str[3][20] = {"res\\envclub1.tga", "res\\envclub2.tga", "res\\envclub3.tga"};
m_pRender->GetG3d()->SetEnvTexture(m_pRender->GetG3d()->LoadTexture(str[index], 0));
//Milo 02-01 for Texture of GRABBING
return m_pRender->GetG3d()->LoadTexture(m_pBgs[index].grabTex);
}
void CDataManager::SetRender(CRender3D* pRender)
{
m_pRender=pRender;
}
#ifdef DATAMANAGER_DEBUG
void CDataManager::Test()
{
DBGPRINTF("ModelCount=%d BallCount=%d PlayerCount=%d",m_iModelCount,m_iBallCount,m_iPlayerCount);
int i,j,k;
for(i=0;i<m_iModelCount;i++)
{
DBGPRINTF("Model: file=%s",m_pModelFile[i]);
}
for(i=0;i<m_iBallCount;i++)
{
DBGPRINTF("Ball: weight=%d name=%s texture=%s",m_pBallWeight[i],m_pBallName[i],m_pBallTexture[i]);
}
for(i=0;i<m_iPlayerCount;i++)
{
DBGPRINTF("Player: name=%s",m_pPlayer[i].name);
DBGPRINTF("Player: name=%s",m_pPlayer[i].cloths[0]);
}
DBGPRINTF("String File:%s", m_StringFile);
DBGPRINTF("String Count:%d", m_StringCount);
for(i=0;i<m_StringCount;i++)
DBGPRINTF("String Item %d: %s",i,m_pStringItem[i]);
for(i=0;i<m_StoryModeCount;i++)
{
DBGPRINTF("==== StoryMode ====");
DBGPRINTF("character:%d",m_StoryModes[i].characterId);
for(int j=0;j<m_StoryModes[i].count;j++)
{
DBGPRINTF("=StoryStage=");
DBGPRINTF("type:%d",m_StoryModes[i].storyStages[j].type);
}
}
DBGPRINTF("==== CoinDeliveryInfo ====");
for(i=0;i<5;i++)
{
DBGPRINTF("==== Level %d ====",i);
for(j=0;j<m_CoinLevelRounds[i];j++)
{
DBGPRINTF("== Round %d ==",j);
for(k=0;k<m_CoinRoundCoins[i][j];k++)
{
DBGPRINTF("info:%d, type:%d, pos:%d,%d",m_Coins[i][j][k].info, m_Coins[i][j][k].type, m_Coins[i][j][k].posX, m_Coins[i][j][k].posY);
}
}
}
for(i=0;i<LANE_COUNT;i++)
{
DBGPRINTF("BG%d GrabTex:%s",i,&m_pBgs[i].grabTex);
}
}
#endif
void CDataManager::LoadSounds(CSound* pSound)
{
// pSound->loadMIDI();
for(int i=0; i< SOUND_NUMBER; ++i)
{
if(!pSound->loadMIDI(i, m_pStringItem[ID_SOUND_ROLL+i]))
return;
}
}
void CDataManager::LoadStoryMode(int PlayerId, StoryMode **pStoryMode)
{
*pStoryMode=&m_StoryModes[PlayerId];
}
void CDataManager::LoadCoinTexture()
{
m_pCoinTexture[CT_BONUS] = m_pRender->GetG3d()->LoadTexture(m_pStringItem[ID_COIN_G]);
m_pCoinTexture[CT_REVERSE] = m_pRender->GetG3d()->LoadTexture(m_pStringItem[ID_COIN_R]);
m_pCoinTexture[CT_FREEZE] = m_pRender->GetG3d()->LoadTexture(m_pStringItem[ID_COIN_F]);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -