//------------------------------------------------- void RTSCamera::onMouseButtonDown( NamedProperties& params ) { int keyCode; vec2i mouseCoords; if( params.get( "keyCode", keyCode ) == NamedProperties::SUCCESS ) { if( keyCode == GLUT_MIDDLE_BUTTON ) { if( params.get( "screenCoords", mouseCoords ) == NamedProperties::SUCCESS ) m_lastDragPos = mouseCoords; m_isDragging = true; } } }
//------------------------------------------------- void RTSCamera::onSpecialKeyUp( NamedProperties& params ) { int keyCode; if( params.get( "keyCode", keyCode ) == NamedProperties::SUCCESS ) { m_activeSpecialKeys[ keyCode ] = false; } }
//------------------------------------------------- void RTSCamera::onMouseButtonUp( NamedProperties& params ) { int keyCode; if( params.get( "keyCode", keyCode ) == NamedProperties::SUCCESS ) { if( keyCode == GLUT_MIDDLE_BUTTON ) m_isDragging = false; } }
//------------------------------------------------------------------- void AttackMoveOrders::entityKilled( NamedProperties& params ) { Entity* entityKilled = nullptr; if( params.get( "entity", entityKilled ) == NamedProperties::SUCCESS ) { if( entityKilled == m_currentTargetEntity ) { m_currentTargetEntity = nullptr; } } }
//---------------------------------------------------------------------- void PlayerController::shipDiedEvt( NamedProperties& params ) { Spaceship* tempShip; if( params.get( "spaceship", tempShip ) == NamedProperties::SUCCESS ) { if( tempShip == m_ship ) { m_shipRespawnTimer->start(); m_ship = nullptr; } } }
//------------------------------------------------- void RTSCamera::onMouseMove( NamedProperties& params ) { vec2i mouseCoords; if( m_isDragging ) { if( params.get( "mouseCoords", mouseCoords ) == NamedProperties::SUCCESS ) { vec2i dirMouseSpace = mouseCoords - m_lastDragPos; vec2f dir = vec2f( (float)dirMouseSpace.x, (float)dirMouseSpace.y ); dir.normalize(); setPosition( getPosition() - dir ); } } }
//------------------------------------------------- void RTSCamera::onSpecialKeyDown( NamedProperties& params ) { int keyCode; if( params.get( "keyCode", keyCode ) == NamedProperties::SUCCESS ) { m_activeSpecialKeys[ keyCode ] = true; switch( keyCode ) { case GLUT_KEY_LEFT: m_impulse.x -= 1.0f; break; case GLUT_KEY_RIGHT: m_impulse.x += 1.0f; break; case GLUT_KEY_UP: m_impulse.y += 1.0f; break; case GLUT_KEY_DOWN: m_impulse.y -= 1.0f; break; } } }