add new meshes and mood decreace
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "BaseItem.h"
|
||||
#include "Female.h"
|
||||
#include "Math/UnrealMathUtility.h"
|
||||
|
||||
// Sets default values
|
||||
ABaseItem::ABaseItem()
|
||||
@@ -50,29 +51,23 @@ void ABaseItem::OnOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherA
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// =======================start used item======================================
|
||||
void ABaseItem::logicOfUsingItems()
|
||||
{
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("ITEM -> logick1"));
|
||||
if (!used && !isBroken)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("ITEM -> logick2"));
|
||||
used = !used;
|
||||
// check for breakage
|
||||
if (isCrushed())
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("ITEM -> logick3"));
|
||||
Health = 0.0f;
|
||||
female->CheckingUpset();
|
||||
showBroken();
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO îòâåò áàáå ÷òî áû îíà íà÷àëà àíèìàöèþ ðàáîòû
|
||||
female->SartAnimUseItem();
|
||||
UE_LOG(LogTemp, Warning, TEXT("ITEM -> logick4"));
|
||||
//EndUseItem();
|
||||
}
|
||||
}
|
||||
@@ -139,6 +134,21 @@ float ABaseItem::getMaxHealth()
|
||||
return MaxHealth;
|
||||
}
|
||||
|
||||
float ABaseItem::GetXMood()
|
||||
{
|
||||
return XMood;
|
||||
}
|
||||
|
||||
float ABaseItem::GetWeight()
|
||||
{
|
||||
return weight;
|
||||
}
|
||||
|
||||
void ABaseItem::SetUseItem(bool isUse)
|
||||
{
|
||||
used = isUse;
|
||||
}
|
||||
|
||||
|
||||
// Called every frame
|
||||
/*
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "Female.h"
|
||||
#include "TimerManager.h"
|
||||
#include "Math/UnrealMathUtility.h"
|
||||
|
||||
// Sets default values
|
||||
AFemale::AFemale()
|
||||
@@ -11,6 +12,7 @@ AFemale::AFemale()
|
||||
//PrimaryActorTick.bCanEverTick = true;
|
||||
}
|
||||
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void AFemale::BeginPlay()
|
||||
{
|
||||
@@ -19,8 +21,17 @@ void AFemale::BeginPlay()
|
||||
capsule = GetCapsuleComponent();
|
||||
capsule->OnComponentBeginOverlap.AddDynamic(this, &AFemale::OnOverlapBegin);
|
||||
capsule->OnComponentEndOverlap.AddDynamic(this, &AFemale::OnOverlapEnd);
|
||||
maxMood = 0.0f;
|
||||
currentMood = 0.0f;
|
||||
GetData();
|
||||
}
|
||||
|
||||
void AFemale::GetData()
|
||||
{
|
||||
gameInstance = Cast<UWBIFGameInstance>(GetGameInstance());
|
||||
maxMood = gameInstance->getMaxMood();
|
||||
currentMood = gameInstance->getCurrentMood();
|
||||
}
|
||||
|
||||
|
||||
void AFemale::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
|
||||
@@ -43,16 +54,53 @@ void AFemale::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherA
|
||||
void AFemale::OnOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
|
||||
{
|
||||
|
||||
ItemForWork = nullptr;
|
||||
UE_LOG(LogTemp, Warning, TEXT("FEMALE OVERLAP END"));
|
||||
}
|
||||
|
||||
void AFemale::StartUseItem()
|
||||
{
|
||||
ItemForWork->logicOfUsingItems();
|
||||
GetWorldTimerManager().ClearTimer(MemberTimerHandle);
|
||||
if(ItemForWork != nullptr && !ItemForWork->isBroken )
|
||||
{
|
||||
if(!ItemForWork->used)
|
||||
{
|
||||
ItemForWork->logicOfUsingItems();
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckingUpset();
|
||||
}
|
||||
}else
|
||||
{
|
||||
CheckingUpset();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ============= MOOD ==========
|
||||
void AFemale::CheckingUpset()
|
||||
{
|
||||
if (!(FMath::RandRange(0.0f, 100.0f) > ItemForWork->GetXMood()))
|
||||
{
|
||||
MoodDecreace();
|
||||
}
|
||||
}
|
||||
|
||||
void AFemale::MoodDecreace()
|
||||
{
|
||||
|
||||
gameInstance->setCurrentMood(gameInstance->getCurrentMood() - ItemForWork->GetWeight());
|
||||
}
|
||||
|
||||
void AFemale::MoodIncreace()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AFemale::EndUseItem_Implementation()
|
||||
{
|
||||
@@ -85,4 +133,3 @@ void AFemale::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "Components/StaticMeshComponent.h"
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Math/UnrealMathUtility.h"
|
||||
#include "BaseItem.generated.h"
|
||||
|
||||
UCLASS()
|
||||
@@ -86,4 +85,10 @@ public:
|
||||
float getHealth();
|
||||
UFUNCTION()
|
||||
float getMaxHealth();
|
||||
UFUNCTION()
|
||||
float GetXMood();
|
||||
UFUNCTION()
|
||||
float GetWeight();
|
||||
UFUNCTION()
|
||||
void SetUseItem(bool isUse);
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "BaseItem.h"
|
||||
#include "GameFramework/GameMode.h"
|
||||
#include "WBIF/WBIFGameModeBase.h"
|
||||
#include "WBIFGameInstance.h"
|
||||
#include "Female.generated.h"
|
||||
|
||||
UCLASS()
|
||||
@@ -35,7 +36,13 @@ protected:
|
||||
void StartUseItem();
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Functions")
|
||||
void whatShouldIDo();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Mood")
|
||||
void MoodDecreace();
|
||||
UFUNCTION(BlueprintCallable, Category = "Mood")
|
||||
void MoodIncreace();
|
||||
|
||||
UFUNCTION()
|
||||
void GetData();
|
||||
|
||||
// ===================Variable===================================
|
||||
UPROPERTY(EditAnyWhere, Category = "Data")
|
||||
@@ -45,6 +52,8 @@ protected:
|
||||
UCapsuleComponent* capsule;
|
||||
UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category = "Data")
|
||||
FName NameItem;
|
||||
UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category= "Data")
|
||||
UWBIFGameInstance* gameInstance;
|
||||
|
||||
|
||||
|
||||
@@ -60,6 +69,8 @@ public:
|
||||
void SartAnimUseItem();
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Use Item")
|
||||
void EndUseItem();
|
||||
UFUNCTION(BlueprintCallable, Category = "Mood")
|
||||
void CheckingUpset();
|
||||
|
||||
// ===================Variable===================================
|
||||
UPROPERTY() // variable for timer
|
||||
|
||||
Reference in New Issue
Block a user