bool Bejeweled::SwapAllowed(Jewel* a,Jewel* b) { // only allow horizontal movement if(a->y != b->y && a->x != b->x) { return false; } // Only allow swapping adjacent items if(abs(a->x - b->x) > 1) { // horizontal return false; } if(abs(a->y - b->y) > 1) { // vertical return false; } // Exchange types temporarily std::swap(grid[a->x][a->y]->type,grid[b->x][b->y]->type); // Now demand a combination of the new positions bool result = (FindCombo(a->x,a->y) || FindCombo(b->x,b->y)); // And exchange back std::swap(grid[a->x][a->y]->type,grid[b->x][b->y]->type); return result; }
//-----------------------------------------------------------------------------// // 에니메이션 찾기 // pCurAct : 현재 행동 상태 // Key : 눌려진 키 // PrevKey : 전에 누른키 // ElapseTime : 전에 키를 누른 시간이후 경과된 시간 //-----------------------------------------------------------------------------// SActInfo* CCharacter::FindComboAnimation( SActInfo *pCurAct, int Key, int PrevKey, int ElapseTime ) { SCombo *pcombo = NULL; // debug용 // 행동이 설정되어 있지 않다면 루트에서 검색한다. SActInfo *pact = NULL; if( !pCurAct || (0 == pCurAct->nextcount) ) { pcombo = FindCombo( m_State, Key, PrevKey, ElapseTime ); if( !pcombo ) { strcpy_s( m_ComboTrace, sizeof(m_ComboTrace), "not found" ); return NULL; } sprintf_s( m_ComboTrace, sizeof(m_ComboTrace), "%6x <%d>", m_State, pcombo->id ); pact = &pcombo->act; } else { // 다음 행동 찾기 for( int i=0; i < pCurAct->nextcount; ++i ) { if( IsCorrectAction(pCurAct->next[ i], Key, m_PrevKey, ElapseTime) ) { pact = pCurAct->next[ i]; char buf[ 16]; sprintf_s( buf, sizeof(buf), "-%d", pact->id ); strcat_s( m_ComboTrace, sizeof(m_ComboTrace), buf ); // g_Dbg.Console( "%d %d %d\n", pCurAct->next[ i]->stime, pCurAct->next[ i]->etime, ElapseTime ); break; } } } if( !pact ) { /* // 못찾으면 버그다 --;; // Debugging Code g_Dbg.Console( "bug name: %s, state: %d, Key: %x\n", m_Name, m_State, Key ); if( pcombo ) { g_Dbg.Console( "root: %x, %x, btn: %x, ani: %s\n", pcombo->cur_state, pcombo->next_state, pcombo->act.btn[0], pcombo->act.ani ); } if( m_pCurAct ) { g_Dbg.Console( "next: %d, cur_ani: %s, cur_btn: %x, cur_elapse: %d \n", pCurAct->nextcount, pCurAct->ani, pCurAct->btn[0], ElapseTime ); } else { g_Dbg.Console( "CurAct: NULL, %d \n", ElapseTime ); } /**/ return NULL; } return pact; }