more dialog json testing
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://dcb1x11exmlab"]
|
[gd_scene load_steps=3 format=3 uid="uid://cnmlidl1blxam"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://src/scene-scripts/gui/dialog_bubble.cs" id="1_txwv4"]
|
[ext_resource type="Script" path="res://src/scene-scripts/gui/dialog_bubble.cs" id="1_txwv4"]
|
||||||
[ext_resource type="FontFile" uid="uid://cx6bvqk0ghmjv" path="res://assets/fonts/urbane-rounded-medium.otf" id="2_qrihj"]
|
[ext_resource type="FontFile" uid="uid://cx6bvqk0ghmjv" path="res://assets/fonts/urbane-rounded-medium.otf" id="2_qrihj"]
|
||||||
@@ -20,7 +20,7 @@ offset_bottom = -0.128052
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
|
|
||||||
[node name="TextLabel" type="Label" parent="."]
|
[node name="text_label" type="Label" parent="."]
|
||||||
anchors_preset = -1
|
anchors_preset = -1
|
||||||
anchor_left = 0.218
|
anchor_left = 0.218
|
||||||
anchor_top = 0.812
|
anchor_top = 0.812
|
||||||
@@ -38,7 +38,7 @@ theme_override_font_sizes/font_size = 32
|
|||||||
text = "This is test text"
|
text = "This is test text"
|
||||||
autowrap_mode = 3
|
autowrap_mode = 3
|
||||||
|
|
||||||
[node name="NameLabel" type="Label" parent="."]
|
[node name="name_label" type="Label" parent="."]
|
||||||
anchors_preset = -1
|
anchors_preset = -1
|
||||||
anchor_left = 0.164
|
anchor_left = 0.164
|
||||||
anchor_top = 0.782
|
anchor_top = 0.782
|
||||||
|
@@ -1,14 +1,22 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Godot.Collections;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public partial class dialog_bubble : CanvasLayer
|
public partial class dialog_bubble : CanvasLayer
|
||||||
{
|
{
|
||||||
|
public Variant parsedDialog;
|
||||||
public override void _Process(double delta)
|
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 string playerName;
|
||||||
[Export] public int speed = 200;
|
[Export] public int speed = 200;
|
||||||
|
public bool allowMovement = true;
|
||||||
public Vector2 movement;
|
public Vector2 movement;
|
||||||
public AnimatedSprite2D animatedSprite;
|
public AnimatedSprite2D animatedSprite;
|
||||||
public Marker2D rotCenter;
|
public Marker2D rotCenter;
|
||||||
@@ -17,23 +18,24 @@ public partial class player : CharacterBody2D
|
|||||||
rotCenter = GetNode<Marker2D>("rotation_center");
|
rotCenter = GetNode<Marker2D>("rotation_center");
|
||||||
dialogRayCast = GetNode<RayCast2D>("rotation_center/ray_cast_2d");
|
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)
|
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();
|
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);
|
MoveAndCollide(movement * speed * (float)delta);
|
||||||
}
|
}
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
if (Input.IsActionJustPressed("ui_accept") && dialogRayCast.IsColliding())
|
if (Input.IsActionJustPressed("ui_accept") && dialogRayCast.IsColliding() && allowMovement)
|
||||||
dialog_bubble.SetDialog(dialogRayCast.GetCollider().Get("dialogFile").AsString());
|
GetNode<dialog_bubble>("dialog_bubble").GetDialog(dialogRayCast.GetCollider().Get("dialogFile").AsString());
|
||||||
|
|
||||||
//animation system (with controller support wich cant get normalized vector)
|
//animation system (with controller support wich cant get normalized vector)
|
||||||
|
if(allowMovement == false)
|
||||||
|
{
|
||||||
|
animatedSprite.Stop();
|
||||||
|
animatedSprite.Frame = 0;
|
||||||
|
}
|
||||||
if (movement.Length() != 0)
|
if (movement.Length() != 0)
|
||||||
animatedSprite.Play();
|
animatedSprite.Play();
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user