当前位置: 首页>>代码示例>>C++>>正文


C++ Missile::Release方法代码示例

本文整理汇总了C++中Missile::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ Missile::Release方法的具体用法?C++ Missile::Release怎么用?C++ Missile::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Missile的用法示例。


在下文中一共展示了Missile::Release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Step

	void Client::Step()
	{
		ENetEvent event;
		
		while(enet_host_service(_host, &event, 1) > 0)
		{
			switch(event.type)
			{
				case ENET_EVENT_TYPE_RECEIVE:
				{
					Packet packet(event.packet->data, event.packet->dataLength);
					enet_packet_destroy(event.packet);
					
					switch(packet.GetType())
					{
						case Packet::Type::Handshake:
							_clientID = packet.ReadUInt32();
							
							RNDebug("Received handshake. I'm client %d", _clientID);
							break;
							
						case Packet::Type::ClientConnected:
						{
							uint32 client = packet.ReadUInt32();
							
							if(client != _clientID)
							{
								RNDebug("Another client, %d, connected", client);
								World::GetSharedInstance()->GetEnemyWithID(client);
							}
							
							break;
						}
						case Packet::Type::ClientDisconnected:
						{
							uint32 client = packet.ReadUInt32();
							
							if(client != _clientID)
							{
								RNDebug("Client %d disconnected", client);
								World::GetSharedInstance()->RemoveEnemy(client);
							}
							
							break;
						}
							
							
						case Packet::Type::PositionUpdate:
						{
							uint32 client = packet.ReadUInt32();
							
							if(client != _clientID)
							{
								Enemy *enemy = World::GetSharedInstance()->GetEnemyWithID(client);
								enemy->UpdateFromPacket(packet);
							}
							
							break;
						}
							
						case Packet::Type::ShotsFired:
						{
							uint32 client = packet.ReadUInt32();
							
							if(client != _clientID)
							{
								Missile *missile = new Missile(client, packet);
								missile->Release();
							}
							
							break;
						}
							
						case Packet::Type::GoodHit:
						{
							uint32 client = packet.ReadUInt32();
							uint32 shooter = packet.ReadUInt32();
							RN::Vector3 position(packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat());
							
							if(client == _clientID)
								SpaceShip::GetLocalShip()->TakeHit(position, shooter);
							
							Explosion *explosion = new Explosion();
							explosion->SetPosition(position);
							explosion->Autorelease();
							
							break;
						}
							
						case Packet::Type::GoodKill:
						{
							uint32 client = packet.ReadUInt32();
							uint32 killer = packet.ReadUInt32();
							
							RNDebug("Good kill on %d by %d", client, killer);
							
							if(killer == _clientID)
								World::GetSharedInstance()->TallyKill();
							
							RN::Vector3 position(packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat());
//.........这里部分代码省略.........
开发者ID:uberpixel,项目名称:Ur,代码行数:101,代码来源:URClient.cpp


注:本文中的Missile::Release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。