more dialog json testing

This commit is contained in:
2023-02-01 11:10:16 +01:00
parent 547e866597
commit ea07e94e0a
3 changed files with 24 additions and 14 deletions

View File

@@ -6,6 +6,7 @@ public partial class player : CharacterBody2D
[Export] public string playerName;
[Export] public int speed = 200;
public bool allowMovement = true;
public Vector2 movement;
public AnimatedSprite2D animatedSprite;
public Marker2D rotCenter;
@@ -17,23 +18,24 @@ public partial class player : CharacterBody2D
rotCenter = GetNode<Marker2D>("rotation_center");
dialogRayCast = GetNode<RayCast2D>("rotation_center/ray_cast_2d");
}
public void ChangeProcess(bool process)
{
if (process) ProcessMode = ProcessModeEnum.Inherit; else ProcessMode = ProcessModeEnum.Disabled;
animatedSprite.Frame = 0;
}
public override void _PhysicsProcess(double delta)
{
movement = Input.GetVector("move_left", "move_right", "move_up", "move_down");
if(allowMovement) movement = Input.GetVector("move_left", "move_right", "move_up", "move_down");
else movement = Vector2.Zero;
if(movement.Length() != 0) rotCenter.Rotation = new Vector2((float)Math.Round(movement.X,0),(float)Math.Round(movement.Y,0)).Angle();
MoveAndCollide(movement * speed * (float)delta);
}
public override void _Process(double delta)
{
if (Input.IsActionJustPressed("ui_accept") && dialogRayCast.IsColliding())
dialog_bubble.SetDialog(dialogRayCast.GetCollider().Get("dialogFile").AsString());
if (Input.IsActionJustPressed("ui_accept") && dialogRayCast.IsColliding() && allowMovement)
GetNode<dialog_bubble>("dialog_bubble").GetDialog(dialogRayCast.GetCollider().Get("dialogFile").AsString());
//animation system (with controller support wich cant get normalized vector)
if(allowMovement == false)
{
animatedSprite.Stop();
animatedSprite.Frame = 0;
}
if (movement.Length() != 0)
animatedSprite.Play();
else