Compare commits

..

No commits in common. "8e1c017515eb3739e03f71bc0976ac014fd88da3" and "b531e28337e23116e255636202cd2a679c275f65" have entirely different histories.

25 changed files with 88 additions and 360 deletions

Binary file not shown.

Binary file not shown.

View File

@ -17,9 +17,8 @@ public class Luckyrobots : ModuleRules
"LuckyMujoco",
"LuckyTextWrite",
"SocketIOClient",
"VaRest",
"SIOJson"
});
"VaRest"
});
PrivateDependencyModuleNames.AddRange(new string[] { });

View File

@ -2,11 +2,4 @@
#include "LobbyGameMode.h"
#include "LuckyRobotsFunctionLibrary.h"
void ALobbyGameMode::BeginPlay()
{
Super::BeginPlay();
ULuckyRobotsFunctionLibrary::UpdateQualitySettings(this);
}

View File

@ -1,79 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "LuckyRobotsFunctionLibrary.h"
#include "LuckyRobotsGameInstance.h"
#include "GameFramework/GameUserSettings.h"
ULuckyRobotsGameInstance* ULuckyRobotsFunctionLibrary::GetLuckyRobotsGameInstance(const UObject* WorldContextObject)
{
return Cast<ULuckyRobotsGameInstance>(WorldContextObject->GetWorld()->GetGameInstance());
}
TArray<FRobotData> ULuckyRobotsFunctionLibrary::GetActiveRobotDataList(const UObject* WorldContextObject)
{
TArray<FRobotData> RobotDataList;
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = GetLuckyRobotsGameInstance(WorldContextObject);
if (LuckyRobotsGameInstance)
{
if (LuckyRobotsGameInstance->RobotDataDataTable)
{
FString ContextString;
TArray<FName> RowNames = LuckyRobotsGameInstance->RobotDataDataTable->GetRowNames();
for (auto RowString : RowNames)
{
FRobotData* pRow = LuckyRobotsGameInstance->RobotDataDataTable->FindRow<FRobotData>(FName(RowString), ContextString);
if (pRow)
{
if (pRow->bActive)
{
RobotDataList.Add(*pRow);
}
}
}
}
}
return RobotDataList;
}
TArray<FLevelData> ULuckyRobotsFunctionLibrary::GetActiveLevelDataList(const UObject* WorldContextObject)
{
TArray<FLevelData> LevelDataList;
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = GetLuckyRobotsGameInstance(WorldContextObject);
if (LuckyRobotsGameInstance)
{
if (LuckyRobotsGameInstance->LevelDataTable)
{
FString ContextString;
TArray<FName> RowNames = LuckyRobotsGameInstance->LevelDataTable->GetRowNames();
for (auto RowString : RowNames)
{
FLevelData* pRow = LuckyRobotsGameInstance->LevelDataTable->FindRow<FLevelData>(FName(RowString), ContextString);
if (pRow)
{
if (pRow->bActive)
{
LevelDataList.Add(*pRow);
}
}
}
}
}
return LevelDataList;
}
void ULuckyRobotsFunctionLibrary::UpdateQualitySettings(const UObject* WorldContextObject)
{
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = GetLuckyRobotsGameInstance(WorldContextObject);
if (LuckyRobotsGameInstance)
{
// Load game user settings and apply
UGameUserSettings* GameUserSettings = GEngine->GetGameUserSettings();
if (GameUserSettings)
{
GameUserSettings->SetOverallScalabilityLevel(int(LuckyRobotsGameInstance->CurrentSelectQuality));
GameUserSettings->SaveSettings();
GameUserSettings->ApplySettings(true);
}
}
}

View File

@ -2,39 +2,4 @@
#include "LuckyRobotsGameMode.h"
#include "LuckyRobotsGameInstance.h"
#include "LuckyRobotsFunctionLibrary.h"
void ALuckyRobotsGameMode::BeginPlay()
{
Super::BeginPlay();
ULuckyRobotsFunctionLibrary::UpdateQualitySettings(this);
}
UClass* ALuckyRobotsGameMode::GetDefaultPawnClassForController_Implementation(AController* InController)
{
UClass* RobotClass = Super::GetDefaultPawnClassForController_Implementation(InController);
ERobotsName CurrentRobot = ERobotsName::None;
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (LuckyRobotsGameInstance)
{
CurrentRobot = LuckyRobotsGameInstance->CurrentSelectRobot;
}
if (CurrentRobot != ERobotsName::None)
{
TArray<FRobotData> ActiveRobotDataList = ULuckyRobotsFunctionLibrary::GetActiveRobotDataList(this);
for (auto ActiveRobotData : ActiveRobotDataList)
{
if (ActiveRobotData.Name == CurrentRobot)
{
RobotClass = ActiveRobotData.RobotClass;
break;
}
}
}
return RobotClass;
}

View File

@ -2,54 +2,4 @@
#include "LuckyRobotsGameState.h"
#include "SocketIOClientComponent.h"
#include "LuckyRobotsFunctionLibrary.h"
#include "LuckyRobotsGameInstance.h"
ALuckyRobotsGameState::ALuckyRobotsGameState()
{
SocketIOClientComponent = CreateDefaultSubobject<USocketIOClientComponent>(TEXT("SocketIOClientComponent"));
}
void ALuckyRobotsGameState::BeginPlay()
{
Super::BeginPlay();
if (SocketIOClientComponent)
{
SocketIOClientComponent->Connect(L"http://localhost:3000/");
}
}
void ALuckyRobotsGameState::DoSendMessage(FString SendValue)
{
if (SocketIOClientComponent)
{
if (SocketIOClientComponent->bIsConnected)
{
USIOJsonValue* SIOJsonValue = USIOJsonValue::ConstructJsonValueString(this, SendValue);
SocketIOClientComponent->Emit("message", SIOJsonValue);
}
}
}
void ALuckyRobotsGameState::DoSocketOnConnect(FString SocketId, FString SessionId, bool IsReconnection)
{
if (SocketIOClientComponent)
{
if (SocketIOClientComponent->bIsConnected)
{
SocketIOClientComponent->BindEventToGenericEvent("response");
}
}
}
void ALuckyRobotsGameState::DoSocketOnGenericEvent(FString EventName, USIOJsonValue* EventData)
{
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = ULuckyRobotsFunctionLibrary::GetLuckyRobotsGameInstance(this);
if (LuckyRobotsGameInstance)
{
LuckyRobotsGameInstance->DoGetDispatch(EventName, EventData);
}
}

View File

@ -4,7 +4,6 @@
#include "MainScreenUserWidget.h"
#include "Engine/DataTable.h"
#include "LuckyRobotsGameInstance.h"
#include "LuckyRobotsFunctionLibrary.h"
void UMainScreenUserWidget::NativeConstruct()
{
@ -21,13 +20,38 @@ void UMainScreenUserWidget::InitData()
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (LuckyRobotsGameInstance)
{
iCurrentSelectQuality = int(LuckyRobotsGameInstance->CurrentSelectQuality);
UEnum* QualityEnum = StaticEnum<EQualityEnum>();
for (int32 i = 0; i < QualityEnum->NumEnums() - 1; i++)
{
if (EQualityEnum(QualityEnum->GetValueByIndex(i)) == LuckyRobotsGameInstance->CurrentSelectQuality)
{
iCurrentSelectRobot = i;
break;
}
}
}
}
void UMainScreenUserWidget::InitRobotData()
{
RobotDataList = ULuckyRobotsFunctionLibrary::GetActiveRobotDataList(this);
if (RobotDataDataTable)
{
RobotDataList.Empty();
FString ContextString;
TArray<FName> RowNames = RobotDataDataTable->GetRowNames();
for (auto RowString : RowNames)
{
FRobotData* pRow = RobotDataDataTable->FindRow<FRobotData>(FName(RowString), ContextString);
if (pRow)
{
if (pRow->bActive)
{
RobotDataList.Add(*pRow);
}
}
}
}
iCurrentSelectRobot = 0;
UpdateSelectRobot();
@ -35,19 +59,49 @@ void UMainScreenUserWidget::InitRobotData()
void UMainScreenUserWidget::InitLevelData()
{
LevelDataList = ULuckyRobotsFunctionLibrary::GetActiveLevelDataList(this);
FRobotData CurrentRobotData = GetCurrentRobotData();
if (CurrentRobotData.Name != ERobotsName::None)
{
TArray<FLevelData> ActiveLevelDataList = LevelDataList;
LevelDataList.Empty();
for (auto ActiveLevelData : ActiveLevelDataList)
if (LevelDataTable)
{
if (ActiveLevelData.RobotTypeList.Find(CurrentRobotData.RobotType) >= 0)
LevelDataList.Empty();
FString ContextString;
TArray<FName> RowNames = LevelDataTable->GetRowNames();
for (auto RowString : RowNames)
{
LevelDataList.Add(ActiveLevelData);
FLevelData* pRow = LevelDataTable->FindRow<FLevelData>(FName(RowString), ContextString);
if (pRow)
{
if (pRow->bActive)
{
if (pRow->RobotTypeList.Find(CurrentRobotData.RobotType) >= 0)
{
LevelDataList.Add(*pRow);
}
}
}
}
}
}
else
{
if (LevelDataTable)
{
LevelDataList.Empty();
FString ContextString;
TArray<FName> RowNames = LevelDataTable->GetRowNames();
for (auto RowString : RowNames)
{
FLevelData* pRow = LevelDataTable->FindRow<FLevelData>(FName(RowString), ContextString);
if (pRow)
{
if (pRow->bActive)
{
LevelDataList.Add(*pRow);
}
}
}
}
}
@ -104,7 +158,7 @@ void UMainScreenUserWidget::SelectNextQuality()
{
UEnum* QualityEnum = StaticEnum<EQualityEnum>();
int QualityEnumNum = QualityEnum->NumEnums() - 1;
iCurrentSelectQuality = FMath::Clamp(iCurrentSelectQuality - 1, 0, QualityEnumNum - 1);
iCurrentSelectQuality = FMath::Clamp(iCurrentSelectQuality + 1, 0, QualityEnumNum - 1);
UpdateSelectQuality();
}
@ -113,7 +167,7 @@ void UMainScreenUserWidget::SelectPreviousQuality()
{
UEnum* QualityEnum = StaticEnum<EQualityEnum>();
int QualityEnumNum = QualityEnum->NumEnums() - 1;
iCurrentSelectQuality = FMath::Clamp(iCurrentSelectQuality + 1, 0, QualityEnumNum - 1);
iCurrentSelectQuality = FMath::Clamp(iCurrentSelectQuality - 1, 0, QualityEnumNum - 1);
UpdateSelectQuality();
}
@ -143,7 +197,8 @@ void UMainScreenUserWidget::UpdateSelectQuality()
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (LuckyRobotsGameInstance)
{
LuckyRobotsGameInstance->CurrentSelectQuality = static_cast<EQualityEnum>(iCurrentSelectQuality);
UEnum* QualityEnum = StaticEnum<EQualityEnum>();
LuckyRobotsGameInstance->CurrentSelectQuality = EQualityEnum(QualityEnum->GetValueByIndex(iCurrentSelectQuality));
}
BPUpdateSelectQuality();
}

View File

@ -13,7 +13,5 @@ UCLASS()
class LUCKYROBOTS_API ALobbyGameMode : public AGameModeBase
{
GENERATED_BODY()
protected:
virtual void BeginPlay() override;
};

View File

@ -1,30 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "SharedDef.h"
#include "LuckyRobotsFunctionLibrary.generated.h"
class ULuckyRobotsGameInstance;
/**
*
*/
UCLASS()
class LUCKYROBOTS_API ULuckyRobotsFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject"))
static ULuckyRobotsGameInstance* GetLuckyRobotsGameInstance(const UObject* WorldContextObject);
UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject"))
static TArray<FRobotData> GetActiveRobotDataList(const UObject* WorldContextObject);
UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject"))
static TArray<FLevelData> GetActiveLevelDataList(const UObject* WorldContextObject);
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"))
static void UpdateQualitySettings(const UObject* WorldContextObject);
};

View File

@ -7,7 +7,6 @@
#include "SharedDef.h"
#include "LuckyRobotsGameInstance.generated.h"
class USIOJsonValue;
/**
*
*/
@ -16,24 +15,13 @@ class LUCKYROBOTS_API ULuckyRobotsGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UDataTable* RobotDataDataTable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UDataTable* LevelDataTable;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ERobotsName CurrentSelectRobot = ERobotsName::None;
ERobotsName CurrentSelectRobot;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ELevelEnum CurrentSelectLevel = ELevelEnum::None;
ELevelEnum CurrentSelectLevel;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
EQualityEnum CurrentSelectQuality = EQualityEnum::Epic;
public:
UFUNCTION(BlueprintImplementableEvent)
void DoGetDispatch(const FString& EventName, USIOJsonValue* EventData);
EQualityEnum CurrentSelectQuality;
};

View File

@ -13,9 +13,5 @@ UCLASS()
class LUCKYROBOTS_API ALuckyRobotsGameMode : public AGameModeBase
{
GENERATED_BODY()
protected:
virtual void BeginPlay() override;
virtual UClass* GetDefaultPawnClassForController_Implementation(AController* InController) override;
};

View File

@ -6,8 +6,6 @@
#include "GameFramework/GameStateBase.h"
#include "LuckyRobotsGameState.generated.h"
class USocketIOClientComponent;
class USIOJsonValue;
/**
*
*/
@ -15,21 +13,5 @@ UCLASS()
class LUCKYROBOTS_API ALuckyRobotsGameState : public AGameStateBase
{
GENERATED_BODY()
protected:
ALuckyRobotsGameState();
virtual void BeginPlay() override;
public:
UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
USocketIOClientComponent* SocketIOClientComponent;
public:
UFUNCTION(BlueprintCallable)
void DoSendMessage(FString SendValue);
UFUNCTION(BlueprintCallable)
void DoSocketOnConnect(FString SocketId, FString SessionId, bool IsReconnection);
UFUNCTION(BlueprintCallable)
void DoSocketOnGenericEvent(FString EventName, USIOJsonValue* EventData);
};

View File

@ -18,6 +18,13 @@ class LUCKYROBOTS_API UMainScreenUserWidget : public UUserWidget
protected:
virtual void NativeConstruct();
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UDataTable* RobotDataDataTable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UDataTable* LevelDataTable;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FRobotData> RobotDataList;

View File

@ -64,18 +64,10 @@ enum class ELevelEnum : uint8
UENUM(BlueprintType)
enum class EQualityEnum : uint8
{
Low UMETA(DisplayName = "Low"),
Middle UMETA(DisplayName = "Middle"),
Epic UMETA(DisplayName = "Epic"),
High UMETA(DisplayName = "High"),
Epic UMETA(DisplayName = "Epic")
};
UENUM(BlueprintType)
enum class EGoalType : uint8
{
GrabAndPull UMETA(DisplayName = "Grab and Pull"),
GrabAndRotate UMETA(DisplayName = "Grab and Rotate"),
Middle UMETA(DisplayName = "Middle"),
Low UMETA(DisplayName = "Low")
};
USTRUCT(BlueprintType)
@ -131,92 +123,4 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<ERobotsCategories> RobotTypeList;
};
USTRUCT(BlueprintType)
struct FGoalsTaskData : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
EGoalType GoalType;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsStart;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FTransform TargetLocation;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
AActor* TargetActor;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsComplate;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FVector DropOffLocation;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString ObjectName;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bActive;
};
USTRUCT(BlueprintType)
struct FCaptureSettingsData : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText FolderName;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText FileName;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText WritesPerSec;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool IsScenario;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FGoalsTaskData> TaskList;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bLight;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bMaterials;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bRobotPosition;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bPets;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfPets;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bPeople;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfPeople;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bObjects;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfObjects;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<UStaticMeshComponent*> RandomMeshes;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bInfiniteCapture;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfCaptures;
};
};