コード例 #1
0
ファイル: Avatar.cpp プロジェクト: phillzz/GoldenEgg
void AAvatar::ToggleInventory()
{
	APlayerController* PController = GetWorld()->GetFirstPlayerController();
	AMyHUD* hud = Cast<AMyHUD>( PController->GetHUD() );
	
	// If inventory is displayed, undisplay it.
	if( inventoryShowing )
	{
		hud->clearWidgets();
		inventoryShowing = false;
		PController->bShowMouseCursor = false;
		return;
	}

	// Otherwise, display the player's inventory
	inventoryShowing = true;
	PController->bShowMouseCursor = true;
	for( TMap<FString,int>::TIterator it = Backpack.CreateIterator(); it; ++it )
	{
		// Combine string name of the item, with qty eg Cow x 5
		FString fs = it->Key + FString::Printf( TEXT(" x %d"), it->Value );
		UTexture2D* tex = NULL;
		if( Icons.Find( it->Key ) )
		{
			tex = Icons[it->Key];
			Widget w( Icon( fs, tex ), Classes[it->Key] );
			w.bpSpell = Spells[it->Key];
			hud->addWidget( w );
		}
	}
}
コード例 #2
0
ファイル: PickUpItem.cpp プロジェクト: dschmidl/GE_Project
void APickUpItem::Prox_Implementation(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32
	OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
	// if the overlapped actor is NOT the player,
	// you simply should return
	if (Cast<AActor>(OtherActor) == nullptr)
	{
		return;
	}
	// Get a reference to the player avatar, to give him
	// the item
	AAvatar *avatar = Cast<AAvatar>(UGameplayStatics::GetPlayerPawn(
		GetWorld(), 0));
	// Let the player pick up item
	// Notice use of keyword this!
	// That is how _this_ Pickup can refer to itself.
	avatar->Pickup(this);
	
	if (CoinSound != NULL)
	{
		UGameplayStatics::PlaySoundAtLocation(this, CoinSound, GetActorLocation());
	}
	// Get a reference to the controller
	APlayerController* PController = GetWorld() ->GetFirstPlayerController();
	// Get a reference to the HUD from the controller
	AMyHUD* hud = Cast<AMyHUD>(PController->GetHUD());
	hud->addMessage(Message(Icon, FString("Picked up ") + FString(" ") + Name + FString(" ")+FString::FromInt(Quantity), 2.0f, FColor::Black, FColor::Black));
	Destroy();

	
}
コード例 #3
0
void FBehaviorTreeDebugger::FindLockedDebugActor(UWorld* World)
{
	APlayerController* LocalPC = GEngine->GetFirstLocalPlayerController(World);
	if (LocalPC && LocalPC->GetHUD() && LocalPC->GetPawnOrSpectator())
	{
		AGameplayDebuggingReplicator* DebuggingReplicator = NULL;
		for (TActorIterator<AGameplayDebuggingReplicator> It(World); It; ++It)
		{
			AGameplayDebuggingReplicator* A = *It;
			if (!A->IsPendingKill())
			{
				DebuggingReplicator = A;
				break;
			}
		}

		const APawn* LockedPawn = DebuggingReplicator != NULL ? Cast<APawn>(DebuggingReplicator->GetSelectedActorToDebug()) : NULL;
		UBehaviorTreeComponent* TestInstance = FindInstanceInActor((APawn*)LockedPawn);
		if (TestInstance)
		{
			TreeInstance = TestInstance;

#if USE_BEHAVIORTREE_DEBUGGER
			ActiveStepIndex = TestInstance->DebuggerSteps.Num() - 1;
#endif
		}
	}
}
コード例 #4
0
ファイル: Avatar.cpp プロジェクト: phillzz/GoldenEgg
void AAvatar::MouseRightClicked()
{
	if( inventoryShowing )
	{
		APlayerController* PController = GetWorld()->GetFirstPlayerController();
		AMyHUD* hud = Cast<AMyHUD>( PController->GetHUD() );
		hud->MouseRightClicked();
	}
}
コード例 #5
0
ファイル: LearningCPPNPC.cpp プロジェクト: Suui/UE4Tutorials
void ALearningCPPNPC::Prox_Implementation(AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	if (Cast<ALearningCPPCharacter>(OtherActor) == nullptr) return;

	APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
	if (PlayerController)
	{
		ALearningCPPHUD* Hud = Cast<ALearningCPPHUD>(PlayerController->GetHUD());
		Hud->AddMessage(FMessage(NpcName + ": " + NpcMessage, 3.0f, FColor::White, Texture));
	}
}
コード例 #6
0
void APawnWithCamera::LMB_Out()
{
	APlayerController* MyController = GetWorld()->GetFirstPlayerController();
	AMyHUD *Hudref = Cast<AMyHUD>(MyController->GetHUD());
	FVector WorldMousePos = Hudref->GetMOuseWorldPosition();

	FVector Start = GetActorLocation();

	DistanceWithToPoints = FVector::Dist(Start, WorldMousePos);

	//DrawDebugSphere(GetWorld(), WorldMousePos, 16.f, 8, FColor(83, 155, 83, 255), false, 0.15f);
	DrawDebugLine(GetWorld(), Start, WorldMousePos, FColor(255, 0, 0), true, 0.5f, 0, 5.0f);
}
コード例 #7
0
ファイル: NPCDialogue.cpp プロジェクト: Rish79/FPS-Horror
void ANPCDialogue::Prox_Implementation(AActor* otherActor, UPrimitiveComponent* 
	otherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
	if (Cast<AFPSHorrorCharacter>(otherActor) == nullptr)
	{
		return;
	}
	APlayerController* PController = GetWorld()->GetFirstPlayerController();
	if (PController)
	{
		AMyHUD* hud = Cast<AMyHUD>(PController->GetHUD());
		hud->addMessage(FMessage(NPCmessage, 5.0f, FColor::White));
	}
}
コード例 #8
0
ファイル: Avatar.cpp プロジェクト: phillzz/GoldenEgg
void AAvatar::Pitch( float amount )
{
	//y
	if( inventoryShowing )
	{
		// if the button is down click drag
		APlayerController* PController = GetWorld()->GetFirstPlayerController();
		AMyHUD* hud = Cast<AMyHUD>( PController->GetHUD() );
		hud->MouseMoved();
	}
	//else
	{
		AddControllerPitchInput(200.f*amount * GetWorld()->GetDeltaSeconds());
	}
}
コード例 #9
0
ファイル: NPC.cpp プロジェクト: mdurn/UnrealSample
void ANPC::Prox_Implementation(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
  if (Cast<AAvatar>(OtherActor) == nullptr) { return; }
  
  APlayerController* PController = GetWorld()->GetFirstPlayerController();
  
  if (PController)
  {
    ANPC_HUD* hud = Cast<ANPC_HUD>(PController->GetHUD());
    FString NameAndMessage = FString::Printf(TEXT("%s: %s"), *Name, *NPCMessage);
    hud->AddMessage(Message(NameAndMessage, 5.f, FColor::White, Face));
    hp->is_visible = true;
    hud->AddHpBar(hp);
  }
}
コード例 #10
0
ファイル: HealthBar.cpp プロジェクト: Siretu/CCUE
// Called every frame
void UHealthBar::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) {
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	if (health == -1) {
		APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);
		if (PC) {
			ACCHUD* hud = Cast<ACCHUD>(PC->GetHUD());
			if (hud) {
				hud->RegisterHealthbar(this);
				health = maxHealth;
			}
		}
	} else {
		//health -= 0.01;
	}
}
コード例 #11
0
void ANotePickup::OnDrop_Implementation()
{
	Super::OnDrop_Implementation();
	APlayerController* c = GetWorld()->GetFirstPlayerController();
	if (c)
	{
		ACharacterHUD* h = Cast<ACharacterHUD>(c->GetHUD());
		if (h)
		{
			h->DrawNoteString = false;
			h->DrawNoteImage = false;
			h->NoteString = "";
			Fade = -1.0;
		}
	}
}
コード例 #12
0
void ANotePickup::Tick(float DeltaTime)
{
	if (Fade != 0)
	{
		APlayerController* c = GetWorld()->GetFirstPlayerController();
		if (c)
		{
			ACharacterHUD* h = Cast<ACharacterHUD>(c->GetHUD());
			if (h)
			{
				h->BlackBackgroundAlpha = FMath::Clamp(h->BlackBackgroundAlpha + (200 * DeltaTime * Fade), 0.0f, 150.0f);

				if (h->BlackBackgroundAlpha == 0.0f || h->BlackBackgroundAlpha == 150)
					Fade = 0;
			}
		}
	}
}
コード例 #13
0
void ASCharacter::ConsumeFood(float AmountRestored)
{
	// Reduce Hunger, ensure we do not go outside of our bounds
	Hunger = FMath::Clamp(Hunger - AmountRestored, 0.0f, GetMaxHunger());

	// Restore Hitpoints
	Health = FMath::Clamp(Health + AmountRestored, 0.0f, GetMaxHealth());

	APlayerController* PC = Cast<APlayerController>(Controller);
	if (PC)
	{
		ASHUD* MyHUD = Cast<ASHUD>(PC->GetHUD());
		if (MyHUD)
		{
			MyHUD->MessageReceived("Food consumed!");
		}
	}
}
コード例 #14
0
void ANotePickup::Read()
{
	APlayerController* c = GetWorld()->GetFirstPlayerController();
	if (c)
	{
		ACharacterHUD* h = Cast<ACharacterHUD>(c->GetHUD());
		if (h)
		{
			h->DrawNoteString = !h->DrawNoteString;
			h->DrawSafeString = false;
			h->NoteString = Notes[NoteIndex];
			h->NoteImage = NoteImage;
			h->DrawNoteImage = !h->DrawNoteImage;

			if (h->DrawNoteString)
				Fade = 1.0;
			else
				Fade = -1.0;
		}
	}
}
コード例 #15
0
PyObject *py_ue_get_player_hud(ue_PyUObject *self, PyObject * args)
{

	ue_py_check(self);

	int controller_id = 0;
	if (!PyArg_ParseTuple(args, "|i:get_player_hud", &controller_id))
	{
		return NULL;
	}

	UWorld *world = ue_get_uworld(self);
	if (!world)
		return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject");

	APlayerController *controller = UGameplayStatics::GetPlayerController(world, controller_id);
	if (!controller)
		return PyErr_Format(PyExc_Exception, "unable to retrieve controller %d", controller_id);

	Py_RETURN_UOBJECT(controller->GetHUD());
}
コード例 #16
0
void ASafeInteract::Tick(float DeltaTime)
{
	APlayerController* c = GetWorld()->GetFirstPlayerController();
	if (!c) return;

	ACharacterHUD* h = Cast<ACharacterHUD>(c->GetHUD());
	if (!h) return;

	if (EnteringCombination)
	{
		if ((this->GetActorLocation() - CharacterReference->GetActorLocation()).Size() > 400.0f)
		{
			EnteringCombination = false;
			Fade = -1.0;
		}

		h->DrawSafeString = true;
		FString string = TestCombination;

		if (CombinationLength < COMBINATION_LENGTH)
		{
			string += "_";
			for (int i = 0; i < (COMBINATION_LENGTH - CombinationLength) - 1; i++)
			{
				string += " ";
			}
		}
		h->SafeString = string;

		if (CheckInput())
		{
			UAudioComponent* SpeakerAudio = SafeSpeaker->GetAudioComponent();
			UAudioComponent* SpeakerAudio2 = SafeUnlockSpeaker->GetAudioComponent();

			if (EnterCombination())
			{
				EnteringCombination = false;
				h->DrawSafeString = false;
				h->SafeString = "";

				SpeakerAudio2->Play();
				IsLocked = false;
				UnlockSafe();
				Fade = -1.0;
			}
			else
			{
				if (!SpeakerAudio->IsPlaying())
					SpeakerAudio->Play();
			}
		}
	}
	else
	{
		h->DrawSafeString = false;
		h->SafeString = "";
	}

	if (Fade != 0)
	{
		h->BlackBackgroundAlpha = FMath::Clamp(h->BlackBackgroundAlpha + (200 * DeltaTime * Fade), 0.0f, 150.0f);

		if (h->BlackBackgroundAlpha == 0.0f || h->BlackBackgroundAlpha == 150)
			Fade = 0;
	}
}