예제 #1
0
//------------------------------------------------------
//
//
void CMiniGameCatchLayer::onExit()
{
	CCLayer::onExit();

	string utf81;
	CChineseCode::GB2312ToUTF_8( utf81, (char*)peteat_1[g_iCurLanguageIndex], 256 );
	
	for( int j = 0; j < m_ItemSave.size(); j ++ )
	{
		char temp[128];
		CBaseDataItem *pDataItem= g_pClientLoader->GetBaseDataItemIndex(m_ItemSave[j].itemIndex );
		sprintf( temp,utf81.c_str(),  m_ItemSave[j].count, pDataItem->itemname.c_str() );
		string rewcord = temp;
		g_pPetDataBlock->addGameMessage( GetGameDayAndTime().c_str(), rewcord.c_str() );
	}
    
    if( !g_pPetDataBlock->recordsave.isNotBeginner[2] )
    {
        g_pPetDataBlock->addItem(7, 10 );
        
        g_pPetDataBlock->recordsave.isNotBeginner[2] = true;
    }

	//g_pPetDataBlock->addGameMessage(  );
}
예제 #2
0
//-----------------------------------------------
//
//
void CFightGroundLayer::SheduleWin( ccTime tt )
{
    CFightFinish *pFightFinish = new CFightFinish( true );
    pFightFinish->init();
    pFightFinish->autorelease();
    addChild( pFightFinish, 100 );
    unscheduleAllSelectors();
    schedule( schedule_selector(CFightGroundLayer::ScheudleExit),2.0f );
    
    string strSendMail = GetGameDayAndTime() + ",";
    strSendMail = strSendMail + m_pPetLeft->GetPetData()->playername;
    
    CurlTest::ShareInstance()->SendMail( m_pPetLeft->GetPetData()->userid, m_pPetRight->GetPetData()->userid, strSendMail.c_str()  );
}
예제 #3
0
//-----------------------------------------------------------------------------
//
//
void CFightGroundLayer::upData( ccTime dt )
{
	if( m_bIsFightOver )
	{
		g_pPlayerEventCtrl->AddCounterNum( 1, SPECIAL_COUNTER_BATTLE, 0 );
		return;
	}
	if( m_iFightTurnId == m_pPetLeft->getSitId() )
	{
		m_iFightTurnId = 0;
		m_pPetLeft->Attack();
	}
	else if( m_iFightTurnId == m_pPetRight->getSitId() )
	{
		m_iFightTurnId = 0;
		m_pPetRight->Attack();
	}

    //if( m_pPetLeft->getHp() <= 0 )
    //{
    //    m_pPetLeft->setHp(10);
    //}
	if( m_pPetLeft->getHp() <= 0 )
	{
		m_pPlayer1Hp->setIsVisible(false);
		m_bIsFightOver = true;
        
        CCSize size = CCDirector::sharedDirector()->getWinSize();
        
        string path = GetGameImagesPath();
        path = path + "lose.png";
        CCSprite *pSprite = CCSprite::spriteWithFile( path.c_str() );
        addChild( pSprite, 100 );
        pSprite->setPosition( ccp( size.width/2, size.height/2 ) );
		g_pPlayerEventCtrl->AddCounterNum( 1, SPECIAL_COUNTER_BATTLE_LOSE, 0 );

		g_pPetDataBlock->recordsave.loseBattleCount++;

//		string utf81;
//		CChineseCode::GB2312ToUTF_8( utf81, (char*)fightmessage_lost[g_iCurLanguageIndex], 256 );
//
//		char buffer[256];
//		sprintf( buffer, utf81.c_str(), m_pPetRight->GetPetData()->playername.c_str(), m_pPetLeft->getName().c_str() );
//		g_pPetDataBlock->addGameMessage( GetGameDayAndTime().c_str(), buffer );

		//CFightFinish *pFightFinish = new CFightFinish( false );
		//pFightFinish->init();
		//pFightFinish->autorelease();
		//addChild( pFightFinish, 100 );
        schedule( schedule_selector(CFightGroundLayer::ScheudleExit),3.0f );
        
        s_iWincount = 0;
		return;
	}
	if( m_pPetRight->getHp() <= 0 )
	{
		m_pPlayer2Hp->setIsVisible(false);
		m_bIsFightOver = true;
		m_bIsWin = true;
        
        CCSize size = CCDirector::sharedDirector()->getWinSize();
        string path = GetGameImagesPath();
        path = path + "win.png";
        CCSprite *pSprite = CCSprite::spriteWithFile( path.c_str() );
        addChild( pSprite, 100 );
        pSprite->setPosition( ccp( size.width/2, size.height/2 ) );
		g_pPlayerEventCtrl->AddCounterNum( 1, SPECIAL_COUNTER_BATTLE_WIN, 0 );

		g_pPetDataBlock->recordsave.winBattleCount++;

		string utf81;
		CChineseCode::GB2312ToUTF_8( utf81, (char*)fightmessage_win[g_iCurLanguageIndex], 256 );

		char buffer[256];
		sprintf( buffer, utf81.c_str(), m_pPetRight->GetPetData()->playername.c_str(), m_pPetRight->getName().c_str() );
		g_pPetDataBlock->addGameMessage( GetGameDayAndTime().c_str(), buffer );
        
        schedule( schedule_selector( CFightGroundLayer::SheduleWin ),3.0f );
        
		//CChineseCode::GB2312ToUTF_8( utf81, (char*)fightplayermessage_lost[g_iCurLanguageIndex], 256 );
        //sprintf( buffer, utf81.c_str(), m_pPetLeft->GetPetData()->playername.c_str() );

        
		s_iWincount++;
        if( s_iWincount >= 2 )
        {
            string utf8;
            CChineseCode::GB2312ToUTF_8( utf8, (char*)message_kill[g_iCurLanguageIndex], 256 );
            
            sprintf( buffer, utf8.c_str(), m_pPetLeft->getName().c_str(), s_iWincount );
            g_pPetDataBlock->addGameMessage( GetGameDayAndTime().c_str(), buffer );
            
        }
		if( CCUserDefault::sharedUserDefault()->getBoolForKey( "sound" ) )
		{
            if( s_iWincount >= 5 )
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("data/audio/rampage.mp3", false);
			}
            else if( s_iWincount >= 4 )
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("data/audio/ultrakill.mp3", false);
			}
            else if( s_iWincount >= 3 )
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("data/audio/triple_kill.mp3", false);
			}
            else if( s_iWincount >= 2 )
			{
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("data/audio/Double_Kill.mp3", false);
			}
		}
		return;
	}

	
	CCRect rect( 0,0, (float)(m_iMaxHpBar) / (float)(m_pPetLeft->getMaxHp()) * m_pPetLeft->getHp(), m_iMaxHpHeight  );
	m_pPlayer1Hp->setTextureRect( rect );
	m_pPlayer1Hp->setPosition( ccp( m_iHpInitPos + ( m_iMaxHpBar - (float)(m_iMaxHpBar) / (float)(m_pPetLeft->getMaxHp()) * m_pPetLeft->getHp() ), m_pPlayer1Hp->getPosition().y ) );

	CCRect rect2( 0,0, (float)(m_iMaxHpBar) / (float)(m_pPetRight->getMaxHp()) * m_pPetRight->getHp(), m_iMaxHpHeight );
	m_pPlayer2Hp->setTextureRect( rect2 );


	CCRect rectMp( 0, 0, (float)(m_iMaxMpBar) / (float)(m_pPetLeft->getMaxMp()) * m_pPetLeft->getMp(), m_iMaxMpHeight  );
	m_pPlayer1Mp->setTextureRect( rectMp );
	m_pPlayer1Mp->setPosition( ccp( m_iMpInitPos + ( m_iMaxMpBar - (float)(m_iMaxMpBar) / (float)(m_pPetLeft->getMaxMp()) * m_pPetLeft->getMp() ), m_pPlayer1Mp->getPosition().y ) );

	CCRect rect2Mp( 0,0, (float)(m_iMaxMpBar) / (float)(m_pPetRight->getMaxMp()) * m_pPetRight->getMp(), m_iMaxMpHeight );
	m_pPlayer2Mp->setTextureRect( rect2Mp );
}