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


C++ Engine类代码示例

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


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

示例1: android_main

/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things.
 */
void android_main(android_app *state) {
  app_dummy();

  g_engine.SetState(state);

  // Init helper functions
  ndk_helper::JNIHelper::Init(state->activity, HELPER_CLASS_NAME,
                              HELPER_CLASS_SONAME);

  // Init play game services
  g_engine.InitGooglePlayGameServices();

  state->userData = &g_engine;
  state->onAppCmd = Engine::HandleCmd;
  state->onInputEvent = Engine::HandleInput;

  // loop waiting for stuff to do.
  while (1) {
    // Read all pending events.
    int id;
    int events;
    android_poll_source *source;

    // If not animating, we will block forever waiting for events.
    // If animating, we loop until all events are read, then continue
    // to draw the next frame of animation.
    while ((id = ALooper_pollAll(g_engine.IsReady() ? 0 : -1, NULL, &events,
                                 (void **)&source)) >= 0) {
      // Process this event.
      if (source != NULL) source->process(state, source);

      // Check if we are exiting.
      if (state->destroyRequested != 0) {
        g_engine.TermDisplay(APP_CMD_TERM_WINDOW);
        return;
      }
    }

    if (g_engine.IsReady()) {
      // Drawing is throttled to the screen update rate, so there
      // is no need to do timing here.
      g_engine.DrawFrame();
    }
  }
}
开发者ID:ggfan,项目名称:cpp-android-basic-samples,代码行数:50,代码来源:ButtonClickerNativeActivity_Engine.cpp

示例2: handleCmd

/**
 * Process the next main command.
 */
void Engine::handleCmd( struct android_app* app, int32_t cmd )
{
    Engine* eng = (Engine*) app->userData;
    switch( cmd )
    {
    case APP_CMD_INIT_WINDOW:
        if( app->window != NULL )
        {
            eng->initDisplay();
            eng->mTimer.updatePausedTime();
            eng->drawFrame();
        }
        break;
    case APP_CMD_TERM_WINDOW:
        eng->termDisplay();
        eng->mHasFocus = false;
        break;
    case APP_CMD_PAUSE:
    	 eng->mTimer.setStopped();
    	 eng->mHasFocus = false;
    	break;
    case APP_CMD_STOP:
    	eng->mTimer.setStopped();
    	eng->mHasFocus = false;
        break;
    case APP_CMD_GAINED_FOCUS:
		eng->resumeSensors();
		eng->mTimer.updatePausedTime();
		eng->mHasFocus = true;
		break;
    case APP_CMD_LOST_FOCUS:
        eng->suspendSensors();
        eng->mHasFocus = false;
        eng->mTimer.setStopped();
        break;
    case APP_CMD_LOW_MEMORY:
        eng->trimMemory();
        break;
    }
}
开发者ID:a-melnichuk,项目名称:Dice,代码行数:43,代码来源:Engine.cpp

示例3: AttalServer

void TestAttal::testEngine()
{
    AttalServer * server = new AttalServer( 1717 );

    QCOMPARE( server->isListening() , true );
    Engine * engine = new Engine( server );
    engine->setGameId( 11 );
    engine->start();

    QCOMPARE( engine->getGameId() ,11 );

    engine->quit();

    engine->wait();

    delete engine;
    delete server;
}
开发者ID:q4a,项目名称:attal,代码行数:18,代码来源:testattal.cpp

示例4: setSWaveAlongZAnalytics

/*
 * Analytics for the test described in tasks/tests/s-wave-test.xml
 * Sets analytical values for CalcNode object provided
 * It does not take into account waves from border, so it works only for wave axis and not too long
 * For high accuracy node should have coordinates (0; 0; z), where -5 < z < 5
 */
void setSWaveAlongZAnalytics(CalcNode& node, float t, Engine& engine)
{
    // Parameters from task file
    float LEFT_MARK_START = 1.0;
    float RIGHT_MARK_START = 3.0;
    float WAVE_AMPLITUDE_SCALE = 0.01;

    const MaterialPtr& mat = engine.getMaterial("trans-isotropic");
    auto p = mat->getRheologyProperties();
    float rho = mat->getRho();

    if (node.coords.z < -5 || node.coords.z > 5)
        THROW_INVALID_INPUT("Z is out of acceptable range");
    if (t < 0 || t > 0.02)
        THROW_INVALID_INPUT("T is out of acceptable range");

    float sWaveXvelocity = sqrt(p.c55 / rho);
    float sWaveYvelocity = sqrt(p.c44 / rho);
    
    float leftMarkX = LEFT_MARK_START - t * sWaveXvelocity;
    float rightMarkX = RIGHT_MARK_START - t * sWaveXvelocity;
	float leftMarkY = LEFT_MARK_START - t * sWaveYvelocity;
    float rightMarkY = RIGHT_MARK_START - t * sWaveYvelocity;

    node.vx = node.vy = node.vz = 0;
    node.sxx = node.sxy = node.sxz = node.syy = node.syz = node.szz = 0;

    if (node.coords.z >= leftMarkX && node.coords.z <= rightMarkX) {
        node.vx = sWaveXvelocity * WAVE_AMPLITUDE_SCALE;
        node.sxz = p.c55 * WAVE_AMPLITUDE_SCALE;
    }
    
    if (node.coords.z >= leftMarkY && node.coords.z <= rightMarkY) {
        node.vy = sWaveYvelocity * WAVE_AMPLITUDE_SCALE;
        node.syz = p.c44 * WAVE_AMPLITUDE_SCALE;
    }
}
开发者ID:AlexanderKazakov,项目名称:gcm-3d,代码行数:43,代码来源:AnisotropicMaterialSWavePropagationAlongOZ.cpp

示例5: TEST

TEST(TestEngine, SendToEnemyFromMany) {
    Engine e;
    tfloat radius = 6;
    std::vector<std::reference_wrapper<Planet> > s;
    for (tfloat j = -100; j < 100; j += 2 * (radius + Planet::CLOSE_RANGE))
        s.push_back(e.AddPlanet(-20, j, radius, 8, 1));

    auto& d = e.AddPlanet(21, 40, 10, 4, 2);
    
    for (Planet& p : s)
        e.Launch(5, p, d);

    while (e.ActiveShipsCount() > 0)
        e.Step();

    EXPECT_EQ(5 * s.size() - 4, d.ShipCount());
    EXPECT_EQ(1, d.GetOwner());
}
开发者ID:Meew,项目名称:web-game,代码行数:18,代码来源:EngineTest1.cpp

示例6: updatePosition

   void Player::updatePosition(Engine& ctx)
   {
      if(m_posUpdateThr(ctx.clock().ticks()))
      {
         setY(y() + m_fallSpeed); // Set vertical position

         // If the player is hurt...
         if(m_hurt) 
         {
            // ...apply knockback.
            int speed_factor = m_kickBackDirection == 1 ? 4 : 2; // Make kick-back a little stronger when going right, to move the player farther from the enemy.
            setX(x() + m_kickBackDirection * m_speed * speed_factor);
         }

         // Otherwise...
         else if((m_dashing || m_moveForward) && // ...if we're moving forward or dashing
                 (m_direction == -1 && x() > m_minX || m_direction != -1))  // and we're remaining within limits 
         {
            // Advance the player forward
            setX(x() + (m_direction) * m_speed * (m_dashing ? 4 : 1));
            if(m_dashing && abs(x() - m_dashStart) > 100) stopDash();
         }
      }
   }
开发者ID:10098,项目名称:braveball,代码行数:24,代码来源:player.cpp

示例7: BeginUpdate

	//-------------------------------------------------------------------------------------------------------
	void WaterManager::BeginUpdate( Engine& engine )
	{
		m_isRender = false;
		Frustumf frustum = engine.GetCamera()->GetFrustum();
		for ( WaterMeshes::iterator it = m_WaterDatas.begin();
			it != m_WaterDatas.end();
			it ++ )
		{
			if( frustum.Intersect( (*it)->BindBox() ) )
			{
				m_isRender = true;
				if( m_LastTileIndex != (*it)->GetIndex() )
				{
					m_LastTileIndex = (*it)->GetIndex();
					m_pWater->WaterSurface( (*it)->GetMaterial(), (*it)->GetWaterParameter() );
				}
				break;
			}
		}
		if( m_isRender )
		{
			m_pWater->BeginUpdate( engine );
		}
	}
开发者ID:RichardOpenGL,项目名称:Bohge_Engine,代码行数:25,代码来源:WaterManager.cpp

示例8: search

void search(const string& query, const Engine& engine, unsigned int start, unsigned int offset)
{
	cout << "searching for: " << query << " with start = " << start << ", offset = " << offset << endl;

	auto docIdSet = engine.search(query, start, offset);

	/*
	auto docSet = engine.getDocs(docIdSet);

	for (auto document : docSet)
	{
		string title;
		document->getEntry("title", title);
		cout << title << " ";
	}
	*/

	for (auto docId : docIdSet)
	{
		cout << docId << " ";
	}

	cout << endl;
}
开发者ID:AndryLeon,项目名称:zsearch,代码行数:24,代码来源:engine_simple_main.cpp

示例9: main

int main(int argc, char* argv[])
{
	Engine engine;

	try	{
		engine.run();
	}
	catch (...)
	{
		MessageBoxA(NULL, "Unknow exception occured, please send your log to the developer at [email protected]", "Eugola catched a fatal exception", MB_OK | MB_ICONERROR);
	}
	if (engine.getLastExceptionCode() > 1 )
		return MessageBoxA(NULL, 
						LPCTSTR(string("Exception code: " +  to_string(engine.getLastExceptionCode()) + "\n" + engine.getExitMessage() +"\nPlease, send your log to the developer at [email protected]").c_str()),
						LPCTSTR(("Eugola: " + to_string(engine.getLastExceptionCode())).c_str()), 
						MB_OK | MB_ICONERROR);
	//"//LPCTSTR(string("Exception code: " +  to_string(engine.getLastExceptionCode()) + "\n" + engine.getExitMessage() + "\nPlease, send your log to the developer at [email protected]").c_str()), "Eugola error " + engine.getLastExceptionCode(), MB_OK | MB_ICONERROR);
    return engine.getLastExceptionCode(); //0 by default
}
开发者ID:Keriz,项目名称:Eugola,代码行数:19,代码来源:main.cpp

示例10: main

int main(int argc, char **argv)
{

	Engine* engine = new Engine();
	engine->Init();

	engine->GetShader_Manager()->CreateProgram("cubeShader",
											   "Shaders\\Cube_Vertex_Shader.glsl",
											   "Shaders\\Cube_Fragment_Shader.glsl");

	CubeIndex* cube = new CubeIndex();
	cube->SetProgram(engine->GetShader_Manager()->GetShader("cubeShader"));
	cube->Create();

	engine->GetModels_Manager()->SetModel("cube", cube);

	engine->Run();

	delete engine;
	return 0;
}
开发者ID:jcharlery,项目名称:in2gpu_tutorials,代码行数:21,代码来源:main.cpp

示例11: slave

static void slave(std::string filename, int taskid)
{
    Engine engine;
    MCCalculator * calculator;
    MCCalculator::Data * curData;
    int buffsize;
    double * recvbuff, *sendbuff;

    /*allocations and initializations*/
    engine.setup(filename, taskid);
    calculator = engine.allocateMCCalculator();
    curData = engine.allocateMCCalculatorData();
    buffsize = 2 * curData->size();
    recvbuff = new double[buffsize];
    sendbuff = new double[buffsize];

    MPI_Barrier(MPI_COMM_WORLD);
    while (true)
    {
        /* Receive a message from the master */
        MPI_Bcast(&curData->m_nbSteps, 1, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);

        /* Check the tag of the received message. */
        if (curData->m_nbSteps == 0)
            break;

        /* Do the work */
        calculator->run(curData);
        curData->transferTo(sendbuff);

        /* Send the result back */
        MPI_Reduce(sendbuff, recvbuff, buffsize, MPI_DOUBLE, MPI_SUM,
					rootTASK, MPI_COMM_WORLD );
    }
    engine.freeMCCalculator(calculator);
    engine.freeMCCalculatorData(curData);
    delete[] recvbuff;
    delete[] sendbuff;
}
开发者ID:vifactor,项目名称:DislScatMCThreadingMisfit,代码行数:39,代码来源:main.cpp

示例12: GameObject

 Player::Player(const Engine& e, int x, int y):
    GameObject(x, y),
    m_landSound(e.resourceManager().getSound("land.wav"), false),
    m_jumpSound(e.resourceManager().getSound("jump.wav"), false),
    m_hurtSound(e.resourceManager().getSound("hurt.wav"), false),
    m_heartSound(e.resourceManager().getSound("heart.wav"), false),
    m_heartPtsSound(e.resourceManager().getSound("heart_nopickup.wav"), false),
    m_dashSound(e.resourceManager().getSound("dash.wav"), false),
    m_speed(1),
    m_direction(1),
    m_lives(4),
    m_hurt(false),
    m_reachedExit(false),
    m_hurtTime(-1),
    m_fallSpeed(0),
    m_accelerationThr(15),
    m_posUpdateThr(15),
    m_jumpState(Standing),
    m_moveForward(false),
    m_breakJump(false),
    m_currentPlatformStart(0),
    m_currentPlatformEnd(9000),
    m_minX(0),
    m_dashing(false),
    m_dashStart(0),
    m_power(0),
    m_canDash(false)
 {
    addTag("player");
    const char* anim_names[] = {"run_right", "run_left", "jump_right", "jump_left", "wait_right", "wait_left", "land_right", "land_left", "fall_right", "fall_left"};
    for(int i = 0; i < sizeof(anim_names)/sizeof(char*); ++i)
    {
       m_anims.addAnim(anim_names[i], graphics::Animation(e.resourceManager().getAnimationData(std::string("ball/") + anim_names[i])));
    }
    m_anims.setCurrentAnim("wait_right");
    setWidth(m_anims.currentAnim().frame().w);
    setHeight(m_anims.currentAnim().frame().h);
 }
开发者ID:10098,项目名称:braveball,代码行数:38,代码来源:player.cpp

示例13: main


//.........这里部分代码省略.........
        dmsg(2,("AFTER SET: res = %d  RequestedMinimumWorkingSetSize=%d, RequestedMaximumWorkingSetSize=%d\n", res,RequestedMinimumWorkingSetSize, RequestedMaximumWorkingSetSize));

        res = GetProcessWorkingSetSize(hProcess, &MinimumWorkingSetSize, &MaximumWorkingSetSize);
        dmsg(2,("AFTER GET: res = %d  MinimumWorkingSetSize=%d, MaximumWorkingSetSize=%d\n", res,MinimumWorkingSetSize, MaximumWorkingSetSize));

        if( RequestedMinimumWorkingSetSize == MinimumWorkingSetSize ) {
            dmsg(2,("RequestedMinimumWorkingSetSize == MinimumWorkingSetSize. OK !\n"));
            break;
        }

        RequestedMinimumWorkingSetSize -=  10*1024*1024;
        if(RequestedMinimumWorkingSetSize < DefaultMinimumWorkingSetSize) break;
    }

    dmsg(2,("AFTER GetProcessWorkingSetSize: res = %d  MinimumWorkingSetSize=%d, MaximumWorkingSetSize=%d\n", res,MinimumWorkingSetSize, MaximumWorkingSetSize));
    #endif
    #endif // WIN32

    if (tune) {
        // detect and print system / CPU specific features
        Features::detect();
        dmsg(1,("Detected features: %s\n", Features::featuresAsString().c_str()));
        // prevent slow denormal FPU modes
        Features::enableDenormalsAreZeroMode();
    }

    dmsg(1,("Automatic Stacktrace: %s\n", (bShowStackTrace) ? "On" : "Off"));

    // create LinuxSampler instance
    dmsg(1,("Creating Sampler..."));
    pSampler = new Sampler;
    dmsg(1,("OK\n"));

    dmsg(1,("Registered sampler engines: %s\n", EngineFactory::AvailableEngineTypesAsString().c_str()));
    dmsg(1,("Registered MIDI input drivers: %s\n", MidiInputDeviceFactory::AvailableDriversAsString().c_str()));
    dmsg(1,("Registered audio output drivers: %s\n", AudioOutputDeviceFactory::AvailableDriversAsString().c_str()));
    dmsg(1,("Registered instrument editors: %s\n", InstrumentEditorFactory::AvailableEditorsAsString().c_str()));
    dmsg(1,("Registered internal effect systems: %s\n", EffectFactory::AvailableEffectSystemsAsString().c_str()));
    dmsg(1,("Registered internal effects: %d\n", EffectFactory::AvailableEffectsCount()));

    // start LSCP network server
    struct in_addr addr;
    addr.s_addr = lscp_addr;
    dmsg(1,("Starting LSCP network server (%s:%d)...", inet_ntoa(addr), ntohs(lscp_port)));
    pLSCPServer = new LSCPServer(pSampler, lscp_addr, lscp_port);
    pLSCPServer->StartThread();
    pLSCPServer->WaitUntilInitialized();
    dmsg(1,("OK\n"));

    if (profile)
    {
        dmsg(1,("Calibrating profiler..."));
        LinuxSampler::gig::Profiler::Calibrate();
        LinuxSampler::gig::Profiler::Reset();
        LinuxSampler::gig::Profiler::enable();
        dmsg(1,("OK\n"));
    }

    printf("LinuxSampler initialization completed. :-)\n\n");
    
    if (ExecAfterInit != "") {
        printf("Executing command: %s\n\n", ExecAfterInit.c_str());
        if (system(ExecAfterInit.c_str()) == -1) {
            std::cerr << "Failed to execute the command" << std::endl;
        }
    }
开发者ID:svn2github,项目名称:linuxsampler,代码行数:67,代码来源:linuxsampler.cpp

示例14: main

int main(int argc, char **argv) {

    // initialize the stack trace mechanism with our binary file
    StackTraceInit(argv[0], -1);

    main_pid = getpid();
    main_thread = pthread_self();

    // setting signal handler for catching SIGINT (thus e.g. <CTRL><C>)
    signal(SIGINT, signal_handler);

    // register signal handler for all unusual signals
    // (we will print the stack trace and exit)
    struct sigaction sact;
    sigemptyset(&sact.sa_mask);
    sact.sa_flags   = 0;
    sact.sa_handler = signal_handler;
    sigaction(SIGSEGV, &sact, NULL);
    sigaction(SIGBUS,  &sact, NULL);
    sigaction(SIGILL,  &sact, NULL);
    sigaction(SIGFPE,  &sact, NULL);
    sigaction(SIGUSR1, &sact, NULL);
    sigaction(SIGUSR2, &sact, NULL);

    lscp_addr = htonl(LSCP_ADDR);
    lscp_port = htons(LSCP_PORT);

    // parse and assign command line options
    parse_options(argc, argv);

    dmsg(1,("LinuxSampler %s\n", VERSION));
    dmsg(1,("Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck\n"));
    dmsg(1,("Copyright (C) 2005-2007 Christian Schoenebeck\n"));

    if (tune) {
        // detect and print system / CPU specific features
        Features::detect();
        dmsg(1,("Detected features: %s\n", Features::featuresAsString().c_str()));
        // prevent slow denormal FPU modes
        Features::enableDenormalsAreZeroMode();
    }

    // create LinuxSampler instance
    dmsg(1,("Creating Sampler..."));
    pSampler = new Sampler;
    dmsg(1,("OK\n"));

    dmsg(1,("Registered sampler engines: %s\n", EngineFactory::AvailableEngineTypesAsString().c_str()));
    dmsg(1,("Registered MIDI input drivers: %s\n", MidiInputDeviceFactory::AvailableDriversAsString().c_str()));
    dmsg(1,("Registered audio output drivers: %s\n", AudioOutputDeviceFactory::AvailableDriversAsString().c_str()));
    dmsg(1,("Registered instrument editors: %s\n", InstrumentEditorFactory::AvailableEditorsAsString().c_str()));

    // start LSCP network server
    struct in_addr addr;
    addr.s_addr = lscp_addr;
    dmsg(1,("Starting LSCP network server (%s:%d)...", inet_ntoa(addr), ntohs(lscp_port)));
    pLSCPServer = new LSCPServer(pSampler, lscp_addr, lscp_port);
    pLSCPServer->StartThread();
    pLSCPServer->WaitUntilInitialized();
    dmsg(1,("OK\n"));

    if (profile)
    {
        dmsg(1,("Calibrating profiler..."));
        LinuxSampler::gig::Profiler::Calibrate();
        LinuxSampler::gig::Profiler::Reset();
        LinuxSampler::gig::Profiler::enable();
        dmsg(1,("OK\n"));
    }

    printf("LinuxSampler initialization completed. :-)\n\n");

    std::list<LSCPEvent::event_t> rtEvents;
    rtEvents.push_back(LSCPEvent::event_voice_count);
    rtEvents.push_back(LSCPEvent::event_stream_count);
    rtEvents.push_back(LSCPEvent::event_buffer_fill);
    rtEvents.push_back(LSCPEvent::event_total_voice_count);

    while (true) {
        if (bPrintStatistics) {
            const std::set<Engine*>& engines = EngineFactory::EngineInstances();
            std::set<Engine*>::iterator itEngine = engines.begin();
            for (int i = 0; itEngine != engines.end(); itEngine++, i++) {
                Engine* pEngine = *itEngine;
                printf("Engine %d) Voices: %3.3d (Max: %3.3d) Streams: %3.3d (Max: %3.3d)\n", i,
                    pEngine->VoiceCount(), pEngine->VoiceCountMax(),
                    pEngine->DiskStreamCount(), pEngine->DiskStreamCountMax()
                );
                fflush(stdout);
            }
        }

      sleep(1);
      if (profile)
      {
          unsigned int samplingFreq = 48000; //FIXME: hardcoded for now
          unsigned int bv = LinuxSampler::gig::Profiler::GetBogoVoices(samplingFreq);
          if (bv != 0)
          {
              printf("       BogoVoices: %i         \r", bv);
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:linuxsampler,代码行数:101,代码来源:linuxsampler.cpp

示例15: Engine

	bool TestCharacter::testCopy()
	{
		Engine *prevEngine = Engine::getEngine();
		Engine *eng = new Engine();
		eng->addRace(new Race("human"));

		Engine::setEngine(eng);
		Handle<Game> game = new Game();
		
		Handle<Character> testChar(new Character());
		testChar->setAge(24);
		testChar->setName("Melli");
		testChar->setCameraOffset(0.8f, 0.4f);
		DialogueComponent *comp = new DialogueComponent(testChar);
		comp->setDialogueAvailable("testSub1");
		comp->setDialogueAvailable("testSub2");
		comp->setSubjectLock("testSub1");
		testChar->setDialogueComp(comp);

		testChar->setFixedToGrid(true);
		testChar->setGender(Gender::FEMALE);
		testChar->setGraphic(new Sprite("characters/mainChar/front"), false);
		testChar->setGridLocation(5, 4);
		testChar->setLevel(2);
		testChar->setMaxLevel(10);
		testChar->setPickupReach(1.4f);
		testChar->setRace(Engine::getEngine()->getRace("human"));

		Handle<Inventory> inv(testChar->getInventory());
		Handle<Item> sword(new Item());
		sword->setGraphic(new Sprite("items/sword"));
		sword->setGroundGraphic(new Sprite("items/swordGround"));
		sword->getStatModifiers().addStatModifier(Stat::MAX_DAMAGE, StatModifier(5.0f, MOD_ADD));
		sword->getStatModifiers().addStatModifier(Stat::MIN_DAMAGE, StatModifier(3.0f, MOD_ADD));
		sword->setItemFullname("Sword", "Wooden", "of Death");
		sword->setItemType(ItemCommon::SWORD);
		sword->setInventorySize(2, 3);
		inv->addItem(sword, 0, 0);

		Handle<Item> shield(new Item());
		shield->getStatModifiers().addStatModifier(Stat::ARMOUR, StatModifier(4.0f, MOD_MULTIPLY));
		shield->getStatModifiers().addStatModifier(Stat::ARMOUR, StatModifier(2.0f, MOD_ADD));
		shield->setItemFullname("Shield", "Padded", "of ASD");
		shield->setItemType(ItemCommon::SHIELD);
		shield->setInventorySize(2, 2);
		inv->addItem(shield, 4, 2);

		testChar->getStats()->setBaseStat(Stat::HEALTH, 10.0f);
		testChar->getStats()->setBaseStat(Stat::STRENGTH, 5.5f);
		testChar->getStats()->setBaseStat(Stat::MAX_DAMAGE, 4.0f);
		testChar->getStats()->setBaseStat(Stat::MIN_DAMAGE, 4.0f);
		testChar->getStats()->setBaseStat(Stat::ARMOUR, 7.0f);
		
		Handle<Item> swordEquip(new Item(*sword));
		swordEquip->setItemFullname("Sword", "Wooden", "of Hit");
		testChar->addBodyPart(new BodyPart("arm", BodyPartType::ARM, swordEquip));
		testChar->addBodyPart(new BodyPart("torso", BodyPartType::TORSO));
		testChar->addBodyPart(new BodyPart("legs", BodyPartType::LEGS));

		am_equalsDelta(10.0f, testChar->getStats()->getStat(Stat::HEALTH), 0.0001f);
		am_equalsDelta(5.5f, testChar->getStats()->getStat(Stat::STRENGTH), 0.0001f);
		am_equalsDelta(9.0f, testChar->getStats()->getStat(Stat::MAX_DAMAGE), 0.0001f);
		am_equalsDelta(7.0f, testChar->getStats()->getStat(Stat::MIN_DAMAGE), 0.0001f);
		am_equalsDelta(7.0f, testChar->getStats()->getStat(Stat::ARMOUR), 0.0001f);

		Handle<Character> copyChar(new Character(*testChar));
		am_equalsDelta(24.0f, copyChar->getAge(), 0.0001f);
		am_equalsStr("Melli", copyChar->getName());
		am_equalsDelta(0.8f, copyChar->getCameraOffsetX(), 0.0001f);
		am_equalsDelta(0.4f, copyChar->getCameraOffsetY(), 0.0001f);

		DialogueComponent *copyComp = copyChar->getDialogueComp();
		assert(copyComp != comp);
		assert(copyComp->getAttachedTo() == copyChar);
		assert(copyComp->isDialogueAvailable("testSub1"));
		assert(copyComp->isDialogueAvailable("testSub2"));
		assert(!copyComp->isSubjectLocked("testSub1"));
		assert(copyComp->isSubjectLocked("testSub2"));

		assert(copyChar->isFixedToGrid());
		assert(copyChar->getGender() == Gender::FEMALE);
		assert(copyChar->getGraphic() != testChar->getGraphic());
		assert(copyChar->getGraphic()->getAsset() == testChar->getGraphic()->getAsset());
		am_equals(5, copyChar->getGridLocationX());
		am_equals(4, copyChar->getGridLocationY());
		am_equals(2, copyChar->getLevel());
		am_equals(10, copyChar->getMaxLevel());
		am_equalsDelta(1.4f, copyChar->getPickupReach(), 0.0001f);
		assert(copyChar->getRace() == Engine::getEngine()->getRace("human"));

		Handle<Inventory> copyInv(copyChar->getInventory());
		assert(copyInv.get() && copyInv != inv);
		
		Handle<Item> copySword(copyInv->getItemAt(0, 0));
		assert(copySword.get() && copySword != sword);
		am_equals(1u, copySword->getStatModifiers().getModifiers()[Stat::MAX_DAMAGE].size());
		am_equalsDelta(5.0f, copySword->getStatModifiers().getModifiers()[Stat::MAX_DAMAGE][0].getValue(), 0.0001f);
		assert(MOD_ADD == copySword->getStatModifiers().getModifiers()[Stat::MAX_DAMAGE][0].getType());
		am_equals(1u, copySword->getStatModifiers().getModifiers()[Stat::MIN_DAMAGE].size());
		assert(MOD_ADD == copySword->getStatModifiers().getModifiers()[Stat::MIN_DAMAGE][0].getType());
//.........这里部分代码省略.........
开发者ID:astrellon,项目名称:GPP,代码行数:101,代码来源:test_character.cpp


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