diff --git a/Sandbox.csproj.old b/Sandbox.csproj.old
deleted file mode 100644
index 6d96b26..0000000
--- a/Sandbox.csproj.old
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- net6.0
- true
-
-
-
-
-
\ No newline at end of file
diff --git a/Sandbox.csproj.old.1 b/Sandbox.csproj.old.1
deleted file mode 100644
index badc74b..0000000
--- a/Sandbox.csproj.old.1
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- net6.0
- true
-
-
-
-
-
\ No newline at end of file
diff --git a/Scenes/Blizzard.tscn b/Scenes/Blizzard.tscn
index be13045..f9b3282 100644
--- a/Scenes/Blizzard.tscn
+++ b/Scenes/Blizzard.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=5 format=3 uid="uid://ds2y8l8onrs4f"]
+[gd_scene load_steps=4 format=3 uid="uid://ds2y8l8onrs4f"]
[ext_resource type="Script" path="res://Scripts/Blizzard.cs" id="1_rqtsv"]
@@ -9,24 +9,19 @@ albedo_color = Color(0.137255, 0.447059, 0.796078, 1)
radial_segments = 4
rings = 1
-[sub_resource type="SphereShape3D" id="SphereShape3D_xe0sc"]
-
[node name="Blizzard" type="Node3D"]
script = ExtResource("1_rqtsv")
+Cooldown = 1.0
_projectileSpeed = 10.0
-[node name="RigidBody3D" type="RigidBody3D" parent="."]
-collision_layer = 0
-collision_mask = 16
-mass = 0.01
-gravity_scale = 0.0
-
-[node name="MeshInstance3D" type="MeshInstance3D" parent="RigidBody3D"]
+[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.11373, 0)
material_override = SubResource("StandardMaterial3D_pd0mo")
mesh = SubResource("SphereMesh_g0pbs")
-skeleton = NodePath("../..")
-[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D"]
-transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.11958, 0)
-shape = SubResource("SphereShape3D_xe0sc")
+[node name="TimeToLive" type="Timer" parent="."]
+wait_time = 2.5
+one_shot = true
+autostart = true
+
+[connection signal="timeout" from="TimeToLive" to="." method="OnTimeToLiveTimeout"]
diff --git a/Scenes/Main.tscn b/Scenes/Main.tscn
index 936a009..d0462ab 100644
--- a/Scenes/Main.tscn
+++ b/Scenes/Main.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=17 format=3 uid="uid://bcsgd8vxy43g2"]
+[gd_scene load_steps=15 format=3 uid="uid://bcsgd8vxy43g2"]
[ext_resource type="Script" path="res://Scripts/Player.cs" id="1_8dc05"]
[ext_resource type="PackedScene" uid="uid://d20uxkpid4ynd" path="res://Models/vivi1.gltf" id="1_mqt2m"]
@@ -7,6 +7,7 @@
[ext_resource type="Script" path="res://Scripts/CameraSystem.cs" id="3_5ecw2"]
[ext_resource type="PackedScene" uid="uid://c13g5orvyhy1p" path="res://Models/moogle.gltf" id="4_dckjs"]
[ext_resource type="Script" path="res://Scripts/NPCFollow.cs" id="4_o5mpp"]
+[ext_resource type="Script" path="res://Scripts/DebugText.cs" id="8_ksx3s"]
[ext_resource type="ArrayMesh" uid="uid://35saq7eyk446" path="res://Models/Cookie.obj" id="8_8xb3w"]
[sub_resource type="BoxShape3D" id="BoxShape3D_8verc"]
@@ -127,3 +128,10 @@ skeleton = NodePath("../..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="CharacterBody3D"]
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, -8.04457, 0.690081, -1.66095)
shape = SubResource("CapsuleShape3D_y33ih")
+
+[node name="DebugUI" type="Node2D" parent="."]
+
+[node name="TextEdit" type="TextEdit" parent="DebugUI"]
+offset_right = 3468.0
+offset_bottom = 777.0
+script = ExtResource("8_ksx3s")
diff --git a/Scenes/fireball.tscn b/Scenes/fireball.tscn
index 9da2786..2cffca3 100644
--- a/Scenes/fireball.tscn
+++ b/Scenes/fireball.tscn
@@ -10,9 +10,16 @@ albedo_color = Color(0.666667, 0, 0.239216, 1)
[node name="Fireball" type="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.916843, 0)
script = ExtResource("1_4ipg4")
+Cooldown = 0.3
_projectileSpeed = 20.0
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.00392, 0)
material_override = SubResource("StandardMaterial3D_jxwqo")
mesh = SubResource("SphereMesh_6bhr7")
+
+[node name="TimeToLive" type="Timer" parent="."]
+one_shot = true
+autostart = true
+
+[connection signal="timeout" from="TimeToLive" to="." method="OnTimeToLiveTimeout"]
diff --git a/Scripts/Blizzard.cs b/Scripts/Blizzard.cs
index cc8923e..cb756f5 100644
--- a/Scripts/Blizzard.cs
+++ b/Scripts/Blizzard.cs
@@ -1,7 +1,9 @@
+using Godot;
+
public partial class Blizzard : Projectile
{
- public override void _PhysicsProcess(double delta)
- {
- Translate(new Godot.Vector3(0, 0, Speed * (float)delta));
- }
+ public override void _PhysicsProcess(double delta)
+ {
+ Translate(new Vector3(0, 0, Speed * (float)delta));
+ }
}
diff --git a/Scripts/Fireball.cs b/Scripts/Fireball.cs
index 422c4da..a8519bc 100644
--- a/Scripts/Fireball.cs
+++ b/Scripts/Fireball.cs
@@ -2,8 +2,8 @@ using Godot;
public partial class Fireball : Projectile
{
- public override void _PhysicsProcess(double delta)
- {
- Translate(new Vector3(0, 0, Speed * (float)delta));
- }
+ public override void _PhysicsProcess(double delta)
+ {
+ Translate(new Vector3(0, 0, Speed * (float)delta));
+ }
}
diff --git a/Scripts/Player.cs b/Scripts/Player.cs
index f85c7fe..dffac5c 100644
--- a/Scripts/Player.cs
+++ b/Scripts/Player.cs
@@ -4,93 +4,102 @@ using Godot.Collections;
public partial class Player : CharacterBody3D
{
- [Export]
- private float _speed = 5.0f;
- [Export]
- private float _jumpVelocity = 4.5f;
- [Export]
- private float _sensitivityHorizontal = 0.05f;
- [Export]
- private float _sensitivityVertical = 0.05f;
- [Export]
- private float _joystickDeadZone = 0.5f;
- [Export]
- private Array _projectiles;
+ [Export]
+ private float _speed = 5.0f;
+ [Export]
+ private float _jumpVelocity = 4.5f;
+ [Export]
+ private float _sensitivityHorizontal = 0.05f;
+ [Export]
+ private float _sensitivityVertical = 0.05f;
+ [Export]
+ private float _joystickDeadZone = 0.5f;
+ [Export]
+ private Array _projectiles;
- private Node3D _cameraMount;
- private Node3D _pivot;
- private Node3D _camera;
- private PackedScene _weaponType;
+ public bool CanShoot { get; private set; }
- // Get the _gravity from the project settings to be synced with RigidBody nodes.
- public float _gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
+ private Node3D _cameraMount;
+ private Node3D _pivot;
+ private Node3D _camera;
+ private PackedScene _weaponType;
- public override void _Ready()
- {
- Input.MouseMode = Input.MouseModeEnum.Captured;
- _cameraMount = GetNode("/root/Main/Player/CameraMount");
- _camera = GetNode("/root/Main/Player/CameraMount/Camera");
- _pivot = GetNode("/root/Main/Player/Pivot");
- _weaponType = _projectiles.First();
- }
+ // Get the _gravity from the project settings to be synced with RigidBody nodes.
+ public float _gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
+
+ public override void _Ready()
+ {
+ Input.MouseMode = Input.MouseModeEnum.Captured;
+ _cameraMount = GetNode("/root/Main/Player/CameraMount");
+ _camera = GetNode("/root/Main/Player/CameraMount/Camera");
+ _pivot = GetNode("/root/Main/Player/Pivot");
+ _weaponType = _projectiles.First();
+ CanShoot = true;
+ }
public override void _Process(double delta)
{
- if (Input.IsActionJustPressed("quit"))
- GetTree().Quit();
- if (Input.IsActionJustPressed("shoot"))
- Shoot();
- if (Input.IsActionJustPressed("switch"))
- SwitchWeaponType();
+ if (Input.IsActionJustPressed("quit"))
+ GetTree().Quit();
+ if (Input.IsActionJustPressed("shoot") && CanShoot)
+ Shoot();
+ if (Input.IsActionJustPressed("switch"))
+ SwitchWeaponType();
}
public override void _PhysicsProcess(double delta)
- {
- var gravityDelta = _gravity * (float)delta;
- var velocity = CalculateMovement(Velocity, Transform, gravityDelta);
+ {
+ var gravityDelta = _gravity * (float)delta;
+ var velocity = CalculateMovement(Velocity, Transform, gravityDelta);
- Velocity = velocity;
- MoveAndSlide();
- }
+ Velocity = velocity;
+ MoveAndSlide();
+ }
- private void Shoot()
- {
- GD.Print("Shoot");
- var projectile = _weaponType.Instantiate();
- projectile.Position = Position;
- projectile.Rotation = Rotation;
- GetParent().AddChild(projectile);
- }
+ private async void Shoot()
+ {
+ GD.Print("Shoot");
+ var projectile = _weaponType.Instantiate();
+ projectile.Position = Position;
+ projectile.Rotation = Rotation;
+ GetParent().AddChild(projectile);
+ CanShoot = false;
+ await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
+ CanShoot = true;
+ }
- private void SwitchWeaponType()
- {
- var index = _projectiles.IndexOf(_weaponType);
- _weaponType = _projectiles[(index + 1) % _projectiles.Count];
+ private async void SwitchWeaponType()
+ {
+ var index = _projectiles.IndexOf(_weaponType);
+ _weaponType = _projectiles[(index + 1) % _projectiles.Count];
+ CanShoot = false;
+ await ToSignal(GetTree().CreateTimer(.5), "timeout");
+ CanShoot = true;
- }
+ }
- private Vector3 CalculateMovement(Vector3 velocity, Transform3D transform, float gravityDelta)
- {
- if (!IsOnFloor())
- velocity.Y -= gravityDelta;
+ private Vector3 CalculateMovement(Vector3 velocity, Transform3D transform, float gravityDelta)
+ {
+ if (!IsOnFloor())
+ velocity.Y -= gravityDelta;
- if (Input.IsActionJustPressed("jump") && IsOnFloor())
- velocity.Y = _jumpVelocity;
+ if (Input.IsActionJustPressed("jump") && IsOnFloor())
+ velocity.Y = _jumpVelocity;
- Vector2 inputDir = Input.GetVector("right", "left", "back", "forward");
- Vector3 direction = (transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
- if (direction != Vector3.Zero)
- {
- velocity.X = direction.X * _speed;
- velocity.Z = direction.Z * _speed;
- GetNode("Pivot").LookAt(Position + direction.Normalized(), Vector3.Up);
- }
- else
- {
- velocity.X = Mathf.MoveToward(Velocity.X, 0, _speed);
- velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed);
- }
+ Vector2 inputDir = Input.GetVector("right", "left", "back", "forward");
+ Vector3 direction = (transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
+ if (direction != Vector3.Zero)
+ {
+ velocity.X = direction.X * _speed;
+ velocity.Z = direction.Z * _speed;
+ GetNode("Pivot").LookAt(Position + direction.Normalized(), Vector3.Up);
+ }
+ else
+ {
+ velocity.X = Mathf.MoveToward(Velocity.X, 0, _speed);
+ velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed);
+ }
- return velocity;
- }
+ return velocity;
+ }
}
diff --git a/Scripts/Projectile.cs b/Scripts/Projectile.cs
index 2f4e2a7..f96b1b3 100644
--- a/Scripts/Projectile.cs
+++ b/Scripts/Projectile.cs
@@ -2,13 +2,21 @@
public partial class Projectile : Node3D
{
- [Export]
- private float _projectileSpeed = 0.1f;
+ [Export]
+ public double Cooldown { get; protected set; }
- public override void _Ready()
- {
- Speed = _projectileSpeed;
- }
+ [Export]
+ private float _projectileSpeed = 0.1f;
- public float Speed { get; private set; }
+ public override void _Ready()
+ {
+ Speed = _projectileSpeed;
+ }
+
+ public float Speed { get; private set; }
+
+ public void OnTimeToLiveTimeout()
+ {
+ QueueFree();
+ }
}
diff --git a/Scripts/WeaponType.cs b/Scripts/WeaponType.cs
deleted file mode 100644
index 8016611..0000000
--- a/Scripts/WeaponType.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Sandbox.Scripts
-{
- internal enum WeaponType
- {
- Fire = 0,
- Blizzard = 1
- }
-}