void ActionsDemo::backCallback(NSObject* pSender) { CCScene* s = new ActionsTestScene(); s->addChild( BackAction() ); CCDirector::sharedDirector()->replaceScene(s); s->release(); }
byte CRCrack3::TranslateWin(byte byScore, byte &byWinBitmap, byte &byChair, byte &byChair1, byte &byType, byte &byRspType, byte &byGrade, byte &byCount) { byte byWinMask = 1 << TblBitCount[byWinBitmap]; byWinBitmap |= (byChair & 1) ? byWinMask << 4 : byWinMask; byte byContract = (byChair & 1) == 0 ? CONTRACT_YES : CONTRACT_FAIL; while (byContract == CONTRACT_YES && (byChair & 1) == 0 || byContract == CONTRACT_FAIL && (byChair & 1) == 1) //完成对家 or 未完成本家 { if (m_nDepth == 1) return byContract; BackAction(byWinBitmap, byChair, byChair1, byType, byRspType, byGrade, byCount); } return CONTRACT_BKT; }
void DebugMenu::OnActivate() { float maxWidth = 0.0f; float height = m_Settings.verticalPadding; float yOffset = height; ActionList* actionList = m_Path ? &m_Path->actionList : &m_ActionList; if (m_Path) { DebugMenuItem* item = spnew DebugMenuItem(spnew BackAction(m_Path->parent), Rectangle(0.0f, 18.0f - yOffset, 0.0f, height)); m_Panel->Add(item); yOffset += height * 2.0f; maxWidth = item->GetFont().GetWidth(item->GetAction()->ToString()) * 0.5f; } for (IAction* action : *actionList) { float y = 18.0f - yOffset; DebugMenuItem* item = spnew DebugMenuItem(action, Rectangle(0.0f, y, 0.0f, height)); m_Panel->Add(item); yOffset += height * 2.0f; const Font& font = item->GetFont(); float stringWidth = font.GetWidth(item->GetAction()->ToString()) * 0.5f; if (stringWidth > maxWidth) maxWidth = stringWidth; } maxWidth += m_Settings.horizontalPadding; for (Widget* widget : m_Panel->GetWidgets()) { DebugMenuItem* item = (DebugMenuItem*)widget; Rectangle& bounds = item->GetBounds(); bounds.x = maxWidth; bounds.width = maxWidth; } const float sliderWidth = 0.75f; float sliderX = maxWidth * 2.0f + sliderWidth; for (uint i = 0; i < 4; i++) { m_Slider[i] = spnew Slider({ sliderX + i * sliderWidth * 2.0f, 9.0f, sliderWidth, 9.0f }, true); m_Panel->Add(m_Slider[i])->SetActive(false); } }
byte CRCrack3::Crack(byte byWinBitmap, byte byChair1, byte byType, byte byRspType, byte byGrade, byte byCount, byte byScore) { //破解初始化 byte byChair = 0; m_nDepth = 0; m_bGvpTag = false; //保存初始状态 SaveAction(byWinBitmap, byChair, byChair1, byType, byRspType, byGrade, byCount); //复原手牌位图 for (int i = 0; i < 4; i++) m_pRPlayer[i]->RestoreBitmap(); dword dwInterrupt = 0; while (m_nDepth < MAX_CRACK_DEPTH) { if (dwInterrupt++ >= g_dwCrackDepth) //检测中断 return INTERRUPT; byRspType = m_pRPlayer[byChair]->RspCards(byType, byRspType, byGrade, byCount); //行为应答 if (byRspType == TYPE_GVP) { //放弃操作转义 if (TranslateGvp(byChair, byChair1, byType, byRspType, byGrade, byCount)) continue; if (byType == TYPE_GVP) //无牌可出 { if (m_nDepth == 1) return (byChair & 1) ? CONTRACT_YES : CONTRACT_FAIL; BackAction(byWinBitmap, byChair, byChair1, byType, byRspType, byGrade, byCount); continue; } //获得下一个出牌的玩家 GetNextRspser(byChair, byChair1); //更新出牌类型 if (byChair == byChair1) byType = TYPE_GVP; else { byType = m_pRAction[m_nDepth - 1]->byRspType; if (byType == TYPE_GVP) byType = m_pRAction[m_nDepth - 1]->byType; byGrade = m_pRAction[m_nDepth - 1]->byGrade; byCount = m_pRAction[m_nDepth - 1]->byCount; } if (m_nDepth == 1) m_bGvpTag = true; continue; } SaveAction(byWinBitmap, byChair, byChair1, byType, byRspType, byGrade, byCount); //保存出牌行为 //获胜处理 if (!m_pRPlayer[byChair]->IsAlive()) { byte byContract = TranslateWin(byScore, byWinBitmap, byChair, byChair1, byType, byRspType, byGrade, byCount); if (byContract == CONTRACT_BKT) continue; if (byContract == CONTRACT_FAIL || byContract == CONTRACT_YES) return byContract; } //更新最后出牌者 byChair1 = byChair; //出牌操作转义 if (TranslatePut(byChair, byChair1, byType, byRspType, byGrade, byCount)) continue; //下一个出牌者 byChair = GetNextPlayer(byChair); byType = byRspType; } return CONTRACT_UNK; //无效语句 }