怪物可以捡起武器打玩家了。
This commit is contained in:
parent
7812d9c570
commit
e4583aed3c
|
@ -84,3 +84,7 @@ log_no_weapon_detected,没有检测到武器。,No weapon detected.,武器が検
|
|||
log_weapon_lost,武器丢失。,Weapon lost.,武器が失われました。
|
||||
log_nearest_node_is_null,最近的节点为空。,The nearest node is null.,最も近いノードが空です。
|
||||
log_node_is_not_WeaponTemplate,节点不是WeaponTemplate。,The node is not a WeaponTemplate.,ノードはWeaponTemplateではありません。
|
||||
log_weapon_not_in_pickup_range,武器不在拾取范围内。,The weapon is not within the pickup range.,武器は拾い取り範囲内にありません。
|
||||
log_weapon_picked_up,武器被拾取。,Weapon picked up.,武器が拾い取られました。
|
||||
log_weapon_pickup_failed,武器拾取失败。,Weapon pickup failed.,武器の拾い取りに失敗しました。
|
||||
log_enter_the_picking_range_body,进入拾取范围。,Enter the picking range.,拾い取り範囲に入ります。
|
|
|
@ -26,7 +26,6 @@ animations = [{
|
|||
collision_layer = 4
|
||||
collision_mask = 34
|
||||
script = ExtResource("1_1dlls")
|
||||
LootListId = null
|
||||
metadata/CampId = "Default"
|
||||
metadata/MaxHp = 32
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ radius = 20.0
|
|||
height = 52.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_vmqbt"]
|
||||
radius = 34.5398
|
||||
radius = 65.3758
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_qumby"]
|
||||
animations = [{
|
||||
|
|
|
@ -8,19 +8,6 @@ namespace ColdMint.scripts;
|
|||
|
||||
public static class Config
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>ID of the behavior tree</para>
|
||||
/// <para>行为树的ID</para>
|
||||
/// </summary>
|
||||
public static class BehaviorTreeId
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>巡逻</para>
|
||||
/// <para>Patrol</para>
|
||||
/// </summary>
|
||||
public const string Patrol = "Patrol";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Loot table ID</para>
|
||||
/// <para>战利品表ID</para>
|
||||
|
@ -34,31 +21,6 @@ public static class Config
|
|||
public const string Test = "test";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>BehaviorTreeResult</para>
|
||||
/// <para>行为树的结果</para>
|
||||
/// </summary>
|
||||
public static class BehaviorTreeResult
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Running</para>
|
||||
/// <para>运行中</para>
|
||||
/// </summary>
|
||||
public const int Running = 0;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Success</para>
|
||||
/// <para>成功</para>
|
||||
/// </summary>
|
||||
public const int Success = 1;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Failure</para>
|
||||
/// <para>失败</para>
|
||||
/// </summary>
|
||||
public const int Failure = 2;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>Camp ID</para>
|
||||
|
|
|
@ -347,9 +347,12 @@ public sealed partial class AiCharacter : CharacterTemplate
|
|||
private void EnterTheScoutArea(Node node)
|
||||
{
|
||||
if (node is WeaponTemplate weaponTemplate)
|
||||
{
|
||||
if (CanPickItem(weaponTemplate))
|
||||
{
|
||||
_weaponInTheScoutRange?.Add(weaponTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
CanCauseHarmNode(node, (canCause, characterTemplate) =>
|
||||
{
|
||||
|
|
|
@ -240,14 +240,12 @@ public partial class CharacterTemplate : CharacterBody2D
|
|||
foreach (var pickingRangeBody in PickingRangeBodies)
|
||||
{
|
||||
if (pickingRangeBody is not WeaponTemplate weaponTemplate) continue;
|
||||
if (weaponTemplate.Owner != null)
|
||||
if (weaponTemplate.Picked)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
weaponTemplates.Add(weaponTemplate);
|
||||
}
|
||||
|
||||
return weaponTemplates.ToArray();
|
||||
}
|
||||
|
||||
|
@ -308,7 +306,7 @@ public partial class CharacterTemplate : CharacterBody2D
|
|||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <returns></returns>
|
||||
private bool CanPickItem(Node node)
|
||||
protected bool CanPickItem(Node node)
|
||||
{
|
||||
if (_currentItem != null && node == _currentItem)
|
||||
{
|
||||
|
@ -336,7 +334,7 @@ public partial class CharacterTemplate : CharacterBody2D
|
|||
///<para>Whether successfully picked up</para>
|
||||
///<para>是否成功拾起</para>
|
||||
/// </returns>
|
||||
protected bool PickItem(Node2D? pickAbleItemNode2D)
|
||||
public bool PickItem(Node2D? pickAbleItemNode2D)
|
||||
{
|
||||
//Empty reference checking is implicitly performed here.
|
||||
//此处隐式的执行了空引用检查。
|
||||
|
@ -585,12 +583,12 @@ public partial class CharacterTemplate : CharacterBody2D
|
|||
if (damageTemplate.Attacker is CharacterTemplate characterTemplate &&
|
||||
!string.IsNullOrEmpty(characterTemplate.CharacterName))
|
||||
{
|
||||
LogCat.LogWithFormat("death_info", LogCat.LogLabel.Default, LogCat.UploadFormat,CharacterName,
|
||||
LogCat.LogWithFormat("death_info", LogCat.LogLabel.Default, LogCat.UploadFormat, CharacterName,
|
||||
characterTemplate.CharacterName);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogCat.LogWithFormat("death_info", LogCat.LogLabel.Default, LogCat.UploadFormat,CharacterName,
|
||||
LogCat.LogWithFormat("death_info", LogCat.LogLabel.Default, LogCat.UploadFormat, CharacterName,
|
||||
damageTemplate.Attacker.Name);
|
||||
}
|
||||
}
|
||||
|
@ -612,6 +610,7 @@ public partial class CharacterTemplate : CharacterBody2D
|
|||
return;
|
||||
}
|
||||
|
||||
LogCat.Log("enter_the_picking_range_body");
|
||||
PickingRangeBodiesList?.Add(node);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,51 @@ public class LookForWeaponProcessor : StateProcessorTemplate
|
|||
{
|
||||
//If the nearest weapon is found, move the character to the weapon.
|
||||
//如果有最近的武器被找到了,那么将角色移动到武器旁边。
|
||||
var weaponTemplates = aiCharacter.GetCanPickedWeapon();
|
||||
//Weapons are not in the range of the pickup.
|
||||
//武器没在拾捡范围内。
|
||||
if (weaponTemplates.Length == 0)
|
||||
{
|
||||
LogCat.Log("weapon_not_in_pickup_range", LogCat.LogLabel.LookForWeaponProcessor);
|
||||
aiCharacter.SetTargetPosition(TargetWeapon.GlobalPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
var haveWeapon = false;
|
||||
foreach (var weaponTemplate in weaponTemplates)
|
||||
{
|
||||
if (weaponTemplate == TargetWeapon)
|
||||
{
|
||||
haveWeapon = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (haveWeapon)
|
||||
{
|
||||
var pickResult = aiCharacter.PickItem(TargetWeapon);
|
||||
if (pickResult)
|
||||
{
|
||||
context.CurrentState = context.PreviousState;
|
||||
//Successfully picked up the weapon.
|
||||
//成功拾起武器。
|
||||
LogCat.Log("weapon_picked_up", LogCat.LogLabel.LookForWeaponProcessor);
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetWeapon = null;
|
||||
//Weapon failed to pick up.
|
||||
//武器捡起时失败。
|
||||
LogCat.Log("weapon_pickup_failed", LogCat.LogLabel.LookForWeaponProcessor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//No weapons are included in the pickup area.
|
||||
//拾捡范围内不包含武器。
|
||||
LogCat.Log("weapon_not_in_pickup_range", LogCat.LogLabel.LookForWeaponProcessor);
|
||||
aiCharacter.SetTargetPosition(TargetWeapon.GlobalPosition);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user