lots of bugfixes

This commit is contained in:
2023-02-24 17:43:03 +01:00
parent 294abe6b6f
commit 851a9fa99c
7 changed files with 31 additions and 17 deletions

View File

@@ -3,17 +3,20 @@ using System;
public partial class essential : Node
{
public string currentController = Input.GetJoyName(0);
public static string currentController = Input.GetJoyName(0);
public override void _Input(InputEvent @event)
{
//Checks if using Keyboard or controller and giving out current controller
if (@event is InputEventKey || @event is InputEventMouseButton || currentController == "")
//Checks if using Keyboard or controller. It gives out the current controller and changes cursor visibillity
if (@event is InputEventKey || @event is InputEventMouseButton || @event is InputEventMouseMotion || currentController == "")
{
currentController = "PC";
if (@event is InputEventJoypadButton && currentController != Input.GetJoyName(0))
Input.MouseMode = Input.MouseModeEnum.Visible;
}
if (@event is InputEventJoypadButton || @event is InputEventJoypadMotion & Input.GetVector("move_left", "move_right", "move_up", "move_down") != Vector2.Zero && currentController != Input.GetJoyName(0))
{
currentController = Input.GetJoyName(0);
console.Print("Current controller device: " + currentController);
Input.MouseMode = Input.MouseModeEnum.Hidden;
}
}
public override void _Process(double delta)

View File

@@ -36,7 +36,8 @@ public partial class dialog_bubble : CanvasLayer
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() != "villager" || introducedVillager)
GetNode<Label>("box/name_label").Text = title;
if (GetParent().Name == "player") player.allowMovement = false;
player.allowMovement = false;
//Get first key
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager")

View File

@@ -26,9 +26,10 @@ public partial class player : CharacterBody2D
}
public override void _PhysicsProcess(double delta)
{
if (allowMovement) 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 (Math.Round(movement.Length(), 0) != 0) rotCenter.Rotation = new Vector2((float)Math.Round(movement.X, 0), (float)Math.Round(movement.Y, 0)).Angle();
MoveAndCollide(movement * speed * 200 * (float)delta);
}
public override void _Process(double delta)
@@ -36,6 +37,7 @@ public partial class player : CharacterBody2D
if (Input.IsActionJustPressed("ui_accept") && dialogRayCast.IsColliding() && allowMovement)
GetNode<dialog_bubble>("dialog_bubble").GetDialog(dialogRayCast.GetCollider().Get("file").AsString(), (Area2D)dialogRayCast.GetCollider());
//animation system (with controller support wich cant get normalized vector)
if (allowMovement == false)
{
@@ -63,6 +65,10 @@ public partial class player : CharacterBody2D
animatedSprite.SpeedScale = Math.Abs(movement.Y * speed * 1.3f);
}
}
public int BeginDialogue(int i)
{
return 0;
}
public void OnAnimationChanged()
{
if (animatedSprite.Animation == "move_side")