完成基本代码迁移重构

This commit is contained in:
Bob.Song
2026-03-10 16:34:31 +08:00
parent cf2e374998
commit d17d13d7e7
11 changed files with 187 additions and 194 deletions

View File

@@ -2,13 +2,14 @@
using Fantasy;
using Fantasy.Entitas;
using NBF.Utils;
using UnityEngine;
namespace NBF
{
/// <summary>
/// 玩家物品
/// </summary>
public abstract class PlayerItem : Entity
public class PlayerItem : Entity
{
public Player Owner;
@@ -17,11 +18,47 @@ namespace NBF
/// </summary>
public int ConfigID;
public List<int> BindItems = new List<int>();
public virtual void Init(Player player, ItemInfo bindInfo)
#region Rod专属
/// <summary>
/// 线长度
/// </summary>
public float LineLength = 1.5f;
/// <summary>
/// 浮漂线长度
/// </summary>
public float FloatLength = 0.5f;
private float _tension;
/// <summary>
/// 拉力
/// </summary>
public float Tension
{
get => _tension;
private set
{
if (!Mathf.Approximately(_tension, value))
{
_tension = value;
// OnTensionChanged?.Invoke(_tension);
}
}
}
#endregion
public void Init(Player player, int configId, List<int> bindItems)
{
Owner = player;
ConfigID = bindInfo.ConfigId;
ConfigID = configId;
BindItems.Clear();
BindItems.AddRange(bindItems);
// var itemType = bindInfo.Item.GetItemType();
// if (itemType == ItemType.Rod)
// {

View File

@@ -1,15 +0,0 @@
using System.Collections.Generic;
using Fantasy;
using Fantasy.Entitas;
namespace NBF
{
public class PlayerItemRod : PlayerItem
{
public override void Init(Player player, ItemInfo bindInfo)
{
//var binds = RoleModel.Instance.GetBindItems(item.Id);
base.Init(player, bindInfo);
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 9e0846296bef4505868010bfe1eee1e3
timeCreated: 1773124278

View File

@@ -103,18 +103,13 @@ namespace NBF
ItemChangeEvent(prevItem);
}
public void UseItem(ItemInfo item)
public void UseItem(int configId, List<int> bindItems)
{
var prevItem = HandItem;
var itemType = item.ConfigId.GetItemType();
if (itemType == ItemType.Rod)
{
var playerItemRod = Create<PlayerItemRod>(Scene);
playerItemRod.Init(this, item);
Items[playerItemRod.Id] = playerItemRod;
HandItemId = playerItemRod.Id;
}
var playerItemRod = Create<PlayerItem>(Scene);
playerItemRod.Init(this, configId, bindItems);
Items[playerItemRod.Id] = playerItemRod;
HandItemId = playerItemRod.Id;
ItemChangeEvent(prevItem);
}