コード例 #1
0
BOOL	ItemBoxManager::Remove(ObjID_t ObjID)
{	
	__ENTER_FUNCTION

	Obj_ItemBox*	pItemBox	=	GetItemBox(ObjID);
		
	Assert( pItemBox ) ;

	uint index = (uint)(pItemBox->GetItemBoxID()) ;
	Assert( index<m_Count ) ;

	Assert( m_Count > 0 ) ;
	Assert( m_pItemBoxObjID[index]==ObjID ) ;

	m_pItemBoxObjID[index] = m_pItemBoxObjID[m_Count-1] ;
	pItemBox->SetItemBoxID( INVALID_ID ) ;

	Obj_ItemBox* pNewItemBox = GetItemBox(m_pItemBoxObjID[index]);
		
	Assert( pNewItemBox ) ;
	pNewItemBox->SetItemBoxID( index ) ;
	m_Count -- ;
	Assert( m_Count>=0 ) ;
	return TRUE ;
	__LEAVE_FUNCTION
	return FALSE ;

}
コード例 #2
0
Obj_ItemBox*	ItemBoxManager::GenItemBox()
{
__ENTER_FUNCTION

	Obj_ItemBox*	pIB		=	g_pItemBoxPool->NewItemBox();

	pIB->CleanUp();


	return pIB;

__LEAVE_FUNCTION

	return NULL ;
}
コード例 #3
0
BOOL			ItemBoxManager::RemoveAllItemBox()
{
	INT iCount = m_Count;

	for(int i = 0;i<iCount;i++)
	{
		Obj_ItemBox* pItemBox = GetItemBox(m_pItemBoxObjID[0]);
		
		if(pItemBox)
		{
			pItemBox->Recycle();
		}
	}

	return TRUE;
}
コード例 #4
0
VOID		ItemBoxManager::RecycleItemBox(ObjID_t ObjID)
{
__ENTER_FUNCTION

	Obj_ItemBox*	pItemBox	=	GetItemBox(ObjID) ;
	Assert( pItemBox ) ;

	//Remove(ObjID);
	
	pItemBox->SetActiveFlag( FALSE );
	pItemBox->CleanUp();

	GetScene()->DeleteObject( pItemBox );

__LEAVE_FUNCTION
}
コード例 #5
0
ファイル: AbilityGather.cpp プロジェクト: gangzi4494/web-pap
ORESULT        AbilityGather::OnProcOver(Obj_Human* pHuman)
{
__ENTER_FUNCTION
    
    AbilityOpera* pAbilityOpera;

    pAbilityOpera = pHuman->GetAbilityOpera();
    Assert( pAbilityOpera );

    ObjID_t        ItemBoxObjID = pAbilityOpera->m_Obj;

    if( ItemBoxObjID == INVALID_ID )
    {
        Assert(FALSE) ;
    }

    Scene* pScene = pHuman->getScene();
    Assert(pScene);

    Obj* pObj = pScene->GetObjManager()->GetObj( ItemBoxObjID ) ;

    if( pObj==NULL )
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "AbilityGather: not find obj=%d", ItemBoxObjID ) ;
        return OR_INVALID_TARGET ;
    }

    Obj_ItemBox*    pItemBox = (Obj_ItemBox*)pObj;

    if( pItemBox->GetObjType()!= Obj::OBJ_TYPE_ITEM_BOX)
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "AbilityGather: Obj_ItemBox obj    =    %d\r\n  is Not class of ITEM_CLASS_BOX", ItemBoxObjID ) ;
        return OR_INVALID_TARGET ;
    }

    INT ItemBoxType = pItemBox->GetType();

    _GROW_POINT_INFO*    pGET = g_GrowPointInfoTbl.Get(ItemBoxType);
    Assert(pGET);

    if(pGET->m_ScriptID>0)
    {
        if(pScene->GetGrowPointManager()->CallScriptProcOverFunc(pGET->m_ScriptID,pHuman->GetID(),ItemBoxObjID,pScene->SceneID()))
        {
            return OnProcFailure(pHuman);
        }
        else
        {
            return OnProcSuccess(pHuman);
            
        }
    }
    else
    {
        return OnProcSuccess(pHuman);
    }
    
__LEAVE_FUNCTION

    return OR_ERROR ;
}
コード例 #6
0
ファイル: AbilityGather.cpp プロジェクト: gangzi4494/web-pap
ORESULT    AbilityGather::CanUseAbility(Obj_Human* pHuman)
{
__ENTER_FUNCTION

    Assert( pHuman );

    ORESULT res;
    res = Ability::CanUseAbility(pHuman);
    if( res != OR_OK )
    {
        return res;
    }
    AbilityOpera* pAbilityOpera;
    pAbilityOpera = pHuman->GetAbilityOpera();
    Assert( pAbilityOpera );

    ObjID_t        ItemBoxObjID = pAbilityOpera->m_Obj;

    if( ItemBoxObjID == INVALID_ID )
    {
        Assert(FALSE) ;
    }
    
    Scene* pScene = pHuman->getScene();
    Assert(pScene);

    Obj* pObj = pScene->GetObjManager()->GetObj( ItemBoxObjID ) ;

    if( pObj==NULL )
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "AbilityGatherMine: not find obj=%d", ItemBoxObjID ) ;
        return OR_INVALID_TARGET ;
    }

    Obj_ItemBox*    pItemBox = (Obj_ItemBox*)pObj;

    if( pItemBox->GetObjType()!= Obj::OBJ_TYPE_ITEM_BOX)
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "AbilityGatherMine: Obj_ItemBox obj    =    %d\r\n  is Not class of ITEM_CLASS_BOX", ItemBoxObjID ) ;
        return OR_INVALID_TARGET ;
    }

    if(!pItemBox->CanPickBox(pHuman->GetID(),pHuman->GetID()))
        return OR_FAILURE;



    INT ItemBoxType = pItemBox->GetType();

    _GROW_POINT_INFO*    pGET = g_GrowPointInfoTbl.Get(ItemBoxType);
    Assert(pGET);

    if(pGET->m_ScriptID>0)
    {
        return (OPERATE_RESULT)(pScene->GetGrowPointManager()->CallScriptOpenBoxFunc(pGET->m_ScriptID,pHuman->GetID(),ItemBoxObjID,pScene->SceneID()));
        
    }


    return OR_OK;

__LEAVE_FUNCTION

    return OR_ERROR ;
}
コード例 #7
0
ファイル: AbilityGather.cpp プロジェクト: gangzi4494/web-pap
ORESULT    AbilityGather::OnProcSuccess(Obj_Human* pHuman)
{
__ENTER_FUNCTION

    Assert(pHuman);
    AbilityOpera* pOpera    =    pHuman->GetAbilityOpera();
    Assert(pOpera);
    
    ObjID_t        TargetID    =    pOpera->m_Obj;
    AbilityID_t    AbilityID    =    pOpera->m_AbilityID;

    Assert(TargetID!=INVALID_ID);

    Obj* pObj        =   pHuman->getScene()->GetObjManager()->GetObj(TargetID);

    if(pObj->GetObjType()==Obj::OBJ_TYPE_ITEM_BOX)
    {
        Obj_ItemBox* pItemBox = static_cast<Obj_ItemBox*>(pObj);
        Assert(pItemBox);

        if(pItemBox->GetItemCount()>0)
        {
            if(pItemBox->GetOpenFlag()!=TRUE)
            {
                pItemBox->SetOpenFlag(TRUE);
            }
            
            GCBoxItemList    Msg;
            int j = 0;
            for(int i =0;i<MAX_BOXITEM_NUMBER;i++)
            {
                _ITEM* pItem = pItemBox->GetItem(i);
                Assert(pItem);

                if(pItem->IsNullType())
                    continue;

                Msg.setItemData(pItem,j);
                j++;
            }
            Msg.setItemNum(pItemBox->GetItemCount());
            Msg.setItemBoxId(pItemBox->GetID());
            Msg.setItemBoxType(pItemBox->GetType());
            pHuman->GetPlayer()->SendPacket(&Msg);
        }
        else
        {
            Scene* pScene = pHuman->getScene();
            Assert(pScene);
            INT ItemBoxType = pItemBox->GetType();
            _GROW_POINT_INFO*    pGET = g_GrowPointInfoTbl.Get(ItemBoxType);
            Assert(pGET);
            if(pGET->m_ScriptID>0)
            {
                if(pScene->GetGrowPointManager()->CallScriptRecycleFunc(pGET->m_ScriptID,pHuman->GetID(),TargetID,pScene->SceneID()))
                {
                    pItemBox->Recycle();
                }
            }

        }

        GCAbilitySucc SuccMsg;
        SuccMsg.SetAbilityID( AbilityID );
        SuccMsg.SetPrescriptionID( INVALID_ID );
        pHuman->GetPlayer()->SendPacket( &SuccMsg );
    
    }
    else
    {
        return OR_INVALID_TARGET;
    }
    return OR_OK;
__LEAVE_FUNCTION
    return OR_ERROR;
}