Exemple #1
0
VOID CUIWindowItem::LoadWindow(VOID)
{
	KLAssert(m_pWindow == NULL);
	if(m_bLayoutLoaded) return;

	//----------------------------------------------------------------------------
	//加载布局文件
	m_pWindow = CEGUI::WindowManager::getSingleton().loadWindowLayout(m_strLayoutFileName, "", "", 
		callbackProperty);
	KLAssert(m_pWindow);
	//初始状态:隐藏
	m_pWindow->hide();
	CUIWindowMng::GetClientScreen()->addChildWindow(m_pWindow);

	//注册控件
	_RegisterControlToScript(m_pWindow);

	//---------------------------------------
	//执行其中的***_OnLoad函数
	CHAR szTemp[MAX_PATH] = {0};
	_snprintf(szTemp, MAX_PATH, "%s_OnLoad", m_strWindowName.c_str());
	m_pScriptEnv->DoFunction(szTemp);

	m_bLayoutLoaded = TRUE;
}
// 把一个物体放到指定得摄影机位置
void CFakeObjectEntityManager::CreateObject(LPCTSTR szObjName, CObjEntityActor* pNode, CObjEntityActor* pAttachNode, LPCTSTR szCameraName, int nTexWidth, int nTexHeight, LPCTSTR szBackgroundName)
{
	// 先根据该fake object的名称来获取摆放位置
	m_fvPosition = Ogre::Vector3(_GetFakeObjPos(szObjName), 10000.f, 0.f);

	//物体不存在,创建新的渲染环境
	FakeObjectMap::iterator it = _GetFakeNode(szObjName, pNode, szCameraName, nTexWidth, nTexHeight, szBackgroundName);

	if(it == m_mapObject.end()) return;

	it->second.pEntityNode = pNode;
	it->second.pAttachEntityNode = pAttachNode;
	//将需要渲染的实体放入渲染环境中

	// 如果骑在马上的,要设置马的位置,把人的位置复位
	Fairy::LogicModel* modelImpl = pNode->GetActorImpl();

	if (modelImpl->isAttached())
	{
		Fairy::LogicModel* parentModel = modelImpl->getAttachModel();

		KLAssert (parentModel);

		modelImpl->setPosition(Ogre::Vector3(0.0f, 0.0f, 0.0f));

		parentModel->setPosition(Ogre::Vector3(m_fvPosition.x, m_fvPosition.y, m_fvPosition.z));
		parentModel->setVisible(true);
	}
	else
		pNode->SetGfxPosition(fVector3(m_fvPosition.x, m_fvPosition.y, m_fvPosition.z));

	//初始就显示,在运行过程中会一直保持visible为true的状态
	pNode->SetVisible(TRUE);
}
Exemple #3
0
// 初始化窗口管理器
VOID CUIWindowMng::Init(VOID)
{
	//创建ui系统底板
//	PROFILE_PUSH(Create_MainBoard);

	m_pBackGroundSheet = CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"DefaultGUISheet", (CEGUI::utf8*)"__BACKGOUNDSHEET__");
	m_pBackGroundSheet->setMouseHollow(true);
	m_pBackGroundSheet->moveToFront();
	//m_pBackGroundSheet->captureInput();
	m_pBackGroundSheet->setDistributesCapturedInputs(true);

	CEGUI::System::getSingleton().setGUISheet( m_pBackGroundSheet );

//	PROFILE_POP(Create_MainBoard);

	//加载UI
	tDataBaseSystem* pUIDBC = (tDataBaseSystem*)g_pKernel->GetNode("bin\\dbc");
	KLAssert(pUIDBC);
	const tDataBase* pDBC = pUIDBC->GetDataBase(DBC_UI_LAYOUTDEFINE);

	for(INT i=0; i<(INT)pDBC->GetRecordsNum(); i++)
	{
		const _DBC_UI_LAYOUTDEFINE* pLine = (const _DBC_UI_LAYOUTDEFINE*)((tDataBase*)pDBC)->Search_LineNum_EQU(i);

		//产生一个新的WindowItem
		CUIWindowItem* pItem = new CUIWindowItem(pLine);
		pItem->setOpenCloseSound(pLine->nOpenSoundID, pLine->nCloseSoundID);
		//预加载窗口

		pItem->PreLoadWindow();

		m_aWindowList.push_back( pItem );
	}
}
VOID CActionItem_Skill::Update_Skill(const SCLIENT_SKILL* pSkill)
{
	KLAssert(pSkill);

	//引用
	m_idSkillImpl =	pSkill->m_pDefine->m_nID;
	//名称
	m_strName = pSkill->m_pDefine->m_lpszName;
	//图标
	m_strIconName = pSkill->m_pDefine->m_lpszIconName;

	BOOL bOldEnable = IsEnabled();
	BOOL bNewEnable = FALSE;
	ORESULT oResult = pSkill->IsCanUse_CheckDeplete( CObjectManager::GetMe()->GetMySelf()->GetID());
	if ( OR_SUCCEEDED( oResult ) )
	{
		oResult = pSkill->IsCanUse_Leaned();
		if ( OR_SUCCEEDED( oResult ) )
		{
			bNewEnable = TRUE;
		}
	}

	if ( bNewEnable != bOldEnable )
	{
		(bNewEnable)?(Enable()):(Disable());

		//通知UI
		UpdateToRefrence();
	}
}
	INT	Pet::GetMaxLife(LuaPlus::LuaState* state)
	{
		LuaStack args(state);
		KLAssert(false&&"Pet::GetMaxLife 没有宠物的最大生命的概念");
		state->PushNumber( 100 );
		return 1;
	}
// 震荡一次
VOID CEngineInterface::Camera_VibrateOneTime()
{
	KLAssert(m_pCamera_Current);

//	((CCamera_Scene*)m_pCamera_Current)->AddOneVib(10, 8, 2);
	Camera_VibrateOneTime(10, 8, 2);
}
Exemple #7
0
VOID WINAPI	CUIWindowItem::_OnGameEvent(const EVENT* pEvent, UINT dwOwnerData)
{
	KLAssert(pEvent);
	
	//--------------------------------------------------------
	// 分发
	CUIWindowItem* pWinItem = (CUIWindowItem*)(DWORD_PTR)(dwOwnerData);
	if(!pWinItem)
		return;

	// 加载
	if(!(pWinItem->m_bLayoutLoaded))
	{
		pWinItem->LoadWindow();
	}

	//--------------------------------------------------------
	// 参数
	for(INT i=0; i<(INT)pEvent->vArg.size(); i++)
	{
		CHAR szTemp[MAX_PATH];
		_snprintf(szTemp, MAX_PATH, "arg%d", i);
		g_pScriptSys->GetLuaState()->GetGlobals().SetString(szTemp, pEvent->vArg[i].c_str());
	}

	//--------------------------------------------------------
	// 调用脚本
	CHAR szFunctionName[MAX_PATH];
	_snprintf(szFunctionName, MAX_PATH, "%s_OnEvent", pWinItem->m_strWindowName.c_str());

	CHAR szFunctionParam[MAX_PATH];
	_snprintf(szFunctionParam, MAX_PATH, "\"%s\"", pEvent->pEventDef->szEvent);

	pWinItem->m_pScriptEnv->DoFunction(szFunctionName, szFunctionParam);
}
VOID CObjEntityModel::SetOrientation(const fVector3& vRotate)
{
	KLAssert(m_pFairyObj);

	Ogre::Quaternion qu(Ogre::Radian(vRotate.y), Ogre::Vector3::UNIT_Y);
	m_pFairyObj->setProperty(FOBJ_ORIENTATION, qu);
}
Exemple #9
0
VOID CObject_Item_Task::AsTask(const _DBC_ITEM_TASK* pTaskDefine)
{
    KLAssert(pTaskDefine);

    m_theBaseDef = pTaskDefine;
    m_nParticularID = ( ( m_theBaseDef->nClass * 100 + m_theBaseDef->nType ) * 10000 ) + m_theBaseDef->nIndex;

}
Exemple #10
0
// 设置当前摄像机状态
BOOL CCamera_Scene::_SetStatus(CAMERA_STATUS nStatus )
{
    switch(nStatus)
    {
    case NORMAL_STATUS:	// 设置
    {
        switch(m_status)
        {
        case VIBRATION_STATUS:
        {

        }
        break;
        default:
            KLAssert(0);
            return FALSE;
        }
        m_status = nStatus;
        return TRUE;
    }
    break;

    case VIBRATION_STATUS:
    {
        switch(m_status)
        {
        case NORMAL_STATUS:
        {

        }
        break;
        default:
            KLAssert(0);
            return FALSE;
        }
        m_status = nStatus;
        return TRUE;
    }
    break;

    default:
        KLAssert(0);
        return FALSE;
    }
    return TRUE;
}
Exemple #11
0
CCamera::CCamera(Ogre::Camera* pOgreCamera) : m_pOgreCamera(pOgreCamera)
{
    KLAssert(pOgreCamera);

    //-----------------------------------------------
    //附加到Ogre摄像机上
    m_pOgreCamera = pOgreCamera;
//	m_pOgreCamera->setNearClipDistance(0.01f);
}
Exemple #12
0
VOID CCamera_Scene::SetAddHeight(FLOAT fAddHeight)
{
    KLAssert(fAddHeight >= 0.0f);


    m_fAddHeight = fAddHeight;

    Update();
}
	//创建专用灯光
	void createSpecialLight(void)
	{
		m_pLightModel = 
			CEngineInterface::GetMe()->GetFairySystem()->getSceneManager()->createLight("Light_ForFakeSystem");
		KLAssert(m_pLightModel);

		//设置VisibleFlag
		m_pLightModel->setVisibilityFlags(Fairy::OVF_GUI_ELEMENTS);
	}
VOID CEngineInterface::Destroy_EntityObject(tEntityNode* pNode)
{
	KLAssert(pNode);

	delete ((CObjectEntity*)pNode);

	// 之后不能调用和该node相关的任何代码
	return;
}
Exemple #15
0
VOID CObjEntityModel::SetPosition(const fVector3& vPos)
{
	KLAssert(m_pFairyObj);

	// 坐标转化
	fVector3 fvGfxPos;
	CEngineInterface::GetMe()->Axis_Trans(CEngineInterface::AX_GAME, vPos, CEngineInterface::AX_GFX, fvGfxPos);

	m_pFairyObj->setProperty(FOBJ_POSITION, Ogre::Vector3(fvGfxPos.x, fvGfxPos.y, fvGfxPos.z));
}
Exemple #16
0
// 插件初始化
extern "C" VOID __stdcall DllInit( tKernel* pKernel )
{
	KLAssert(pKernel);

	g_pKernel = pKernel;

	pKernel->ReisgerClass(GETCLASS(CUISystem));

	
}
Exemple #17
0
//设置详细解释
VOID CObject_Item_Task::SetExtraInfo(const _ITEM * pItemInfo)
{
    KLAssert(pItemInfo);

    const MEDIC_INFO& infoMedic = pItemInfo->m_Medic;

    SetNumber(pItemInfo->GetItemCount());
    for ( int i=0; i<MAX_ITEM_PARAM; ++i)
    {
        m_Param[i] = pItemInfo->m_Param[i];
    }
}
Exemple #18
0
VOID CCamera_Scene::SetDistance(FLOAT fDistance)
{
    KLAssert(fDistance>0.0f);

    //取得放缩系数
    fVector3 fvScale = CEngineInterface::GetMe()->GetSacle();

    //Attention!!!
    //一般来说,fvScale的三个值都是一样的,so...
    m_fDistance = fDistance*fvScale.y;
    Update();
}
Exemple #19
0
//从文件中读取变量
VOID CVariableSystem::LoadVariable(LPCTSTR szFileName, VARIABLE_MAP& mapBuf)
{
	KLAssert(szFileName);
	//	mapBuf.clear();

	//-----------------------------------------------------------
	//取得配置文件的大小
	HANDLE hFile = CreateFile(szFileName,
		GENERIC_READ,
		FILE_SHARE_READ | FILE_SHARE_WRITE,
		NULL,
		OPEN_EXISTING,
		FILE_ATTRIBUTE_NORMAL,
		NULL);

	if(INVALID_HANDLE_VALUE == hFile) return;

	DWORD dwHigh;
	DWORD dwFileSize = GetFileSize(hFile, &dwHigh);
	CloseHandle(hFile); hFile = NULL;
	if(0==dwFileSize) return;

	//-----------------------------------------------------------
	//分配足够的内存
	CHAR* pTempBuf = new CHAR[dwFileSize+32];
	if(!pTempBuf) return;

	//-----------------------------------------------------------
	//从配置文件中读取"Variable"节
	::GetPrivateProfileSection("Variable", pTempBuf, dwFileSize, szFileName);
	//分解
	std::vector< STRING > vRet;
	ConvertSectionInVector(pTempBuf, dwFileSize, vRet);

	delete[] pTempBuf; pTempBuf=NULL;

	//加入变量定义
	for(INT i=0; i<(INT)vRet.size(); i++)
	{
		STRING& strLine = vRet[i];

		STRING::size_type tEqu = strLine.find_first_of("= \t");
		if(tEqu == STRING::npos) continue;

		STRING strName = strLine.substr(0, tEqu);

		CHAR szTemp[1024];
		::GetPrivateProfileString("Variable", strName.c_str(), "", szTemp, 1024, szFileName);

		SetVariable(strName.c_str(), szTemp, FALSE);
	}

}
VOID CEngineInterface::Scene_Load(INT nID, const STRING& theSceneDefine)
{
	Fairy::ExpatParser parserExpat(NULL);
	
	if(m_pTerrainGrid)
	{
		m_pTerrainGrid->destroyRenderable();
	}
	// 卸载现有资源
	m_pFairySystem->resetScene();

	// 加载场景文件
	m_pFairySystem->loadSceneFromResource(&parserExpat, theSceneDefine.c_str(), "Scene");

	// 释放未使用资源
	{
		Ogre::ResourceGroupManager& resManager = Ogre::ResourceGroupManager::getSingleton();

		const Ogre::StringVector& strGroupVec = resManager.getResourceGroups();

		for(int i=0; i<(int)strGroupVec.size(); i++)
		{
			if( strGroupVec[i] != Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME &&
				strGroupVec[i] != Fairy::BOOTSTRAP_RESOURCE_GROUP_NAME)
			{
				resManager.unloadUnreferencedResourcesInGroup(strGroupVec[i]);
			}
		}
	}
	
	// 设置LightMap
	BOOL bHave = FALSE;
	INT qu = g_pVaribleSys->GetAs_Uint(szLightmapQualityVar, &bHave);
	if ( !bHave )
	{
		qu = 3;
	}
	Scene_SetLightmapQuality(qu);
	
	// 取得环境特效
	Fairy::SceneInfo::ObjectsByTypeRange objEnviroment = m_pFairySystem->getSceneInfo()->findObjectsByType("Enviroment");

	if (objEnviroment.first != objEnviroment.second)
	{
		m_pEnviromentObject = static_cast< Fairy::EnviromentObject * >(objEnviroment.first->get());
		KLAssert(m_pEnviromentObject);
	}
	else
	{
		m_pEnviromentObject = NULL;
	}
}
VOID CEngineInterface::Camera_SetLookAt(const fVector3& fvPos)
{
	KLAssert(m_pCamera_Current);

	fVector3 pos = fvPos;

//	pos.x += m_fParallelOffset;
	//pos.z += m_fVerticalOffset;

	((CCamera_Scene*)m_pCamera_Current)->SetLookAt( pos );

	CheckObjectTransparent();
}
Exemple #22
0
VOID CObject_Item_Mount::AsMount(const _DBC_ITEM_MOUNT_ATT* pStoreMapDefine)
{
	KLAssert(pStoreMapDefine);
	m_theBaseDef = const_cast<_DBC_ITEM_MOUNT_ATT*>(pStoreMapDefine);

	DBC_DEFINEHANDLE(s_pCharMountDBC, DBC_CHARACTER_MOUNT)
	m_characterData = (const _DBC_CHARACTER_MOUNT*)(s_pCharMountDBC->Search_Index_EQU(m_theBaseDef->nCharMountID));

	//m_theBaseDef->szIcon = "xinshouzhuangnan";
	//m_theBaseDef->nClass = ICLASS_MOUNT; 
	//m_nParticularID = ( ( ICLASS_MOUNT * 100  + m_theBaseDef->nType ) * 10000 ) + m_theBaseDef->nIndex;

}
Exemple #23
0
VOID CZone::UnRegisterObject(CObject_Map* pObject)
{
	KLAssert(pObject);

	// 从Set中搜索该物体,如果找到则删除
	INT id = pObject->GetID();
	std::set< INT >::iterator it = m_setRegisterObject.find( id );
	if(it != m_setRegisterObject.end())
	{
		m_setRegisterObject.erase(it);
	}

	pObject->m_pZone = NULL;
}
Exemple #24
0
//根据当前状态刷新摄像机
VOID CCamera_Scene::_UpdateCurStatus( fVector3& vEyePos, fVector3& vLookatPos)
{
    switch(m_status)
    {
    // 普通状态
    case NORMAL_STATUS:
    {
        return;
    }
    break;

    // 震荡状态
    case VIBRATION_STATUS:
    {
        //----------------------------------------------------------------------
        // 说明:更新相机震动动画                             [6/13/2010 陈军龙]
        // 原理:将时间映射到曲线函数Sin上
        // 映射公式: (2 * PI) / (1 / Frequency) = x / Age
        // 计算偏移量公式: offset = Amplitude * Sin(x) * (1 - Age / Duration)
        //----------------------------------------------------------------------

        // 记录当前累计震动时间
        m_CurVibParam.fAge += CGameProcedure::s_pTimeSystem->GetDeltaTime() / 1000;

        // 若超时则归位
        if(m_CurVibParam.fAge > m_CurVibParam.fDuration)
        {
            _SetStatus(NORMAL_STATUS);
            return;
        }

        // 按照公式求偏移量
        FLOAT offset = m_CurVibParam.fAmplitude
                       * Ogre::Math::Sin(m_CurVibParam.fAge * Ogre::Math::TWO_PI * m_CurVibParam.fFrequency)
                       * (1 - m_CurVibParam.fAge / m_CurVibParam.fDuration);

        // 进行偏移产生震动效果
        vLookatPos.y += offset;
        vEyePos.y += offset;

        return;
    }
    break;

    default:
        KLAssert(0);
        return;
    }
    return;
}
Exemple #25
0
VOID CZone::RegisterObject(CObject_Map* pObject)
{
	KLAssert(pObject);

	// 判断是否确实是CObject_Map继承类
	if(!g_theKernel.IsKindOf(pObject->GetClass(), GETCLASS(CObject_Map))) 
		return;

	// 注册到Set中,如果已经有该id的物体注册,则直接替换
	INT id = pObject->GetID();
	m_setRegisterObject.insert( id );

	pObject->m_pZone = this;
}
Exemple #26
0
CUIWindowItem::CUIWindowItem(const _DBC_UI_LAYOUTDEFINE* pLayoutDef)
{
	KLAssert(pLayoutDef);

	m_dwID				= pLayoutDef->nID;
	m_strWindowName		= pLayoutDef->szName;
	m_strLayoutFileName = pLayoutDef->szLayout;
	m_strScriptFileName = pLayoutDef->szScript;
	m_nIsCanDemise		= pLayoutDef->nDemise;
	m_strDefaultPositionProperty = pLayoutDef->szDefaultPosition;

	m_pWindow			= NULL;
	
	m_bShow = FALSE;
	m_bLayoutLoaded = FALSE;
}
VOID CActionItem_LifeAbility::Update_LifeAbility(const SCLIENT_LIFEABILITY* pAbility)
{
	KLAssert(pAbility);

	//引用
	m_idLifeAbilityImpl = pAbility->m_pDefine->nID;
	//名称
	m_strName = pAbility->m_pDefine->szName;
	//图标
	m_strIconName = pAbility->m_pDefine->szIconName;

	m_iLevel = pAbility->m_nLevel;

	//通知UI
	UpdateToRefrence();
}
Exemple #28
0
BOOL CUIWindowMng::IsWindowShow(LPCTSTR szUIName, LPCTSTR szChildName)
{
	KLAssert(szUIName);

	WINDOWLIST::iterator  it;
	for( it=m_aWindowList.begin(); it != m_aWindowList.end(); it ++ )
	{
		if(strcmp((*it)->GetWindowName(), szUIName) == 0)
		{
			if( szChildName == NULL )
				return (*it)->IsWindowShow();
			else
				return (*it)->IsChildWindowShow(szChildName);
		}
	}

	return FALSE;
}
Exemple #29
0
VOID CObjEntityModel::StaObj_SetMeshFile(LPCTSTR szMeshFile)
{
	KLAssert(szMeshFile && m_pFairyObj);

	m_pFairyObj->setProperty(FOBJ_MODEL_FILE, Fairy::String(szMeshFile));
}
Exemple #30
0
extern VOID InstallUISystem( tKernel* pKernel )
{
	KLAssert(pKernel);
	g_pKernel = pKernel;
	pKernel->ReisgerClass(GETCLASS(CUISystem));
}