怪物可以捡起武器打玩家了。
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_weapon_lost,武器丢失。,Weapon lost.,武器が失われました。
|
||||||
log_nearest_node_is_null,最近的节点为空。,The nearest node is null.,最も近いノードが空です。
|
log_nearest_node_is_null,最近的节点为空。,The nearest node is null.,最も近いノードが空です。
|
||||||
log_node_is_not_WeaponTemplate,节点不是WeaponTemplate。,The node is not a WeaponTemplate.,ノードはWeaponTemplateではありません。
|
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_layer = 4
|
||||||
collision_mask = 34
|
collision_mask = 34
|
||||||
script = ExtResource("1_1dlls")
|
script = ExtResource("1_1dlls")
|
||||||
LootListId = null
|
|
||||||
metadata/CampId = "Default"
|
metadata/CampId = "Default"
|
||||||
metadata/MaxHp = 32
|
metadata/MaxHp = 32
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ radius = 20.0
|
||||||
height = 52.0
|
height = 52.0
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_vmqbt"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_vmqbt"]
|
||||||
radius = 34.5398
|
radius = 65.3758
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id="SpriteFrames_qumby"]
|
[sub_resource type="SpriteFrames" id="SpriteFrames_qumby"]
|
||||||
animations = [{
|
animations = [{
|
||||||
|
|
|
@ -8,19 +8,6 @@ namespace ColdMint.scripts;
|
||||||
|
|
||||||
public static class Config
|
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>
|
/// <summary>
|
||||||
/// <para>Loot table ID</para>
|
/// <para>Loot table ID</para>
|
||||||
/// <para>战利品表ID</para>
|
/// <para>战利品表ID</para>
|
||||||
|
@ -34,31 +21,6 @@ public static class Config
|
||||||
public const string Test = "test";
|
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>
|
/// <summary>
|
||||||
/// <para>Camp ID</para>
|
/// <para>Camp ID</para>
|
||||||
|
|
|
@ -347,9 +347,12 @@ public sealed partial class AiCharacter : CharacterTemplate
|
||||||
private void EnterTheScoutArea(Node node)
|
private void EnterTheScoutArea(Node node)
|
||||||
{
|
{
|
||||||
if (node is WeaponTemplate weaponTemplate)
|
if (node is WeaponTemplate weaponTemplate)
|
||||||
|
{
|
||||||
|
if (CanPickItem(weaponTemplate))
|
||||||
{
|
{
|
||||||
_weaponInTheScoutRange?.Add(weaponTemplate);
|
_weaponInTheScoutRange?.Add(weaponTemplate);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CanCauseHarmNode(node, (canCause, characterTemplate) =>
|
CanCauseHarmNode(node, (canCause, characterTemplate) =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -240,14 +240,12 @@ public partial class CharacterTemplate : CharacterBody2D
|
||||||
foreach (var pickingRangeBody in PickingRangeBodies)
|
foreach (var pickingRangeBody in PickingRangeBodies)
|
||||||
{
|
{
|
||||||
if (pickingRangeBody is not WeaponTemplate weaponTemplate) continue;
|
if (pickingRangeBody is not WeaponTemplate weaponTemplate) continue;
|
||||||
if (weaponTemplate.Owner != null)
|
if (weaponTemplate.Picked)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
weaponTemplates.Add(weaponTemplate);
|
weaponTemplates.Add(weaponTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return weaponTemplates.ToArray();
|
return weaponTemplates.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +306,7 @@ public partial class CharacterTemplate : CharacterBody2D
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="node"></param>
|
/// <param name="node"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private bool CanPickItem(Node node)
|
protected bool CanPickItem(Node node)
|
||||||
{
|
{
|
||||||
if (_currentItem != null && node == _currentItem)
|
if (_currentItem != null && node == _currentItem)
|
||||||
{
|
{
|
||||||
|
@ -336,7 +334,7 @@ public partial class CharacterTemplate : CharacterBody2D
|
||||||
///<para>Whether successfully picked up</para>
|
///<para>Whether successfully picked up</para>
|
||||||
///<para>是否成功拾起</para>
|
///<para>是否成功拾起</para>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
protected bool PickItem(Node2D? pickAbleItemNode2D)
|
public bool PickItem(Node2D? pickAbleItemNode2D)
|
||||||
{
|
{
|
||||||
//Empty reference checking is implicitly performed here.
|
//Empty reference checking is implicitly performed here.
|
||||||
//此处隐式的执行了空引用检查。
|
//此处隐式的执行了空引用检查。
|
||||||
|
@ -612,6 +610,7 @@ public partial class CharacterTemplate : CharacterBody2D
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogCat.Log("enter_the_picking_range_body");
|
||||||
PickingRangeBodiesList?.Add(node);
|
PickingRangeBodiesList?.Add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,51 @@ public class LookForWeaponProcessor : StateProcessorTemplate
|
||||||
{
|
{
|
||||||
//If the nearest weapon is found, move the character to the weapon.
|
//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);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user