Skip to content
4 changes: 2 additions & 2 deletions Fracture.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33829.357
# Visual Studio Version 18
VisualStudioVersion = 18.5.11716.220
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fracture.Server", "Server\Fracture.Server.csproj", "{D06D3FCB-F773-4E5E-A6D3-6C6D052F7996}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion Server/Components/Pages/GamePage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
</div>
<div class="settingsBtn">
<div class="settingsBtn-content">
<img src="assets/icons/hourglassbutton.svg" />
<img @onclick="() => _popup.ShowComponent<TestPopup>()" src="assets/icons/hourglassbutton.svg" />
</div>
</div>
<div class="settingsBtn">
Expand Down
34 changes: 33 additions & 1 deletion Server/Components/Pages/GamePage.razor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Fracture.Server.Components.Popups;
using Fracture.Server.Components.UI;
using Fracture.Server.Modules.Items.Models;
using Fracture.Server.Modules.MapGenerator.Models.Map;
using Fracture.Server.Modules.MapGenerator.UI.Models;
using Fracture.Server.Modules.Pathfinding.Models;
Expand Down Expand Up @@ -29,7 +31,7 @@ protected override async Task OnInitializedAsync()

if (MovementService.CurrentMap is null)
{
MovementService.Initialize();
await MovementService.InitializeAsync();
BackgroundImage = GetBackgroundImagePath();
}

Expand All @@ -45,6 +47,36 @@ protected override async Task OnInitializedAsync()
StateHasChanged();
};

MovementService.OnItemPickupRequested += async (sender, item) =>
{
var parameters = new Dictionary<string, object>
{
{ "Item", item },
{
"OnConfirm",
(Func<Task>)(
async () =>
{
await MovementService.ConfirmPickupAsync();
_popup.Hide();
}
)
},
{
"OnCancel",
(Func<Task>)(
async () =>
{
await MovementService.CancelPickupAsync();
_popup.Hide();
}
)
},
};

_popup.ShowComponent<ItemPickupRequest>(parameters);
};

_mapDisplayOptions.ShowColorMap = true;
_mapPopupParameters = new Dictionary<string, object>
{
Expand Down
36 changes: 36 additions & 0 deletions Server/Components/Popups/ItemPickupRequest.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@using Fracture.Server.Modules.Items.Models
@using Fracture.Server.Components.UI

<div class="item-popup">
<h3>You found a new item, Do you want to pick it up?</h3>
<div class="item-title">
<strong>@Item.Name</strong> (@Item.Type) - @Item.Rarity
</div>

<div class="item-stats">
<ItemStats Item="@Item"></ItemStats>
</div>

<div class="popup-actions">
<button @onclick="ConfirmAsync">Yes</button>
<button @onclick="CancelAsync">No</button>
</div>
</div>

@code {
[Parameter] public Item Item { get; set; } = null!;
[Parameter] public Func<Task>? OnConfirm { get; set; }
[Parameter] public Func<Task>? OnCancel { get; set; }

private async Task ConfirmAsync()
{
if (OnConfirm is not null)
await OnConfirm();
}

private async Task CancelAsync()
{
if (OnCancel is not null)
await OnCancel();
}
}
5 changes: 5 additions & 0 deletions Server/Components/Popups/TestPopup.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h3>You got a new item, check it out!</h3>

@code {

}
11 changes: 8 additions & 3 deletions Server/Components/UI/PopupContainer.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
@using Fracture.Server.Components.Pages
@rendermode InteractiveServer


<div class="popup @(IsVisible ? "" : "hidden")">
@if (_componentType is not null)
{
<DynamicComponent Type="@_componentType" Parameters="@_parameters" @ref="Component" />
}
<div>
<button class="closeBtn" @onclick="() => IsVisible = false"><img src="assets/icons/closebutton.svg" /></button>
<button class="closeBtn" @onclick="Hide"><img src="assets/icons/closebutton.svg" /></button>
</div>
</div>

Expand All @@ -25,9 +24,15 @@
StateHasChanged();
}

public void Hide()
{
IsVisible = false;
_componentType = null;
_parameters = null;
StateHasChanged();
}

public DynamicComponent? Component = null;
private Type? _componentType = null;
private IDictionary<string, object>? _parameters;

}
180 changes: 180 additions & 0 deletions Server/Migrations/FractureDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
// <auto-generated />
using System;
using Fracture.Server.Modules.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

#nullable disable

namespace Fracture.Server.Migrations
{
[DbContext(typeof(FractureDbContext))]
partial class FractureDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.5");

modelBuilder.Entity("Fracture.Server.Modules.Items.Models.Item", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");

b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");

b.Property<int?>("CreatedById")
.HasColumnType("INTEGER");

b.Property<string>("History")
.HasColumnType("TEXT");

b.Property<bool>("IsEquipped")
.HasColumnType("INTEGER");

b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");

b.Property<int>("Rarity")
.HasColumnType("INTEGER");

b.Property<int>("Type")
.HasColumnType("INTEGER");

b.HasKey("Id");

b.HasIndex("CreatedById");

b.ToTable("Items");
});

modelBuilder.Entity("Fracture.Server.Modules.Items.Models.ItemDropped", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");

b.Property<int?>("ItemId")
.HasColumnType("INTEGER");

b.Property<int>("MapSeed")
.HasColumnType("INTEGER");

b.Property<int>("UserId")
.HasColumnType("INTEGER");

b.Property<int>("X")
.HasColumnType("INTEGER");

b.Property<int>("Y")
.HasColumnType("INTEGER");

b.HasKey("Id");

b.HasIndex("ItemId");

b.HasIndex("UserId", "MapSeed", "X", "Y")
.IsUnique();

b.ToTable("ItemsDropped", (string)null);
});

modelBuilder.Entity("Fracture.Server.Modules.Items.Models.ItemStatistics", b =>
{
b.Property<int>("ItemId")
.HasColumnType("INTEGER");

b.Property<int>("Armor")
.HasColumnType("INTEGER");

b.Property<int>("Health")
.HasColumnType("INTEGER");

b.Property<int>("Luck")
.HasColumnType("INTEGER");

b.Property<int>("Power")
.HasColumnType("INTEGER");

b.HasKey("ItemId");

b.ToTable("ItemStatistics");
});

modelBuilder.Entity("Fracture.Server.Modules.Users.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");

b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");

b.Property<string>("Username")
.IsRequired()
.HasColumnType("TEXT");

b.HasKey("Id");

b.ToTable("Users");
});

modelBuilder.Entity("Fracture.Server.Modules.Items.Models.Item", b =>
{
b.HasOne("Fracture.Server.Modules.Users.Models.User", "CreatedBy")
.WithMany("Items")
.HasForeignKey("CreatedById");

b.Navigation("CreatedBy");
});

modelBuilder.Entity("Fracture.Server.Modules.Items.Models.ItemDropped", b =>
{
b.HasOne("Fracture.Server.Modules.Items.Models.Item", "Item")
.WithMany("DroppedItems")
.HasForeignKey("ItemId");

b.HasOne("Fracture.Server.Modules.Users.Models.User", "User")
.WithMany("ItemDrops")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("Item");

b.Navigation("User");
});

modelBuilder.Entity("Fracture.Server.Modules.Items.Models.ItemStatistics", b =>
{
b.HasOne("Fracture.Server.Modules.Items.Models.Item", "Item")
.WithOne("Statistics")
.HasForeignKey("Fracture.Server.Modules.Items.Models.ItemStatistics", "ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("Item");
});

modelBuilder.Entity("Fracture.Server.Modules.Items.Models.Item", b =>
{
b.Navigation("DroppedItems");

b.Navigation("Statistics")
.IsRequired();
});

modelBuilder.Entity("Fracture.Server.Modules.Users.Models.User", b =>
{
b.Navigation("ItemDrops");

b.Navigation("Items");
});
#pragma warning restore 612, 618
}
}
}
Loading
Loading