コード例 #1
0
void ACharacterTargetSystem::cleanUpTargets(UWorld* currentGameWorld)
{
	// clean up all previous focused enemies
	for (TObjectIterator<ABasicEnemy> enemyFocusIterator; enemyFocusIterator; ++enemyFocusIterator)
	{
		if (enemyFocusIterator->GetWorld() == currentGameWorld)
		{
			ABasicEnemy* enemyChar = *enemyFocusIterator;
			if (!enemyChar->IsPendingKill())
			{
				enemyChar->hideFocusComponent();
				enemyChar->removeFocus();
				enemyChar->disableMenu();
			}
		}
	}

	// clean up all previous focused enemies
	for (TObjectIterator<ABasicNpc> npcFocusIterator; npcFocusIterator; ++npcFocusIterator)
	{
		if (npcFocusIterator->GetWorld() == currentGameWorld)
		{
			ABasicNpc* npcChar = *npcFocusIterator;
			npcChar->hideFocusComponent();
			npcChar->removeFocus();
		}
	}

}
コード例 #2
0
// check only for enemies which are free to target in the given range
bool ACharacterTargetSystem::checkFreeTargetEnemies(ACharacter* player, UWorld* currentGameWorld, float distance)
{
	ABasicEnemy* enemyChar;
	bool enemyFreeForTarget = false;
	float distanceToTarget = distance;
	// TODO
	for (TObjectIterator<ABasicEnemy> enemyIterator; enemyIterator; ++enemyIterator)
	{
		if (enemyIterator->GetWorld() == currentGameWorld)
		{
			enemyChar = *enemyIterator;
			float distanceToPlayer = enemyChar->GetDistanceTo(player);
			if (!enemyChar->IsPendingKill() && distanceToPlayer < distanceToTarget)
			{
				bool isEnemySkipped = enemyChar->bSkippedTarget;
				if (!isEnemySkipped)
				{
					enemyFreeForTarget = true;
				}
			}

		}
	}
	return enemyFreeForTarget;
}
コード例 #3
0
ファイル: Skill.cpp プロジェクト: weelcheel/Mythos-Realm
bool ASkill::SphereTrace(AActor* actorToIgnore, const FVector& start, const FVector& end, const float radius, TArray<FHitResult>& hitOut, ECollisionChannel traceChannel /* = ECC_Pawn */)
{
    FCollisionQueryParams traceParams(FName(TEXT("Sphere Trace")), true, actorToIgnore);
    traceParams.bTraceComplex = true;
    traceParams.bReturnPhysicalMaterial = false;

    traceParams.AddIgnoredActor(actorToIgnore);

    TObjectIterator<APlayerController> pc;
    if (!pc)
        return false;

    DrawDebugSphere(pc->GetWorld(), start, radius, 8, FColor::Red, true);

    return pc->GetWorld()->SweepMultiByChannel(hitOut, start, end, FQuat(), traceChannel, FCollisionShape::MakeSphere(radius), traceParams);
}
コード例 #4
0
void AFPSCharacter::GetMyHealth()
{
	if (GEngine)
	{
		TObjectIterator< APlayerController > ThePC;
		UWorld* TheWorld = ThePC->GetWorld();
		AFPSGM* MyGM = Cast<AFPSGM>(UGameplayStatics::GetGameMode(TheWorld));
		if (MyGM != NULL)
		{
			GEngine->AddOnScreenDebugMessage(1, 5.f, FColor::Red, FString::FromInt(MyGM->Health));
		}
	}
}
コード例 #5
0
void ACharacterTargetSystem::makeAllNpcsFocusable(UWorld* currentGameWorld)
{
	ABasicNpc* npcChar;
	for (TObjectIterator<ABasicNpc> npcFreeIterator; npcFreeIterator; ++npcFreeIterator)
	{
		if (npcFreeIterator->GetWorld() == currentGameWorld)
		{
			npcChar = *npcFreeIterator;
			if (npcChar)
			{
				npcChar->bSkippedTarget = false;
			}
		}
	}
}
コード例 #6
0
void ACharacterTargetSystem::makeAllEnemiesFocusable(UWorld* currentGameWorld)
{
	ABasicEnemy* enemyChar;
	for (TObjectIterator<ABasicEnemy> enemyFreeIterator; enemyFreeIterator; ++enemyFreeIterator)
	{
		if (enemyFreeIterator->GetWorld() == currentGameWorld)
		{
			enemyChar = *enemyFreeIterator;
			if (enemyChar && !enemyChar->IsPendingKill())
			{
				enemyChar->bSkippedTarget = false;
			}
		}
	}

}
コード例 #7
0
void ACharacterTargetSystem::findNPCTargetByDistance(ACharacter* player, UWorld* currentGameWorld, float distance)
{
	ABasicNpc* npcChar;
	float distanceToPlayer;
	float distanceToTarget = distance;
	bool npcFreeForTarget = checkFreeTargetNpcs(currentGameWorld);



	// if every enemy has been skipped, set all to be focusable again
	if (!npcFreeForTarget)
	{
		makeAllNpcsFocusable(currentGameWorld);
	}

	// get distance to enemy that can be focused
	for (TObjectIterator<ABasicNpc> npcFocusIterator; npcFocusIterator; ++npcFocusIterator)
	{
		if (npcFocusIterator->GetWorld() == currentGameWorld)
		{
			npcChar = *npcFocusIterator;
			if (npcChar && player && npcChar->bSkippedTarget == false)
			{
				distanceToPlayer = npcChar->GetDistanceTo(player);
				if (distanceToPlayer < distanceToTarget)
				{
					npcChar->bSkippedTarget = true;
					npcChar->setFocus();
					targetedNpc = npcChar;
					break;
				}
				else
				{
					npcChar->removeFocus();
					targetedNpc = nullptr;
				}
			}
			else
			{
				npcChar->removeFocus();
				targetedNpc = nullptr;
			}
		}

	}
}
コード例 #8
0
void ACharacterTargetSystem::findEnemyTargetByDistance(ACharacter* player, UWorld* currentGameWorld, float distance)
{
	ABasicEnemy* enemyChar;
	float distanceToPlayer;
	float distanceToTarget = distance;
	//TODO CHECK THIS IN DISTANCE
	bool enemyFreeForTarget = checkFreeTargetEnemies(player, currentGameWorld, distance);

	// if every enemy has been skipped, set all to be focusable again
	if (!enemyFreeForTarget)
	{
		makeAllEnemiesFocusable(currentGameWorld);
	}

	// get distance to enemy that can be focused
	for (TObjectIterator<ABasicEnemy> enemyFocusIterator; enemyFocusIterator; ++enemyFocusIterator)
	{
		if (enemyFocusIterator->GetWorld() == currentGameWorld)
		{
			enemyChar = *enemyFocusIterator;
			if (enemyChar && !enemyChar->IsPendingKill() && player && enemyChar->bSkippedTarget == false)
			{
				distanceToPlayer = enemyChar->GetDistanceTo(player);
				if (distanceToPlayer < distanceToTarget)
				{
					enemyChar->bSkippedTarget = true;
					enemyChar->setFocus();
					targetedEnemy = enemyChar;
					break;
				}
				else
				{
					enemyChar->removeFocus();
				}
			}
			else
			{
				enemyChar->removeFocus();
				targetedEnemy = nullptr;
			}
		}

	}
}
コード例 #9
0
bool ACharacterTargetSystem::checkFreeTargetNpcs(UWorld* currentGameWorld)
{
	ABasicNpc* npcChar;
	bool npcFreeForTarget = false;
	// check if every enemy has been focused yet
	for (TObjectIterator<ABasicNpc> npcIterator; npcIterator; ++npcIterator)
	{
		if (npcIterator->GetWorld() == currentGameWorld)
		{
			npcChar = *npcIterator;
			bool isEnemySkipped = npcChar->bSkippedTarget;
			if (!isEnemySkipped)
			{
				npcFreeForTarget = true;
			}
		}
	}

	return npcFreeForTarget;
}
コード例 #10
0
void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(int32 &NumNetPlayers)
{
	//Get an actor to GetWorld() from
	TObjectIterator<AActor> Itr;
	if (!Itr)
	{
		UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetNumberOfNetworkPlayers Failed to get iterator!"));
		return;
	}
	//~~~~~~~~~~~~

	//Get World
	UWorld* TheWorld = Itr->GetWorld();
	if (!TheWorld)
	{
		UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetNumberOfNetworkPlayers Failed to get World()!"));
		return;
	}
	TArray<class APlayerState*>& PlayerArray = (TheWorld->GetGameState()->PlayerArray);
	NumNetPlayers = PlayerArray.Num();
}