No backpack nesting backpack.
禁止背包嵌套背包。
This commit is contained in:
parent
d587c4fc01
commit
dea683dbc5
|
@ -20,7 +20,7 @@ public static class Config
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string Patrol = "Patrol";
|
public const string Patrol = "Patrol";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Loot table ID</para>
|
/// <para>Loot table ID</para>
|
||||||
/// <para>战利品表ID</para>
|
/// <para>战利品表ID</para>
|
||||||
|
@ -90,7 +90,7 @@ public static class Config
|
||||||
/// <para>抛出的物品击中敌人后减少的速度百分比</para>
|
/// <para>抛出的物品击中敌人后减少的速度百分比</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const float ThrownItemsHitEnemiesReduceSpeedByPercentage = 0.5f;
|
public const float ThrownItemsHitEnemiesReduceSpeedByPercentage = 0.5f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>How much blood does a heart represent</para>
|
/// <para>How much blood does a heart represent</para>
|
||||||
/// <para>一颗心代表多少血量</para>
|
/// <para>一颗心代表多少血量</para>
|
||||||
|
|
|
@ -25,6 +25,7 @@ public partial class BehaviorNode : Node2D
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Root.Execute(isPhysicsProcess, delta);
|
Root.Execute(isPhysicsProcess, delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
using ColdMint.scripts.character;
|
using ColdMint.scripts.character;
|
||||||
|
|
||||||
using WeaponTemplate = ColdMint.scripts.weapon.WeaponTemplate;
|
using WeaponTemplate = ColdMint.scripts.weapon.WeaponTemplate;
|
||||||
|
|
||||||
namespace ColdMint.scripts.behaviorTree.ai;
|
namespace ColdMint.scripts.behaviorTree.ai;
|
||||||
|
@ -10,8 +9,6 @@ namespace ColdMint.scripts.behaviorTree.ai;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AiPickNode : BehaviorTreeNodeTemplate
|
public class AiPickNode : BehaviorTreeNodeTemplate
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public AiCharacter? Character { get; set; }
|
public AiCharacter? Character { get; set; }
|
||||||
|
|
||||||
public override int Execute(bool isPhysicsProcess, double delta)
|
public override int Execute(bool isPhysicsProcess, double delta)
|
||||||
|
@ -51,7 +48,7 @@ public class AiPickNode : BehaviorTreeNodeTemplate
|
||||||
{
|
{
|
||||||
closestDistance = distanceLength;
|
closestDistance = distanceLength;
|
||||||
closestWeapon = weaponTemplate;
|
closestWeapon = weaponTemplate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//绘制一条线,从AI到武器
|
//绘制一条线,从AI到武器
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ColdMint.scripts.damage;
|
using ColdMint.scripts.damage;
|
||||||
using ColdMint.scripts.deathInfo;
|
using ColdMint.scripts.deathInfo;
|
||||||
|
using ColdMint.scripts.debug;
|
||||||
using ColdMint.scripts.inventory;
|
using ColdMint.scripts.inventory;
|
||||||
using ColdMint.scripts.map.events;
|
using ColdMint.scripts.map.events;
|
||||||
using ColdMint.scripts.utils;
|
using ColdMint.scripts.utils;
|
||||||
|
@ -49,6 +50,7 @@ public partial class Player : CharacterTemplate
|
||||||
{
|
{
|
||||||
base._Ready();
|
base._Ready();
|
||||||
CharacterName = TranslationServerUtils.Translate("default_player_name");
|
CharacterName = TranslationServerUtils.Translate("default_player_name");
|
||||||
|
LogCat.LogWithFormat("player_spawn_debug", ReadOnlyCharacterName, GlobalPosition);
|
||||||
_floatLabelPackedScene = GD.Load<PackedScene>("res://prefab/ui/FloatLabel.tscn");
|
_floatLabelPackedScene = GD.Load<PackedScene>("res://prefab/ui/FloatLabel.tscn");
|
||||||
_parabola = GetNode<Line2D>("Parabola");
|
_parabola = GetNode<Line2D>("Parabola");
|
||||||
_platformDetectionRayCast2D = GetNode<RayCast2D>("PlatformDetectionRayCast");
|
_platformDetectionRayCast2D = GetNode<RayCast2D>("PlatformDetectionRayCast");
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
using System;
|
|
||||||
using ColdMint.scripts.map.events;
|
|
||||||
using ColdMint.scripts.utils;
|
using ColdMint.scripts.utils;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
|
@ -13,18 +11,20 @@ public partial class HotBar : HBoxContainer
|
||||||
{
|
{
|
||||||
private IItemContainer? _itemContainer;
|
private IItemContainer? _itemContainer;
|
||||||
|
|
||||||
Action<SelectedItemSlotChangeEvent>? SelectedItemSlotChangeEvent { get; set; }
|
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
base._Ready();
|
base._Ready();
|
||||||
_itemContainer = new UniversalItemContainer();
|
_itemContainer = new UniversalItemContainer();
|
||||||
_itemContainer.SupportSelect = true;
|
_itemContainer.SupportSelect = true;
|
||||||
_itemContainer.SelectedItemSlotChangeEvent += SelectedItemSlotChangeEvent;
|
|
||||||
NodeUtils.DeleteAllChild(this);
|
NodeUtils.DeleteAllChild(this);
|
||||||
for (var i = 0; i < Config.HotBarSize; i++)
|
for (var i = 0; i < Config.HotBarSize; i++)
|
||||||
{
|
{
|
||||||
_itemContainer.AddItemSlot(this);
|
var itemSlotNode = _itemContainer.AddItemSlot(this);
|
||||||
|
if (itemSlotNode != null)
|
||||||
|
{
|
||||||
|
itemSlotNode.BackpackAllowed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,13 +113,4 @@ public partial class HotBar : HBoxContainer
|
||||||
{
|
{
|
||||||
return _itemContainer;
|
return _itemContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _ExitTree()
|
|
||||||
{
|
|
||||||
base._ExitTree();
|
|
||||||
if (_itemContainer != null)
|
|
||||||
{
|
|
||||||
_itemContainer.SelectedItemSlotChangeEvent -= SelectedItemSlotChangeEvent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -85,7 +85,7 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _item == null;
|
return CanAddItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -125,7 +125,7 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (number > _item.Quantity)
|
if (number > _item.Quantity)
|
||||||
{
|
{
|
||||||
//The number of item instances created exceeds the current number of items
|
//The number of item instances created exceeds the current number of items
|
||||||
|
@ -163,9 +163,15 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
itemSlotNode.Item = null;
|
itemSlotNode.Item = null;
|
||||||
Item = item;
|
AddItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>Whether to place a backpack in the current slot</para>
|
||||||
|
/// <para>当前槽位是否允许放置背包</para>
|
||||||
|
/// </summary>
|
||||||
|
public bool BackpackAllowed { get; set; }
|
||||||
|
|
||||||
public bool IsSelect
|
public bool IsSelect
|
||||||
{
|
{
|
||||||
get => _isSelect;
|
get => _isSelect;
|
||||||
|
@ -282,6 +288,12 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
|
|
||||||
public bool CanAddItem(IItem item)
|
public bool CanAddItem(IItem item)
|
||||||
{
|
{
|
||||||
|
if (!BackpackAllowed && item is Packsack)
|
||||||
|
{
|
||||||
|
//如果禁止放置背包,且新物品是背包
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (_item == null)
|
if (_item == null)
|
||||||
{
|
{
|
||||||
//If there is no item in the current item slot, it is allowed to add.
|
//If there is no item in the current item slot, it is allowed to add.
|
||||||
|
@ -352,6 +364,7 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
{
|
{
|
||||||
node2D.QueueFree();
|
node2D.QueueFree();
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateQuantityLabel();
|
UpdateQuantityLabel();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public partial class Packsack : PickAbleTemplate
|
||||||
_packsackUi = NodeUtils.InstantiatePackedScene<PacksackUi>(_packedScene);
|
_packsackUi = NodeUtils.InstantiatePackedScene<PacksackUi>(_packedScene);
|
||||||
if (_packsackUi != null)
|
if (_packsackUi != null)
|
||||||
{
|
{
|
||||||
NodeUtils.CallDeferredReparent(this, _packsackUi);
|
NodeUtils.CallDeferredAddChild(NodeUtils.FindContainerNode(_packsackUi, this), _packsackUi);
|
||||||
_packsackUi.Title = Name;
|
_packsackUi.Title = Name;
|
||||||
_packsackUi.ItemContainer = ItemContainer;
|
_packsackUi.ItemContainer = ItemContainer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,8 @@ public partial class AiCharacterSpawn : Marker2D
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeUtils.CallDeferredAddChild(NodeUtils.FindContainerNode(aiCharacter, this), aiCharacter);
|
NodeUtils.CallDeferredAddChild(GameSceneNodeHolder.AiCharacterContainer, aiCharacter);
|
||||||
aiCharacter.Position = GlobalPosition;
|
aiCharacter.GlobalPosition = GlobalPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _ExitTree()
|
public override void _ExitTree()
|
||||||
|
|
|
@ -28,7 +28,7 @@ public partial class PlayerSpawn : Marker2D
|
||||||
if (GameSceneNodeHolder.Player != null)
|
if (GameSceneNodeHolder.Player != null)
|
||||||
{
|
{
|
||||||
GameSceneNodeHolder.Player.ProcessMode = ProcessModeEnum.Inherit;
|
GameSceneNodeHolder.Player.ProcessMode = ProcessModeEnum.Inherit;
|
||||||
GameSceneNodeHolder.Player.Position = GlobalPosition;
|
GameSceneNodeHolder.Player.GlobalPosition = GlobalPosition;
|
||||||
GameSceneNodeHolder.Player.Revive(GameSceneNodeHolder.Player.MaxHp);
|
GameSceneNodeHolder.Player.Revive(GameSceneNodeHolder.Player.MaxHp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,9 @@ public partial class PlayerSpawn : Marker2D
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeUtils.CallDeferredAddChild(NodeUtils.FindContainerNode(playerNode, this), playerNode);
|
//The player's parent node must be GameSceneNodeHolder PlayerContainer.
|
||||||
|
//玩家的父节点必须是GameSceneNodeHolder.PlayerContainer。
|
||||||
|
NodeUtils.CallDeferredAddChild(GameSceneNodeHolder.PlayerContainer, playerNode);
|
||||||
var itemContainer = GameSceneNodeHolder.HotBar?.GetItemContainer();
|
var itemContainer = GameSceneNodeHolder.HotBar?.GetItemContainer();
|
||||||
if (itemContainer == null)
|
if (itemContainer == null)
|
||||||
{
|
{
|
||||||
|
@ -71,8 +73,7 @@ public partial class PlayerSpawn : Marker2D
|
||||||
|
|
||||||
playerNode.ItemContainer = itemContainer;
|
playerNode.ItemContainer = itemContainer;
|
||||||
GameSceneNodeHolder.Player = playerNode;
|
GameSceneNodeHolder.Player = playerNode;
|
||||||
playerNode.Position = GlobalPosition;
|
playerNode.GlobalPosition = GlobalPosition;
|
||||||
LogCat.LogWithFormat("player_spawn_debug", playerNode.ReadOnlyCharacterName, playerNode.Position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MapGenerationCompleteEvent(MapGenerationCompleteEvent mapGenerationCompleteEvent)
|
private void MapGenerationCompleteEvent(MapGenerationCompleteEvent mapGenerationCompleteEvent)
|
||||||
|
|
|
@ -4,7 +4,4 @@
|
||||||
/// <para>Game replay event</para>
|
/// <para>Game replay event</para>
|
||||||
/// <para>游戏重玩事件</para>
|
/// <para>游戏重玩事件</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameReplayEvent
|
public class GameReplayEvent;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,7 +4,4 @@
|
||||||
/// <para>The map generator starts the event</para>
|
/// <para>The map generator starts the event</para>
|
||||||
/// <para>地图生成器启动事件</para>
|
/// <para>地图生成器启动事件</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MapGenerationStartEvent
|
public class MapGenerationStartEvent;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +1,3 @@
|
||||||
namespace ColdMint.scripts.projectile;
|
namespace ColdMint.scripts.projectile;
|
||||||
|
|
||||||
public partial class Projectile : ProjectileTemplate
|
public partial class Projectile : ProjectileTemplate;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user