예제 #1
0
Geoscape::Geoscape(Career* career)
{
    _career = career;
    _endOfActivity = false;
    _requestedActivity = NULL;
    _passedTime = 0.0f;
    _blinkingTime = 0.0f;

    // create geoscape window
    _geoscape = Gameplay::iGui->createWindow( "Geoscape" ); assert( _geoscape );
    _geoscape->getPanel()->setRenderCallback( panelRenderCallback, this );
    _moveMap = false;
    _lastPosIsValid = false;
    _lastX = _lastY = 0;
    _currX = _currY = 0;
    _geoscapeMode = NULL;

    // create locations
    if( _career->isHomeDefined() )
    {
        Location* homeLocation = new Location( this, 0 );
        _locations.push_back( homeLocation );
        if( _career->getHomePlacementFlag() )
        {
            homeLocation->setPlayer( true );
            _career->setHomePlacementFlag( false );
        }
    }
    for( unsigned int i=1; i<database::LocationInfo::getNumRecords(); i++ )
    {
        _locations.push_back( new Location( this, i ) );
    }

    // make market offers
    for( unsigned int i=0; i<125; i++ )
    {
        Gear marketOffer = generateGear( getCore()->getRandToolkit()->getUniform( 0, 1 ) > 0.75f );
        if( marketOffer.isTradeable() ) addGearToMarket( marketOffer );
    }

    // MULTIVERSION ISSUE �    // if player is in inaccessible location
    if( _career->isHomeDefined() )
    {
        Location* location = getPlayerLocation();
        if( location && !database::LocationInfo::getRecord( location->getDatabaseId() )->accessible )
        {
            // move player to the dropzone
            location->setPlayer( false );
            getLocation( unsigned int( 0 ) )->setPlayer( true );
        }
예제 #2
0
void Divine::onBeginEvent(Geoscape* geoscape)
{
    castBoogieEvent();
    castFestivalEvent();
    castClimbingEvent();
    castSmokeballEvent();
    castCommunityEvent();

    // if player isn't in home location and isn't travelling
    if( geoscape->getPlayerLocation() && geoscape->getPlayerLocation()->getDatabaseId() != 0 )
    {
        // location info
        database::LocationInfo* info = database::LocationInfo::getRecord( geoscape->getPlayerLocation()->getDatabaseId() );

        // home location travelling cost
        Vector2f currentCoords = geoscape->getPlayerLocation()->getLocationCoords();
        Vector2f targetCoords = geoscape->getHomeLocation()->getLocationCoords();
        float targetDistance = ( targetCoords - currentCoords ).length();
        targetDistance = targetDistance * 40075.696f / geoscape->getWindow()->getPanel()->getRect().getWidth();
        float referenceCost = 0.05f;
        float targetCost = targetDistance * referenceCost;
        float referenceTime = 0.1f;
        float targetTime = targetDistance * referenceTime;

        // check we have enought money to stay in location
        if( targetCost + info->stayFee < _career->getVirtues()->evolution.funds )
        {
            // pay fee
            _career->getVirtues()->evolution.funds -= info->stayFee;
        }
        else
        {
            // travel to home location
            // remove player from location
            unsigned int departureId = geoscape->getPlayerLocation()->getDatabaseId();
            geoscape->getPlayerLocation()->setPlayer( false );
            // decrease funds
            _career->getVirtues()->evolution.funds -= targetCost;
            // add event
            _career->addEvent( new Travel( _career, departureId, 0, targetTime ) );
            // message
            geoscape->addHistory( Gameplay::iLanguage->getUnicodeString(293), Vector4f( 1,0.25,0.25,1 ) );
        }
    }

    // simulate market dynamics
    unsigned int maxTransactions = 210;
    // simulate buying
    unsigned int numTransactions = getCore()->getRandToolkit()->getUniformInt() % maxTransactions;
    while( numTransactions && geoscape->getMarketSize() )
    {
        // buy random gear
        geoscape->removeGearFromMarket( 
            getCore()->getRandToolkit()->getUniformInt() % geoscape->getMarketSize()
        );
        numTransactions--;
    }
    // simulate selling
    numTransactions = getCore()->getRandToolkit()->getUniformInt() % maxTransactions;
    while( numTransactions )
    {
        // sell random gear
        Gear gear = geoscape->generateGear( getCore()->getRandToolkit()->getUniform( 0, 1 ) > 0.75f );
        if( gear.isTradeable() ) geoscape->addGearToMarket( gear );
        numTransactions--;
    }
}
void castingCallback_OpenAir_HardLanding(Actor* parent)
{
    Mission* mission = dynamic_cast<Mission*>( parent ); assert( mission );    

    // exit point
    Enclosure* exitPoint = parent->getScene()->getExitPointEnclosure( mission->getMissionInfo()->exitPointId );

    // cast player on exit point
    mission->setPlayer( new Jumper( mission, NULL, exitPoint, NULL, NULL, NULL ) );

    // setup full signature for player
    mission->getPlayer()->setSignatureType( stFull );

    // choose prize
    Gear prize;
    prize.state = 1.0f;
    unsigned int numOfAttempts = 0;
    do
    {
        switch( getCore()->getRandToolkit()->getUniformInt() % 4 )
        {
        case 0: 
            prize.type = gtHelmet;
            prize.id   = getCore()->getRandToolkit()->getUniformInt() % database::Helmet::getNumRecords();
            assert( prize.id < database::Helmet::getNumRecords() );
            break;
        case 1: 
            prize.type = gtSuit; 
            prize.id   = getCore()->getRandToolkit()->getUniformInt() % database::Suit::getNumRecords();
            assert( prize.id < database::Suit::getNumRecords() );
            break;
        case 2: 
            prize.type = gtRig; 
            prize.id   = getCore()->getRandToolkit()->getUniformInt() % database::Rig::getNumRecords();
            assert( prize.id < database::Rig::getNumRecords() );
            break;
        case 3: 
            prize.type = gtCanopy; 
            prize.id   = getCore()->getRandToolkit()->getUniformInt() % database::Canopy::getNumRecords();
            assert( prize.id < database::Canopy::getNumRecords() );
            break;
        default:
            assert( !"shouldn't be here!" );
        }
        numOfAttempts++;
        if( numOfAttempts >= 100 ) break;
    }
    while( !prize.isTradeable() );

    // cast goals
    new GoalStateOfHealth( mission->getPlayer() );
    new GoalStateOfGear( mission->getPlayer() );
    new GoalLanding( mission->getPlayer() );
    new GoalExperience( mission->getPlayer() );
	new GoalFreeFallTime( mission->getPlayer() );
	new GoalCanopyTime( mission->getPlayer() );

    // cast hard landing goal
    switch( getCore()->getRandToolkit()->getUniformInt() % 4 )
    {
    case 0:
        new GoalHardLanding( mission->getPlayer(), Vector3f( 54729.2f, 12.5f, 710.7f ), 25, prize );
        break;
    case 1:
        new GoalHardLanding( mission->getPlayer(), Vector3f( -20161.7f, 5270.0f, 14244.7f ), 15, prize );
        break;
    case 2:
        new GoalHardLanding( mission->getPlayer(), Vector3f( -33753.8f, 9175.5f, -41883.1f ), 25, prize );
        break;
    case 3:
        new GoalHardLanding( mission->getPlayer(), Vector3f( 29874.7f, 1350.1f, 15392.7f ), 25, prize );
        break;
    }

    // play original music for this mission
    Gameplay::iGameplay->playSoundtrack( "./res/sounds/music/lot of lie.ogg" );
}