Beispiel #1
0
void CAccountLayer::button_press(int tag)
{      
    CGameScene *pGameScene = (CGameScene *)parent();

    if (tag == 10200)     
    {                      
          pGameScene->window_closed(0);
           Root::instance()->queue_end_rendering();		
    }
    else if (tag == 10201)
    {
         CMD_C_Account Account;
         Account.wChairID = pGameScene->GetMeChairID();

         pGameScene->GetClientKernel()->SendSocketData(MDM_GF_GAME, SUB_C_ACCOUNT, &Account, sizeof(CMD_C_Account));

         DisableWindow(true);
    }
    else if (tag == 10202)
    {
        ShowWidnow(false);
    }
}
Beispiel #2
0
void CAccountLayer::draw()
{
    if (!visible_)
    {
        return;
    }

    __super::draw();

    CGameScene *pGameScene = (CGameScene *)parent();
    CClientKernel *pClientKernel = pGameScene->GetClientKernel();
    if ( !pClientKernel)
        return ;

    Point pt(position_absolute());
    Point ptDraw;
    std::ostringstream ostr;

    for (int i=0; i<4; i++)
    {
        ostr.str("");
        ostr << m_CaptureFishs[i];

        ptDraw.x_ = pt.x_ + 136+i*180;
        ptDraw.y_ = pt.y_ +104;

        DrawNumber(ostr.str(), ptDraw);
    }

    for (int i=0; i<4; i++)
    {
        ostr.str("");
        ostr << m_CaptureFishs[i+4];

        ptDraw.x_ = pt.x_ + 136+i*180;
        ptDraw.y_ = pt.y_ +104+74;

        DrawNumber(ostr.str(), ptDraw);
    }

    for (int i=0; i<4; i++)
    {
        ostr.str("");
        ostr << m_CaptureFishs[i+8];

        ptDraw.x_ = pt.x_ + 136+i*180;
        ptDraw.y_ = pt.y_ +104+148;

        DrawNumber(ostr.str(), ptDraw);
    }


     WORD wMeChairID = pGameScene->GetMeChairID();

     if (wMeChairID != INVALID_CHAIR)
     {
         int nFishGold = pGameScene->m_layRoles[wMeChairID]->GetFishGold();
         ostr.str("");
         ostr << nFishGold; 
         ptDraw.x_ = pt.x_ + 296;
         ptDraw.y_ = pt.y_ + 310;
         DrawNumber(ostr.str(), ptDraw);

         LONG lCellScore = pGameScene->m_layBuyBulletLayer->GetCellScore();

         ostr.str("");
         ostr << nFishGold*lCellScore; 
         ptDraw.x_ = pt.x_ + 500;
         ptDraw.y_ = pt.y_ + 310;
         DrawNumber(ostr.str(), ptDraw);



         const tagUserData *pUserData = pClientKernel->GetMeUserInfo();

         if (pUserData)
         {
             ostr.str("");
             ostr << 0; 
             ptDraw.x_ = pt.x_ + 240;
             ptDraw.y_ = pt.y_ + 352;
             DrawNumber(ostr.str(), ptDraw);

             ostr.str("");
             ostr << pUserData->lScore; 
             ptDraw.x_ = pt.x_ + 580;
             ptDraw.y_ = pt.y_ + 352;
             DrawNumber(ostr.str(), ptDraw);
         }



     }

     DWORD dwTime = (DWORD)time(NULL) - m_dwStartTime;

     if (dwTime >= 20)
     {
         ShowWidnow(false);
     }
     else
     {
         ostr.str("");
         ostr << 20-dwTime; 

         ptDraw.x_ = pt.x_ + 696;
         ptDraw.y_ = pt.y_ + 38;

         DrawTimer(ostr.str(), ptDraw);
     }
}
Beispiel #3
0
bool CNetLayer::NetEnd(Node *node, int tag)
{
    Point ptNet;
    Point ptTNet;
    Point ptFish;
    Size szFish;
    Point ptDifference;
    Rect rcScreen(0,0,1280,738);
    float sint, cost;


    CGameScene *pGameScene = (CGameScene *)parent();
    CNetObjectExtend *pNetObjectExtend = (CNetObjectExtend *)node->node_extend();

    if (pNetObjectExtend->wChairID == pGameScene->GetMeChairID() || pGameScene->IsAndroidLogicChairID())
    {
        CMD_C_Cast_Net CastNet;
		CastNet.wChairID = pNetObjectExtend->wChairID;
        CastNet.cbCount = 0;

        ptNet = node->position();

        Nodes::iterator j=pGameScene->m_layFishObject->child_begin();
        for (; j!=pGameScene->m_layFishObject->child_end(); ++j)
        {
			if (CastNet.cbCount >= MAX_FISH_IN_NET)
			    break;

            CFishObjectExtend *pFishObjectExtend = (CFishObjectExtend *)(*j)->node_extend();

            if (pFishObjectExtend->wID == INVALID_WORD)
                continue;

            ptFish = (*j)->position();
            szFish = pFishObjectExtend->GetFishObjectSize();

            cost = std::cosf((*j)->rotation());
            sint = std::sinf((*j)->rotation());
            ptTNet.x_ = (ptNet.x_-ptFish.x_)*cost + (ptNet.y_-ptFish.y_)*sint;
            ptTNet.y_ = -(ptNet.x_-ptFish.x_)*sint + (ptNet.y_-ptFish.y_)*cost;

            if (CFishObjectExtend::ComputeCollision(szFish.width_, szFish.height_, pNetObjectExtend->GetNetRadius(), ptTNet.x_, ptTNet.y_ ))
            {
                CastNet.FishNetObjects[CastNet.cbCount].wID = pFishObjectExtend->wID;
                CastNet.FishNetObjects[CastNet.cbCount].wRoundID = pFishObjectExtend->wRoundID;
                CastNet.FishNetObjects[CastNet.cbCount].wType = pFishObjectExtend->FishType;
                CastNet.FishNetObjects[CastNet.cbCount].dwTime = pFishObjectExtend->dwTime;

                CastNet.cbCount++;
                
            }
        }

		CClientKernel *pClientKernel = pGameScene->GetClientKernel();

		if (pClientKernel != NULL)
			pClientKernel->SendSocketData(MDM_GF_GAME, SUB_C_CAST_NET, &CastNet, sizeof(CMD_C_Cast_Net)-(MAX_FISH_IN_NET-CastNet.cbCount)*sizeof(Fish_Net_Object));
    }

    remove_child(node);

    return true;
}