void CPlayer::process(double eTime) { //플레이어가 없다면 리턴 if(playMode==NONE) return; //살아있는 동안 if(isAlive) { if(playMode==PERSON) { eventProcess(eTime); keyboardProcess(eTime);//키보드나 시간에 따른 처리를 한다. } else networkProcess(eTime); //네트워크 관련 처리를 한다. } }
bool MainScene::init() { if (!Layer::init()) return false; size = Director::getInstance()->getVisibleSize(); createBackground(); createCloud(); createMouse(); createProp(); createCucrbit(); createWeather(); eventProcess(); initCucurbit(); createProgress(); createProgressBlood(); LoadingScene::loadData(); if (hudLayer != nullptr) hudLayer->updateIQ(); scheduleProcess(); isHold = false; isFall = false; isAction = false; isJump = false; isSkateboardHit = false; isSkateboardFinishAction = false; isSkateboard = false; isSholvePropChose = false; mouseFallingSnare = nullptr; skateboard = nullptr; snares.clear(); return true; }
void cBuilder::parseInput() { sObjectPart *part = 0; sPlayerInput *input = mInput->inputGet(0); bool update = false; // Get the current selected 'part' of the object if(mCurrentObject) part = mCurrentObject->partGet(); // Left if(input->mLeft) { if( part && mDragMode ) { switch( part->mDragDirection ) { case eDirectionLeft: part->mLength++; break; case eDirectionRight: part->mLength--; break; default: break; } } else mCursorX -= 4; update = true; } // Right if(input->mRight) { if( part && mDragMode ) { switch( part->mDragDirection ) { case eDirectionLeft: part->mLength--; break; case eDirectionRight: part->mLength++; break; default: break; } } else mCursorX += 4; update = true; } // Down if(input->mDown) { if( part && mDragMode ) { switch( part->mDragDirection ) { case eDirectionDown: part->mLength++; break; case eDirectionUp: part->mLength--; break; default: break; } } else mCursorY += 8; update = true; } // Up if(input->mUp) { if( part && mDragMode ) { switch( part->mDragDirection ) { case eDirectionDown: part->mLength--; break; case eDirectionUp: part->mLength++; break; default: break; } } else mCursorY -= 8; update = true; } // if(part && ((int) part->mLength) < 1) part->mLength = 1; // Button if(input->mButton) { eventProcess( true ); if( part && part->mDrags == true ) { if( mDragMode == false ) mDragMode = true; else { mDragMode = false; if(mLinkMode) { if(mOriginalObject) { mOriginalObject->mLinkedSet( findItemIndex( mCurrentObject ) ); mOriginalObject->mLinked2Set( mCurrentRoom->mNumber ); } mSearchObject = eObjectNone; mLinkMode = false; mCurrentObject = 0; } else if(mCurrentObject) { mCurrentObject->partPlace(); } } } else { mDragMode = false; if(mLinkMode) { if(mOriginalObject) { mOriginalObject->mLinkedSet( findItemIndex( mCurrentObject ) ); mOriginalObject->mLinked2Set( mCurrentRoom->mNumber ); } mSearchObject = eObjectNone; mLinkMode = false; mCurrentObject = 0; } else if(mCurrentObject) { mCurrentObject->partPlace(); } } update = true; } // ESC: Quit builder if( mInput->restoreGet() ) { mTest = false; mQuit = true; return; } // F1: Save Castle To Disk if( mInput->runStopGet() ) castleSaveToDisk(); if( mInput->f3Get() ) { mapBuilder(); update = true; } // F4: Quit builder in test castle mode if( mInput->f4Get() ) { mTest = true; mQuit = true; } // Check cursor position to see if its outside screen range int downWidth = 1; int downHeight = 1; if(mCurrentObject) { downHeight= mCurrentObject->partGet()->mCursorHeight; downWidth = mCurrentObject->partGet()->mCursorWidth; } downHeight *= 8; downWidth *= 4; // Cursor minimum and maximums if( (mCursorX + downWidth) > 0xB0) mCursorX = 0xB0 - downWidth; if( mCursorX < 0x10 ) mCursorX = 0x10; if( mCursorY > 0xF0 ) mCursorY = 0; if( (mCursorY + downHeight) > 0xC8 ) mCursorY = 0xC8 - downHeight; // Does the cursor actually need updating if(update) cursorObjectUpdate(); }
void CPlayer::networkProcess(double nowTime) { bool value; int i,j,temp; bool isDropped=false; int deletedLine; //EnterCriticalSection(&criticalSection); //블록을 움직여야 하고 특정 시간이 지난 경우(너무 빨리 놓는 일 없게) if(isAutoMoving) { int xx=3; int tt=0; if(nowTime-messageSendedTime>CState_CustomSetting::GetLimitRespondTime()) { // MYTRACE("[%d]AUTUMOVE:%d %f %f",playerNum,isAutoMoving?1:0,nowTime-messageSendedTime,CState_CustomSetting::GetLimitRespondTime()); double remainedProcessTime=nowTime-messageSendedTime-CState_CustomSetting::GetLimitRespondTime(); int iteration=remainedProcessTime/CState_CustomSetting::GetAutoMoveDelay(); if(!decisionInfo.useHold) //홀드 사용안하는 경우 { //벽에 부딪힌다거나 놓을 수 없는경우 if(board.chkBlock(decisionInfo.posX,0,CBlockMgr::getBlock(playerNum,playInfo.turnNum),decisionInfo.turn)!=CBoard::ONNOTHING) { MYTRACE("[%d]### Death by collision (posX=%d turn=%d turnNum=%d blockNum=%d)",playerNum,decisionInfo.posX,decisionInfo.turn,playInfo.turnNum, CBlockMgr::getBlock(playerNum,playInfo.turnNum)); setDead(); //죽는다. return; } } for(i=0;i<iteration;i++) { if(decisionInfo.useHold)//홀드 사용한 경우 { if(playInfo.isOnHold) //사용할수 없는데 사용한 경우 { game.ogg.Play(OGG_HOLDFAIL); setDead(); //죽는다. MessageBox(NULL,L"Invalid use of 'Hold'",L"Rule violation",MB_OK); MYTRACE("[%d]### Death by invalid use of 'Hold'(Rule violation)(blockNum=%d)",playerNum, CBlockMgr::getBlock(playerNum,playInfo.turnNum)); return; } else { playInfo.holdCount++; playInfo.isOnHold=TRUE; game.ogg.Play(OGG_HOLD); if(playInfo.holdNum==0) { playInfo.holdNum=CBlockMgr::getBlock(playerNum,playInfo.turnNum); setNextBlock(nowTime); } else { int holdBlock=CBlockMgr::getBlock(playerNum,playInfo.turnNum); CBlockMgr::setBlock(playerNum,playInfo.turnNum,playInfo.holdNum); playInfo.holdNum=holdBlock; playInfo.turnNum--; setNextBlock(nowTime); //다음 메시지를 받도록 한다. } } isAutoMoving=false; isMessageWait=false; isMessageReceived=false; break; } else //홀드 사용이 아닌 경우 { if(decisionInfo.posX-xx<0) xx--; else if(decisionInfo.posX-xx>0) xx++; else if(decisionInfo.turn-tt<0) tt--; else if(decisionInfo.turn-tt>0) tt++; else { //원하는 위치로 되었으면 isDropped=true; isAutoMoving=false; isMessageWait=false; isMessageReceived=false; break; } } } } //현재의 블록 움직임 설정 playInfo.nowXPos=xx; playInfo.nowYPos=0; playInfo.nowTurn=tt; } else { if(isMessageWait) //응답을 기다리는 중이라면 { if(isMessageReceived) //응답을 받았다면 { //줄 높이기 이벤트를 처리한다. eventProcess(nowTime); isMessageWait=false; isAutoMoving=true; isMessageReceived=false; MYTRACE("[%d]RECEIVED(useHold:%d posX:%d turn:%d)",playerNum,decisionInfo.useHold,decisionInfo.posX,decisionInfo.turn); //메시지를 설정한다 if(((WCHAR*)decisionInfo.message)[0]!=NULL) //null이 아니면(바꿔야 하는 상황이면) { memcpy(message,(char*)decisionInfo.message,sizeof(message)); } } } else //요청을 해야할 때라면 { MYTRACE("[%d]REQUEST:start",playerNum); sendRequestMessage(); isMessageWait=true; MYTRACE("[%d]REQUEST:end",playerNum); messageSendedTime=nowTime; } } if(isDropped) { playInfo.isOnHold=FALSE; game.ogg.Stop(OGG_HARDDROP);game.ogg.Play(OGG_HARDDROP); //블럭을 놓는다. board.putBlock(playInfo.nowXPos,playInfo.nowYPos,CBlockMgr::getBlock(playerNum,playInfo.turnNum),playInfo.nowTurn); //꽉찬 줄을 지운다. if((deletedLine=board.deleteFilledLine())>0) { playInfo.lineDeletionCount+=deletedLine; switch(deletedLine) { case 1: game.ogg.Stop(OGG_SINGLE);game.ogg.Play(OGG_SINGLE,false); playInfo.isBackToBack=FALSE; break; case 2: game.ogg.Stop(OGG_DOUBLE);game.ogg.Play(OGG_DOUBLE,false); playInfo.isBackToBack=FALSE; if(targetPlayer!=NULL) targetPlayer->getEventQueue()->push_back(makePushEvent(1,false));//old 0 break; case 3: game.ogg.Stop(OGG_TRIPLE);game.ogg.Play(OGG_TRIPLE,false); playInfo.isBackToBack=FALSE; if(targetPlayer!=NULL) targetPlayer->getEventQueue()->push_back(makePushEvent(2,false));//old 1 break; case 4: if(playInfo.isBackToBack) { game.ogg.Stop(OGG_BACKTOBACK_TETRIS);game.ogg.Play(OGG_BACKTOBACK_TETRIS); if(targetPlayer!=NULL) targetPlayer->getEventQueue()->push_back(makePushEvent(5,false));//old 4 } else { game.ogg.Stop(OGG_TETRIS);game.ogg.Play(OGG_TETRIS); if(targetPlayer!=NULL) targetPlayer->getEventQueue()->push_back(makePushEvent(4,false));//old 3 } playInfo.isBackToBack=TRUE; break; } //콤보 수 증가. playInfo.nowCombo++; //콤보에 따른 라인 추가 if(playInfo.nowCombo>=3 && playInfo.nowCombo<=4) { if(targetPlayer!=NULL) targetPlayer->getEventQueue()->push_back(makePushEvent(1,false)); }else if(playInfo.nowCombo>=5 && playInfo.nowCombo<=6){ if(targetPlayer!=NULL) targetPlayer->getEventQueue()->push_back(makePushEvent(2,false)); }else if(playInfo.nowCombo>=7 && playInfo.nowCombo<=8){ if(targetPlayer!=NULL) targetPlayer->getEventQueue()->push_back(makePushEvent(3,false)); }else if(playInfo.nowCombo>=9){ if(targetPlayer!=NULL) targetPlayer->getEventQueue()->push_back(makePushEvent(4,false)); } //콤보 음성효과 switch(playInfo.nowCombo) { case 0: case 1:break; case 2:game.ogg.Stop(OGG_COMBO1);game.ogg.Play(OGG_COMBO1);break; case 3:game.ogg.Stop(OGG_COMBO2);game.ogg.Play(OGG_COMBO2);break; case 4:game.ogg.Stop(OGG_COMBO3);game.ogg.Play(OGG_COMBO3);break; case 5:game.ogg.Stop(OGG_COMBO4);game.ogg.Play(OGG_COMBO4);break; case 6:game.ogg.Stop(OGG_COMBO5);game.ogg.Play(OGG_COMBO5);break; case 7:game.ogg.Stop(OGG_COMBO6);game.ogg.Play(OGG_COMBO6);break; case 8:game.ogg.Stop(OGG_COMBO7);game.ogg.Play(OGG_COMBO7);break; default:game.ogg.Stop(OGG_COMBO8);game.ogg.Play(OGG_COMBO8);break; } //콤보 애니메이션 if(playInfo.nowCombo>1) { if(playInfo.nowCombo<18) game.effectCollection.insertEffect(ANI_COMBO2+playInfo.nowCombo-2,CBoard::boardPosition[playerNum].x+30,270,nowTime); else game.effectCollection.insertEffect(ANI_COMBOWOW,CBoard::boardPosition[playerNum].x+30,270,nowTime); } //터진 것에 대한 effect를 준다 for(i=0;i<21;i++) { if(board.deletedLine[i]) //지워진 라인에 대해서 effect를 준다. { game.effectCollection.insertEffect(ANI_BOMB,CBoard::boardPosition[playerNum].x,CBoard::boardPosition[playerNum].y+i*22,nowTime); game.effectCollection.insertEffect(ANI_BOMB,CBoard::boardPosition[playerNum].x+64,CBoard::boardPosition[playerNum].y+i*22,nowTime); game.effectCollection.insertEffect(ANI_BOMB,CBoard::boardPosition[playerNum].x+128,CBoard::boardPosition[playerNum].y+i*22,nowTime); } } } else //라인이 지워지지 않았다면 { playInfo.nowCombo=0; //콤보 초기화. if(CBlockMgr::getBlock(playerNum,playInfo.turnNum)==5) playInfo.isBackToBack=FALSE; } setNextBlock(nowTime); playInfo.nowXPos=3; playInfo.nowYPos=0; playInfo.nowTurn=0; } //LeaveCriticalSection(&criticalSection); }