diff --git a/locals/Log.en.translation b/locals/Log.en.translation
index 3b2867b..26a2d18 100644
Binary files a/locals/Log.en.translation and b/locals/Log.en.translation differ
diff --git a/locals/Log.ja.translation b/locals/Log.ja.translation
index ae0f924..bcce44b 100644
Binary files a/locals/Log.ja.translation and b/locals/Log.ja.translation differ
diff --git a/locals/Log.zh.translation b/locals/Log.zh.translation
index a879ff0..b618fc9 100644
Binary files a/locals/Log.zh.translation and b/locals/Log.zh.translation differ
diff --git a/locals/Slogan.ja.translation b/locals/Slogan.ja.translation
index e44c84c..db766f6 100644
Binary files a/locals/Slogan.ja.translation and b/locals/Slogan.ja.translation differ
diff --git a/locals/slogan.en.translation b/locals/slogan.en.translation
index afca762..77ebe61 100644
Binary files a/locals/slogan.en.translation and b/locals/slogan.en.translation differ
diff --git a/locals/slogan.zh.translation b/locals/slogan.zh.translation
index 357757f..04ff434 100644
Binary files a/locals/slogan.zh.translation and b/locals/slogan.zh.translation differ
diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs
index aff45c9..75e2fb0 100644
--- a/scripts/character/CharacterTemplate.cs
+++ b/scripts/character/CharacterTemplate.cs
@@ -485,8 +485,8 @@ public partial class CharacterTemplate : CharacterBody2D
///
///
public void GenerateLootObjects(Node parentNode,
- LootData[] lootDataArray,
- Vector2 position)
+ LootData[] lootDataArray,
+ Vector2 position)
{
LootListManager.GenerateLootObjects(parentNode, lootDataArray, position);
}
@@ -617,8 +617,8 @@ public partial class CharacterTemplate : CharacterBody2D
/// 抛出物品
///
///
- ///Item slot subscript in item container
- ///物品容器内的物品槽下标
+ ///Item slot index in item container
+ ///物品容器内的物品槽位置
///
///
/// How many to throw
@@ -633,8 +633,41 @@ public partial class CharacterTemplate : CharacterBody2D
protected void ThrowItem(int index, int number, Vector2 velocity)
{
var itemSlotNode = ItemContainer?.GetItemSlotNode(index);
+ if (itemSlotNode is null) return;
- var item = itemSlotNode?.GetItem();
+ if (number < 0)
+ {
+ while (!itemSlotNode.IsEmpty())
+ {
+ ThrowOneItem(itemSlotNode, velocity);
+ }
+ }
+ else
+ {
+ for (int i = 0; i < number && !itemSlotNode.IsEmpty(); i++)
+ {
+ ThrowOneItem(itemSlotNode, velocity);
+ }
+ }
+ }
+
+ ///
+ /// Throw item
+ /// 抛出物品
+ ///
+ ///
+ ///Item slot index in item container
+ ///物品容器内的物品槽位置
+ ///
+ ///
+ ///The speed to be applied to the item
+ ///要施加到物品上的速度
+ ///
+ protected void ThrowOneItem(ItemSlotNode itemSlotNode, Vector2 velocity)
+ {
+ //Pick an item from the item container
+ //从物品容器内取出一个物品
+ var item = itemSlotNode?.PickItem();
if (item is not Node2D node2D)
{
@@ -685,17 +718,6 @@ public partial class CharacterTemplate : CharacterBody2D
rigidBody2D.LinearVelocity = velocity;
break;
}
-
- //Remove items from the item container
- //在物品容器内移除物品
- if (number < 0)
- {
- itemSlotNode!.RemoveItem(item.Quantity);
- }
- else
- {
- itemSlotNode!.RemoveItem(number);
- }
}
///
diff --git a/scripts/inventory/ItemSlotNode.cs b/scripts/inventory/ItemSlotNode.cs
index b129e1c..9208cd5 100644
--- a/scripts/inventory/ItemSlotNode.cs
+++ b/scripts/inventory/ItemSlotNode.cs
@@ -37,6 +37,8 @@ public partial class ItemSlotNode : MarginContainer
public TextureRect? BackgroundTextureRect => _backgroundTextureRect;
+ public bool IsEmpty() => _itemStack == null;
+
///
/// Get the item stack in the item slot
/// 获取物品槽内的物品堆
diff --git a/scripts/item/SingleItemStack.cs b/scripts/item/SingleItemStack.cs
index 86850bf..839066e 100644
--- a/scripts/item/SingleItemStack.cs
+++ b/scripts/item/SingleItemStack.cs
@@ -27,8 +27,8 @@ public class SingleItemStack(IItem_New item) : IItemStack
public int CanTakeFrom(IItemStack itemStack) => 0;
- public int TakeFrom(IItemStack itemStack) => 0;
-
+ public bool TakeFrom(IItemStack itemStack) => false;
+
public IItem_New? GetItem()
{
throw new NotImplementedException();
diff --git a/scripts/item/weapon/WeaponTemplate.cs b/scripts/item/weapon/WeaponTemplate.cs
index 851cca1..6b5d314 100644
--- a/scripts/item/weapon/WeaponTemplate.cs
+++ b/scripts/item/weapon/WeaponTemplate.cs
@@ -35,6 +35,11 @@ public abstract partial class WeaponTemplate : RigidBody2D, IItem_New
Fire(owner, targetGlobalPosition);
}
+ public virtual void Destroy()
+ {
+ QueueFree();
+ }
+
///
/// Whether the weapon is currently picked up
@@ -168,7 +173,7 @@ public abstract partial class WeaponTemplate : RigidBody2D, IItem_New
//Determine if your side can cause damage
//判断所属的阵营是否可以造成伤害
- var canCauseHarm = CampManager.CanCauseHarm(CampManager.GetCamp(ownerCharacterTemplate.CampId),
+ var canCauseHarm = CampManager.CanCauseHarm(CampManager.GetCamp(ownerCharacterTemplate.CampId),
CampManager.GetCamp(characterTemplate.CampId));
if (!canCauseHarm)
{
diff --git a/scripts/projectile/ProjectileTemplate.cs b/scripts/projectile/ProjectileTemplate.cs
index 8d8b4f5..3079f72 100644
--- a/scripts/projectile/ProjectileTemplate.cs
+++ b/scripts/projectile/ProjectileTemplate.cs
@@ -1,8 +1,11 @@
using System;
+
using ColdMint.scripts.camp;
using ColdMint.scripts.character;
using ColdMint.scripts.damage;
-using ColdMint.scripts.weapon;
+using ColdMint.scripts.item;
+using ColdMint.scripts.item.weapon;
+
using Godot;
namespace ColdMint.scripts.projectile;
@@ -64,10 +67,10 @@ public partial class ProjectileTemplate : CharacterBody2D
Area2D.Monitoring = true;
Area2D.BodyEntered += OnBodyEnter;
Area2D.BodyExited += OnBodyExited;
- Durability = GetMeta("Durability", "1").AsDouble();
- MaxDamage = GetMeta("MaxDamage", "7").AsInt32();
- MinDamage = GetMeta("MinDamage", "5").AsInt32();
- DamageType = GetMeta("DamageType", Config.DamageType.Physical).AsInt32();
+ Durability = GetMeta("Durability", "1").AsDouble();
+ MaxDamage = GetMeta("MaxDamage", "7").AsInt32();
+ MinDamage = GetMeta("MinDamage", "5").AsInt32();
+ DamageType = GetMeta("DamageType", Config.DamageType.Physical).AsInt32();
KnockbackForce = GetMeta("Knockback", Vector2.Zero).AsVector2();
//life(ms)
//子弹的存在时间(毫秒)
@@ -111,7 +114,9 @@ public partial class ProjectileTemplate : CharacterBody2D
return true;
}
- if (target is WeaponTemplate)
+ //Match any item now
+ //现在使它识别任何物品
+ if (target is IItem_New)
{
//Bullets are allowed to strike objects.
//允许子弹撞击物品。
@@ -126,7 +131,7 @@ public partial class ProjectileTemplate : CharacterBody2D
//First get the owner's camp and compare it with the target camp
//先获取主人的阵营与目标阵营进行比较
var canCauseHarm = CampManager.CanCauseHarm(CampManager.GetCamp(ownerCharacterTemplate.CampId),
- CampManager.GetCamp(characterTemplate.CampId));
+ CampManager.GetCamp(characterTemplate.CampId));
return canCauseHarm;
}
@@ -169,7 +174,8 @@ public partial class ProjectileTemplate : CharacterBody2D
force.Y = KnockbackForce.Y * Config.CellSize;
characterTemplate.AddForce(force);
}
- }else if (target is WeaponTemplate weaponTemplate)
+ }
+ else if (target is WeaponTemplate weaponTemplate)
{
if (KnockbackForce != Vector2.Zero)
{
@@ -225,9 +231,7 @@ public partial class ProjectileTemplate : CharacterBody2D
/// 当子弹离开节点时
///
///
- protected virtual void OnBodyExited(Node2D node)
- {
- }
+ protected virtual void OnBodyExited(Node2D node) { }
///
diff --git a/scripts/utils/NodeUtils.cs b/scripts/utils/NodeUtils.cs
index 5714db6..44ac247 100644
--- a/scripts/utils/NodeUtils.cs
+++ b/scripts/utils/NodeUtils.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using ColdMint.scripts.debug;
-using ColdMint.scripts.weapon;
+using ColdMint.scripts.item.weapon;
using Godot;
namespace ColdMint.scripts.utils;