more dialog json testing
This commit is contained in:
@@ -1,14 +1,22 @@
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System;
|
||||
|
||||
public partial class dialog_bubble : CanvasLayer
|
||||
{
|
||||
|
||||
public Variant parsedDialog;
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
}
|
||||
public static void SetDialog(string dialogFile)
|
||||
public void GetDialog(string dialogFile)
|
||||
{
|
||||
var parsedDialog = Json.ParseString(FileAccess.Open(dialogFile, FileAccess.ModeFlags.Read).GetAsText());
|
||||
parsedDialog = Json.ParseString(FileAccess.Open(dialogFile, FileAccess.ModeFlags.Read).GetAsText());
|
||||
GetNode<Label>("name_label").Text = parsedDialog.AsGodotDictionary()["dialogTitle"].AsString();
|
||||
Array<string> dialogLinestest = new Array<string>();
|
||||
dialogLinestest.Add("test");
|
||||
dialogLinestest.Add("test2");
|
||||
GD.Print(dialogLinestest);
|
||||
GD.Print((parsedDialog.AsGodotDictionary()["tipp"]).AsGodotArray()[2].AsGodotArray()[4].VariantType);
|
||||
if(GetParent().Name == "player") GetParent<player>().allowMovement = true;
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user