Пример #1
0
//============================================================================
int main( int argc, char *argv[] )
{	
    
    printf("Game Data Dir: %s\n", getResourceDir().c_str() );
	// Initialize SDL
	if (SDL_Init( SDL_INIT_NOPARACHUTE | SDL_INIT_VIDEO ) < 0 ) 
	{
		fprintf( stderr, "Unable to init SDL: %s\n", SDL_GetError() );
	}

	if (SDL_SetVideoMode( SCREEN_RES_X, SCREEN_RES_Y, 32, SDL_OPENGL /* | SDL_FULLSCREEN */  ) == 0 ) 
	{
		fprintf(stderr,	"Unable to set video mode: %s\n", SDL_GetError());
        exit(1);
	}

	SDL_WM_SetCaption( "LD13 Crossroads", NULL );

	// seed rand
	srand( time(0) );

	// Game
	GameState game;
	game.nextLevel();
	GameViewGL gameView( &game );

	//=====[ Main loop ]======
	Uint32 ticks = SDL_GetTicks(), ticks_elapsed, sim_ticks = 0;
	bool done = false;
	while(!done)
	{
		SDL_Event event;

		while (SDL_PollEvent( &event ) ) 
		{
			switch (event.type )
			{
				case SDL_KEYDOWN:
					switch( event.key.keysym.sym ) 
					{						
						case SDLK_ESCAPE:
								game.cancelWord();
								break;

						case SDLK_RETURN:
						case SDLK_SPACE:
								game.commitWord();
								break;	
						case SDLK_r:
							game.restartLevel();
							break;
						case SDLK_n:
							game.nextLevel();
							break;
                        default:
                            break;
					}
					break;
				case SDL_MOUSEMOTION:
					gameView.mouseMove( event.motion.x, event.motion.y );					
					break;
				case SDL_MOUSEBUTTONDOWN:
					gameView.mouseDown();
					break;
				case SDL_MOUSEBUTTONUP:
					gameView.mouseUp();
					break;
				case SDL_QUIT:
					done = true;
					break;
			}
		}

		// Timing
		ticks_elapsed = SDL_GetTicks() - ticks;
		ticks += ticks_elapsed;

		// fixed sim update
		sim_ticks += ticks_elapsed;
		while (sim_ticks > STEPTIME) 
		{
			sim_ticks -= STEPTIME;						

//			printf("update sim_ticks %d ticks_elapsed %d\n", sim_ticks, ticks_elapsed );			
			game.update( (float)STEPTIME / 1000.0f );
		}	

		// redraw as fast as possible		
		float dtRaw = (float)(ticks_elapsed) / 1000.0f;
		//_RPT2( _CRT_WARN, "ticks_elapsed %d dtraw %f\n", ticks_elapsed, dtRaw );
		gameView.update( dtRaw ); 
		gameView.redraw( dtRaw );

		SDL_GL_SwapBuffers();
	}

	SDL_Quit();

	return 0;
}
Пример #2
0
bool CometConquestEventListener::HandleEvent( IEventData const & event )
{
	if ( EvtData_Request_Start_Game::sk_EventType == event.VGetEventType() )
	{
		m_CometConquest->VChangeState(BGS_WaitingForPlayers);
	}
	else if ( EvtData_Game_State::sk_EventType == event.VGetEventType() )
	{
		const EvtData_Game_State & castEvent = static_cast< const EvtData_Game_State & >( event );
		m_CometConquest->VChangeState(castEvent.m_gameState);
	}
	else if ( EvtData_Remote_Client::sk_EventType == event.VGetEventType() )
	{
		// This event is always sent from clients to the game server.

		const EvtData_Remote_Client & castEvent = static_cast< const EvtData_Remote_Client & >( event );
		const int sockID = castEvent.m_socketId;
		const int ipAddress = castEvent.m_ipAddress;

		// The teapot has already been created - we need to go find it.
		//ActorMap::iterator i = m_CometConquest->m_ActorList.begin();
		//ActorMap::iterator end = m_CometConquest->m_ActorList.end();
		//shared_ptr<IActor> actor = shared_ptr<BaseActor>(); 
		//while (i != end)
		//{
		//	actor = (*i).second;
		//	if (actor->VGetType() == AT_Ship)
		//	{
		//		shared_ptr<ActorParams> params = actor->VGetParams();
		//		shared_ptr<ShipParams> teapotParams = boost::static_pointer_cast<ShipParams>(params);
		//		if (teapotParams->m_ViewId == VIEWID_NO_VIEW_ATTACHED)
		//		{
		//			break;
		//		}
		//	}
		//	++i;
		//}

		//if (actor != shared_ptr<BaseActor>())
		//{
		NetworkGameView *netGameView = GCC_NEW NetworkGameView( sockID );

		shared_ptr<IGameView> gameView(netGameView);
		m_CometConquest->VAddView(gameView, sockID);

		extern void ListenForCometConquestViewEvents(EventListenerPtr listener);

		EventListenerPtr listener ( GCC_NEW NetworkEventForwarder( sockID ) );
		ListenForCometConquestViewEvents( listener );
		//}
	}

	else if ( EvtData_Network_Player_Actor_Assignment::sk_EventType == event.VGetEventType() )
	{
		// we're a remote client getting an actor assignment.
		// the server assigned us a playerId when we first attached (the server's socketId, actually)
		const EvtData_Network_Player_Actor_Assignment & castEvent =
			static_cast< const EvtData_Network_Player_Actor_Assignment & >( event );

		shared_ptr<IGameView> playersView(GCC_NEW CometConquestGameView(true));
		playersView.get()->VOnAttach(castEvent.m_remotePlayerId, castEvent.m_actorId);
		m_CometConquest->VAddView(playersView, castEvent.m_actorId);	
	}

	else if ( EvtData_PhysCollision::sk_EventType == event.VGetEventType() )
	{
		const EvtData_PhysCollision & castEvent = static_cast< const EvtData_PhysCollision & >( event );
		shared_ptr<IActor> pGameActorA = m_CometConquest->VGetActor(castEvent.m_ActorA);
		shared_ptr<IActor> pGameActorB = m_CometConquest->VGetActor(castEvent.m_ActorB);
		if (!pGameActorA || !pGameActorB)
			return false;

		int typeA = pGameActorA->VGetType();
		int typeB = pGameActorB->VGetType();

		//Bullets hitting things
		if(AT_Bullet == typeA && AT_Ship != typeB && AT_Floor != typeB)
		{
			m_CometConquest->VRemoveActor(pGameActorA->VGetID());
		}
		if(AT_Bullet == typeB && AT_Ship != typeA && AT_Floor != typeA)
		{
			m_CometConquest->VRemoveActor(pGameActorB->VGetID());
		}
		//Comets hitting boundry wall
		if(AT_Comet == typeB && AT_BoundryWall == typeA)
		{
			m_CometConquest->VRemoveActor(pGameActorB->VGetID());
		}
		if(AT_Comet == typeA && AT_BoundryWall == typeB)
		{
			m_CometConquest->VRemoveActor(pGameActorA->VGetID());
		}
		//Ship getting hit by a comet
		if(AT_Ship == typeA && AT_Comet == typeB)
		{
			ShipParams tp;
			tp.m_StartPosition = static_cast<ShipParams *>(pGameActorA->VGetParams().get())->m_StartPosition;
			tp.m_Mat = tp.m_StartPosition;
			tp.m_Length = 2.5;
			tp.m_ViewId = static_cast<ShipParams *>(pGameActorA->VGetParams().get())->m_ViewId;
			tp.m_Team = static_cast<ShipParams *>(pGameActorA->VGetParams().get())->m_Team;
			const EvtData_Request_New_Actor requestShip( &tp );
			m_CometConquest->VRemoveActor(pGameActorA->VGetID());
			safeTriggerEvent( requestShip );
		}
		if(AT_Ship == typeB && AT_Comet == typeA)
		{
			ShipParams tp;
			tp.m_StartPosition = static_cast<ShipParams *>(pGameActorB->VGetParams().get())->m_StartPosition;
			tp.m_Mat = tp.m_StartPosition;
			tp.m_Length = 2.5;
			tp.m_ViewId = static_cast<ShipParams *>(pGameActorB->VGetParams().get())->m_ViewId;
			tp.m_Team = static_cast<ShipParams *>(pGameActorB->VGetParams().get())->m_Team;
			const EvtData_Request_New_Actor requestShip( &tp );
			m_CometConquest->VRemoveActor(pGameActorB->VGetID());
			safeTriggerEvent( requestShip );
		}
		//Shooting players
		if(AT_Ship == typeA && AT_Bullet == typeB)
		{

			ShipParams tp;
			tp.m_StartPosition = static_cast<ShipParams *>(pGameActorA->VGetParams().get())->m_StartPosition;
			tp.m_Mat = tp.m_StartPosition;
			tp.m_Length = 2.5;
			//tp.m_Id = pGameActorA->VGetID();
			tp.m_ViewId = static_cast<ShipParams *>(pGameActorA->VGetParams().get())->m_ViewId;
			tp.m_Team = static_cast<ShipParams *>(pGameActorA->VGetParams().get())->m_Team;
			const EvtData_Request_New_Actor requestShip( &tp );
			//m_CometConquest->VRemoveActor(pGameActorB->VGetID());

			safeTriggerEvent( requestShip );
			m_CometConquest->VRemoveActor(pGameActorA->VGetID());

		}
		if(AT_Ship == typeB && AT_Bullet == typeA)
		{

			ShipParams tp;
			tp.m_StartPosition = static_cast<ShipParams *>(pGameActorB->VGetParams().get())->m_StartPosition;
			tp.m_Mat = tp.m_StartPosition;
			tp.m_Length = 2.5;
			//tp.m_Id = pGameActorB->VGetID();
			tp.m_ViewId = static_cast<ShipParams *>(pGameActorB->VGetParams().get())->m_ViewId;
			const EvtData_Request_New_Actor requestShip( &tp );

			safeTriggerEvent( requestShip );
			m_CometConquest->VRemoveActor(pGameActorB->VGetID());
		}
		//Shooting Comets
		if(AT_Bullet == typeA && AT_Comet == typeB)
		{
			m_CometConquest->VRemoveActor(pGameActorB->VGetID());
			//m_CometConquest->VRemoveActor(pGameActorA->VGetID());
		}
		if(AT_Bullet == typeB && AT_Comet == typeA)
		{
			//m_CometConquest->VRemoveActor(pGameActorB->VGetID());
			m_CometConquest->VRemoveActor(pGameActorA->VGetID());
		}

		//Goal & Ring
		if(AT_Ring == typeA && AT_Goal == typeB)
		{
			RingParams rp;
			rp.m_StartPosition == static_cast<RingParams *>(pGameActorA->VGetParams().get())->m_StartPosition;
			rp.m_Mat = rp.m_StartPosition;
			const EvtData_Request_New_Actor requestRing (&rp);
			safeTriggerEvent (requestRing);
			m_CometConquest->VRemoveActor(pGameActorA->VGetID());
						if(0 == static_cast<GoalParams*>(pGameActorB->VGetParams().get())->m_Team)
			{
				m_CometConquest->blueTeamScore();
			}
			else
			{
				m_CometConquest->redTeamScore();
			}
		}
		if(AT_Ring == typeB && AT_Goal == typeA)
		{
			RingParams rp;
			rp.m_StartPosition == static_cast<RingParams *>(pGameActorB->VGetParams().get())->m_StartPosition;
			rp.m_Mat = rp.m_StartPosition;
			const EvtData_Request_New_Actor requestRing (&rp);
			safeTriggerEvent (requestRing);
			m_CometConquest->VRemoveActor(pGameActorB->VGetID());
			if(0 == static_cast<GoalParams*>(pGameActorA->VGetParams().get())->m_Team)
			{
				m_CometConquest->blueTeamScore();
			}
			else
			{
				m_CometConquest->redTeamScore();
			}

		}

	}
	else if ( EvtData_Thrust::sk_EventType == event.VGetEventType() )
	{
		const EvtData_Thrust & castEvent = static_cast< const EvtData_Thrust & >( event );
		shared_ptr<IActor> pActor = m_CometConquest->VGetActor(castEvent.m_id);
		if( pActor )
		{
			static const float newtonForce = 1.f;
			float thrustForce = castEvent.m_throttle * newtonForce;

			Mat4x4 rotation = pActor->VGetMat();
			rotation.SetPosition(Vec3(0,0,0));
			Vec3 dir = rotation.Xform(g_Forward);
			dir.Normalize();
			m_CometConquest->m_pPhysics->VApplyForce(dir, thrustForce, castEvent.m_id);
		}
	}
	else if ( EvtData_Steer::sk_EventType == event.VGetEventType() )
	{
		static const float newtonForce = -.25 * 1.8f;

		const EvtData_Steer & castEvent = static_cast< const EvtData_Steer & >( event );
		float steerForce = -castEvent.m_dir * newtonForce;
		m_CometConquest->m_pPhysics->VApplyTorque(Vec3(0,1,0), steerForce, castEvent.m_id);
	}
	else if ( EvtData_Fire_Weapon::sk_EventType == event.VGetEventType() )
	{
		if(!this->m_CometConquest->m_bProxy)
		{
			const EvtData_Fire_Weapon & castEvent = static_cast< const EvtData_Fire_Weapon & >( event );
			ActorId gunnerId = castEvent.m_id;

			shared_ptr<IActor> pGunner = m_CometConquest->VGetActor(gunnerId);
			if (pGunner)
			{

				//Calculate depth offset from the controller
				Vec4 at = g_Forward4 * 3.0f;
				Vec4 atWorld = pGunner->VGetMat().Xform(at);

				Vec3 normalDir(atWorld);
				normalDir.Normalize();

				BulletParams sp;
				sp.m_Pos = pGunner->VGetMat().GetPosition() + Vec3(atWorld) * 3;
				sp.m_Radius = 0.25;
				sp.m_Segments = 16;
				sp.m_Color = g_Cyan;
				sp.m_NormalDir = normalDir;
				sp.m_Force = g_WeaponForce;
				sp.m_TeamFiredBy = static_cast<ShipParams *>(pGunner->VGetParams().get())->m_Team;
				//Request creation of this actor.
				const EvtData_Request_New_Actor cannonBallEvt( &sp );
				safeTriggerEvent( cannonBallEvt );
				return true;
			}
		}

	}
	else if ( EvtData_Move_Actor::sk_EventType == event.VGetEventType() )
	{
		const EvtData_Move_Actor & castEvent = static_cast< const EvtData_Move_Actor & >( event );
		m_CometConquest->VMoveActor(castEvent.m_Id, castEvent.m_Mat);
	}
	else if ( EvtData_Request_New_Actor::sk_EventType == event.VGetEventType() )
	{
		const EvtData_Request_New_Actor & castEvent = static_cast< const EvtData_Request_New_Actor & >( event );

		ActorParams * pActorParams = NULL;

		pActorParams = castEvent.m_pActorParams;


		//Did we get valid actor params?
		if ( NULL == pActorParams )
		{
			assert( 0 && "Invalid parameters specified for actor!" );
			return false;
		}

		//Valid params.
		const ActorId actorID = m_CometConquest->GetNewActorID();
		pActorParams->m_Id = actorID;
		//Package as a new actor event.
		/*
		IEventDataPtr actorEvent( IEventDataPtr( GCC_NEW EvtData_New_Actor( actorID, pActorParams ) ) );
		const bool bSuccess = safeQueEvent( actorEvent );
		*/
		const EvtData_New_Actor actorEvent( actorID, pActorParams );
		const bool bSuccess = safeTriggerEvent( actorEvent );

		return bSuccess;
	}
	else if ( EvtData_New_Actor::sk_EventType == event.VGetEventType() )
	{
		const EvtData_New_Actor & castEvent = static_cast< const EvtData_New_Actor & >( event );
		ActorParams * pActorParams = castEvent.m_pActorParams;

		if ( NULL == pActorParams )
		{
			assert( 0 && "Received a new actor event with NULL actor parameters!" );
			return false;
		}

		pActorParams->VCreate(m_CometConquest);


		if ( false == castEvent.m_id )
		{
			assert( 0 && "Unable to construct desired actor type!" );
			return false;
		}
	}

	return false;
}
bool nxNexteroidsGameLogicEventListener::HandleEvent( nxIEventData const & event )
{
	if(event.VGetEventType() == NX_EVENT_RequestNewGame)
	{
		log(NX_LOG_DEBUG, "New game event received");
//		m_pGameLogic->VChangeState(NX_GS_LoadingGameEnvironment);
		m_pGameLogic->VChangeState(NX_GS_WaitingForPlayers);
		return true;
	}
	else if(event.VGetEventType() == NX_EVENT_GameState)
	{
        nxGameStateEventData* gameStateEvent = (nxGameStateEventData*)(&event);
		if(gameStateEvent->GetState() == NX_GS_LoadingGameEnvironment)
		{
		}
		else if(gameStateEvent->GetState() == NX_GS_LoadedLevel00)
		{
			m_pGameLogic->VBuildLevel00();
		}

		return true;
	}
	else if(event.VGetEventType() == NX_EVENT_RequestNewActor)
	{
		//Check to make sure request is worthy
		const nxRequestNewActorEventData & castEvent =
			static_cast< const nxRequestNewActorEventData & >( event );
		//Validate event and get a new actor id and generate a new actor event.
		nxIActor* pActor = castEvent.GetActor();
		pActor->VCreate();

		const nxIEventDataPtr eventPtr( NX_NEW nxNewActorEventData(pActor));
		nxEventManager::GetInstance().VQueueEvent( eventPtr );

		return true;
	}
	else if(event.VGetEventType() == NX_EVENT_NewActor)
	{
		const nxNewActorEventData & castEvent =
			static_cast< const nxNewActorEventData & >( event );

		shared_ptr<nxIActor> pActor(castEvent.GetActor()->VClone());

		m_pGameLogic->VAddActor(pActor);

		return true;

	}
	else if(event.VGetEventType() == NX_EVENT_Thrust)
	{
		const nxThrustEventData & castEvent =
			static_cast< const nxThrustEventData & >( event );
		shared_ptr<nxIActor> pActor = m_pGameLogic->VGetActor(castEvent.GetActorId());

		if( pActor )
		{
			m_pGameLogic->VGetPhysics()->VApplyThrottle(pActor->VGetId(), castEvent.GetThrustAmount());
		}
		return true;
	}
	else if(event.VGetEventType() == NX_EVENT_Steer)
	{
		const nxSteerEventData & castEvent =
			static_cast< const nxSteerEventData & >( event );
		shared_ptr<nxIActor> pActor = m_pGameLogic->VGetActor(castEvent.GetActorId());

		if( pActor )
		{
			m_pGameLogic->VGetPhysics()->VApplySteering(pActor->VGetId(), castEvent.GetSteerAmount());
		}
		return true;
	}
	else if(event.VGetEventType() == NX_EVENT_FireWeapon)
	{
		const nxFireWeaponEventData & castEvent =
			static_cast< const nxFireWeaponEventData & >( event );
		shared_ptr<nxIActor> pActor = m_pGameLogic->VGetActor(castEvent.GetActorId());

		if( pActor )
		{
			float r = 30.0f;
			float bulletRadius = 1.0f;
			pActor->VSetRadius(bulletRadius);
			r += bulletRadius;
			float bulletSpeed = 40000.0f;
			nxPoint3 bulletPos(pActor->VGetPos().GetX() + (r * cos(pActor->VGetOrientation())),
								pActor->VGetPos().GetY() + (r * sin(pActor->VGetOrientation())),
								0);
			nxReal bulletRot = pActor->VGetOrientation();
			shared_ptr<nxBulletActor> pBullet(NX_NEW nxBulletActor(bulletRot, bulletPos, bulletRadius, bulletSpeed));
			const nxActorId actorId = m_pGameLogic->GetNewActorId();
			pBullet->VSetId(actorId);
			nxColour bulletColour;
			bulletColour.r = 1;
			bulletColour.g = 1;
			bulletColour.b = 0; //Server is always green! Best colour
			pBullet->VSetColour(bulletColour);
			pBullet->VSetViewId(-1); //Don't think I need this?

			const nxIEventDataPtr eventPtr( NX_NEW nxRequestNewActorEventData(pBullet));
			nxEventManager::GetInstance().VQueueEvent(eventPtr);
		}
		return true;
	}
	else if(event.VGetEventType() == NX_EVENT_PhysCollision)
	{
		const nxPhysCollisionEventData & castEvent =
			static_cast< const nxPhysCollisionEventData & >( event );

		shared_ptr<nxIActor> actorA = m_pGameLogic->VGetActor(castEvent.GetActorIdA());
		shared_ptr<nxIActor> actorB = m_pGameLogic->VGetActor(castEvent.GetActorIdB());

		if( actorA && actorB )
		{
			if( 
					((actorA->VGetType() == NX_ACTOR_ROCK) &&
					 (actorB->VGetType() == NX_ACTOR_BULLET)) ||
					((actorA->VGetType() == NX_ACTOR_BULLET) &&
					 (actorB->VGetType() == NX_ACTOR_ROCK))
			  )
			{
				shared_ptr<nxIActor> rock, bullet;
				//Rock hit bullet
				if(actorA->VGetType() == NX_ACTOR_BULLET)
				{
					bullet = actorA;
					rock = actorB;
				}
				else
				{
					rock = actorA;
					bullet = actorB;
				}
				//Now register hit and kill actor. 
				m_pGameLogic->VRegisterHit(rock->VGetId(), bullet->VGetId());

				const nxIEventDataPtr eventPtr( NX_NEW nxActorDeathEventData(bullet->VGetId()));
				nxEventManager::GetInstance().VQueueEvent(eventPtr);

				nxPoint3 rockPos = rock->VGetPos();
				nxReal rockRot = rock->VGetOrientation();
				nxReal rockRadius = rock->GetRadius();
//				int rockType = ((nxRockActor*)(rock.get()))->VGetRockType();

				const nxIEventDataPtr rockEventPtr( NX_NEW nxActorDeathEventData(rock->VGetId()));
				nxEventManager::GetInstance().VQueueEvent(rockEventPtr);

				//TODO:Blowing up sounds, effects, what have you.
				//If not a small rock, make smaller ones.
				if(rockRadius >= 20)
				{
					//Spawn 2 rocks in place
					//1st rock
					rockPos.SetX(rockPos.GetX() + 20 ); //TODO:Make more random
					nxReal rockSpeed = 4;
					nxReal rockRadius = 10; //Make a smaller rock
					shared_ptr<nxRockActor> pRock(NX_NEW nxRockActor(rockRot, rockPos, rockRadius, rockSpeed));
					nxColour rockColour;
					rockColour.r = 1;
					rockColour.g = 1;
					rockColour.b = 1; //Server is always green! Best colour
					pRock->VSetColour(rockColour);
					pRock->VSetViewId(-1); //Don't need this I think
					pRock->VSetRockType(0);
					const nxActorId rockActorId = m_pGameLogic->GetNewActorId();
					pRock->VSetId(rockActorId);
					const nxIEventDataPtr newRockEventPtr( NX_NEW nxRequestNewActorEventData(pRock));
					nxEventManager::GetInstance().VQueueEvent(newRockEventPtr);
					
					//2nd rock
					rockPos.SetX(rockPos.GetX() - 40); //TODO:Make more random
					rockSpeed = 4;
					rockRadius = 10;  //Make a smaller rock
					shared_ptr<nxRockActor> pRock2(NX_NEW nxRockActor(rockRot, rockPos, rockRadius, rockSpeed));
					nxColour rockColour2;
					rockColour2.r = 1;
					rockColour2.g = 1;
					rockColour2.b = 1; //Server is always green! Best colour
					pRock2->VSetColour(rockColour2);
					pRock2->VSetViewId(-1); //Don't need this I think
					pRock2->VSetRockType(0);
					const nxActorId rock2ActorId = m_pGameLogic->GetNewActorId();
					pRock2->VSetId(rock2ActorId);
					const nxIEventDataPtr newRock2EventPtr( NX_NEW nxRequestNewActorEventData(pRock2));
					nxEventManager::GetInstance().VQueueEvent(newRock2EventPtr);
				}
			}
			else if( 
					((actorA->VGetType() == NX_ACTOR_BULLET) &&
					 (actorB->VGetType() == NX_ACTOR_SPACESHIP)) ||
					((actorA->VGetType() == NX_ACTOR_SPACESHIP) &&
					 (actorB->VGetType() == NX_ACTOR_BULLET))
			  )
			{
				shared_ptr<nxIActor> ship, bullet;
				//Rock hit bullet
				if(actorA->VGetType() == NX_ACTOR_BULLET)
				{
					bullet = actorA;
					ship = actorB;
				}
				else
				{
					ship = actorA;
					bullet = actorB;
				}
				const nxIEventDataPtr bulletEventPtr( NX_NEW nxActorDeathEventData(bullet->VGetId()));
				nxEventManager::GetInstance().VQueueEvent(bulletEventPtr);

				const nxIEventDataPtr shipEventPtr( NX_NEW nxActorDeathEventData(ship->VGetId()));
				nxEventManager::GetInstance().VQueueEvent(shipEventPtr);
			}
			else if( 
					((actorA->VGetType() == NX_ACTOR_ROCK) &&
					 (actorB->VGetType() == NX_ACTOR_SPACESHIP)) ||
					((actorA->VGetType() == NX_ACTOR_SPACESHIP) &&
					 (actorB->VGetType() == NX_ACTOR_ROCK))
			  )
			{
				shared_ptr<nxIActor> ship, rock;
				//Rock hit rock
				if(actorA->VGetType() == NX_ACTOR_ROCK)
				{
					rock = actorA;
					ship = actorB;
				}
				else
				{
					ship = actorA;
					rock = actorB;
				}
				const nxIEventDataPtr rockEventPtr( NX_NEW nxActorDeathEventData(rock->VGetId()));
				nxEventManager::GetInstance().VQueueEvent(rockEventPtr);

				const nxIEventDataPtr shipEventPtr( NX_NEW nxActorDeathEventData(ship->VGetId()));
				nxEventManager::GetInstance().VQueueEvent(shipEventPtr);

			}
		}
		return true;
	}
	else if(event.VGetEventType() == NX_EVENT_ActorDeath)
	{
		const nxActorDeathEventData & castEvent =
			static_cast< const nxActorDeathEventData & >( event );

		nxActorId aid = castEvent.GetActorId();

		shared_ptr<nxIActor> pActor = m_pGameLogic->VGetActor(aid);
		if(pActor)
		{
			//Spawn another one!
//			m_pGameLogic->SpawnActor(pActor->VGetType());
			m_pGameLogic->VRemoveActor(aid);
		}

		return true;
	}
	else if(event.VGetEventType() == NX_EVENT_ActorMoved)
	{
		const nxActorMovedEventData & castEvent =
			static_cast< const nxActorMovedEventData & >( event );

		m_pGameLogic->VMoveActor(castEvent.GetActorId(), castEvent.GetPos(), castEvent.GetOrientation());
	}
	else if(event.VGetEventType() == NX_EVENT_RemoteClient)
	{
		const nxRemoteClientEventData & castEvent =
			static_cast< const nxRemoteClientEventData & >( event );

		if(m_pGameLogic->IsProxy())
		{
			//We need to create the real game view.
			//Now this will listen to all events from server, we can just kick back.:D
			int viewId = m_pGameLogic->GetIpInt();
			shared_ptr<nxIGameView> gameView(NX_NEW nxNexteroidsGameView());
			gameView->Init();
			m_pGameLogic->VPopView();
//			m_pGameLogic->VAddView(gameView, -1); //Should be set automagically over net!
			m_pGameLogic->VAddViewExplicit(gameView, viewId, -1); //Should be set automagically over net!
		}	
		else
		{
			//Set the number of players connected up!
			m_pGameLogic->SetNRemotePlayers(m_pGameLogic->GetNRemotePlayers() + 1);
			m_pGameLogic->VAddConnectedClientId(castEvent.GetIpInt());
		}
	}
	return false;
}