diff --git a/.gitignore b/.gitignore index 715b38f..7b2784a 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ *.sdf *.VC.db *.VC.opendb +.vsconfig # Precompiled Assets SourceArt/**/*.png diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 5489156..aec5a8b 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -15,8 +15,8 @@ ManualIPAddress= [/Script/EngineSettings.GameMapsSettings] GlobalDefaultGameMode=/Game/Blueprint/Bp_BusyGameMode.Bp_BusyGameMode_C GameInstanceClass=/Script/BusyRabbit.BusyGameInstance -EditorStartupMap=/Game/Level/FalconPlain.FalconPlain -GameDefaultMap=/Game/Level/FalconPlain.FalconPlain +EditorStartupMap=/Game/Level/HomeLand.HomeLand +GameDefaultMap=/Game/Level/HomeLand.HomeLand [/Script/Engine.RendererSettings] r.Mobile.AntiAliasing=0 diff --git a/Content/Blueprint/Bp_HomelandGameMode.uasset b/Content/Blueprint/Bp_HomelandGameMode.uasset new file mode 100644 index 0000000..24e0ca4 Binary files /dev/null and b/Content/Blueprint/Bp_HomelandGameMode.uasset differ diff --git a/Content/Blueprint/HomeLand/Bp_HomeLandHud.uasset b/Content/Blueprint/HomeLand/Bp_HomeLandHud.uasset new file mode 100644 index 0000000..e047d3d Binary files /dev/null and b/Content/Blueprint/HomeLand/Bp_HomeLandHud.uasset differ diff --git a/Content/Blueprint/HomeLand/Bp_HomeLandPlayerController.uasset b/Content/Blueprint/HomeLand/Bp_HomeLandPlayerController.uasset new file mode 100644 index 0000000..63d9201 Binary files /dev/null and b/Content/Blueprint/HomeLand/Bp_HomeLandPlayerController.uasset differ diff --git a/Content/Blueprint/HomeLand/Bp_HomelandGameMode.uasset b/Content/Blueprint/HomeLand/Bp_HomelandGameMode.uasset new file mode 100644 index 0000000..4e8c733 Binary files /dev/null and b/Content/Blueprint/HomeLand/Bp_HomelandGameMode.uasset differ diff --git a/Content/Data/BusyGameAsset.uasset b/Content/Data/BusyGameAsset.uasset index 54c121d..e159280 100644 Binary files a/Content/Data/BusyGameAsset.uasset and b/Content/Data/BusyGameAsset.uasset differ diff --git a/Content/Level/HomeLand.umap b/Content/Level/HomeLand.umap index 993a2bc..3dd5a1c 100644 Binary files a/Content/Level/HomeLand.umap and b/Content/Level/HomeLand.umap differ diff --git a/Content/Lua/GamePlay/Level/BusyLevelLogicSubSystem.lua b/Content/Lua/GamePlay/Level/BusyLevelLogicSubSystem.lua index 4b4f455..64282bb 100644 --- a/Content/Lua/GamePlay/Level/BusyLevelLogicSubSystem.lua +++ b/Content/Lua/GamePlay/Level/BusyLevelLogicSubSystem.lua @@ -16,6 +16,10 @@ local function CreateItemGenerator(level_config_data) return Generator(period, item_data) end +function SubSystem:Bp_ShouldCreateSubsystem(world) + return false +end + function SubSystem:ReceiveSubSystemInitialize() local world = BusyGamePlayLibrary.K2_GetWorld(self) self.start_time = GameplayStatics.GetTimeSeconds(world) diff --git a/Content/Lua/GamePlay/LevelItem/LevelItem.lua b/Content/Lua/GamePlay/LevelItem/LevelItem.lua index e2c6cf7..ed39fe0 100644 --- a/Content/Lua/GamePlay/LevelItem/LevelItem.lua +++ b/Content/Lua/GamePlay/LevelItem/LevelItem.lua @@ -5,26 +5,15 @@ local RoleUtils = require("GamePlay.Utils.RoleUtils") local GameplayUtils = require("GamePlay.Utils") local KismetSystemLibrary = import("KismetSystemLibrary") ---[[ - -Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_0" ExportPath="/Script/BlueprintGraph.K2Node_CallFunction'/Game/Blueprint/Bp_BusyCharacter.Bp_BusyCharacter:EventGraph.K2Node_CallFunction_0'" - bIsPureFunc=True - FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/Engine.KismetSystemLibrary'",MemberName="IsValid") - NodePosX=416 - NodePosY=576 - NodeGuid=FAEC35AE4921EA704624228C12C6567F - CustomProperties Pin (PinId=560B26AF426C21B8AC88EDB90990EDF1,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nKismet System Library Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.KismetSystemLibrary'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultObject="/Script/Engine.Default__KismetSystemLibrary",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) - CustomProperties Pin (PinId=5F3C3BC8429FA25D9B78099F2107C098,PinName="Object",PinToolTip="Object\nObject Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/CoreUObject.Object'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=True,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) - CustomProperties Pin (PinId=5C7188354FCB6B61DE0AC8A14D6E3EEC,PinName="ReturnValue",PinToolTip="Return Value\nBoolean\n\nReturn true if the object is usable : non-null and not pending kill",Direction="EGPD_Output",PinType.PinCategory="bool",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="false",AutogeneratedDefaultValue="false",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) -End Object - - -]] - function LevelItem:ReceiveBeginPlay() - self.Super:ReceiveBeginPlay() self:SetLevelItemID(self.CurrentItemID) self.world = self:GetWorld() + print("LevelItem:ReceiveBeginPlay") +end + + +function LevelItem:TempSetting() + self:ReceiveBeginPlay() end function LevelItem:ReceiveLevelItemSetted(Config) @@ -46,17 +35,6 @@ function LevelItem:ReceiveLevelItemSetted(Config) end) end --- function LevelItem:ReceiveDamage(value) --- local remain = self.proxy.RemainProcess - value --- if remain > 0 then --- self.proxy.RemainProcess = remain --- return true --- else --- self.proxy.RemainProcess = 0 --- self:SetLifeSpan(0.3) --- return false --- end --- end function LevelItem:GenerateDropItems() local BusyActorManagerSubSystem = import("BusyActorManagerSubSystem").Get(self.world) diff --git a/Content/Lua/HomeLand/UI/HomeLandMainUI.lua b/Content/Lua/HomeLand/UI/HomeLandMainUI.lua new file mode 100644 index 0000000..c53f604 --- /dev/null +++ b/Content/Lua/HomeLand/UI/HomeLandMainUI.lua @@ -0,0 +1,11 @@ +local GameplayStatics = import("GameplayStatics") +local HomeLandMainUI = {} + +function HomeLandMainUI:Construct() + self.Gateway.OnClicked:Add(function() + GameplayStatics.OpenLevel(self, "FalconPlain", false, "") + end) + +end + +return Class(nil, nil, HomeLandMainUI) \ No newline at end of file diff --git a/Content/Lua/UI/UIHud/HomeLandHud.lua b/Content/Lua/UI/UIHud/HomeLandHud.lua new file mode 100644 index 0000000..4b48add --- /dev/null +++ b/Content/Lua/UI/UIHud/HomeLandHud.lua @@ -0,0 +1,7 @@ +local HomeLandHud = {} + +function HomeLandHud:ReceiveBeginPlay() + self:PushWidget("HomeLandMain") +end + +return Class(nil, nil, HomeLandHud) \ No newline at end of file diff --git a/Content/Resource/Map/LakeTest/lake1.uasset b/Content/Resource/Map/LakeTest/lake1.uasset deleted file mode 100644 index 45e8065..0000000 Binary files a/Content/Resource/Map/LakeTest/lake1.uasset and /dev/null differ diff --git a/Content/Resource/Map/LakeTest/lake1_TileMap.uasset b/Content/Resource/Map/LakeTest/lake1_TileMap.uasset deleted file mode 100644 index f936d64..0000000 Binary files a/Content/Resource/Map/LakeTest/lake1_TileMap.uasset and /dev/null differ diff --git a/Content/Resource/Map/LakeTest/lake1_TileSet.uasset b/Content/Resource/Map/LakeTest/lake1_TileSet.uasset deleted file mode 100644 index eb95e08..0000000 Binary files a/Content/Resource/Map/LakeTest/lake1_TileSet.uasset and /dev/null differ diff --git a/Content/UI/HomeLand/WBP_HomeLandMain.uasset b/Content/UI/HomeLand/WBP_HomeLandMain.uasset new file mode 100644 index 0000000..ba0a0f2 Binary files /dev/null and b/Content/UI/HomeLand/WBP_HomeLandMain.uasset differ diff --git a/Content/UI/WBP_UILayer.uasset b/Content/UI/WBP_UILayer.uasset index a959e53..deccf18 100644 Binary files a/Content/UI/WBP_UILayer.uasset and b/Content/UI/WBP_UILayer.uasset differ diff --git a/Source/BusyRabbit/Private/BusyLevelLogicSubSystem.cpp b/Source/BusyRabbit/Private/BusyLevelLogicSubSystem.cpp index 905c383..cc93a82 100644 --- a/Source/BusyRabbit/Private/BusyLevelLogicSubSystem.cpp +++ b/Source/BusyRabbit/Private/BusyLevelLogicSubSystem.cpp @@ -2,6 +2,7 @@ #include "BusyLevelLogicSubSystem.h" +#include "Kismet/GameplayStatics.h" UBusyLevelLogicSubSystem::UBusyLevelLogicSubSystem(){ @@ -12,6 +13,14 @@ void UBusyLevelLogicSubSystem::Initialize(FSubsystemCollectionBase& Collection){ ReceiveSubSystemInitialize(); } +bool UBusyLevelLogicSubSystem::ShouldCreateSubsystem(UObject* Outer) const{ + if (!Super::ShouldCreateSubsystem(Outer)) { + return false; + } + auto s = UGameplayStatics::GetCurrentLevelName(Outer); + return UGameplayStatics::GetCurrentLevelName(Outer) != "HomeLand"; +} + void UBusyLevelLogicSubSystem::Tick(float DeltaTime){ Super::Tick(DeltaTime); ReceiveSubSystemTick(DeltaTime); diff --git a/Source/BusyRabbit/Private/Core/UI/PW_UIHud.cpp b/Source/BusyRabbit/Private/Core/UI/PW_UIHud.cpp new file mode 100644 index 0000000..392ad73 --- /dev/null +++ b/Source/BusyRabbit/Private/Core/UI/PW_UIHud.cpp @@ -0,0 +1,37 @@ +#include "Core/UI/PW_UIHud.h" +#include "Core/PW_UserWidget.h" +#include "Core/UI/PW_UILayer.h" + +FString APW_UIHud::GetLuaFilePath_Implementation() const { + return LuaFilePath; +} + +void APW_UIHud::BeginPlay() { + ensureMsgf(LayerClass, TEXT("LayerClass not be nullptr")); + if ((UILayer = CreateWidget(GetWorld(), LayerClass))) { + UILayer->AddToViewport(); + } + Super::BeginPlay(); +} + +UPW_UserWidget* APW_UIHud::PushWidget(const FName& WidgetName) { + if (UILayer == nullptr) { + return nullptr; + } + TSubclassOf* WidgetClass = UIClassMapping.Find(WidgetName); + if (WidgetClass == nullptr) { + return nullptr; + } + UPW_UserWidget* Inst = CreateWidget(GetWorld(), WidgetClass->Get()); + if (Inst == nullptr) { + return nullptr; + } + + if (UILayer->PushWidget(WidgetName, Inst)) { + return Inst; + } + else { + return nullptr; + } +} + diff --git a/Source/BusyRabbit/Private/Core/UI/PW_UILayer.cpp b/Source/BusyRabbit/Private/Core/UI/PW_UILayer.cpp new file mode 100644 index 0000000..d985df4 --- /dev/null +++ b/Source/BusyRabbit/Private/Core/UI/PW_UILayer.cpp @@ -0,0 +1,53 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Core/UI/PW_UILayer.h" +#include "Core/PW_UserWidget.h" +#include "Components/Overlay.h" +#include "Components/OverlaySlot.h" + + + +bool UPW_UILayer::ShowWidget(const FName& WidgetName){ + UPW_UserWidget* Widget = *WidgetPool.Find(WidgetName); + if (Widget == nullptr) { + return false; + } + Widget->SetVisible(true); + return true; +} + +bool UPW_UILayer::HideWidget(const FName& WidgetName){ + UPW_UserWidget* Widget = *WidgetPool.Find(WidgetName); + if (Widget == nullptr) { + return false; + } + Widget->SetVisible(false); + return true; +} + +bool UPW_UILayer::PushWidget(const FName& WidgetName, UPW_UserWidget* WidgetInst){ + UOverlay* Overlay; + UOverlaySlot* OverlaySlot; + switch (WidgetInst->LayoutType) { + case EWidgetLayoutType::MainLayer: Overlay = MainLayer; break; + case EWidgetLayoutType::PopupLayer: Overlay = PopupLayer; break; + case EWidgetLayoutType::FloatLayer: Overlay = FloatLayer; break; + case EWidgetLayoutType::TopLayer: Overlay = TopLayer; break; + default: return false; + } + Overlay->AddChild(WidgetInst); + if ((OverlaySlot = Cast(WidgetInst->Slot))) { + OverlaySlot->SetVerticalAlignment(EVerticalAlignment::VAlign_Fill); + OverlaySlot->SetHorizontalAlignment(EHorizontalAlignment::HAlign_Fill); + WidgetInst->SetVisible(true); + WidgetPool.Add(WidgetName, WidgetInst); + return true; + } else { + return false; + } +} + +bool UPW_UILayer::PopWidget(const FName& WidgetName){ + return true; +} diff --git a/Source/BusyRabbit/Private/Hud/BusyGameHud.cpp b/Source/BusyRabbit/Private/Hud/BusyGameHud.cpp index 6c898a6..f79143e 100644 --- a/Source/BusyRabbit/Private/Hud/BusyGameHud.cpp +++ b/Source/BusyRabbit/Private/Hud/BusyGameHud.cpp @@ -3,12 +3,8 @@ #include "Hud/BusyGameHud.h" + + FString ABusyGameHud::GetLuaFilePath_Implementation() const{ return LuaFilePath; -} - -//void ABusyGameHud::PushWidget(const FName& WidgetName){ -// auto WidgetClass = UIClassMapping.Find(WidgetName); -// APlayerController* PC = GetOwningPlayerController(); -// CreateWidget(); -//} +} \ No newline at end of file diff --git a/Source/BusyRabbit/Private/Level/BusyLevelItem.cpp b/Source/BusyRabbit/Private/Level/BusyLevelItem.cpp index 0372a5a..3968292 100644 --- a/Source/BusyRabbit/Private/Level/BusyLevelItem.cpp +++ b/Source/BusyRabbit/Private/Level/BusyLevelItem.cpp @@ -39,6 +39,18 @@ void ABusyLevelItem::BeginPlay(){ PickBar->SetWidgetClass(cls); } Super::BeginPlay(); + bIsBeginPlay = true; +} + +void ABusyLevelItem::EndPlay(const EEndPlayReason::Type EndPlayReason){ + Super::EndPlay(EndPlayReason); + bIsBeginPlay = false; +} + +void ABusyLevelItem::PostLuaHook(){ + if (bIsBeginPlay) { + CallLuaFunctionIfExist("TempSetting"); + } } void ABusyLevelItem::InitCapsule(){ diff --git a/Source/BusyRabbit/Public/BusyLevelLogicSubSystem.h b/Source/BusyRabbit/Public/BusyLevelLogicSubSystem.h index 2be18d1..5a85d5a 100644 --- a/Source/BusyRabbit/Public/BusyLevelLogicSubSystem.h +++ b/Source/BusyRabbit/Public/BusyLevelLogicSubSystem.h @@ -23,6 +23,9 @@ public: public: virtual void Initialize(FSubsystemCollectionBase& Collection) override; + virtual bool ShouldCreateSubsystem(UObject* Outer) const override; + + virtual void Tick(float DeltaTime) override; virtual FString GetLuaFilePath_Implementation() const override; @@ -47,5 +50,4 @@ public: // UFUNCTION(BlueprintImplementableEvent) void ReceiveSubSystemTick(float DeltaTime); - }; diff --git a/Source/BusyRabbit/Public/BusyRabbit.lnk b/Source/BusyRabbit/Public/BusyRabbit.lnk new file mode 100644 index 0000000..16c8e3c Binary files /dev/null and b/Source/BusyRabbit/Public/BusyRabbit.lnk differ diff --git a/Source/BusyRabbit/Public/Core/UI/PW_UIHud.h b/Source/BusyRabbit/Public/Core/UI/PW_UIHud.h new file mode 100644 index 0000000..ac4eaec --- /dev/null +++ b/Source/BusyRabbit/Public/Core/UI/PW_UIHud.h @@ -0,0 +1,34 @@ +#include "CoreMinimal.h" +#include "GameFramework/HUD.h" +#include "LuaOverriderInterface.h" +#include "PW_UIHud.generated.h" + +class UPW_UILayer; +class UPW_UserWidget; + +UCLASS() +class BUSYRABBIT_API APW_UIHud : public AHUD, public ILuaOverriderInterface { + GENERATED_BODY() + + virtual FString GetLuaFilePath_Implementation() const override; + + virtual void BeginPlay()override; + +public: + UFUNCTION(BlueprintCallable) + UPW_UserWidget* PushWidget(const FName& WidgetName); + +public: + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + FString LuaFilePath; + + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + TSubclassOf LayerClass; + + + UPROPERTY(EditAnywhere, Category = "UI Class Mapping") + TMap> UIClassMapping; + +protected: + TObjectPtr UILayer; +}; diff --git a/Source/BusyRabbit/Public/Core/UI/PW_UILayer.h b/Source/BusyRabbit/Public/Core/UI/PW_UILayer.h new file mode 100644 index 0000000..12fd8d4 --- /dev/null +++ b/Source/BusyRabbit/Public/Core/UI/PW_UILayer.h @@ -0,0 +1,48 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Core/PW_UserWidget.h" +#include "PW_UILayer.generated.h" + +class UOverlay; + +/** + * + */ +UCLASS() +class BUSYRABBIT_API UPW_UILayer : public UPW_UserWidget +{ + GENERATED_BODY() + +public: + UFUNCTION(BlueprintCallable) + bool ShowWidget(const FName& WidgetName); + + UFUNCTION(BlueprintCallable) + bool HideWidget(const FName& WidgetName); + + UFUNCTION(BlueprintCallable) + bool PushWidget(const FName& WidgetName, UPW_UserWidget* WidgetInst); + + UFUNCTION(BlueprintCallable) + bool PopWidget(const FName& WidgetName); + + +protected: + UPROPERTY(BlueprintReadOnly, meta = (BindWidget)) + TObjectPtr MainLayer; + + UPROPERTY(BlueprintReadOnly, meta = (BindWidget)) + TObjectPtr PopupLayer; + + UPROPERTY(BlueprintReadOnly, meta = (BindWidget)) + TObjectPtr FloatLayer; + + UPROPERTY(BlueprintReadOnly, meta = (BindWidget)) + TObjectPtr TopLayer; + +protected: + TMap WidgetPool; +}; diff --git a/Source/BusyRabbit/Public/Gas/BusyAttributeSet.h b/Source/BusyRabbit/Public/Gas/BusyAttributeSet.h index a11c031..7c673ed 100644 --- a/Source/BusyRabbit/Public/Gas/BusyAttributeSet.h +++ b/Source/BusyRabbit/Public/Gas/BusyAttributeSet.h @@ -29,6 +29,7 @@ public: virtual void PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue)override; public: + UPROPERTY(BlueprintReadWrite) FPW_OnAttributeChanged OnAttributeChanged; protected: diff --git a/Source/BusyRabbit/Public/Hud/BusyGameHud.h b/Source/BusyRabbit/Public/Hud/BusyGameHud.h index 839f210..7437d30 100644 --- a/Source/BusyRabbit/Public/Hud/BusyGameHud.h +++ b/Source/BusyRabbit/Public/Hud/BusyGameHud.h @@ -15,11 +15,6 @@ class BUSYRABBIT_API ABusyGameHud : public AHUD, public ILuaOverriderInterface{ GENERATED_BODY() virtual FString GetLuaFilePath_Implementation() const override; - -public: - //UFUNCTION(BlueprintCallable) - //void PushWidget(const FName& WidgetName); - public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) FString LuaFilePath; diff --git a/Source/BusyRabbit/Public/Level/BusyLevelItem.h b/Source/BusyRabbit/Public/Level/BusyLevelItem.h index 4b4fb40..461b262 100644 --- a/Source/BusyRabbit/Public/Level/BusyLevelItem.h +++ b/Source/BusyRabbit/Public/Level/BusyLevelItem.h @@ -63,6 +63,10 @@ public: virtual void BeginPlay() override; + virtual void EndPlay(const EEndPlayReason::Type EndPlayReason)override; + + virtual void PostLuaHook() override; + protected: void InitCapsule(); void InitSprite(); @@ -102,6 +106,9 @@ protected: UPROPERTY() TObjectPtr LevelItemAttribute; +protected: + bool bIsBeginPlay; + public: // 需要蓝图实现的函数 // LevelItem被设置时的回调 UFUNCTION(BlueprintImplementableEvent)