Rework game over logic and game initialization
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
@@ -6,11 +7,16 @@ using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public partial class ItemDatabase : Node
|
||||
public class ItemDatabase
|
||||
{
|
||||
private static readonly Lazy<ItemDatabase> lazy =
|
||||
new Lazy<ItemDatabase>(() => new ItemDatabase());
|
||||
|
||||
public static ItemDatabase Instance { get { return lazy.Value; } }
|
||||
|
||||
public ImmutableList<InventoryItem> Items { get; set; }
|
||||
|
||||
public InventoryItem PickItem<T>(T itemToExclude = null)
|
||||
public T PickItem<T>(T itemToExclude = null)
|
||||
where T : InventoryItem
|
||||
{
|
||||
var rng = new RandomNumberGenerator();
|
||||
@@ -27,10 +33,10 @@ public partial class ItemDatabase : Node
|
||||
if (selectedItem is ThrowableItem throwableItem)
|
||||
throwableItem.SetCount(rng.RandiRange(throwableItem.Stats.MinimumCount, throwableItem.Stats.MaximumCount));
|
||||
|
||||
return selectedItem;
|
||||
return (T)selectedItem;
|
||||
}
|
||||
|
||||
public ItemDatabase()
|
||||
private ItemDatabase()
|
||||
{
|
||||
var database = new List<InventoryItem>();
|
||||
var armorResources = DirAccess.GetFilesAt("res://src/items/armor/resources/");
|
||||
|
||||
Reference in New Issue
Block a user