mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 07:37:12 +08:00
(client) feat:添加基地界面到游玩界面的过程,添加存档管理,技能树变得可用 (#58)
Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com> Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/58
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using Configs;
|
||||
using Data;
|
||||
using Item;
|
||||
using Managers;
|
||||
using UnityEngine;
|
||||
// 添加 System 命名空间以使用 Action
|
||||
|
||||
@@ -36,23 +39,34 @@ namespace Entity
|
||||
get => _currentSelected;
|
||||
set
|
||||
{
|
||||
var maxIndex = Inventory != null && Inventory.Capacity > 0 ? Inventory.Capacity - 1 : 0;
|
||||
var maxIndex = PlayerInventory != null && PlayerInventory.Capacity > 0 ? PlayerInventory.Capacity - 1 : 0;
|
||||
var clampedValue = Mathf.Clamp(value, 0, maxIndex);
|
||||
_currentSelected = clampedValue;
|
||||
InitWeaponAnimator();
|
||||
}
|
||||
}
|
||||
|
||||
public Inventory Inventory { get; private set; }
|
||||
public Inventory PlayerInventory { get; private set; }
|
||||
public InventorySlot Coin{get;private set;}
|
||||
|
||||
|
||||
public override void Init(EntityDef entityDef)
|
||||
public override void Init(EntityDef entityDefine)
|
||||
{
|
||||
Inventory = new Inventory(this, 3);
|
||||
Inventory.OnInventoryChanged += InventoryChange;
|
||||
PlayerInventory = new Inventory(this, 3);
|
||||
var coinItem = ItemResourceManager.Instance.GetItem(ConfigManager.Instance.GetValue<string>("CoinItem"));
|
||||
if(!KeyValueArchiveManager.Instance.HasKey("coinCount"))
|
||||
{
|
||||
KeyValueArchiveManager.Instance.Set("coinCount", 0);
|
||||
}
|
||||
|
||||
Coin = Program.Instance.OutsidePlayDimension == null
|
||||
? new InventorySlot(coinItem, Program.Instance.CoinCount)
|
||||
: new InventorySlot(coinItem, 0);
|
||||
|
||||
PlayerInventory.OnInventoryChanged += InventoryChange;
|
||||
CurrentSelected = 0;
|
||||
base.Init(entityDef);
|
||||
base.Init(entityDefine);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 尝试将指定物品添加到角色的背包中。
|
||||
@@ -67,21 +81,21 @@ namespace Entity
|
||||
/// </returns>
|
||||
public int TryPickupItem(ItemResource itemResource, int quantity)
|
||||
{
|
||||
if (Inventory == null)
|
||||
if (PlayerInventory == null)
|
||||
{
|
||||
Debug.LogError($"Character '{name}' inventory is not initialized. Cannot pickup item.");
|
||||
return quantity; // 如果背包未初始化,则视为未能添加任何物品
|
||||
}
|
||||
|
||||
|
||||
var remainingQuantity = Inventory.AddItem(itemResource, quantity);
|
||||
var remainingQuantity = PlayerInventory.AddItem(itemResource, quantity);
|
||||
|
||||
return remainingQuantity;
|
||||
}
|
||||
|
||||
public override WeaponResource GetCurrentWeapon()
|
||||
{
|
||||
var currentSelectItem = Inventory.GetSlot(CurrentSelected);
|
||||
var currentSelectItem = PlayerInventory.GetSlot(CurrentSelected);
|
||||
return currentSelectItem?.Item as WeaponResource;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user