You've already forked LuckyWorld
Luckyrobots->LuckyRobots
This commit is contained in:
5
Source/Luckyrobots/Private/LobbyGameMode.cpp
Normal file
5
Source/Luckyrobots/Private/LobbyGameMode.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "LobbyGameMode.h"
|
||||
|
25
Source/Luckyrobots/Private/LobbyPlayerController.cpp
Normal file
25
Source/Luckyrobots/Private/LobbyPlayerController.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "LobbyPlayerController.h"
|
||||
|
||||
void ALobbyPlayerController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
void ALobbyPlayerController::SetupInputComponent()
|
||||
{
|
||||
Super::SetupInputComponent();
|
||||
|
||||
InputComponent->BindAction("LobbyInit", IE_Pressed, this, &ALobbyPlayerController::Init).bConsumeInput = false;
|
||||
InputComponent->BindAction("LobbyInit", IE_Released, this, &ALobbyPlayerController::Init).bConsumeInput = false;
|
||||
}
|
||||
|
||||
void ALobbyPlayerController::Init()
|
||||
{
|
||||
bShowMouseCursor = true;
|
||||
SetIgnoreMoveInput(true);
|
||||
}
|
5
Source/Luckyrobots/Private/LuckyRobotsGameInstance.cpp
Normal file
5
Source/Luckyrobots/Private/LuckyRobotsGameInstance.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "LuckyRobotsGameInstance.h"
|
||||
|
5
Source/Luckyrobots/Private/LuckyRobotsGameMode.cpp
Normal file
5
Source/Luckyrobots/Private/LuckyRobotsGameMode.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "LuckyRobotsGameMode.h"
|
||||
|
5
Source/Luckyrobots/Private/LuckyRobotsGameState.cpp
Normal file
5
Source/Luckyrobots/Private/LuckyRobotsGameState.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "LuckyRobotsGameState.h"
|
||||
|
@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "LuckyRobotsPlayerController.h"
|
||||
|
204
Source/Luckyrobots/Private/MainScreenUserWidget.cpp
Normal file
204
Source/Luckyrobots/Private/MainScreenUserWidget.cpp
Normal file
@ -0,0 +1,204 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "MainScreenUserWidget.h"
|
||||
#include "Engine/DataTable.h"
|
||||
#include "LuckyRobotsGameInstance.h"
|
||||
|
||||
void UMainScreenUserWidget::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
InitData();
|
||||
}
|
||||
|
||||
void UMainScreenUserWidget::InitData()
|
||||
{
|
||||
InitRobotData();
|
||||
InitLevelData();
|
||||
|
||||
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (LuckyRobotsGameInstance)
|
||||
{
|
||||
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()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
void UMainScreenUserWidget::InitLevelData()
|
||||
{
|
||||
FRobotData CurrentRobotData = GetCurrentRobotData();
|
||||
if (CurrentRobotData.Name != ERobotsName::None)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iCurrentSelectLevel = 0;
|
||||
UpdateSelectLevel();
|
||||
}
|
||||
|
||||
FRobotData UMainScreenUserWidget::GetCurrentRobotData()
|
||||
{
|
||||
FRobotData CurrentRobotData;
|
||||
if (RobotDataList.IsValidIndex(iCurrentSelectRobot))
|
||||
{
|
||||
CurrentRobotData = RobotDataList[iCurrentSelectRobot];
|
||||
}
|
||||
return CurrentRobotData;
|
||||
}
|
||||
|
||||
FLevelData UMainScreenUserWidget::GetCurrentLevelData()
|
||||
{
|
||||
FLevelData CurrentLevelData;
|
||||
if (LevelDataList.IsValidIndex(iCurrentSelectLevel))
|
||||
{
|
||||
CurrentLevelData = LevelDataList[iCurrentSelectLevel];
|
||||
}
|
||||
return CurrentLevelData;
|
||||
}
|
||||
|
||||
void UMainScreenUserWidget::SelectNextRobot()
|
||||
{
|
||||
iCurrentSelectRobot = FMath::Clamp(iCurrentSelectRobot + 1, 0, RobotDataList.Num() - 1);
|
||||
UpdateSelectRobot();
|
||||
}
|
||||
|
||||
void UMainScreenUserWidget::SelectPreviousRobot()
|
||||
{
|
||||
iCurrentSelectRobot = FMath::Clamp(iCurrentSelectRobot - 1, 0, RobotDataList.Num() - 1);
|
||||
UpdateSelectRobot();
|
||||
}
|
||||
|
||||
void UMainScreenUserWidget::SelectNextLevel()
|
||||
{
|
||||
iCurrentSelectLevel = FMath::Clamp(iCurrentSelectLevel + 1, 0, LevelDataList.Num() - 1);
|
||||
UpdateSelectLevel();
|
||||
}
|
||||
|
||||
void UMainScreenUserWidget::SelectPreviousLevel()
|
||||
{
|
||||
iCurrentSelectLevel = FMath::Clamp(iCurrentSelectLevel - 1, 0, LevelDataList.Num() - 1);
|
||||
UpdateSelectLevel();
|
||||
}
|
||||
|
||||
void UMainScreenUserWidget::SelectNextQuality()
|
||||
{
|
||||
UEnum* QualityEnum = StaticEnum<EQualityEnum>();
|
||||
int QualityEnumNum = QualityEnum->NumEnums() - 1;
|
||||
iCurrentSelectQuality = FMath::Clamp(iCurrentSelectQuality + 1, 0, QualityEnumNum - 1);
|
||||
|
||||
UpdateSelectQuality();
|
||||
}
|
||||
|
||||
void UMainScreenUserWidget::SelectPreviousQuality()
|
||||
{
|
||||
UEnum* QualityEnum = StaticEnum<EQualityEnum>();
|
||||
int QualityEnumNum = QualityEnum->NumEnums() - 1;
|
||||
iCurrentSelectQuality = FMath::Clamp(iCurrentSelectQuality - 1, 0, QualityEnumNum - 1);
|
||||
|
||||
UpdateSelectQuality();
|
||||
}
|
||||
|
||||
void UMainScreenUserWidget::UpdateSelectRobot()
|
||||
{
|
||||
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (LuckyRobotsGameInstance)
|
||||
{
|
||||
LuckyRobotsGameInstance->CurrentSelectRobot = GetCurrentRobotData().Name;
|
||||
}
|
||||
BPUpdateSelectRobot();
|
||||
InitLevelData();
|
||||
}
|
||||
void UMainScreenUserWidget::UpdateSelectLevel()
|
||||
{
|
||||
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (LuckyRobotsGameInstance)
|
||||
{
|
||||
LuckyRobotsGameInstance->CurrentSelectLevel = GetCurrentLevelData().LevelEnum;
|
||||
}
|
||||
BPUpdateSelectLevel();
|
||||
}
|
||||
|
||||
void UMainScreenUserWidget::UpdateSelectQuality()
|
||||
{
|
||||
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (LuckyRobotsGameInstance)
|
||||
{
|
||||
UEnum* QualityEnum = StaticEnum<EQualityEnum>();
|
||||
LuckyRobotsGameInstance->CurrentSelectQuality = EQualityEnum(QualityEnum->GetValueByIndex(iCurrentSelectQuality));
|
||||
}
|
||||
BPUpdateSelectQuality();
|
||||
}
|
Reference in New Issue
Block a user