⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slotmanager.cpp

📁 奇迹世界 部分源代码奇迹世界 部分源代码奇迹世界 部分源代码
💻 CPP
字号:
#include "StdAfx.h"
#include ".\slotmanager.h"
#include ".\Player.h"
#include "InventorySlotContainer.h"
#include "EquipmentSlotContainer.h"
#include "WarehouseSlotContainer.h"
#include "TempStoreSlotContainer.h"
#include "SkillSlotContainer.h"
#include "QuickSlotContainer.h"
#include "SCQuickStyleSlotContainer.h"

SlotManager::SlotManager(void):	
m_pPlayer(NULL)
{
	m_pSlotContainer[SI_INVENTORY]		= new CInventorySlotContainer();
	m_pSlotContainer[SI_TEMPINVENTORY]	= new CTempStoreSlotContainer();
	m_pSlotContainer[SI_EQUIPMENT]		= new CEquipmentSlotContainer();
	m_pSlotContainer[SI_WAREHOUSE]		= new CWarehouseSlotContainer();
	m_pSlotContainer[SI_SKILL]			= new CSkillSlotContainer();
	m_pSlotContainer[SI_QUICK]			= new QuickSlotContainer();
	m_pSlotContainer[SI_STYLE]			= new SCQuickStyleSlotContainer();
	m_pSlotContainer[SI_STYLE]->Init(MAX_STYLE_SLOT_NUM,SI_STYLE);			//< 惑加罐瘤 臼绊 荤侩窍扁 困秦
}

SlotManager::~SlotManager(void)
{
	SAFE_DELETE( m_pSlotContainer[SI_INVENTORY] );
	SAFE_DELETE( m_pSlotContainer[SI_TEMPINVENTORY] );
	SAFE_DELETE( m_pSlotContainer[SI_EQUIPMENT] );
	SAFE_DELETE( m_pSlotContainer[SI_WAREHOUSE] );
	SAFE_DELETE( m_pSlotContainer[SI_SKILL] );
	SAFE_DELETE( m_pSlotContainer[SI_QUICK] );
	SAFE_DELETE( m_pSlotContainer[SI_STYLE] );
}

VOID SlotManager::Release()
{
}


VOID SlotManager::Init( Player * pPlayer )
{
	m_pPlayer = pPlayer;	
	m_pSlotContainer[SI_INVENTORY]->ClearAll();
	m_pSlotContainer[SI_TEMPINVENTORY]->ClearAll();
	m_pSlotContainer[SI_EQUIPMENT]->ClearAll();
	m_pSlotContainer[SI_WAREHOUSE]->ClearAll();
	m_pSlotContainer[SI_SKILL]->ClearAll();
	m_pSlotContainer[SI_QUICK]->ClearAll();
	m_pSlotContainer[SI_STYLE]->ClearAll();

	(static_cast<CEquipmentSlotContainer *>(m_pSlotContainer[SI_EQUIPMENT]))->SetPlayer( pPlayer );
	(static_cast<CInventorySlotContainer *>(m_pSlotContainer[SI_INVENTORY]))->SetPlayer( pPlayer );
	(static_cast<CWarehouseSlotContainer *>(m_pSlotContainer[SI_WAREHOUSE]))->SetPlayer( pPlayer );
	(static_cast<CTempStoreSlotContainer *>(m_pSlotContainer[SI_TEMPINVENTORY]))->SetPlayer( pPlayer );
	
}

BOOL SlotManager::IsEmpty( SLOTIDX Index, POSTYPE pos )
{
	ASSERT( Index < SI_MAX );
	return m_pSlotContainer[Index]->IsEmpty( pos );
}


SCSlotContainer * SlotManager::GetSlotContainer( SLOTIDX Index )
{
	ASSERT( Index < SI_MAX );
	return m_pSlotContainer[Index];
}

BOOL SlotManager::ValidPos( SLOTIDX atIndex, POSTYPE atPos, BOOL bEmptyCheck )
{
	if( atIndex >= SI_MAX )
		return FALSE;

	SCSlotContainer * pAtContainer	= GetSlotContainer( atIndex );

	if( pAtContainer == NULL )
		return FALSE;

	if( !pAtContainer->ValidState() )
			return FALSE;

	if( !pAtContainer->ValidPos(atPos) )
		return FALSE;

	// 遏咯何 眉农
	if( pAtContainer->IsLocked(atPos) )
		return FALSE;

	if( bEmptyCheck && pAtContainer->IsEmpty( atPos ) )
		return FALSE;

	return TRUE;
}

BOOL SlotManager::ValidContainer( SLOTIDX AtIndex )
{
	SCSlotContainer * pAtContainer	= GetSlotContainer( AtIndex );

	if( pAtContainer == NULL )
		return FALSE;

	if( !pAtContainer->ValidState() )
		return FALSE;

	return TRUE;
}

BOOL SlotManager::ValidState()
{
	if( !m_pPlayer ) return FALSE;
	if( !m_pPlayer->GetField()) return FALSE;
	if( m_pPlayer->IsDead()) return FALSE;

	return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -