Changed zombie speed from int to floatmod, added hobo
This commit is contained in:
parent
5d8e45469d
commit
ad8ecb875a
9 changed files with 310 additions and 158 deletions
|
|
@ -8,26 +8,30 @@ public partial class EatBox : Area2D
|
|||
{
|
||||
// Rewrite this class completely when field system will be introduced.
|
||||
|
||||
[Export] private int _damage;
|
||||
[Export] private AnimationTree _animationTree;
|
||||
[Export] private FloatModifiers _damage;
|
||||
private RuntimePlantData plant;
|
||||
|
||||
public bool isEating = false;
|
||||
|
||||
public void Bite()
|
||||
{
|
||||
if (GetParent<RuntimeZombieData>().AbleToEat)
|
||||
plant?.TakeDamage(_damage,GetParent());
|
||||
{
|
||||
plant?.TakeDamage((int)_damage.GetValue(), GetParent());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void OnAreaEntered(Area2D area)
|
||||
{
|
||||
var parent = area.GetParent();
|
||||
GD.Print(parent.Name);
|
||||
|
||||
if (parent != null && parent is RuntimePlantData plantData)
|
||||
{
|
||||
plant = plantData;
|
||||
_animationTree.Set("parameters/conditions/eat", true);
|
||||
_animationTree.Set("parameters/conditions/end_eat", false);
|
||||
isEating = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -38,8 +42,7 @@ public partial class EatBox : Area2D
|
|||
if (parent == plant)
|
||||
{
|
||||
plant = null;
|
||||
_animationTree.Set("parameters/conditions/eat", false);
|
||||
_animationTree.Set("parameters/conditions/end_eat", true);
|
||||
isEating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,30 +4,40 @@ namespace Newlon.Components.Zombies;
|
|||
|
||||
public partial class ZombieMover : Node
|
||||
{
|
||||
[Export(hintString: "suffix:tile/sec")]
|
||||
private float _speedMultiplier = 1.0f;
|
||||
|
||||
private float _speed = 1;
|
||||
|
||||
[Export]
|
||||
private FloatModifiers _speed;
|
||||
private Node2D _zombie;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_zombie = GetParent<Node2D>();
|
||||
_speed = (FloatModifiers)_speed.Duplicate();
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
_zombie.Position -= _zombie.Transform.X
|
||||
* _speed
|
||||
* (float)delta
|
||||
* Utility.TileWidth
|
||||
* GetParent<RuntimeZombieData>().LocalTimescale
|
||||
* _speedMultiplier;
|
||||
_zombie.Position -= _zombie.Transform.X
|
||||
* (float)delta
|
||||
* Utility.TileWidth
|
||||
* GetParent<RuntimeZombieData>().LocalTimescale
|
||||
* _speed.GetValue();
|
||||
GD.Print(_speed.GetMult());
|
||||
}
|
||||
|
||||
public void SetSpeed(float speed)
|
||||
public void SetSpeedFlat(float speed)
|
||||
{
|
||||
_speed = speed;
|
||||
_speed.SetFlat(speed);
|
||||
}
|
||||
public void SetSpeedPercentage(float speed)
|
||||
{
|
||||
_speed.SetPercentage(speed);
|
||||
}
|
||||
public void SetSpeedMult(float speed)
|
||||
{
|
||||
_speed.SetMult(speed);
|
||||
}
|
||||
public void AddMult(float amount)
|
||||
{
|
||||
_speed.ChangeMult(amount);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
using Godot;
|
||||
|
||||
namespace Newlon.Components.Zombies.Behaviours;
|
||||
|
||||
public partial class BasicZombieBehaviour : Node
|
||||
{
|
||||
[Export] private AnimationTree _animationTree;
|
||||
public void StartEating()
|
||||
{
|
||||
_animationTree.Set("parameters/conditions/eat",true);
|
||||
_animationTree.Set("parameters/conditions/end_eat", false);
|
||||
GD.Print("StartEating");
|
||||
}
|
||||
public void EndEating()
|
||||
{
|
||||
_animationTree.Set("parameters/conditions/eat", false);
|
||||
_animationTree.Set("parameters/conditions/end_eat", true);
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://cgf61r46dgh4m
|
||||
17
scripts/components/zombies/behaviours/HoboBehaviour.cs
Normal file
17
scripts/components/zombies/behaviours/HoboBehaviour.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using Godot;
|
||||
|
||||
namespace Newlon.Components.Zombies.Behaviours;
|
||||
|
||||
public partial class HoboBehaviour : Node
|
||||
{
|
||||
[Export] private EatBox _eatBox;
|
||||
[Export] private AnimationTree _animationTree;
|
||||
public bool isEating => _eatBox.isEating;
|
||||
public bool canDestroyed = false;
|
||||
public void Trashed()
|
||||
{
|
||||
canDestroyed = true;
|
||||
((AnimationNodeStateMachinePlayback)_animationTree.Get("parameters/playback")).Travel("hobo_zombie_can_destroy");
|
||||
_animationTree.Set("parameters/eat_Tree/blend/blend_amount", 1.0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://c5v2og85t7s6j
|
||||
Loading…
Add table
Add a link
Reference in a new issue