更新添加对战结束后,返回对战前的场景
This commit is contained in:
parent
828ced50ab
commit
17e1f726e2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -4,6 +4,7 @@
|
|||||||
#include "Engine/Engine.h"
|
#include "Engine/Engine.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
#include "ProjectFish/DataAsset/MapConfigAsset.h"
|
#include "ProjectFish/DataAsset/MapConfigAsset.h"
|
||||||
|
#include "ProjectFish/Utils/FishFunctionLibrary.h"
|
||||||
|
|
||||||
UFishingMapNode::UFishingMapNode()
|
UFishingMapNode::UFishingMapNode()
|
||||||
{
|
{
|
||||||
@ -104,13 +105,22 @@ void UFishingMapSubSystem::MoveToNode(FGuid NodeID)
|
|||||||
case EMapNodeType::Battle:
|
case EMapNodeType::Battle:
|
||||||
{
|
{
|
||||||
FString enemyConfigPath = MapConfig->FishConfigAssets[FMath::RandRange(0, MapConfig->FishConfigAssets.Num() - 1)].GetAssetPathString();
|
FString enemyConfigPath = MapConfig->FishConfigAssets[FMath::RandRange(0, MapConfig->FishConfigAssets.Num() - 1)].GetAssetPathString();
|
||||||
UGameplayStatics::OpenLevel(this, MapConfig->BattleMapName, true, "enemyConfig=" + enemyConfigPath);
|
TMap<FString, FString> Options;
|
||||||
|
Options.Add("enemyConfig", enemyConfigPath); //添加敌人的配置
|
||||||
|
Options.Add("fromMap", TEXT("MapSystemTest")); //添加战斗结束后的地图
|
||||||
|
UFishFunctionLibrary::OpenLevelWithOptions(this, MapConfig->BattleMapName, Options);
|
||||||
|
//UGameplayStatics::OpenLevel(this, MapConfig->BattleMapName, true, "enemyConfig=" + enemyConfigPath);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EMapNodeType::Boss:
|
case EMapNodeType::Boss:
|
||||||
{
|
{
|
||||||
FString bossConfigPath = MapConfig->BossConfigAsset.GetAssetPathString();
|
FString bossConfigPath = MapConfig->BossConfigAsset.GetAssetPathString();
|
||||||
UGameplayStatics::OpenLevel(this, MapConfig->BattleMapName, true, "enemyConfig=" + bossConfigPath);
|
TMap<FString, FString> Options;
|
||||||
|
Options.Add("enemyConfig", bossConfigPath); //添加敌人的配置
|
||||||
|
Options.Add("fromMap", TEXT("MapSystemTest")); //添加战斗结束后的地图
|
||||||
|
UFishFunctionLibrary::OpenLevelWithOptions(this, MapConfig->BattleMapName, Options);
|
||||||
|
//UGameplayStatics::OpenLevel(this, MapConfig->BattleMapName, true, "enemyConfig=" + bossConfigPath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
ProjectFish/Source/ProjectFish/Utils/FishFunctionLibrary.cpp
Normal file
16
ProjectFish/Source/ProjectFish/Utils/FishFunctionLibrary.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "FishFunctionLibrary.h"
|
||||||
|
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
|
void UFishFunctionLibrary::OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName, TMap<FString, FString> OptionsPaairs)
|
||||||
|
{
|
||||||
|
FString OptionStr = "";
|
||||||
|
for (auto optionPair: OptionsPaairs)
|
||||||
|
{
|
||||||
|
OptionStr += TEXT("?") + optionPair.Key + TEXT("=") + optionPair.Value;
|
||||||
|
}
|
||||||
|
UGameplayStatics::OpenLevel(WorldContextObject, LevelName, true,OptionStr);
|
||||||
|
}
|
||||||
20
ProjectFish/Source/ProjectFish/Utils/FishFunctionLibrary.h
Normal file
20
ProjectFish/Source/ProjectFish/Utils/FishFunctionLibrary.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||||
|
#include "Containers/Map.h"
|
||||||
|
#include "FishFunctionLibrary.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class PROJECTFISH_API UFishFunctionLibrary : public UBlueprintFunctionLibrary
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
public:
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject"))
|
||||||
|
static void OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName,TMap<FString, FString> OptionsPaairs);
|
||||||
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user