more dialogue system stuff
This commit is contained in:
@@ -18,7 +18,7 @@ public partial class dialog_bubble : CanvasLayer
|
||||
public void GetDialog(string dialogFile)
|
||||
{
|
||||
parsedDialog = Json.ParseString(FileAccess.Open(dialogFile, FileAccess.ModeFlags.Read).GetAsText());
|
||||
GetNode<Label>("name_label").Text = parsedDialog.AsGodotDictionary()["dialogTitle"].AsString();
|
||||
GetNode<Label>("color_rect/name_label").Text = parsedDialog.AsGodotDictionary()["dialogTitle"].AsString();
|
||||
Array<string> dialogLinestest = new Array<string>();
|
||||
dialogLinestest.Add("test");
|
||||
dialogLinestest.Add("test2");
|
@@ -5,7 +5,7 @@ public partial class player : CharacterBody2D
|
||||
{
|
||||
|
||||
[Export] public string playerName;
|
||||
[Export] public int speed = 200;
|
||||
[Export] public int speed = 200;
|
||||
public bool allowMovement = true;
|
||||
public Vector2 movement;
|
||||
public AnimatedSprite2D animatedSprite;
|
||||
@@ -19,10 +19,10 @@ public partial class player : CharacterBody2D
|
||||
dialogRayCast = GetNode<RayCast2D>("rotation_center/ray_cast_2d");
|
||||
}
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
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 (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)
|
||||
@@ -31,7 +31,7 @@ public partial class player : CharacterBody2D
|
||||
GetNode<dialog_bubble>("dialog_bubble").GetDialog(dialogRayCast.GetCollider().Get("dialogFile").AsString());
|
||||
|
||||
//animation system (with controller support wich cant get normalized vector)
|
||||
if(allowMovement == false)
|
||||
if (allowMovement == false)
|
||||
{
|
||||
animatedSprite.Stop();
|
||||
animatedSprite.Frame = 0;
|
||||
@@ -47,14 +47,14 @@ public partial class player : CharacterBody2D
|
||||
{
|
||||
animatedSprite.Animation = "move_side";
|
||||
animatedSprite.FlipH = movement.X < 0.5;
|
||||
animatedSprite.SpeedScale = Math.Abs(movement.X * speed/150);
|
||||
animatedSprite.SpeedScale = Math.Abs(movement.X * speed / 150);
|
||||
}
|
||||
else if (Math.Round(movement.Y, 0) != 0)
|
||||
{
|
||||
if (movement.Y > 0.05) animatedSprite.Animation = "move_down";
|
||||
if (movement.Y < 0.05) animatedSprite.Animation = "move_up";
|
||||
animatedSprite.FlipH = false;
|
||||
animatedSprite.SpeedScale = Math.Abs(movement.Y * speed/150);
|
||||
animatedSprite.SpeedScale = Math.Abs(movement.Y * speed / 150);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user