//----------------------------------------------------------------------------
void vesKiwiBrainAtlasRepresentation::showTextLabel(int modelIndex) {

  std::string anatomicalName = this->Internal->AnatomicalNames[modelIndex];

  anatomicalName = GetHumanReadableName(anatomicalName);

  this->Internal->TextRep->setText(anatomicalName);
  this->Internal->TextRep->addSelfToRenderer(this->renderer());

  bool useWorldAnchor = true;

  if (!useWorldAnchor) {
    this->Internal->TextRep->actor()->setIsOverlayNode(true);
    this->Internal->TextRep->setBinNumber(21);
    vesVector2f displayPosition;
    displayPosition[0] = (this->renderer()->width()/2.0) - (this->Internal->TextRep->textWidth()/2.0);
    displayPosition[1] = 150;
    this->Internal->TextRep->setDisplayPosition(displayPosition);
    this->Internal->TextRep->setWorldAnchorPointEnabled(false);
  }
  else {

    vesVector3f worldPoint = this->Internal->AnnotationAnchors[modelIndex];
    double anchorOffset = this->Internal->AnchorOffsets[modelIndex];

    this->Internal->TextRep->setWorldAnchorPoint(worldPoint);
    this->Internal->TextRep->setAnchorOffset(anchorOffset);
    this->Internal->TextRep->setWorldAnchorPointEnabled(true);
  }


  this->Internal->TextVisible = true;
}
Exemplo n.º 2
0
// Update the statistics of players involved in the death
void AMurphysLawCharacter::UpdateStatsOnKill(AController* InstigatedBy, AActor* DamageCauser)
{
	AMurphysLawGameState* GameState = GetWorld()->GetGameState<AMurphysLawGameState>();
	FString DeathMessage = "";
	// Try to cast the DamageCauser to DamageZone to see if the player committed suicide
	auto DamageZone = Cast<AMurphysLawDamageZone>(DamageCauser);

	// Does the player committed suicide?
	if (InstigatedBy == GetController() || DamageCausedByDamageZone(DamageCauser))
	{
		InstigatedBy = GetController();
		DeathMessage = FString::Printf(TEXT("%s committed suicide."), *GetHumanReadableName());
		if (GetPlayerState())
			GetPlayerState()->IncrementNbDeaths();
		if (GameState)
			GameState->PlayerCommitedSuicide(GetPlayerState()->GetTeam() == AMurphysLawGameMode::TEAM_A);
	}
	else if (IsFriendlyFire(InstigatedBy) && DamageCausedByExplosive(DamageCauser))
	{
		// Or was he killed by a teammate because of explosion?
		DeathMessage = FString::Printf(TEXT("%s was killed by a teammate."), *GetHumanReadableName());
		if (GetPlayerState())
			GetPlayerState()->IncrementNbDeaths();

		if (GameState)
			GameState->PlayerKilledTeammate(GetPlayerState()->GetTeam() == AMurphysLawGameMode::TEAM_A);
	}
	else
	{
		// If the player was killed by somebody else
		if (InstigatedBy)
		{
			DeathMessage = FString::Printf(TEXT("%s was killed by %s"), *GetHumanReadableName(), *InstigatedBy->GetHumanReadableName());

			// Increment the number of kills of the other player
			auto OtherPlayerState = Cast<AMurphysLawPlayerState>(InstigatedBy->PlayerState);
			if (OtherPlayerState)
				OtherPlayerState->IncrementNbKills();


			// And increment the number of deaths of the current player
			if (GetPlayerState())
				GetPlayerState()->IncrementNbDeaths();

			if (GameState)
			{
				if (GetPlayerState())
				{
					GameState->PlayerWasKilled(OtherPlayerState->GetTeam() == AMurphysLawGameMode::TEAM_A);
				}
				else
					ShowError("PlayerState is null");
			}
			else
				ShowError("GameState is null");
		}
	}

	AMurphysLawGameMode* GameMode = Cast<AMurphysLawGameMode>(GetWorld()->GetAuthGameMode());
	if (GameMode && DeathMessage != "")
		GameMode->SendDeathMessage(Cast<AMurphysLawPlayerController>(InstigatedBy), DeathMessage);
}