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

@@ -88,7 +88,7 @@ radius = 9.0
height = 60.0 height = 60.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_sgrqb"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_sgrqb"]
size = Vector2(64, 100) size = Vector2(64, 79)
[node name="base_npc" type="CharacterBody2D"] [node name="base_npc" type="CharacterBody2D"]
@@ -112,7 +112,7 @@ title = "Debug NPC"
metadata/_edit_lock_ = true metadata/_edit_lock_ = true
[node name="collision_shape_2d" parent="dialog_trigger_area" index="0"] [node name="collision_shape_2d" parent="dialog_trigger_area" index="0"]
position = Vector2(0, -10.5)
shape = SubResource("RectangleShape2D_sgrqb") shape = SubResource("RectangleShape2D_sgrqb")
metadata/_edit_lock_ = true
[editable path="dialog_trigger_area"] [editable path="dialog_trigger_area"]

View File

@@ -6,6 +6,7 @@
transparent_bg = true transparent_bg = true
size = Vector2i(1537, 193) size = Vector2i(1537, 193)
visible = true visible = true
always_on_top = true
script = ExtResource("1_gdt1r") script = ExtResource("1_gdt1r")
[node name="v_box_container" type="VBoxContainer" parent="."] [node name="v_box_container" type="VBoxContainer" parent="."]
@@ -39,5 +40,8 @@ caret_blink = true
caret_blink_interval = 0.5 caret_blink_interval = 0.5
caret_force_displayed = true caret_force_displayed = true
[node name="cheatcode_timer" type="Timer" parent="."]
one_shot = true
[connection signal="popup_hide" from="." to="." method="OnPopupHide"] [connection signal="popup_hide" from="." to="." method="OnPopupHide"]
[connection signal="text_submitted" from="v_box_container/line_edit" to="." method="OnLineEditTextSubmitted"] [connection signal="text_submitted" from="v_box_container/line_edit" to="." method="OnLineEditTextSubmitted"]

View File

@@ -98,7 +98,7 @@ metadata/_edit_lock_ = true
[node name="ray_cast_2d" type="RayCast2D" parent="rotation_center"] [node name="ray_cast_2d" type="RayCast2D" parent="rotation_center"]
rotation = 3.14159 rotation = 3.14159
target_position = Vector2(-64, 0) target_position = Vector2(-32, 0)
collision_mask = 2 collision_mask = 2
hit_from_inside = true hit_from_inside = true
collide_with_areas = true collide_with_areas = true

View File

@@ -2,15 +2,15 @@
[ext_resource type="Texture2D" uid="uid://diwxy1fl5m02y" path="res://assets/textures/debug/debugitem_one64.png" id="1_2m632"] [ext_resource type="Texture2D" uid="uid://diwxy1fl5m02y" path="res://assets/textures/debug/debugitem_one64.png" id="1_2m632"]
[sub_resource type="CircleShape2D" id="CircleShape2D_2d5dy"] [sub_resource type="CircleShape2D" id="CircleShape2D_qgi6t"]
radius = 30.8058 radius = 33.1361
[node name="first_debug_tile" type="RigidBody2D"] [node name="rigid_body_2d" type="RigidBody2D"]
gravity_scale = 0.0 gravity_scale = 0.0
[node name="Sprite2D" type="Sprite2D" parent="."] [node name="Sprite2D" type="Sprite2D" parent="."]
position = Vector2(0, -4)
texture = ExtResource("1_2m632") texture = ExtResource("1_2m632")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="collision_shape_2d" type="CollisionShape2D" parent="."]
position = Vector2(-1, 4) shape = SubResource("CircleShape2D_qgi6t")
shape = SubResource("CircleShape2D_2d5dy")

View File

@@ -3,17 +3,20 @@ using System;
public partial class essential : Node public partial class essential : Node
{ {
public string currentController = Input.GetJoyName(0); public static string currentController = Input.GetJoyName(0);
public override void _Input(InputEvent @event) public override void _Input(InputEvent @event)
{ {
//Checks if using Keyboard or controller and giving out current controller //Checks if using Keyboard or controller. It gives out the current controller and changes cursor visibillity
if (@event is InputEventKey || @event is InputEventMouseButton || currentController == "") if (@event is InputEventKey || @event is InputEventMouseButton || @event is InputEventMouseMotion || currentController == "")
{
currentController = "PC"; 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); currentController = Input.GetJoyName(0);
console.Print("Current controller device: " + currentController); Input.MouseMode = Input.MouseModeEnum.Hidden;
} }
} }
public override void _Process(double delta) 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) if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() != "villager" || introducedVillager)
GetNode<Label>("box/name_label").Text = title; GetNode<Label>("box/name_label").Text = title;
if (GetParent().Name == "player") player.allowMovement = false;
player.allowMovement = false;
//Get first key //Get first key
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager") if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager")

View File

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