//调用自定义极其父类构造
CDriveGameClient::CDriveGameClient(Timer* pTimer, unsigned uID)
: CGameClient(pTimer),
m_pDrivePlayer(NULL), 
m_pDriveRegion(NULL)
{
	SetDriveMainPlayer(CreateMainPlayer());
	SetDriveMainRegion(CreateMainRegion());
	SetMemServeruID(uID);
}
示例#2
0
void Init() {
	world->tileMap.Load("test.fmp", 100);

	textures.gunAnim = renderer.CreateTextureFromFile("darkwalltile.bmp");
	textures.anim = renderer.CreateTextureFromFile("plane.bmp");
	textures.dude = renderer.CreateTextureFromFile("idkmonster.bmp");
	textures.sawblade = renderer.CreateTextureFromFile("sawblade.bmp");


	world->dude = CreateMainPlayer(0, 5);
	world->AddEntity(world->dude);


	Entity *floor = CreateBox(-20.0f, 0.0f, 40.0f, 2.0f);
	world->AddEntity(floor);
	Entity *leftWall = CreateBox(-22.0f, 0.0f, 2.0f, 42.0f);
	world->AddEntity(leftWall);
	Entity *ceiling = CreateBox(-20.0f, 40.0f, 40.0f, 2.0f);
	world->AddEntity(ceiling);
	Entity *rightWall = CreateBox(20.0f, 0.0f, 2.0f, 42.0f);
	world->AddEntity(rightWall);
		
	for(int i = 1; i < 12; i++)	{	
		Entity *e = CreateBox(-12.0f + float(i)*1.1f, 13.2f, 1.0f, 1.0f);
		Entity* q = CreateDude(-12.0f + float(i)*1.1f, 15.0f);
		world->AddEntity(e);
		world->AddEntity(q);
	}


	Entity *platform = CreateUpDownMovingPlatform(0, 2, 6, 1);
	world->AddEntity(platform);

	platform = CreateUpDownMovingConveyerPlatform(-8, 2, 6, 1);
	world->AddEntity(platform);

	platform = CreateUpDownMovingConveyerPlatform(0, 12, 6, 1); 
	world->AddEntity(platform);


	Entity * saw = CreateSaw(15, 15);
	world->AddEntity(saw);

	editor.LoadLevelFromFile("level1.txt");
	camera.halfSize = Vector2(12.0f, 12.0f);
	renderer.SetCamera(&camera);
	camera.position = ScreenToWorld(Vector2(mouse.posX,mouse.posY), camera, window);
}
//初始化主玩家数据
void CDriveGameClient::InitPlayerData(CMessage *pMsg)
{		
	long lCode = pMsg->GetLong();
	long lFlag = pMsg->GetLong();
	if (lFlag)
	{
		CGUID PlayerID;
		pMsg->GetGUID(PlayerID);

		if (m_pDrivePlayer==NULL)
		{
			m_pDrivePlayer = CreateMainPlayer();
		}
		if (m_pDrivePlayer)
		{
			// 属性转换设置
			float fStr2MinAtk[33];
			long  lHitTime			= 0;
			WORD  wBaseRp_Lv1		= 0;
			WORD  wBaseRp_Lv2       = 0;
			WORD  wPkCountPerKill   = 0;
			pMsg->GetEx(fStr2MinAtk, sizeof(float)*33);
			lHitTime		= pMsg->GetLong();
			wBaseRp_Lv1		= pMsg->GetWord();
			wBaseRp_Lv2		= pMsg->GetWord();
			wPkCountPerKill = pMsg->GetWord();
			//////////////////////////////////////////世界范围内的属性///////////////////////////////////
			float fBasePriceRate = 0;
			float fTradeInRate	 = 0;
			float fRepairFactor  = 0;
			fBasePriceRate = pMsg->GetFloat();
			fTradeInRate   = pMsg->GetFloat();
			fRepairFactor  = pMsg->GetFloat();
			char szTalkCountryGoodsName[32] = " ";
			pMsg->GetStr(szTalkCountryGoodsName, 32);
			int	nTalkCountryGoodsNum = 0;
			DWORD dwTalkCountryMoney = 0;
			nTalkCountryGoodsNum = pMsg->GetLong();
			dwTalkCountryMoney   = pMsg->GetDWord();
			char szTalkWorldGoodsName[32] = " "; 
			pMsg->GetStr(szTalkWorldGoodsName, 32);
			int	nTalkWorldGoodsNum = 0;
			DWORD dwTalkWorldMoney = 0;
			nTalkWorldGoodsNum = pMsg->GetLong();
			dwTalkWorldMoney = pMsg->GetDWord();
			// 盟国
			//pMsg->GetStr(GetGame()->GetSetup()->szTalkCountryUnionGoodsName, 32);
			//GetGame()->GetSetup()->nTalkCountryUnionGoodsNum = 0;//pMsg->GetLong();
			//GetGame()->GetSetup()->dwTalkCountryUnionMoney = 0;//pMsg->GetDWord();
			/////////////////////////////////////////////////////////////////////////////////////////////
			pMsg->GetByte();//m_pDrivePlayer->SetEnemyPlayerLevelFirstQuotiety(pMsg->GetByte());
			pMsg->GetByte();//m_pDrivePlayer->SetEnemyPlayerLevelSecondQuotiety(pMsg->GetByte());

			extern long AREA_WIDTH;
			extern long AREA_HEIGHT;
			AREA_WIDTH = pMsg->GetLong();
			AREA_HEIGHT = pMsg->GetLong();

			if (m_pDrivePlayer->GetFather())
			{
				((CClientRegion*)m_pDrivePlayer->GetFather())->RemoveObject(m_pDrivePlayer);
			}
			for(int i=0;i<EQUIP_SUM;i++)
			{
//				m_pDrivePlayer->SetEquip(i,NULL);
			}

			//开始解人物数据db
			DBReadSet setReadDB;
			pMsg->GetDBReadSet(setReadDB);
			m_pDrivePlayer->DecordFromDataBlock(setReadDB);

			//解读地图
			InitGameRegionData(pMsg);	

			//	CDriveClientDlg * pDlg = CMapScriptSystem::getInstance()->GetTestDialog()->GetDriveDlg();
			/*	pDlg->SetEvent(TRUE);*/
		}
	}
}