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


C++ Actor类代码示例

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


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

示例1: if

void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
{
    GameClient &computer = *static_cast< GameClient * >(comp);
    MessageOut result;

    if (computer.status == CLIENT_LOGIN)
    {
        if (message.getId() != PGMSG_CONNECT)
            return;

        std::string magic_token = message.readString(MAGIC_TOKEN_LENGTH);
        computer.status = CLIENT_QUEUED; // Before the addPendingClient
        mTokenCollector.addPendingClient(magic_token, &computer);
        return;
    }
    else if (computer.status != CLIENT_CONNECTED)
    {
        return;
    }

    switch (message.getId())
    {
        case PGMSG_SAY:
        {
            std::string say = message.readString();
            if (say.empty()) break;

            if (say[0] == '@')
            {
                CommandHandler::handleCommand(computer.character, say);
                break;
            }
            GameState::sayAround(computer.character, say);
            std::string msg = computer.character->getName() + " said " + say;
            accountHandler->sendTransaction(computer.character->getDatabaseID(), TRANS_MSG_PUBLIC, msg);
        } break;

        case PGMSG_NPC_TALK:
        case PGMSG_NPC_TALK_NEXT:
        case PGMSG_NPC_SELECT:
        case PGMSG_NPC_NUMBER:
        case PGMSG_NPC_STRING:
        {
            int id = message.readShort();
            Actor *o = findActorNear(computer.character, id);
            if (!o || o->getType() != OBJECT_NPC)
            {
                sendError(comp, id, "Not close enough to NPC\n");
                break;
            }

            NPC *q = static_cast< NPC * >(o);
            if (message.getId() == PGMSG_NPC_SELECT)
            {
                q->select(computer.character, message.readByte());
            }
            else if (message.getId() == PGMSG_NPC_NUMBER)
            {
                q->integerReceived(computer.character, message.readLong());
            }
            else if (message.getId() == PGMSG_NPC_STRING)
            {
                q->stringReceived(computer.character, message.readString());
            }
            else
            {
                q->prompt(computer.character, message.getId() == PGMSG_NPC_TALK);
            }
        } break;

        case PGMSG_PICKUP:
        {
            int x = message.readShort();
            int y = message.readShort();
            Point ppos = computer.character->getPosition();

            // TODO: use a less arbitrary value.
            if (std::abs(x - ppos.x) + std::abs(y - ppos.y) < 48)
            {
                MapComposite *map = computer.character->getMap();
                Point ipos(x, y);
                for (FixedActorIterator i(map->getAroundPointIterator(ipos, 0)); i; ++i)
                {
                    Actor *o = *i;
                    Point opos = o->getPosition();
                    if (o->getType() == OBJECT_ITEM && opos.x == x && opos.y == y)
                    {
                        Item *item = static_cast< Item * >(o);
                        ItemClass *ic = item->getItemClass();
                        Inventory(computer.character)
                            .insert(ic->getDatabaseID(), item->getAmount());
                        GameState::remove(item);
                        // log transaction
                        std::stringstream str;
                        str << "User picked up item " << ic->getDatabaseID()
                            << " at " << opos.x << "x" << opos.y;
                        accountHandler->sendTransaction(computer.character->getDatabaseID(),
                            TRANS_ITEM_PICKUP, str.str());
                        break;
                    }
//.........这里部分代码省略.........
开发者ID:Ablu,项目名称:invertika,代码行数:101,代码来源:gamehandler.cpp

示例2: EvaluateObject

/* returns actors that match the [x.y.z] expression */
static Targets* EvaluateObject(Map *map, Scriptable* Sender, Object* oC, int ga_flags)
{
	// if you ActionOverride a global actor, they might not have a map :(
	// TODO: don't allow this to happen?
	if (!map) {
		return NULL;
	}

	if (oC->objectName[0]) {
		//We want the object by its name...
		Scriptable* aC = map->GetActor( oC->objectName, ga_flags );

		/*if (!aC && (ga_flags&GA_GLOBAL) ) {
			aC = FindActorNearby(oC->objectName, map, ga_flags );
		}*/

		//This order is the same as in GetActorObject
		//TODO:merge them
		if (!aC) {
			aC = map->GetTileMap()->GetDoor(oC->objectName);
		}
		if (!aC) {
			aC = map->GetTileMap()->GetContainer(oC->objectName);
		}
		if (!aC) {
			aC = map->GetTileMap()->GetInfoPoint(oC->objectName);
		}

		//return here because object name/IDS targeting are mutually exclusive
		return ReturnScriptableAsTarget(aC);
	}

	if (oC->objectFields[0]==-1) {
		// this is an internal hack, allowing us to pass actor ids around as objects
		Actor* aC = map->GetActorByGlobalID( (ieDword) oC->objectFields[1] );
		if (aC) {
			if (!aC->ValidTarget(ga_flags)) {
				return NULL;
			}
			return ReturnScriptableAsTarget(aC);
		}
		Door *door = map->GetDoorByGlobalID( (ieDword) oC->objectFields[1]);
		if (door) {
			return ReturnScriptableAsTarget(door);
		}

		Container* cont = map->GetContainerByGlobalID((ieDword) oC->objectFields[1]);
		if (cont) {
			return ReturnScriptableAsTarget(cont);
		}

		InfoPoint* trap = map->GetInfoPointByGlobalID((ieDword) oC->objectFields[1]);
		if (trap) {
			return ReturnScriptableAsTarget(trap);
		}

		return NULL;
	}

	Targets *tgts = NULL;

	//we need to get a subset of actors from the large array
	//if this gets slow, we will need some index tables
	int i = map->GetActorCount(true);
	while (i--) {
		Actor *ac = map->GetActor(i, true);
		if (!ac) continue; // is this check really needed?
		// don't return Sender in IDS targeting!
		// unless it's pst, which relies on it in 3012cut2-3012cut7.bcs
		// FIXME: do we need more fine-grained control?
		// FIXME: stop abusing old GF flags
		if (!core->HasFeature(GF_AREA_OVERRIDE)) {
			if (ac == Sender) continue;
		}
		bool filtered = false;
		if (DoObjectIDSCheck(oC, ac, &filtered)) {
			// this is needed so eg. Range trigger gets a good object
			// HACK: our parsing of Attack([0]) is broken
			if (!filtered) {
				// if no filters were applied..
				assert(!tgts);
				return NULL;
			}
			int dist;
			if (DoObjectChecks(map, Sender, ac, dist, (ga_flags & GA_DETECT) != 0)) {
				if (!tgts) tgts = new Targets();
				tgts->AddTarget((Scriptable *) ac, dist, ga_flags);
			}
		}
	}

	return tgts;
}
开发者ID:MarcelHB,项目名称:gemrb,代码行数:94,代码来源:Matching.cpp

示例3: collide

void ExitPoint::collide(Actor& otherActor) {
	if (otherActor.isPlayer())
	{
		printf("You are victorious! (But we don't have a victory UI.)\n");
	}
}
开发者ID:jsj2008,项目名称:Last-Escape,代码行数:6,代码来源:ExitPoint.cpp

示例4: DYNAMIC_CAST

void ObjectWidget::QueryState(TESObjectREFR * reference, bool * isVisible, bool * isFriendly)
{
	bool isHidden = false;
	bool isHostileToActor = false;
	bool isHostile = false;
	UInt8 unk1 = 0;
	if((flags & kFlag_UseLineOfSight) == kFlag_UseLineOfSight)
		isHidden = !HasLOS((*g_thePlayer), reference, &unk1);
	Actor * actor = DYNAMIC_CAST(reference, TESObjectREFR, Actor);
	if(actor) {
		if ((flags & kFlag_UpdatePercent) == kFlag_UpdatePercent) {
			// Get values from Tes5Mod Actor Value Indices.
			// http://www.uesp.net/wiki/Tes5Mod:Actor_Value_Indices
			params[kProperty_HealthCurrentValue].SetNumber(actor->actorValueOwner.GetCurrent(24));
			params[kProperty_HealthMaximumValue].SetNumber(actor->actorValueOwner.GetMaximum(24));
			params[kProperty_MagickaCurrentValue].SetNumber(actor->actorValueOwner.GetCurrent(25));
			params[kProperty_MagickaMaximumValue].SetNumber(actor->actorValueOwner.GetMaximum(25));
			params[kProperty_StaminaCurrentValue].SetNumber(actor->actorValueOwner.GetCurrent(26));
			params[kProperty_StaminaMaximumValue].SetNumber(actor->actorValueOwner.GetMaximum(26));

			// Checks if at health is at 100%+ and hides if true.
			double percent = params[kProperty_HealthCurrentValue].GetNumber() / params[kProperty_HealthMaximumValue].GetNumber();
			if (percent >= 1.0 && (g_hudExtension->hudFlags & HUDExtension::kFlags_HideAtFull) == HUDExtension::kFlags_HideAtFull)
				isHidden = true;
		}
		if((flags & kFlag_ShowInCombat) == kFlag_ShowInCombat)
			if(actor->IsInCombat())
				isHidden = !isHidden;
		if((flags & kFlag_HideOutOfCombat) == kFlag_HideOutOfCombat) // When these are not flagged, hide instead
			if(!actor->IsInCombat())
				isHidden = true;
		if((flags & kFlag_HideOnDeath) == kFlag_HideOnDeath)
			if(actor->IsDead(1))
				isHidden = true;
		if ((flags & kFlag_HideOnInvisibility) == kFlag_HideOnInvisibility)
			if (actor->actorValueOwner.GetCurrent(54) > 0)
				isHidden = true;
		if ((flags & kFlag_UseHostility) == kFlag_UseHostility || g_hudExtension->hudFlags != HUDExtension::kFlags_None) {
			isHostileToActor = CALL_MEMBER_FN(*g_thePlayer, IsHostileToActor)(actor);
			if ((flags & kFlag_UseHostility) == kFlag_UseHostility)
				isHostile = isHostileToActor;
		}

		if (g_hudExtension->hudFlags != HUDExtension::kFlags_None) {
			if (isHostileToActor && (g_hudExtension->hudFlags & HUDExtension::kFlags_HideEnemies) == HUDExtension::kFlags_HideEnemies)
				isHidden = true;
			else if (!isHostileToActor) {
				SInt32 relationshipRank = RelationshipRanks::GetRelationshipRank(actor->baseForm, (*g_thePlayer)->baseForm);
				if ((g_hudExtension->hudFlags & HUDExtension::kFlags_HideAllies) == HUDExtension::kFlags_HideAllies && relationshipRank >= 3)
					isHidden = true;
				if ((g_hudExtension->hudFlags & HUDExtension::kFlags_HideFriendly) == HUDExtension::kFlags_HideFriendly && relationshipRank >= 1 && relationshipRank < 3)
					isHidden = true;
				if ((g_hudExtension->hudFlags & HUDExtension::kFlags_HideNonHostile) == HUDExtension::kFlags_HideNonHostile && relationshipRank < 1)
					isHidden = true;
			}
		}
	}

	*isVisible = !isHidden;
	*isFriendly = !isHostile;
}
开发者ID:BlueAccords,项目名称:SKSEPlugins,代码行数:61,代码来源:HUDExtension.cpp

示例5: UtcDaliScriptingNewActorProperties

int UtcDaliScriptingNewActorProperties(void)
{
  TestApplication application;

  Property::Map map;
  map[ "type" ] = "Actor";
  map[ "size" ] = Vector3::ONE;
  map[ "position" ] = Vector3::XAXIS;
  map[ "scale" ] = Vector3::ONE;
  map[ "visible" ] = false;
  map[ "color" ] = Color::MAGENTA;
  map[ "name" ] = "MyActor";
  map[ "color-mode" ] = "USE_PARENT_COLOR";
  map[ "inherit-shader-effect" ] = false;
  map[ "sensitive" ] = false;
  map[ "leave-required" ] = true;
  map[ "position-inheritance" ] = "DONT_INHERIT_POSITION";
  map[ "draw-mode" ] = "STENCIL";
  map[ "inherit-orientation" ] = false;
  map[ "inherit-scale" ] = false;

  // Default properties
  {
    Actor handle = NewActor( map );
    DALI_TEST_CHECK( handle );

    Stage::GetCurrent().Add( handle );
    application.SendNotification();
    application.Render();

    DALI_TEST_EQUALS( handle.GetCurrentSize(), Vector3::ONE, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.IsVisible(), false, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetName(), "MyActor", TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.IsSensitive(), false, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetLeaveRequired(), true, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.IsOrientationInherited(), false, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION );

    Stage::GetCurrent().Remove( handle );
  }

  // Check Anchor point and parent origin vector3s
  map[ "parent-origin" ] = ParentOrigin::TOP_CENTER;
  map[ "anchor-point" ] = AnchorPoint::TOP_LEFT;
  {
    Actor handle = NewActor( map );
    DALI_TEST_CHECK( handle );

    Stage::GetCurrent().Add( handle );
    application.SendNotification();
    application.Render();

    DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::TOP_LEFT, TEST_LOCATION );

    Stage::GetCurrent().Remove( handle );
  }

  // Check Anchor point and parent origin STRINGS
  map[ "parent-origin" ] = "TOP_LEFT";
  map[ "anchor-point" ] = "CENTER_LEFT";
  {
    Actor handle = NewActor( map );
    DALI_TEST_CHECK( handle );

    Stage::GetCurrent().Add( handle );
    application.SendNotification();
    application.Render();

    DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
    DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );

    Stage::GetCurrent().Remove( handle );
  }
  END_TEST;
}
开发者ID:mettalla,项目名称:dali,代码行数:82,代码来源:utc-Dali-Scripting.cpp

示例6: Persist

void Grafkit::SceneLoader::SceneLoaderHelper::Load(Archive &ar, IResourceManager * const & resman)
{
	Persist(ar, resman);

	LOGGER(Log::Logger().Info("-- ASSIGN --"));

	// 5. material -> mesh relation
	LOGGER(Log::Logger().Info("Materials: %d", m_materials_to_meshes.size()));
	for (auto it = m_materials_to_meshes.begin(); it != m_materials_to_meshes.end(); ++it)
	{
		USHORT key = it->first;
		USHORT val = it->second;

		Material * material = m_materials[key];
		Model *model = dynamic_cast<Model *>(m_entities[val]);

		if (model && material) {
			model->SetMaterial(material);

			LOGGER(Log::Logger().Info("%hu (\"%s\") -> %hu (\"%s\")", key, material->GetName().c_str(), val, model->GetName().c_str()));
		}
	}
	// ... 

	// 6. entitiy -> actor relation
	LOGGER(Log::Logger().Info("Entities: %d", m_entities_to_actors.size()));
	for (auto it = m_entities_to_actors.begin(); it != m_entities_to_actors.end(); ++it)
	{
		USHORT key = it->first;
		USHORT val = it->second;

		Entity3D *entity = m_entities[key];
		Actor *actor = m_actors[val];

		if (actor && entity) {
			actor->AddEntity(entity);

			LOGGER(Log::Logger().Info("%hu (\"%s\") -> %hu (\"%s\")", key, entity->GetName().c_str()), val, actor->GetName().c_str());
		}
	}

	// ...

	// 7. actor -> actor relation - scenegraph
	LOGGER(Log::Logger().Info("Actors: %d", m_actor_to_actor.size()));
	for (auto it = m_actor_to_actor.begin(); it != m_actor_to_actor.end(); ++it)
	{
		USHORT key = it->first;
		USHORT val = it->second;

		Actor *child = m_actors[val];
		Actor *parent = m_actors[key];

		if (parent && child) {
			parent->AddChild(child);

			LOGGER(Log::Logger().Info("%hu (\"%s\") -> %hu (\"%s\")", key, parent->GetName().c_str(), val, child->GetName().c_str()));
		}
	}

	//8, 9 animation -> actor, entity
	LOGGER(Log::Logger().Info("Animations: %d", m_animation_to_actor.size() + m_animation_to_entity.size()));
	for (auto it = m_animation_to_actor.cbegin(); it != m_animation_to_actor.cend(); ++it)
	{
		USHORT key = it->first;
		USHORT value = it->second;
		ActorAnimation *actor_animation = dynamic_cast<ActorAnimation *>(m_Animations[key]);
		if (actor_animation) {
			Actor* actor = m_actors[value];
			if (actor) {
				actor_animation->SetActor(ActorRef(actor));
				m_scene->AddAnimation(actor_animation);
				LOGGER(Log::Logger().Info("Actor %hu (\"%s\") -> %hu (\"%s\")", key, actor->GetName().c_str(), value, actor_animation->GetName().c_str()));
			}
		}

	}

	for (auto it = m_animation_to_entity.cbegin(); it != m_animation_to_entity.cend(); ++it)
	{
		USHORT key = it->first;
		USHORT value = it->second;

		EntityAnimation *entity_animation = dynamic_cast<EntityAnimation*>(m_Animations[key]);
		if (entity_animation) {
			Entity3D* entity = m_entities[value];
			if (entity) {
				entity_animation->SetEntity(Ref<Entity3D>(entity));
				m_scene->AddAnimation(entity_animation);
				LOGGER(Log::Logger().Info("Entity %hu -> %hu", key, value));
			}
		}

	}

	if (m_actors.empty())
		throw new EX_DETAILS(SceneLoadException, "Actors are empty for some reason");

	Actor * root = m_actors[0];
	m_scene->Initialize(root);
//.........这里部分代码省略.........
开发者ID:caiwan,项目名称:Grafkit2,代码行数:101,代码来源:SceneLoader.cpp

示例7: b2Vec2

/// Step forward the simulation
void Box2DSystem::update(const Time& deltaTime)
{
	mSimulation->Step(deltaTime.seconds(), 8, 8);

	// Compute stuff with the world
	ComponentManager* colliderBoxManager = mWorld->getComponentManager<CColliderBox>();
	ComponentManager* transformManager = mWorld->getComponentManager<CTransform>();

	for (std::size_t i = 0; i < colliderBoxManager->getInstanceCount(); ++i)
	{
		CColliderBox* boxCollider = (CColliderBox*)colliderBoxManager->getInstance(i);
		CTransform* transform = (CTransform*)transformManager->getComponentFromEntity(colliderBoxManager->getInstanceEntity(i));
		if (!transform)
		{
			mWorld->createComponent(CTransform(), colliderBoxManager->getInstanceEntity(i));
			transform = (CTransform*)transformManager->getComponentFromEntity(colliderBoxManager->getInstanceEntity(i));
		}

		if (!boxCollider->userData)
		{
			b2BodyDef groundBodyDef2;
			groundBodyDef2.type = boxCollider->_isDynamic ? b2_dynamicBody : b2_staticBody;
			groundBodyDef2.position = b2Vec2(transform->getPosition().x, transform->getPosition().y);
			b2Body* groundBody2 = mSimulation->CreateBody(&groundBodyDef2);

			b2PolygonShape groundShape2;
			groundShape2.SetAsBox(10.f, 10.f);
			groundBody2->CreateFixture(&groundShape2, 1.f);

			groundBody2->SetUserData(boxCollider);
			boxCollider->userData = groundBody2;
		}
		else
		{
			b2Body* boxColliderBody = (b2Body*)boxCollider->userData;
			transform->position.x = boxColliderBody->GetPosition().x;
			transform->position.y = boxColliderBody->GetPosition().y;
			transform->rotation = Quaternion::fromMatrix(mat4::rotatez(boxColliderBody->GetAngle()));
		}
	}

	// Now let's go through the actors to find stuff in them
	for (std::size_t i = 0; i < mWorld->actors.size(); ++i)
	{
		Actor* actor = mWorld->actors[i];
		SCColliderBox* box = dynamic_cast<SCColliderBox*>(actor->getRootComponent());
		if (box)
		{
			if (!box->userData)
			{
				b2BodyDef groundBodyDef2;
				groundBodyDef2.type = box->_isDynamic ? b2_dynamicBody : b2_staticBody;
				groundBodyDef2.position = b2Vec2(actor->getActorLocation().x, actor->getActorLocation().y);
				b2Body* groundBody2 = mSimulation->CreateBody(&groundBodyDef2);

				b2PolygonShape groundShape2;
				groundShape2.SetAsBox(10.f, 10.f);
				groundBody2->CreateFixture(&groundShape2, 1.f);

				groundBody2->SetUserData(box);
				box->userData = groundBody2;

				box->rigidBody = new RigidBodyBox2D(groundBody2);
				
			}

			// Apply manual forces
			b2Body* boxColliderBody = (b2Body*)box->userData;
			

			CTransform transform = box->t;

			
			transform.position.x = boxColliderBody->GetPosition().x;
			transform.position.y = boxColliderBody->GetPosition().y;
			transform.rotation = Quaternion::fromMatrix(mat4::rotatez(boxColliderBody->GetAngle()));

			// Push the new physics transform back to the actor
			actor->setTransform(transform);
		}
	}
}
开发者ID:GrimshawA,项目名称:Nephilim,代码行数:83,代码来源:Box2DSystem.cpp

示例8: UtcDaliFocusManagerFocusGroup

int UtcDaliFocusManagerFocusGroup(void)
{
  ToolkitTestApplication application;

  tet_infoline(" UtcDaliFocusManagerFocusGroup");

  FocusManager manager = FocusManager::Get();
  DALI_TEST_CHECK(manager);

  // Create an actor with two child actors and add it to the stage
  Actor parent = Actor::New();
  Actor firstChild = Actor::New();
  Actor secondChild = Actor::New();
  parent.Add(firstChild);
  parent.Add(secondChild);
  Stage::GetCurrent().Add(parent);

  // Create three actors and add them as the children of the first child actor
  Actor firstGrandChild = Actor::New();
  Actor secondGrandChild = Actor::New();
  Actor thirdGrandChild = Actor::New();
  firstChild.Add(firstGrandChild);
  firstChild.Add(secondGrandChild);
  firstChild.Add(thirdGrandChild);

  // Set focus order to the actors
  manager.SetFocusOrder(parent, 1);
  manager.SetFocusOrder(firstChild, 2);
  manager.SetFocusOrder(firstGrandChild, 3);
  manager.SetFocusOrder(secondGrandChild, 4);
  manager.SetFocusOrder(thirdGrandChild, 5);
  manager.SetFocusOrder(secondChild, 6);

  // Set the parent and the first child actor as focus groups
  manager.SetFocusGroup(parent, true);
  DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true);

  // The focus group of the parent should be itself, as it is set to be a focus group.
  DALI_TEST_CHECK(manager.GetFocusGroup(parent) == parent);

  // The focus group of the firstChild should be its parent, as it is the immediate parent which is also a group.
  DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == parent);

  manager.SetFocusGroup(firstChild, true);
  DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true);

  // The focus group of the firstChild should be itself, as it is set to be a focus group now.
  DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == firstChild);

  // Enable wrap mode for focus movement.
  manager.SetWrapMode(true);
  DALI_TEST_CHECK(manager.GetWrapMode() == true);

  // Check that no actor is being focused yet.
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());

  // Check that the focus is set on the parent actor.
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(parent) == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent);

  // Check that group mode is disabled.
  DALI_TEST_CHECK(manager.GetGroupMode() == false);

  // Check that the focus movement is wrapped as normal.
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild);
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondChild);
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent);
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);

  // Enable the group mode.
  manager.SetGroupMode(true);
  DALI_TEST_CHECK(manager.GetGroupMode() == true);

  // Check that the focus movement is now limited to the current focus group.
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild);
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
  DALI_TEST_CHECK(manager.MoveFocusForward() == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
  END_TEST;
}
开发者ID:Tarnyko,项目名称:dal-toolkit,代码行数:96,代码来源:utc-Dali-FocusManager.cpp

示例9: if

void BattleManager::implementAction(Action theAction)
{
	Actor *movingActor;
	Actor *target;
	if(whoseTurn == 1)
	{
		movingActor = first;
		target = second;

		if(firstActorExtraDefense > 0)
		{
			//Defending wears off.
			first->setDefense(first->getCurrentDefense() - firstActorExtraDefense);
			firstActorExtraDefense = 0;
		}
	}
	else
	{
		movingActor = second;
		target = first;

		if(secondActorExtraDefense > 0)
		{
			//Defending wears off.
			second->setDefense(second->getCurrentDefense() - secondActorExtraDefense);
			secondActorExtraDefense = 0;
		}
	}

	//Only permit action if there's enough MP to do the action - otherwise do nothing.
	if(movingActor->getCurrentMP() >= theAction.magicCost)
	{
		movingActor->setMP(movingActor->getCurrentMP() - theAction.magicCost);

		if(theAction.theType == DAMAGE)
		{
			int damageAmount = theAction.data - target->getCurrentDefense();

			if(damageAmount > 0)
			{
				target->setHealth(target->getCurrentHealth() - damageAmount);
			}
		}
		else if(theAction.theType == DEFEND)
		{
			int oldDefense = movingActor->getCurrentDefense();
			movingActor->setDefense(oldDefense + theAction.data);

			if(whoseTurn == 1)
			{
				firstActorExtraDefense = theAction.data;
			}
			else
			{
				secondActorExtraDefense = theAction.data;
			}
		}
		else if(theAction.theType == HEAL)
		{
			//Cap healing at max HP.
			movingActor->setHealth(movingActor->getCurrentHealth() + theAction.data);

			if(movingActor->getCurrentHealth() > movingActor->getMaxHealth())
			{
				movingActor->setHealth(movingActor->getMaxHealth());
			}
		}
		else
		{
			//other things, like charging mana, taunting, etc.
		}
	}
	else
	{
		//some sort of "out of magic" error
	}


	//Finished implementing action: change whose turn it is.
	if(whoseTurn == 1)
	{
		whoseTurn = 2;
	}
	else
	{
		whoseTurn = 1;
	}
}
开发者ID:captainriku75,项目名称:straight_line_RPG,代码行数:88,代码来源:BattleManager.cpp

示例10: UtcDaliFocusManagerGetCurrentFocusGroup

int UtcDaliFocusManagerGetCurrentFocusGroup(void)
{
  ToolkitTestApplication application;

  tet_infoline(" UtcDaliFocusManagerGetCurrentFocusGroup");

  FocusManager manager = FocusManager::Get();
  DALI_TEST_CHECK(manager);

  // Create an actor with two child actors and add it to the stage
  Actor parent = Actor::New();
  Actor firstChild = Actor::New();
  Actor secondChild = Actor::New();
  parent.Add(firstChild);
  parent.Add(secondChild);
  Stage::GetCurrent().Add(parent);

  // Create three actors and add them as the children of the first child actor
  Actor firstGrandChild = Actor::New();
  Actor secondGrandChild = Actor::New();
  Actor thirdGrandChild = Actor::New();
  firstChild.Add(firstGrandChild);
  firstChild.Add(secondGrandChild);
  firstChild.Add(thirdGrandChild);

  // Set focus order to the actors
  manager.SetFocusOrder(parent, 1);
  manager.SetFocusOrder(firstChild, 2);
  manager.SetFocusOrder(firstGrandChild, 3);
  manager.SetFocusOrder(secondGrandChild, 4);
  manager.SetFocusOrder(thirdGrandChild, 5);
  manager.SetFocusOrder(secondChild, 6);

  // Set the parent and the first child actor as focus groups
  manager.SetFocusGroup(parent, true);
  DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true);

  // Set focus to the first grand child actor
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(firstGrandChild) == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);

  // The current focus group should be the parent, As it is the immediate parent which is also a focus group.
  DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == parent);

  manager.SetFocusGroup(firstChild, true);
  DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true);

  // The current focus group should be the firstChild, As it is the immediate parent which is also a focus group.
  DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild);

  manager.SetFocusGroup(firstGrandChild, true);
  DALI_TEST_CHECK(manager.IsFocusGroup(firstGrandChild) == true);

  // The current focus group should be itself, As it is also a focus group.
  DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstGrandChild);

  // Set focus to the second grand child actor
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(secondGrandChild) == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);

  // The current focus group should be the firstChild, As it is the immediate parent which is also a
  // focus group for the current focus actor.
  DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild);

  END_TEST;
}
开发者ID:Tarnyko,项目名称:dal-toolkit,代码行数:66,代码来源:utc-Dali-FocusManager.cpp

示例11: UtcDaliFocusManagerMoveFocusBackward

int UtcDaliFocusManagerMoveFocusBackward(void)
{
  ToolkitTestApplication application;

  tet_infoline(" UtcDaliFocusManagerMoveFocusBackward");

  FocusManager manager = FocusManager::Get();
  DALI_TEST_CHECK(manager);

  Actor first = Actor::New();
  Stage::GetCurrent().Add(first);

  Actor second = Actor::New();
  Stage::GetCurrent().Add(second);

  Actor third = Actor::New();
  Stage::GetCurrent().Add(third);

  // Set the focus order and description for the first actor
  manager.SetFocusOrder(first, 1);
  manager.SetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL, "first");
  DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
  DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL) == "first");

  // Set the focus order and description for the second actor
  manager.SetFocusOrder(second, 2);
  manager.SetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL, "second");
  DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
  DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL) == "second");

  // Set the focus order and description for the second actor
  manager.SetFocusOrder(third, 3);
  manager.SetAccessibilityAttribute(third, FocusManager::ACCESSIBILITY_LABEL, "third");
  DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3);
  DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, FocusManager::ACCESSIBILITY_LABEL) == "third");

  // Check that no actor is being focused yet.
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());

  // Set the focus on the third actor
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
  DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "third");

  // Test the non-wrapped move first
  manager.SetWrapMode(false);
  DALI_TEST_CHECK(manager.GetWrapMode() == false);

  // Move the focus backward to the second actor
  manager.MoveFocusBackward();
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
  DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "second");

  // Move the focus backward to the first actor
  manager.MoveFocusBackward();
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
  DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "first");

  // Check that it will fail to move the focus backward again as the first actor is the first
  // focusable actor in the focus chain
  manager.MoveFocusBackward();
  // The focus should still be set on the first actor
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
  DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "first");

  // Now test the wrapped move
  manager.SetWrapMode(true);
  DALI_TEST_CHECK(manager.GetWrapMode() == true);

  // Move the focus backward recursively and this time the third actor should be focused
  manager.MoveFocusBackward();
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
  DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "third");

  // Make the second actor not focusable
  Property::Index propertyActorFocusable = second.GetPropertyIndex("focusable");
  second.SetProperty(propertyActorFocusable, false);
  // flush the queue and render once
  application.SendNotification();
  application.Render();

  // Move the focus backward and check that the second actor should be skipped and
  // the first actor should be focused now.
  manager.MoveFocusBackward();
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
  DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "first");

  // Make the third actor invisible
  third.SetVisible(false);
  // flush the queue and render once
  application.SendNotification();
  application.Render();

  // Move the focus backward and check that the third actor should be skipped as it's
  // invisible and the second actor should also be skipped as it's not focusable,
  // so the focus will still be on the first actor
  manager.MoveFocusBackward();
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
  DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "first");

//.........这里部分代码省略.........
开发者ID:Tarnyko,项目名称:dal-toolkit,代码行数:101,代码来源:utc-Dali-FocusManager.cpp

示例12: UtcDaliFocusManagerSetAndGetCurrentFocusActor

int UtcDaliFocusManagerSetAndGetCurrentFocusActor(void)
{
  ToolkitTestApplication application;

  tet_infoline(" UtcDaliFocusManagerSetAndGetCurrentFocusActor");

  FocusManager manager = FocusManager::Get();
  DALI_TEST_CHECK(manager);

  // Create the first actor and add it to the stage
  Actor first = Actor::New();
  manager.SetFocusOrder(first, 1);
  Stage::GetCurrent().Add(first);

  // Create the second actor and add it to the stage
  Actor second = Actor::New();
  manager.SetFocusOrder(second, 2);
  Stage::GetCurrent().Add(second);

  // Create the third actor but don't add it to the stage
  Actor third = Actor::New();
  manager.SetFocusOrder(third, 3);

  // Check that no actor is being focused yet.
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());

  // Check that it will fail to set focus on an invalid actor
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(Actor()) == false);

  // Check that the focus is set on the first actor
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);

  // Check that the focus is set on the second actor
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);

  // Check that it will fail to set focus on the third actor as it's not in the stage
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);

  // Add the third actor to the stage
  Stage::GetCurrent().Add(third);

  // make the third actor invisible
  third.SetVisible(false);
  // flush the queue and render once
  application.SendNotification();
  application.Render();

  // Check that it will fail to set focus on the third actor as it's invisible
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);

  // Make the third actor visible
  third.SetVisible(true);
  // flush the queue and render once
  application.SendNotification();
  application.Render();

  // Make the third actor not focusable
  Property::Index propertyActorFocusable = third.GetPropertyIndex("focusable");
  third.SetProperty(propertyActorFocusable, false);
  // flush the queue and render once
  application.SendNotification();
  application.Render();

  // Check that it will fail to set focus on the third actor as it's not focusable
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);

  // Make the third actor focusable
  third.SetProperty(propertyActorFocusable, true);
  // flush the queue and render once
  application.SendNotification();
  application.Render();

  // Check that the focus is successfully moved to the third actor
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);

  // Make the current focused actor to be not focusable by setting its focus order to be 0
  manager.SetFocusOrder(third, 0);

  // Check that the focus is automatically cleared
  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());

  // Set the focus order of the third actor again
  manager.SetFocusOrder(third, 3);

  // Check that the third actor can be focused successfully now
  DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
  END_TEST;
}
开发者ID:Tarnyko,项目名称:dal-toolkit,代码行数:90,代码来源:utc-Dali-FocusManager.cpp

示例13:

/* virtual */
void
Attack::operator()()
{
	if (fObject == NULL)
		std::cerr << "NULL OBJECT" << std::endl;
	Actor* actor = dynamic_cast<Actor*>(fObject);
	if (actor == NULL)
		return;
	
	Actor* target = dynamic_cast<Actor*>(Script::FindTargetObject(fObject, fActionParams));
	if (target == NULL){
		SetCompleted();
		return;
	}

	if (!Initiated()) {
		IE::point point = target->NearestPoint(actor->Position());
		if (!PointSufficientlyClose(actor->Position(), point))
			actor->SetDestination(point);
		SetInitiated();
	}

	if (actor->Position() != actor->Destination()) {
		actor->SetAnimationAction(ACT_WALKING);
		actor->MoveToNextPointInPath(actor->IsFlying());
	} else {
		actor->SetAnimationAction(ACT_ATTACKING);
		actor->AttackTarget(target);
		SetCompleted();
	}
}
开发者ID:jackburton79,项目名称:bgemu,代码行数:32,代码来源:Action.cpp

示例14: GetHoldHeadActor

void NoteDisplay::DrawHoldHead( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYHead, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset )
{
	//
	// Draw the head
	//
	Actor* pActor = GetHoldHeadActor( NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld );

	pActor->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );

	// draw with normal Sprite
	const float fY				= fYHead;
	const float fYOffset		= ArrowEffects::GetYOffsetFromYPos( m_pPlayerState, iCol, fY, m_fYReverseOffsetPixels );
	if( fYOffset < fYStartOffset || fYOffset > fYEndOffset )
			return;

	// TRICKY: skew the rotation by a few pixels so this lines up with the start of the twirly hold.
	const float fRotationY		= ArrowEffects::GetRotationY( m_pPlayerState, fYOffset+16 );
	const float fX				= ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset );
	const float fZ				= ArrowEffects::GetZPos( m_pPlayerState, iCol, fYOffset );
	const float	fAlpha			= ArrowEffects::GetAlpha( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels );
	const float	fGlow			= ArrowEffects::GetGlow( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels );
	const RageColor colorDiffuse= RageColor(fColorScale,fColorScale,fColorScale,fAlpha);
	const RageColor colorGlow	= RageColor(1,1,1,fGlow);

	pActor->SetRotationY( fRotationY );
	pActor->SetRotationZ( 0 );
	pActor->SetXY( fX, fY );
	pActor->SetZ( fZ );

	if( bGlow )
	{
		pActor->SetDiffuse( RageColor(1,1,1,0) );
		pActor->SetGlow( colorGlow );
	}
	else
	{
		pActor->SetDiffuse( colorDiffuse );
		pActor->SetGlow( RageColor(0,0,0,0) );
	}

	if( cache->m_bHoldHeadUseLighting )
	{
		DISPLAY->SetLighting( true );
		DISPLAY->SetLightDirectional( 
			0, 
			RageColor(1,1,1,1), 
			RageColor(1,1,1,1),
			RageColor(1,1,1,1),
			RageVector3(1, 0, +1) );
	}

	pActor->Draw();

	if( cache->m_bHoldHeadUseLighting )
	{
		DISPLAY->SetLightOff( 0 );
		DISPLAY->SetLighting( false );
	}
}
开发者ID:BitMax,项目名称:openitg,代码行数:59,代码来源:NoteDisplay.cpp

示例15: Actor

/***********************************************************
 update with external info
***********************************************************/
void ExternalPlayer::UpdateGhost(const LbaNet::GhostActorInfo & ainfo)
{
	std::map<int, Actor *>::iterator it = _ghosts.find(ainfo.GhostId);
	if(it == _ghosts.end())
	{
		//create new actor
		Actor * tmp = new Actor(0.6);
		tmp->SetRenderer(DataLoader ::getInstance()->CreateSpriteRenderer(ainfo.SpriteId));

		tmp->SetPosition(ainfo.X, ainfo.Y, ainfo.Z);
		tmp->SetRotation(ainfo.Rotation);

		// add missing attached
		for(size_t i=0; i<ainfo.AttachedToActors.size(); ++i)
			ThreadSafeWorkpile::getInstance()->AddEvent(new AttachActorToActorEvent(_renderer, ainfo.AttachedToActors[i]));

		if(ainfo.AttachedToPlayer)
			_renderer->Attach(tmp);

		_ghosts[ainfo.GhostId] = tmp;
	}
	else
	{
		//update existing actor
		Actor * tmp = it->second;
		tmp->SetPosition(ainfo.X, ainfo.Y, ainfo.Z);
		tmp->SetRotation(ainfo.Rotation);

		const std::vector<Actor *> & attachingacts = tmp->GetAttaching();

		// add missing attached
		for(size_t i=0; i<ainfo.AttachedToActors.size(); ++i)
		{
			bool found = false;
			for(size_t j=0; j<attachingacts.size(); ++j)
			{
				if(	attachingacts[j]->GetId() == ainfo.AttachedToActors[i])
				{
					found = true;
					break;
				}
			}	

			if(!found)
				ThreadSafeWorkpile::getInstance()->AddEvent(new AttachActorToActorEvent(tmp, ainfo.AttachedToActors[i]));
		}

		// remove old attached
		for(size_t j=0; j<attachingacts.size(); ++j)
		{
			bool found = false;
			for(size_t i=0; i<ainfo.AttachedToActors.size(); ++i)
			{
				if(	attachingacts[j]->GetId() == ainfo.AttachedToActors[i])
				{
					found = true;
					break;
				}
			}
			
			if(!found)
				tmp->RemoveAttaching(attachingacts[j]);
		}

		if(ainfo.AttachedToPlayer)
			_renderer->Attach(tmp);
		else
			_renderer->Dettach(tmp);
	}	
}   
开发者ID:leloulight,项目名称:lbanet,代码行数:73,代码来源:ExternalPlayer.cpp


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