UINT GCSpecialObj_ActNowHandler::Execute( GCSpecialObj_ActNow* pPacket, Player* pPlayer )
{
//__ENTER_FUNCTION

	if(CGameProcedure::GetActiveProcedure() == (CGameProcedure*)CGameProcedure::s_pProcMain)
	{
		CObjectManager* pObjectManager = CObjectManager::GetMe();

		CObject* pObj = (CObject*)(pObjectManager->FindServerObject( (INT)pPacket->GetObjID() ));
		if ( pObj == NULL )
			return PACKET_EXE_CONTINUE;

		const ObjID_List &listObjID	= pPacket->GetTargetList();

		SCommand_Object cmdTemp;
		cmdTemp.m_wID			= OC_SPECIAL_OBJ_TRIGGER;
		cmdTemp.m_anParam[0]	= pPacket->GetLogicCount();
		cmdTemp.m_anParam[1]	= listObjID.m_nCount;
		cmdTemp.m_apParam[2]	= (VOID*)(listObjID.m_aIDs);
		pObj->PushCommand(&cmdTemp );

		pObj->PushDebugString("GCSpecialObj_ActNowHandler");
		pObj->SetMsgTime(CGameProcedure::s_pTimeSystem->GetTimeNow());
	}

	return PACKET_EXE_CONTINUE ;

//__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}
uint GCNotifyTeamInfoHandler::Execute( GCNotifyTeamInfo* pPacket, Player* pPlayer )
{
//__ENTER_FUNCTION

	if(CGameProcedure::GetActiveProcedure() == (CGameProcedure*)CGameProcedure::s_pProcMain)
	{
		CObjectManager* pObjectManager = CObjectManager::GetMe();

		CObject* pObj = (CObject*)(pObjectManager->FindServerObject( (INT)pPacket->GetObjID() ));
		if ( pObj == NULL )
			return PACKET_EXE_CONTINUE;

		SCommand_Object cmdTemp;
		cmdTemp.m_wID			= OC_UPDATE_TEAM_FLAG;
		cmdTemp.m_abParam[0]	= pPacket->GetHaveTeamFlag();
		cmdTemp.m_abParam[1]	= pPacket->GetTeamLeaderFlag();
		cmdTemp.m_abParam[2]	= pPacket->GetTeamFullFlag();
//		cmdTemp.m_abParam[3]	= pPacket->GetTeamFollowFlag();
		pObj->PushCommand( &cmdTemp );

		// CGameProcedure::s_pEventSystem->PushEvent( GE_NEW_DEBUGMESSAGE, "GCNotifyTeamInfo Received." );
	}

	return PACKET_EXE_CONTINUE ;

//__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}
Exemple #3
0
void ProcessInput()
{
  static bool leftButtonDown = false;
  static bool rightButtonDown = false;
  static bool first = true;
 
  
  

  // rotate through mouse cursors on mouseclicks or wheel movement
  if (g_input.ButtonDown(0)){
    leftButtonDown = true;

	if(theObjects.lives_remaining >= 0) theObjects.fire(Timer.time());
  }
  if (g_input.ButtonDown(1)){
	if(theObjects.lives_remaining >= 0) theObjects.fire(Timer.time());
    rightButtonDown = true;
  }



  // update the mouse position
  int dx, dy;
  g_input.GetMouseMovement(dx, dy);

  int scale = (dx < 0)? 2:4;	//going up is faster than going down
  theObjects.changedirection(dx * 3,dy/scale);

} // end ProcessInput()
Exemple #4
0
/**
* CAIManager::CAIManager
* @date Modified March 30, 2006
*/
CAIManager::CAIManager(void) : m_bUpdateGoalLinks(true), m_bSkipCurrentObjective(false)
{
	// go to the object manager and get the players and create nodes for them
	CObjectManager* poObjectManager = CObjectManager::getInstancePtr();
	CObjectManager::ObjectList loPlayers;
	poObjectManager->getObjects(OBJ_PLAYER, &loPlayers);

	CObjectManager::ObjectList::iterator oPlayerIter = loPlayers.begin();

	while (oPlayerIter != loPlayers.end())
	{
		CAINode* newNode = new CAINode;
		newNode->setPosition(ACTOR_PTR(oPlayerIter)->getBV().centerPt);
		newNode->setRadius(1.0f);
		m_loGoals.push_back(newNode);
		oPlayerIter++;
	}

	m_oLeaderTimer.setInterval(0.1f);
	m_oObjectiveTimer.setInterval(0.15f);
	m_poCurrentObjective = NULL;

	m_poObjectiveEmitter = (CParticleEmitter*)CObjectManager::getInstance().createObject(OBJ_PARTICLE_EMITTER);
	m_poObjectiveEmitter->setSystem((CParticleSystem*)CResourceManager::getInstance().loadResource(RES_PARTICLEEMITTER, "objective.xml"));
}
void CGUIContainer::InitObject(const char * strObjectName, const char * alignment, int x, int y, int width, int height)
{
	CObjectManager *pOm = &CSingleton<CObjectManager>::Instance();
	if (!pOm->IsExist("default_CGUIContainer")) {
		CGUIContainer::StaticInit();
	}
	pOm->CloneObject("default_CGUIContainer", this);
	CGUIBase::InitObject(strObjectName, alignment, x, y, width, height);
	//initialize scrollbars
	string str;

	str = GetName() + ".vscrollbar";
	// Modified 2007.4.10 LiXizhi, alignment type is changed.
	//m_VScroll->InitObject(str.c_str(),"_rt",-m_nSBWidth-m_nBorder,m_nBorder,m_nSBWidth,RectHeight(m_objResource->GetDrawingRects(0)));
	m_VScroll->InitObject(str.c_str(), "_mr", m_nBorder, m_nBorder, m_nSBWidth, m_nBorder);
	m_VScroll->m_parent = this;
	m_VScroll->SetLinkedObject(this);
	// 	m_VScroll->UpdateRects();

	str = GetName() + ".hscrollbar";
	//m_HScroll->InitObject(str.c_str(),"_lb",m_nBorder,-m_nSBWidth-m_nBorder,RectWidth(m_objResource->GetDrawingRects(0)),m_nSBWidth);
	m_HScroll->InitObject(str.c_str(), "_mb", m_nBorder, m_nBorder, m_nBorder + m_nSBWidth, m_nSBWidth);
	m_HScroll->m_parent = this;
	m_HScroll->SetLinkedObject(this);
	// 	m_HScroll->UpdateRects();
	SetSize(width, height);
}
Exemple #6
0
void ObjectDestroy(RakNet::BitStream *bitStream, Packet *packet)
{
	CObjectManager *pObjectManager = pNetowkManager->GetObjectManager();
	EntityId objId=0;

	bitStream->Read(objId);

	pObjectManager->Delete(objId);
}
Exemple #7
0
void DebugLayout()
{
	float y_offset = 100;

	CPlayer* LocalPlayer;

	if (NetworkManager)
	{
		LocalPlayer = NetworkManager->GetLocalPlayer();

		Render::DrawText(20, y_offset, color_white, DT_LEFT, "R3DNetwork: %x", NetworkManager);
		y_offset += 15;
	}

	CObjectManager* ObjectManager = CObjectManager::Get();

	if (ObjectManager)
	{
		Render::DrawText(20, y_offset, color_white, DT_LEFT, "ObjectManager: %x", ObjectManager);
		y_offset += 15;

		//Finds LocalPlayer in the main menu (For the shooting range)
		if (!LocalPlayer)
		{
			CGameObject* Object = ObjectManager->GetFirst();

			for (CGameObject* Object = ObjectManager->GetFirst(); Object && Object->GetNext(); Object = Object->GetNext())
			{
				if (Object->GetObjectInfo()->m_id == OBJECT_AI_PLAYER)
				{
					LocalPlayer = (CPlayer*)Object;
					break;
				}
			} 
		}
	}

	if (LocalPlayer)
	{
		Render::DrawText(20, y_offset, color_white, DT_LEFT, "LocalPlayer: %x [0x%x]", LocalPlayer, LocalPlayer->GetObjectInfo());
		y_offset += 15;

		for (int slot = 0; slot < SLOT_MAX; slot++)
		{
			Weapon* pWeapon = LocalPlayer->m_weaponSlots[slot];

			if (!pWeapon)
				continue;

			Render::DrawText(40, y_offset, color_white, DT_LEFT, "Slot Weapon %i: %x (CWeaponConfig: %x)", slot, pWeapon, pWeapon->GetWeaponConfig());
			y_offset += 15;
		}

		Render::DrawTextA(20, y_offset, color_white, DT_LEFT, "Health: %f", LocalPlayer->GetHealth());
	}
}
Exemple #8
0
void ObjectSpawn(RakNet::BitStream *bitStream, Packet *packet)
{
	CObjectManager *pObjectManager = pNetowkManager->GetObjectManager();
	EntityId ObjectID=0;
	int iModel;
	Vector3 vecPos, vecRot;
	bitStream->Read(ObjectID);
	bitStream->Read(iModel);
	bitStream->Read(vecPos);
	bitStream->Read(vecRot);

	pObjectManager->New(ObjectID, iModel, vecPos, vecRot);
}
Exemple #9
0
CCardIssuer* CCardIssuer::FromHandle(ISSUERHANDLE hIssuer)
{
	if ( _objmgr.IsExist( (void*) hIssuer ))
		return (CCardIssuer*) hIssuer;

	return NULL;
}
Exemple #10
0
void CreateObjects(){
	g_pSoundManager->LoadSounds(1); //load game sounds
	g_cObjectManager.createZone(1);
//		 g_pSoundManager->clear(); //clear out old sounds
//      g_pSoundManager->LoadSounds(1); //load game sounds

	
} //CreateObjects
Exemple #11
0
/**
* CAIManager::getDistanceToObjective
* @date Modified June 2, 2006
*/
float CAIManager::getDistanceToObjective(D3DXVECTOR3* vDirection)
{
	if (m_poCurrentObjective == NULL)
	{
		memset(vDirection, 0, sizeof(D3DXVECTOR3));
		return 0.0f;
	}

	CObjectManager* poObjectManager = CObjectManager::getInstancePtr();
	CObjectManager::ObjectList loPlayers;
	poObjectManager->getObjects(OBJ_PLAYER, &loPlayers);

	D3DXVec3Subtract(vDirection, &m_poCurrentObjective->getPosition(), &((CPlayer*)loPlayers.front())->getPosition());
	vDirection->y = 0.0f;

	float fLength = 0.0f;
	D3DXVec3Normalize(&fLength, vDirection, vDirection);
	return fLength;
}
// 检测是否要透明
void CEngineInterface::CheckObjectTransparent()
{
	if(!m_pFairySystem)
		return ;

	CObjectManager* objMng = CObjectManager::GetMe();
	fVector3 fvPos;
	
	if( objMng->GetMySelf()->GetRenderInterface() )
	{
		objMng->GetMySelf()->GetRenderInterface()->Actor_GetLocator( GetCharaLocatorName(LOCATOR_CHAR_ATTACK), fvPos );		// 取人物绑定点的位置, 判断起来比较合理	"人物身体受击点"
	}

	Axis_Trans(tGfxSystem::AX_GAME, fvPos, tGfxSystem::AX_GFX, fvPos);

	Ogre::Camera* pOgreCamera = m_pFairySystem->getCamera();
	Ogre::Vector3 origin = pOgreCamera->getPosition();

	// 屏掉下边这句了by czg 200911-30
	m_pFairySystem->makeObjectTransparent(origin, Ogre::Vector3(fvPos.x, fvPos.y, fvPos.z), 0.8, 1, NULL);
}
Exemple #13
0
LONG	CCardIssuer::Disconnect()
{
	if ( m_hDevice != INVALID_HANDLE_VALUE )
	{
		if (! CloseHandle( m_hDevice ) )
			return F1_E_UNKNOWN_ERROR;

		m_hDevice = INVALID_HANDLE_VALUE;
	}

	_objmgr.Remove(this);

	return 0;
}
Exemple #14
0
void CGUIListBox::InitObject(const char * strObjectName, const char * alignment, int x, int y, int width, int height)
{
	CObjectManager *pOm = &CSingleton<CObjectManager>::Instance();
	if (!pOm->IsExist("default_CGUIListBox")) {
		CGUIListBox::StaticInit();
	}
	pOm->CloneObject("default_CGUIListBox", this);
	CGUIBase::InitObject(strObjectName, alignment, x, y, width, height);
	//initialize scrollbars
	string str;

	str = GetName() + ".vscrollbar";
	m_VScroll->InitObject(str.c_str(), "_rt", -m_nSBWidth - m_nBorder, m_nBorder, m_nSBWidth, RectHeight(m_objResource->GetDrawingRects(0)));
	m_VScroll->SetParent(this);
	m_VScroll->SetLinkedObject(this);
	m_VScroll->UpdateRects();

	// 	str=GetName()+".hscrollbar";
	// 	m_HScroll->InitObject(str.c_str(),"_lb",m_nBorder,-m_nSBWidth-m_nBorder,RectWidth(m_objResource->GetDrawingRects(0)),m_nSBWidth);
	// 	m_HScroll->m_parent=this;
	// 	m_HScroll->SetLinkedObject(this);
	// 	m_HScroll->UpdateRects();
}
Exemple #15
0
/**
* CAIManager::updateSpawnTriggers
* @date Modified May 9, 2006
*/
void CAIManager::updateSpawnTriggers(void)
{
	CObjectManager* poObjectManager = CObjectManager::getInstancePtr();
	CObjectManager::ObjectList loTriggers;
	poObjectManager->getObjects(OBJ_AI_SPAWNTRIGGER, &loTriggers);
	CObjectManager::ObjectList::iterator oTriggerIter = loTriggers.begin();

	while (oTriggerIter != loTriggers.end())
	{
		((CActorSpawnTrigger*)(*oTriggerIter))->activateSpawns();
		oTriggerIter++;
	}

	CObjectManager::ObjectList loSpawns;
	poObjectManager->getObjects(OBJ_SPAWN, &loSpawns);
	CObjectManager::ObjectList::iterator oSpawnIter = loSpawns.begin();

	while (oSpawnIter != loSpawns.end())
	{
		((CActorSpawn*)(*oSpawnIter))->setUsed(false);
		oSpawnIter++;
	}
}
Exemple #16
0
void ProcessFrame(){
 GameRenderer.ProcessFrame();

    g_pSoundManager->beginframe();
	if(!MenuUp)
   g_cObjectManager.UpdateMP();

  
	//DEBUGPRINTF("This is a test of the DEBUGPRINTF system.\n");
  //input handlers 
  if(g_pInputManager->ProcessKeyboardInput()){ //process  input
    DestroyWindow(g_HwndApp); 
    return; //bail from ProcessFrame
	
	
  }
}
Exemple #17
0
CBomb::CBomb(Ogre::SceneNode *pParentNode, CObjectManager &objectManager, const Ogre::Vector3 &vPosition)
: CLiftableObject(pParentNode, objectManager, NULL, LOT_BOMB, false, UserData()), m_pListener(NULL) {
    m_pSceneNode = pParentNode->createChildSceneNode();
    m_pSceneNode->attachObject(pParentNode->getCreator()->createEntity(BOMB_MESH));
    m_pSceneNode->setScale(Ogre::Vector3::UNIT_SCALE * CPerson::PERSON_SCALE);
    m_fTimer = BOMB_TIMER;

    btCollisionShape *pShape = new btSphereShape(BOMB_COL_RADIUS);
    btRigidBody::btRigidBodyConstructionInfo ci(BOMB_MASS, new BtOgre::RigidBodyState(m_pSceneNode), pShape);
    btRigidBody *pRB = new btRigidBody(ci);

    objectManager.getMap().getPhysicsManager()->getWorld()->addRigidBody(pRB, COL_INTERACTIVE, MASK_STATIC_COLLIDES_WITH | COL_STATIC);
    m_pCollisionObject = pRB;

    setAsUserPointer(m_pCollisionObject);

    pRB->getWorldTransform().setOrigin(BtOgre::Convert::toBullet(vPosition + Ogre::Vector3::UNIT_Y * BOMB_COL_RADIUS));
}
Exemple #18
0
CChest::CChest(Ogre::SceneNode *pNode, CObjectManager &objectManager, btCollisionObject *pCollisionObject, EChestType eChestType, const Ogre::String &id)
	: CObject(objectManager, CHEST_OBJECT, pCollisionObject, id), m_eChestType(eChestType) {

	m_eChestState = CS_CLOSED;
	//setInnerObject(&innerObject);
	m_pInnerObject = NULL;

	m_pLidSceneNode = objectManager.getMap().getRootSceneNode()->createChildSceneNode();
	m_pLidSceneNode->setPosition(pNode->getPosition());
	m_pLidSceneNode->setOrientation(pNode->getOrientation());
	m_pLidSceneNode->setScale(pNode->getScale());
	m_vInnerObjectPos = m_pLidSceneNode->getPosition();
	btCollisionShape *pColShape(0);
	switch (m_eChestType) {
	case CT_SMALL:
		m_pLidSceneNode->attachObject(pNode->getCreator()->createEntity("Chest.Small.Upper.mesh"));
		m_pLidSceneNode->translate(0, 0.37465f, -0.30862f, Ogre::Node::TS_LOCAL);
		m_vInnerObjectPos += m_pLidSceneNode->getOrientation() * Ogre::Vector3(0, 0.15f, 0);
		pColShape = new btBoxShape(btVector3(0.3f, 0.08f, 0.2f));
		m_vPhysicsOffset = Ogre::Vector3(0, 0.15f, 0.25f);
		break;
	default:
		throw Ogre::Exception(0, "Unknown chest type", __FILE__);
		break;
	}
	m_pLidPhysics = new btRigidBody(0, new btDefaultMotionState(), pColShape);
	m_pLidPhysics->getWorldTransform().setOrigin(BtOgre::Convert::toBullet(m_pLidSceneNode->getPosition() + m_pLidSceneNode->getOrientation() * m_vPhysicsOffset));
	m_pLidPhysics->getWorldTransform().setRotation(BtOgre::Convert::toBullet(m_pLidSceneNode->getOrientation()));

	m_ObjectManager.getMap().getPhysicsManager()->getWorld()->addRigidBody(m_pLidPhysics, COL_STATIC, MASK_STATIC_COLLIDES_WITH);

	// check for safe state
	if (id.length() > 0) {
        EItemSaveState iss = CPlayerData::getSingleton().getMapItemState(m_ObjectManager.getMap().getName(), id, ISS_CLOSED);
        if (iss == ISS_OPENED) {
            // open chest as initial state
            m_eChestState = CS_OPENED;
            m_pLidSceneNode->pitch(Ogre::Radian(-CHEST_MAX_ANGLE));
            m_pLidPhysics->getWorldTransform().setOrigin(BtOgre::Convert::toBullet(m_pLidSceneNode->getPosition() + m_pLidSceneNode->getOrientation() * m_vPhysicsOffset));
            m_pLidPhysics->getWorldTransform().setRotation(BtOgre::Convert::toBullet(m_pLidSceneNode->getOrientation()));
        }
    }
}
Exemple #19
0
LONG	CCardIssuer::Connect(DWORD dwPort, DWORD dwBaudRate, BYTE bAddress)
{
	LONG	lResult = InitPort(dwPort, dwBaudRate);
	if ( lResult != 0 )
		return lResult;

	m_bAddress = bAddress;

	lResult = ExecCommand('R', 'S', NULL, NULL, NULL, NULL);
	if ( lResult != 0 )
		return F1_E_DEVICE_UNRECOGNIZED;

	if (! _objmgr.Add(this))
	{
		Disconnect();
		return F1_E_NO_MEMORY;
	}

	return 0;
}
Exemple #20
0
BOOL game_keyboard_handler(WPARAM keystroke){ //keyboard handler
  BOOL result=FALSE; 
  switch(keystroke){
    theObjects.set_current(STARFIRE_INDEX);
  
  
    case VK_SPACE: if(theObjects.lives_remaining >= 0) theObjects.fire(Timer.time());/* theObjects.fire(Timer.time())*/; break;
    case VK_ESCAPE:	endphase=TRUE; break; //exit game
    case VK_UP: theObjects.changedirection(0,-2); break;
    case VK_DOWN: theObjects.changedirection(0,1); break;
    case VK_LEFT: theObjects.changedirection(-3,0); break;
    case VK_RIGHT: theObjects.changedirection(3,0); break;
	case 'Z': mouse_mode = !mouse_mode; break;
	
 
    default: break;
  }
  return result;
} //keyboard_handler
Exemple #21
0
BOOL ComposeFrame(){ //compose a frame of animation
  //draw background


  static int next_powerup = Timer.time()+Random.number(3000,12000);
  static int frame = 1;
  RECT rect; //drawing rectangle
  rect.left=0; rect.right=g_nScreenWidth; 
  rect.top=0; rect.bottom=g_nScreenHeight; 
  lpSecondary->Blt(&rect,lpBackground,&rect,DDBLT_WAIT,NULL);
  //move objects


  Viewpoint.draw_background(lpBackground,lpSecondary,8);
  
  int collision = theObjects.collisiondetection();
  
  
  theObjects.animate(lpSecondary);	//animate the current frame
  theObjects.refresh(collision);	//refresh the objects

  


if(Timer.time()>=next_powerup){
	theObjects.powerup();
    next_powerup += Random.number(10000,30000);	//next power up in 10 - 30 sec
	
}

  //frame rate
  framecount++; //count frame
  if(Timer.elapsed(framerate_timer,500)){

   theObjects.set_current(STARFIRE_INDEX);
	  theObjects.changedirection(0,0);
    last_framecount=framecount; framecount=0;
  }
 
  return PageFlip(); //flip video memory surfaces
 // return TRUE;
} //ComposeFrame
Exemple #22
0
void CGameRenderer::ComposeFrame(){  
	m_d3ddevice->Clear(0L, NULL, D3DCLEAR_TARGET, 0xFFFFFF, 1.0f, 0L); //clear render buffer
	if(SUCCEEDED(m_d3ddevice->BeginScene())){ //can start rendering
		//move objects
		g_cObjectManager.move();
		//set camera location
		float x, y; //plane's current location
		g_cObjectManager.GetPlayerLocation(x, y); //get plane's lcoation
		if(m_bCameraDefaultMode)  
			SetViewMatrix(x+500, y, -350.0f);
		else SetViewMatrix(x + g_nScreenWidth/2.0f, 1000.0f, -5000.0f);

		//draw background 
		DrawBackground(x + g_nScreenWidth/2);

		//draw objects
		g_cObjectManager.draw();

		if(currentKey > 4){
			//while(VFrameCount < 6){
			//for(VFrameCount = 0; VFrameCount < 6; VFrameCount++){ 
				g_cObjectManager.draw2(currentKey-4);
			//	VFrameCount++;
			//}
			//}
		if(AttackCount)
			currentKey = currentKey - 4; 
		VFrameCount = 0;
		}else{
			AttackCount = FALSE;
			g_cObjectManager.draw(currentKey);
		}
	    //draw text on the HUD
		g_cObjectManager.DrawTextHeader();

		m_d3ddevice->EndScene(); //done rendering
	}
} //ComposeFrame
uint GCNewPlayerHandler :: Execute( GCNewPlayer* pPacket, Player* pPlayer ) 
{
//__ENTER_FUNCTION

	//当前流程是主流程
	if(CGameProcedure::GetActiveProcedure() == (CGameProcedure*)CGameProcedure::s_pProcMain)
	{
		CObjectManager* pObjectManager = CObjectManager::GetMe();
		//检查位置是否合法
		if(!CWorldManager::GetMe()->GetActiveScene()->IsValidPosition(fVector2(pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ)))
		{
			TDThrow("ERROR POSITION @ GCNewPlayerHandler");
		}

		//创建玩家
		CObject_PlayerOther* pOther = (CObject_PlayerOther*)(pObjectManager->FindServerObject( (INT)pPacket->getObjID()));
		fVector3 fvGame;
		CGameProcedure::s_pGfxSystem->Axis_Trans(
			CRenderSystem::AX_PLAN, fVector3(pPacket->getWorldPos().m_fX, 0.0f, pPacket->getWorldPos().m_fZ),
			CRenderSystem::AX_GAME, fvGame);

		FLOAT fFaceDir = pPacket->getDir();

		if ( pOther == NULL )
		{
			pOther = pObjectManager->NewPlayerOther( (INT)pPacket->getObjID() );

			SObjectInit initPlayerOther;
			initPlayerOther.m_fvPos	= fvGame;
			initPlayerOther.m_fvRot = fVector3( 0.f, fFaceDir, 0.f );
			pOther->Initial( &initPlayerOther );

			fVector2 mapPos(fvGame.x, fvGame.z);
			pOther->SetMapPosition( mapPos );
		}
		else
		{
			fVector2 mapPos(fvGame.x, fvGame.z);
			pOther->SetMapPosition( mapPos );
			pOther->SetFaceDir( fFaceDir );
			pOther->Enable( OSF_VISIABLE );
			pOther->Disalbe( OSF_OUT_VISUAL_FIELD );
		}

		//更新装备信息
		pOther->GetCharacterData()->Set_EquipVer(pPacket->getEquipVer());

		pOther->GetCharacterData()->Set_MoveSpeed(pPacket->getMoveSpeed());

		////激活鼠标查询
		//if(pOther->GetRenderInterface())
		//{
		//	pOther->Enable(OSF_RAY_QUERY);
		//}

		SCommand_Object cmdTemp;
		cmdTemp.m_wID			= OC_IDLE;
		cmdTemp.m_afParam[0]	= fvGame.x;
		cmdTemp.m_afParam[1]	= fvGame.z;
		cmdTemp.m_abParam[2]	= FALSE;
		pOther->PushCommand(&cmdTemp );

		//放入Ask队列
		CObjectManager::GetMe()->GetLoadQueue()->TryAddLoadTask(pOther->GetID(), CObject_Character::CT_PLAYEROTHER);

		// tempcode{
		// 此版不做服务器繁忙客户端延后发消息的处理
//		CGCharAskBaseAttrib msgAskBaseAttrib;
//		msgAskBaseAttrib.setTargetID( (INT)pPacket->getObjID() );
//		CNetManager::GetMe()->SendPacket( &msgAskBaseAttrib );

		//AxTrace(0, 0, "[%d]Ask %d", m_hmObject.size(), pPacket->getObjID());
		// }

		//如果是自己,退出死亡效果
		if(pOther == (CObject_PlayerOther*)pObjectManager->GetMySelf())
		{
			CGameProcedure::s_pGfxSystem->Scene_SetPostFilter_Death(FALSE);
		}

		pOther->PushDebugString("GCNewPlayer");
		pOther->SetMsgTime(CGameProcedure::s_pTimeSystem->GetTimeNow());
	}

	return PACKET_EXE_CONTINUE ;

//__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}
Exemple #24
0
void CGameObject::move(){ //move object
  int time = g_cTimer.time();

  if(time > waitTime){
	  if(!MenuUp){
		  bool moved = false;
		  //do{
			  const float XSCALE = 100.0f; //to scale back horizontal motion
			  const float YSCALE = 100.0f; //to scale back vertical motion
			  const float MARGIN = 100.0f; //margin on top of page

			  float xdelta = 0.0f, ydelta = 0.0f; //change in position
			   //current time
			  int tfactor = time-m_nLastMoveTime; //time since last move

			  //compute xdelta and ydelta, horizontal and vertical distance
			  xdelta = (m_fXspeed * (float)tfactor)/XSCALE; //x distance moved  
			  if(m_bCanFly)
				ydelta = (m_fYspeed * (float)tfactor)/YSCALE; //y distance moved
			  else{
				float t = (float)(time-m_nBirthTime);
				ydelta = 3.0f + m_fYspeed * 2.0f + t*t/10000.0f; //y distance moved
			  }

			  //delta motion

			 D3DXVECTOR3 v = D3DXVECTOR3(m_structLocation.x + xdelta, m_structLocation.y - ydelta, 500.0f);
			 CGameObject* temp = new CGameObject(DUMMY_OBJECT,"dummy",v,0,0);

			 //Check and see if object is a spell

			 switch(m_nObjectType){
			 case FIREBALL_OBJECT: 
			 case LIGHTNING_OBJECT: 
			 case TORNADO_OBJECT: 
			 case BARRIER_OBJECT: 
			 case ENEMYFIREBALL_OBJECT: 
			 case ENEMYHOMING_OBJECT: moved = true; break;

			 case CROW_OBJECT:
			 case MONSTER_OBJECT:
			 case MONSTER2_OBJECT:
			 case FLAMEGUY_OBJECT:
			 case FLAMEGUY2_OBJECT:
			 case ROUNDMAN_OBJECT:
			 case ROUNDMAN2_OBJECT: if(g_cObjectManager.monsterSmartMoveCheck(temp)) moved = true; break;
			 default: moved = true;
			 }

			 /*
			 if(isSpell)
				 moved = true;
			 else if( g_cObjectManager.distance(g_cObjectManager.m_pPlayerObject,temp) < 700.0f) //Can we see the monster? {
				   if(g_cObjectManager.monsterSmartMoveCheck(temp))
						moved = true;
			  else
				  moved = true; //Who cares if the monster is on a tree
			*/

		   if(moved){
			   m_structLocation.x += xdelta; //x motion
			   m_structLocation.y -= ydelta; //y motion
		   }


		   if(m_nBounceCount>=3)m_nLifeTime = 1; //force cull by making lifetime tiny
				m_nLastMoveTime = time;

		 // }while(!moved);

		}
	  else
		  m_nLastMoveTime = time;
	}
  else
	  m_nLastMoveTime = time;
  
}
Exemple #25
0
void CGUIListBox::StaticInit()
{
	CObjectManager *pOm = &CSingleton<CObjectManager>::Instance();
	if (!pOm->IsExist("default_CGUIContainer")) {
		CGUIContainer::StaticInit();
	}
	//load the default CGUIBase object and copy all its value to the new button
	CGUIListBox *pListbox = new CGUIListBox();
	pOm->CloneObject("default_CGUIContainer", pListbox);
	//pListbox->m_objType=CGUIBase::Type_GUIListBox|CGUIBase::GUIContainer;
	pListbox->m_bMultiSelect = false;
	pListbox->m_nSelected = -1;
	pListbox->m_bAllowAdvObject = false;
	pListbox->m_bNeedUpdate = true;
	pListbox->m_deltaX = 0;
	pListbox->m_deltaY = 0;
	pListbox->m_SelBkColor = COLOR_ARGB(255, 40, 50, 92);
	pListbox->m_ItemHeight = 0;
	pListbox->m_nBorder = 2;
	pListbox->m_nMargin = 6;
	pListbox->m_bCanHasFocus = true;
	pListbox->m_bDrag = false;
	pListbox->m_nSelStart = 0;
	pListbox->m_bFastRender = true;
	pListbox->m_bWordBreak = false;
	pListbox->m_bScrollable = true;

	CEventBinding* pBinding = (CEventBinding*)pListbox->m_event->GetEventBindingObj();
	pBinding->EnableKeyboard();
	pBinding->EnableMouse();

	//	pBinding->MapEvent(EM_MOUSE_LEFTDOWN,EM_CTRL_CAPTUREMOUSE);
	//	pBinding->MapEvent(EM_MOUSE_LEFTDOWN,EM_LB_ACTIONBEGIN);
	//	pBinding->MapEvent(EM_MOUSE_LEFTUP,EM_CTRL_RELEASEMOUSE);
	//	pBinding->MapEvent(EM_MOUSE_LEFTUP,EM_LB_ACTIONEND);
	//	pBinding->MapEvent(EM_MOUSE_LEFTCLICK,EM_LB_ACTIONEND);
	//	pBinding->MapEvent(EM_MOUSE_LEFTCLICK,EM_CTRL_RELEASEMOUSE);
	//	pBinding->MapEvent(EM_MOUSE_LEFTDBCLICK,EM_CTRL_CHANGE);
	//	pBinding->MapEvent(EM_KEY_RETURN,EM_CTRL_CHANGE);
	pBinding->MapEvent(EM_KEY_HOME, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_END, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_PAGE_DOWN, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_PAGE_UP, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_LEFT, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_RIGHT, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_DOWN, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_UP, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_RETURN, EM_CTRL_HOLDKEY);
	pBinding->EnableEvent(EM_MOUSE_DBCLICK);
	pBinding->EnableEvent(EM_MOUSE_CLICK);

	using namespace ParaInfoCenter;
	CICConfigManager *cm = CGlobals::GetICConfigManager();

	string value0, value1;
	int event0, event1, a;
	DWORD b;
	HRESULT hr;
	hr = cm->GetSize("GUI_listbox_control_mapping", &b);
	if (hr == E_INVALIDARG || hr == E_ACCESSDENIED) {
		//error
	}
	else{
		for (a = 0; a < (int)b; a += 2) {
			hr = cm->GetTextValue("GUI_listbox_control_mapping", value0, a);
			if (FAILED(hr)) {
				break;
			}
			hr = cm->GetTextValue("GUI_listbox_control_mapping", value1, a + 1);
			if (FAILED(hr)) {
				break;
			}
			event0 = CEventBinding::StringToEventValue(value0);
			event1 = CEventBinding::StringToEventValue(value1);
			pBinding->MapEvent(event0, event1);
		}
	}
	int tempint;
	if (cm->GetIntValue("GUI_listbox_control_visible", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bIsVisible = false;
		}
		else
			pListbox->m_bIsVisible = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_enable", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bIsEnabled = false;
		}
		else
			pListbox->m_bIsEnabled = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_canhasfocus", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bCanHasFocus = false;
		}
		else
			pListbox->m_bCanHasFocus = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_candrag", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->SetCandrag(false);
		}
		else
			pListbox->SetCandrag(true);
	}
	if (cm->GetIntValue("GUI_listbox_control_lifetime", &tempint) == S_OK) {
		pListbox->m_nLifeTimeCountDown = tempint;
	}
	if (cm->GetIntValue("GUI_listbox_control_multiselect", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bMultiSelect = false;
		}
		else
			pListbox->m_bMultiSelect = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_fastrender", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bFastRender = false;
		}
		else
			pListbox->m_bFastRender = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_wordbreak", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bWordBreak = false;
		}
		else
			pListbox->m_bWordBreak = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_margin", &tempint) == S_OK) {
		pListbox->m_nMargin = tempint;
	}
	if (cm->GetIntValue("GUI_listbox_control_borderwidth", &tempint) == S_OK) {
		pListbox->m_nBorder = tempint;
	}
	if (cm->GetIntValue("GUI_listbox_control_itemheight", &tempint) == S_OK) {
		pListbox->m_ItemHeight = tempint;
	}
	if (cm->GetIntValue("GUI_listbox_control_scrollbarwidth", &tempint) == S_OK) {
		pListbox->m_nSBWidth = tempint;
	}
	if (cm->GetIntValue("GUI_listbox_control_scrollable", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bScrollable = false;
		}
		else
			pListbox->m_bScrollable = true;
	}


	//Set the default texture and font of the default scrollbar

	pListbox->m_objResource->SetActiveLayer();
	pListbox->m_objResource->SetCurrentState();
	pListbox->m_objResource->SetLayerType(GUILAYER::ONE_ELEMENT);

	RECT *prect = NULL;
	RECT rect;
	SpriteFontEntity* pFont;
	TextureEntity* pTexture = NULL;
	pFont = CGlobals::GetAssetManager()->GetFont("sys");
	GUIFontElement font_;
	GUIFontElement* pFontElement = &font_;
	GUITextureElement tex_;
	GUITextureElement* pElement = &tex_;

	pListbox->m_objResource->Clear();	//clean all resources;

	pFontElement->SetElement(pFont, COLOR_ARGB(255, 16, 16, 16), DT_LEFT | DT_TOP);
	pListbox->m_objResource->AddElement(pFontElement, "text");
	pFontElement->SetElement(pFont, COLOR_ARGB(255, 255, 255, 255), DT_LEFT | DT_TOP);
	pListbox->m_objResource->AddElement(pFontElement, "selected_text");
	string background, filename;
	bool bLoadDefault = true;
	if (cm->GetTextValue("GUI_listbox_control_background", background) == S_OK) {
		prect = ParaEngine::StringHelper::GetImageAndRect(background, filename, &rect);
		pTexture = CGlobals::GetAssetManager()->LoadTexture(filename.c_str(), filename.c_str(), TextureEntity::StaticTexture);
		if (pTexture != NULL) {
			bLoadDefault = false;
		}
	}
	if (bLoadDefault) {
		//Set the default texture and font of the default button
		pTexture = CGlobals::GetAssetManager()->LoadTexture("__Default_GUI", "Texture/dxutcontrols.dds", TextureEntity::StaticTexture);
		prect = &rect;
		SetRect(prect, 13, 123, 241, 160);
	}
	pElement->SetElement(pTexture, prect, COLOR_ARGB(255, 255, 255, 255));

	pListbox->m_objResource->SetCurrentState(GUIResourceState_Normal);
	pListbox->m_objResource->AddElement(pElement, "background");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Pressed);
	pListbox->m_objResource->AddElement(pElement, "background");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Highlight);
	pListbox->m_objResource->AddElement(pElement, "background");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Disabled);
	pListbox->m_objResource->AddElement(pElement, "background");
	pListbox->m_objResource->SetCurrentState();

	bLoadDefault = true;
	if (cm->GetTextValue("GUI_listbox_control_selection", background) == S_OK) {
		prect = StringHelper::GetImageAndRect(background, filename, &rect);
		pTexture = CGlobals::GetAssetManager()->LoadTexture(filename.c_str(), filename.c_str(), TextureEntity::StaticTexture);
		if (pTexture != NULL)
			bLoadDefault = false;
	}
	if (bLoadDefault) {
		//Set the default texture and font of the default button
		pTexture = CGlobals::GetAssetManager()->LoadTexture("__Default_GUI", "Texture/dxutcontrols.dds", TextureEntity::StaticTexture);
		prect = &rect;
		SetRect(prect, 17, 269, 241, 287);
	}
	pElement->SetElement(pTexture, prect, COLOR_ARGB(255, 255, 255, 255));

	pListbox->m_objResource->SetCurrentState(GUIResourceState_Normal);
	pListbox->m_objResource->AddElement(pElement, "selection");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Pressed);
	pListbox->m_objResource->AddElement(pElement, "selection");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Highlight);
	pListbox->m_objResource->AddElement(pElement, "selection");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Disabled);
	pListbox->m_objResource->AddElement(pElement, "selection");
	pListbox->m_objResource->SetCurrentState();


	pOm->SetObject("default_CGUIListBox", pListbox);
	SAFE_RELEASE(pListbox);

}
uint GCNewPlayer_MoveHandler :: Execute( GCNewPlayer_Move* pPacket, Player* pPlayer ) 
{
//__ENTER_FUNCTION
	//AxTrace(0, 2, "GCNewPlayerHandler");
//	return PACKET_EXE_CONTINUE ;

	//当前流程是主流程
	if(CGameProcedure::GetActiveProcedure() == (CGameProcedure*)CGameProcedure::s_pProcMain)
	{
		CObjectManager* pObjectManager = CObjectManager::GetMe();

		//检查位置是否合法
		if(!CWorldManager::GetMe()->GetActiveScene()->IsValidPosition(fVector2(pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ)))
		{
			TDThrow("ERROR POSITION @ GCNewPlayer_MoveHandler");
		}

		//创建玩家
		CObject_PlayerOther* pOther = (CObject_PlayerOther*)(pObjectManager->FindServerObject( (INT)pPacket->getObjID() ));
		fVector3 fvGame;
		CGameProcedure::s_pGfxSystem->Axis_Trans(
			CRenderSystem::AX_PLAN, fVector3(pPacket->getWorldPos().m_fX, 0.0f, pPacket->getWorldPos().m_fZ),
			CRenderSystem::AX_GAME, fvGame);

		if ( pOther == NULL )
		{
			pOther = pObjectManager->NewPlayerOther( (INT)pPacket->getObjID() );

			SObjectInit initPlayerOther;
			initPlayerOther.m_fvPos	= fvGame;

			pOther->Initial( &initPlayerOther );
		}
		else
		{
			fVector2 mapPos(fvGame.x, fvGame.z);
			pOther->SetMapPosition(mapPos);
			pOther->Enable( OSF_VISIABLE );
			pOther->Disalbe( OSF_OUT_VISUAL_FIELD );
		}

		////激活鼠标查询
		//if(pOther->GetRenderInterface())
		//{
		//	pOther->Enable(OSF_RAY_QUERY);
		//}

		//更新装备信息
		pOther->GetCharacterData()->Set_EquipVer(pPacket->getEquipVer());
		//跟新移动速度
		pOther->GetCharacterData()->Set_MoveSpeed(pPacket->getMoveSpeed());

		// move to command
		{
			WORLD_POS posTarget;
			posTarget.m_fX	= pPacket->getTargetPos().m_fX;
			posTarget.m_fZ	= pPacket->getTargetPos().m_fZ;

			SCommand_Object cmdTemp;
			cmdTemp.m_wID			= OC_MOVE;
			cmdTemp.m_auParam[0]	= 0;
			cmdTemp.m_anParam[1]	= pPacket->getHandleID();
			cmdTemp.m_anParam[2]	= 1;
			cmdTemp.m_apParam[3]	= &posTarget;
			pOther->PushCommand(&cmdTemp );
		}

		//放入Ask队列
		CObjectManager::GetMe()->GetLoadQueue()->TryAddLoadTask(pOther->GetID(), CObject_Character::CT_PLAYEROTHER);

		// tempcode{
		// 此版不做服务器繁忙客户端延后发消息的处理
//		CGCharAskBaseAttrib msgAskBaseAttrib;
//		msgAskBaseAttrib.setTargetID( (INT)pPacket->getObjID() );
//		CNetManager::GetMe()->SendPacket( &msgAskBaseAttrib );

		//AxTrace(0, 0, "[%d]Ask %d", m_hmObject.size(), pPacket->getObjID());
		// }

		pOther->PushDebugString("GCNewPlayer");
		pOther->SetMsgTime(CGameProcedure::s_pTimeSystem->GetTimeNow());
	}

	return PACKET_EXE_CONTINUE ;

//__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
//__ENTER_FUNCTION
//	AxTrace(0, 2, "GCNewPlayerHandler");
//
//	//当前流程是主流程
//	if(CGameProcedure::GetActiveProcedure() == (CGameProcedure*)CGameProcedure::s_pProcMain)
//	{
//		CObjectManager* pObjectManager = CObjectManager::GetMe();
//
//		//创建玩家
//		CObject_PlayerOther* pOther = pObjectManager->CreatePlayerOther(
//											(INT)pPacket->getObjID(),
//											(INT)pPacket->getRace(),
//											pPacket->getEquipVer(),
//											fVector2(pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ),
//											true);
//
//		if(!pOther) return PACKET_EXE_CONTINUE;
//
//		//设置新的位置
//		pOther->SetMapPosition(fVector2(pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ));
//		pOther->RegisterToZone();
//		//IDLE装态
//		pOther->SetMotionStatus(CMS_STATUS_IDLE);
//		pOther->PushDebugString("GCNewPlayer");
//		pOther->SetMsgTime(CGameProcedure::s_pTimeSystem->GetTimeNow());
//	}
//
//	return PACKET_EXE_CONTINUE ;
//
//__LEAVE_FUNCTION
//
//	return PACKET_EXE_ERROR ;
}
uint GCNewPet_MoveHandler::Execute( GCNewPet_Move* pPacket, Player* pPlayer ) 
{
	//当前流程是主流程
	if(CGameProcedure::GetActiveProcedure() == (CGameProcedure*)CGameProcedure::s_pProcMain)
	{
		CObjectManager* pObjectManager = CObjectManager::GetMe();

		//检查位置是否合法
		if(!CWorldManager::GetMe()->GetActiveScene()->IsValidPosition(fVector2(pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ)))
		{
			TDThrow("ERROR POSITION @ GCNewMonster_MoveHandler");
		}
		if(!CWorldManager::GetMe()->GetActiveScene()->IsValidPosition(fVector2(pPacket->getTargetPos().m_fX, pPacket->getTargetPos().m_fZ)))
		{
			TDThrow("ERROR POSITION @ GCNewMonster_MoveHandler target");
		}

		//创建玩家
		CObject_PlayerNPC* pNPC = (CObject_PlayerNPC*)pObjectManager->FindServerObject( (INT)pPacket->getObjID() );
		fVector3 fvGame;
		CGameProcedure::s_pGfxSystem->Axis_Trans(
			CRenderSystem::AX_PLAN, fVector3(pPacket->getWorldPos().m_fX, 0.0f, pPacket->getWorldPos().m_fZ),
			CRenderSystem::AX_GAME, fvGame);

		if ( pNPC == NULL )
		{
			pNPC = pObjectManager->NewPlayerNPC( (INT)pPacket->getObjID() );

			SObjectInit initPlayerNPC;
			initPlayerNPC.m_fvPos	= fvGame;
			initPlayerNPC.m_fvRot	= fVector3( 0.f, 0.f, 0.f );

			pNPC->Initial( &initPlayerNPC );
		}
		else
		{
			fVector2 mapPos(fvGame.x, fvGame.z);
			pNPC->SetMapPosition(mapPos);
			pNPC->Enable( OSF_VISIABLE );
			pNPC->Disalbe( OSF_OUT_VISUAL_FIELD );
		}
		pNPC->SetNpcType(NPC_TYPE_PET);

		pNPC->GetCharacterData()->Set_MoveSpeed(pPacket->getMoveSpeed());

		// move to command
		{
			WORLD_POS posTarget;
			posTarget.m_fX	= pPacket->getTargetPos().m_fX;
			posTarget.m_fZ	= pPacket->getTargetPos().m_fZ;

			SCommand_Object cmdTemp;
			cmdTemp.m_wID			= OC_MOVE;
			cmdTemp.m_auParam[0]	= 0;
			cmdTemp.m_anParam[1]	= pPacket->getHandleID();
			cmdTemp.m_anParam[2]	= 1;
			cmdTemp.m_apParam[3]	= &posTarget;
			pNPC->PushCommand(&cmdTemp );
		}

		//放入Ask队列
		CObjectManager::GetMe()->GetLoadQueue()->TryAddLoadTask(pNPC->GetID(), CObject_Character::CT_MONSTER);

		// tempcode{
		// 此版不做服务器繁忙客户端延后发消息的处理
//		CGCharAskBaseAttrib msgAskBaseAttrib;
//		msgAskBaseAttrib.setTargetID( (INT)pPacket->getObjID() );
//		CNetManager::GetMe()->SendPacket( &msgAskBaseAttrib );

		// }


		//同步渲染层
		char szTemp[MAX_PATH];
		_snprintf(szTemp, MAX_PATH, "GCNewPet_Move(%.1f,%.1f)", 
			pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ);
		pNPC->PushDebugString(szTemp);
		pNPC->SetMsgTime(CGameProcedure::s_pTimeSystem->GetTimeNow());
	}

	return PACKET_EXE_CONTINUE ;
}
void CGUIContainer::StaticInit()
{
	CObjectManager *pOm = &CSingleton<CObjectManager>::Instance();
	if (!pOm->IsExist("default_CGUIBase")) {
		CGUIBase::StaticInit();
	}
	//load the default CGUIBase object and copy all its value to the new button
	CGUIContainer *pContainer = new CGUIContainer();
	pContainer->m_bFastRender = true;
	pContainer->m_bScrollable = false;
	pContainer->m_nMargin = DEFAULT_CONTAINER_MARGIN_SIZE;
	pContainer->m_nSBWidth = 16;
	pContainer->m_nBorder = DEFAULT_CONTAINER_BORDER_SIZE;
	pOm->CloneObject("default_CGUIBase", pContainer);
	pContainer->m_bCanCaptureMouse = false;
	// 	pContainer->m_objType=CGUIBase::GUIContainer;
	CEventBinding* pBinding = pContainer->m_event->GetEventBindingObj();
	//pBinding->DisableKeyboard();
	pBinding->EnableKeyboard();
	pBinding->EnableMouse();
	//in button, i define that a click on the button will get the button key focus
	//	pBinding->MapEvent(EM_MOUSE_LEFTDOWN,EM_CTRL_CAPTUREMOUSE);
	//	pBinding->MapEvent(EM_MOUSE_LEFTUP,EM_CTRL_RELEASEMOUSE);

	pBinding->DisableEvent(EM_MOUSE_DBCLICK);
	pBinding->DisableEvent(EM_MOUSE_CLICK);
	//	pBinding->EnableEvent(EM_KEY);
	//	pBinding->EnableEvent(EM_KEY_PAGE_DOWN);
	//	pBinding->EnableEvent(EM_KEY_PAGE_UP);
	//	pContainer->m_event->SetEventBinding(pBinding);


	if (!pOm->IsExist("default_CGUIScrollbar")) {
		CGUIScrollBar::StaticInit();
	}

	pContainer->m_VScroll = (CGUIScrollBar*)pOm->CloneObject("default_CGUIScrollbar");
	pContainer->m_VScroll->SetName("vscrollbar");
	pContainer->m_HScroll = (CGUIScrollBar*)pOm->CloneObject("default_CGUIScrollbar");
	pContainer->m_HScroll->SetName("hscrollbar");

	// TODO: 2006.8.LXZ: when GUI object is reference counted, the default container should reference the default scroll bar, so that when 
	// the style of default scroll bar is changed, so does the container scroll bar. Right now, we clone the scroll bar. 
	//pContainer->m_VScroll = (CGUIScrollBar*)pOm->GetObject("default_CGUIScrollbar");
	//pContainer->m_HScroll = (CGUIScrollBar*)pContainer->m_VScroll;

	//TODO: we could add default texture or text here, load from config
	using namespace ParaInfoCenter;
	CICConfigManager *cm = CGlobals::GetICConfigManager();
	string value0, value1;
	int event0, event1, a;
	DWORD b;
	HRESULT hr;
	hr = cm->GetSize("GUI_container_control_mapping", &b);
	if (hr == E_INVALIDARG || hr == E_ACCESSDENIED) {
		//error
	}
	else{
		for (a = 0; a < (int)b; a += 2) {
			hr = cm->GetTextValue("GUI_container_control_mapping", value0, a);
			if (FAILED(hr)) {
				break;
			}
			hr = cm->GetTextValue("GUI_container_control_mapping", value1, a + 1);
			if (FAILED(hr)) {
				break;
			}
			event0 = CEventBinding::StringToEventValue(value0);
			event1 = CEventBinding::StringToEventValue(value1);
			pBinding->MapEvent(event0, event1);
		}
	}
	int tempint;;
	if (cm->GetIntValue("GUI_container_control_fastrender", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->m_bFastRender = false;
		}
		else
			pContainer->m_bFastRender = true;
	}
	if (cm->GetIntValue("GUI_container_control_canhasfocus", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->m_bCanHasFocus = false;
		}
		else
			pContainer->m_bCanHasFocus = true;
	}
	if (cm->GetIntValue("GUI_container_control_visible", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->m_bIsVisible = false;
		}
		else
			pContainer->m_bIsVisible = true;
	}
	if (cm->GetIntValue("GUI_container_control_enable", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->m_bIsEnabled = false;
		}
		else
			pContainer->m_bIsEnabled = true;
	}
	if (cm->GetIntValue("GUI_container_control_candrag", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->SetCandrag(false);
		}
		else
			pContainer->SetCandrag(true);
	}
	if (cm->GetIntValue("GUI_container_control_scrollable", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->m_bScrollable = false;
		}
		else
			pContainer->m_bScrollable = true;
	}
	if (cm->GetIntValue("GUI_container_control_lifetime", &tempint) == S_OK) {
		pContainer->m_nLifeTimeCountDown = tempint;
	}
	if (cm->GetIntValue("GUI_container_control_scrollbarwidth", &tempint) == S_OK) {
		pContainer->m_nSBWidth = tempint;
	}
	if (cm->GetIntValue("GUI_container_control_margin", &tempint) == S_OK) {
		pContainer->m_nMargin = tempint;
	}
	if (cm->GetIntValue("GUI_container_control_borderwidth", &tempint) == S_OK) {
		pContainer->m_nBorder = tempint;
	}



	//Set the default texture and font of the default button
	pContainer->m_objResource->SetActiveLayer();
	pContainer->m_objResource->SetCurrentState();
	pContainer->m_objResource->SetLayerType(GUILAYER::ONE_ELEMENT);
	RECT *prect = NULL;
	RECT rect;
	SpriteFontEntity* pFont;
	TextureEntity* pTexture = NULL;
	pFont = CGlobals::GetAssetManager()->GetFont("sys");
	GUIFontElement font_;
	GUIFontElement* pFontElement = &font_;
	GUITextureElement tex_;
	GUITextureElement* pElement = &tex_;
	pFontElement->SetElement(pFont, COLOR_ARGB(255, 0, 0, 0), DT_LEFT | DT_TOP | DT_WORDBREAK);
	pContainer->m_objResource->AddElement(pFontElement, "text");
	string background, filename;
	bool bLoadDefault = true;
	if (cm->GetTextValue("GUI_container_control_background", background) == S_OK) {
		prect = ParaEngine::StringHelper::GetImageAndRect(background, filename, &rect);
		pTexture = CGlobals::GetAssetManager()->LoadTexture(filename.c_str(), filename.c_str(), TextureEntity::StaticTexture);
		if (pTexture != NULL)
			bLoadDefault = false;
	}
	if (bLoadDefault) {
		//Set the default texture and font of the default button
		pTexture = CGlobals::GetAssetManager()->LoadTexture("__Default_GUI", "Texture/dxutcontrols.dds", TextureEntity::StaticTexture);
		prect = &rect;
		SetRect(prect, 13, 124, 241, 265);
	}
	pElement->SetElement(pTexture, prect, COLOR_ARGB(255, 255, 255, 255));
	pContainer->m_objResource->SetCurrentState(GUIResourceState_Normal);
	pContainer->m_objResource->AddElement(pElement, "background");
	pContainer->m_objResource->SetCurrentState(GUIResourceState_Pressed);
	pContainer->m_objResource->AddElement(pElement, "background");
	pContainer->m_objResource->SetCurrentState(GUIResourceState_Highlight);
	pContainer->m_objResource->AddElement(pElement, "background");
	pContainer->m_objResource->SetCurrentState(GUIResourceState_Disabled);
	pContainer->m_objResource->AddElement(pElement, "background");
	pContainer->m_objResource->SetCurrentState();
	pContainer->m_objResource->SetActiveLayer();

	pOm->SetObject("default_CGUIContainer", pContainer);
	SAFE_RELEASE(pContainer);
}
Exemple #29
0
void CreateObjects(){
srand(time(NULL));
 theObjects.create(STARFIRE_OBJECT,SCREEN_WIDTH/2,SCREEN_HEIGHT,0,-1); //put fighter at bottom of screen
 

 for(int i = 0; i < NUM_BLASTERS; i++)
 theObjects.create(BLASTER_OBJECT,0,0,0,0);
 


 for(int j = 0; j < NUM_EBLASTERS; j++)
 theObjects.create(ENEMY_BLASTER_OBJECT,0,0,0,0);

 for(int k = 0; k < NUM_BULLETS; k++)
 theObjects.create(BULLET_OBJECT,0,0,0,0); 
  

 theObjects.create(POWER_OBJECT,SCREEN_WIDTH/2,0,0,1);
 theObjects.create(SHIELD_OBJECT,SCREEN_WIDTH/2,0,0,1);
 theObjects.create(BONUS_OBJECT,SCREEN_WIDTH/2,0,0,1);
 theObjects.create(X_OBJECT,SCREEN_WIDTH/2,0,0,1);

 theObjects.create(DART_OBJECT,400,0,0,2);
 theObjects.create(DART_OBJECT,256,0,0,1);		//and enemies at top
 theObjects.create(DART_OBJECT,600,0,0,2);

 theObjects.initExplosions();

} //CreateObjects
Exemple #30
0
void ProcessFrame(){ //process a frame of animation
  const int LOGO_DISPLAY_TIME=5500; //duration of logo
  const int TITLE_DISPLAY_TIME=20000; //duration of title
  static int not_first = 0;
  static int last_time = Timer.time();
  
  //check for lost surfaces, eg alt+tab
  if(lpPrimary->IsLost()){
    RestoreSurfaces(); Redraw();
  }
  


  switch(GamePhase){ //what phase are we in?
    case LOGO_PHASE: //displaying logo screen
      Sleep(100); //surrender time to other processes
      if(endphase||Timer.elapsed(PhaseTime,LOGO_DISPLAY_TIME))
        change_phase(TITLE_PHASE); //go to title screen
      break;
    case TITLE_PHASE: //displaying title screen
      Sleep(100); //surrender time to other processes
      if(endphase||Timer.elapsed(PhaseTime,TITLE_DISPLAY_TIME))
        change_phase(MENU_PHASE); //go to menu
      break;
	case HELP_PHASE: if(endphase)
					  change_phase(ENEMY_PHASE); //go to menu
    case ENEMY_PHASE: if(endphase)
					  change_phase(MENU_PHASE); //go to menu
      
    case MENU_PHASE: //main menu
	
      Sleep(100); //surrender time to other processes
      if(endphase){
		  if(not_first){
		   CurrentLevel = 0;
		  theObjects.reset(0);
		  }
		  else{
			   not_first = 1;

		  }

		  change_phase(PLAYING_PHASE); //play game
	  }
      break;
    case PLAYING_PHASE: //game engine
	  
		if(Timer.elapsed(last_time,35)){
			if(mouse_mode){
			g_input.Update();	//update the input
			ProcessInput();	//process it
			}
			last_time = Timer.time();
		}

	  ComposeFrame(); //compose a frame in back surface
	  //PutText(temp.c_str(),lpPrimary);
      if(endphase) 
        change_phase(MENU_PHASE); 
	  if(theObjects.lives_remaining < 0){

		  change_phase(GAMEOVER_PHASE);
	  }
	  if(theObjects.won()) {
		 //change_phase(MENU_PHASE);
		  theObjects.reset(++CurrentLevel);
	  }
	  
	  
	  
      break;
	case GAMEOVER_PHASE:
		Sleep(100);
		if(endphase){
			change_phase(MENU_PHASE);
		}
		break;
	default: break;
  }
} //ProcessFrame