Compare commits
1 Commits
f15e1031bd
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2bb5ec656 |
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Godot.NET.Sdk/4.1.1">
|
<Project Sdk="Godot.NET.Sdk/4.0.3">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
@@ -6,4 +6,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Scenes\" />
|
<Folder Include="Scenes\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Chickensoft.AutoInject" Version="1.3.0" />
|
||||||
|
<PackageReference Include="Chickensoft.SuperNodes" Version="1.2.1" />
|
||||||
|
<PackageReference Include="Chickensoft.SuperNodes.Types" Version="1.2.1" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://ds2y8l8onrs4f"]
|
[gd_scene load_steps=5 format=3 uid="uid://ds2y8l8onrs4f"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/Blizzard.cs" id="1_rqtsv"]
|
[ext_resource type="Script" path="res://Scripts/Blizzard.cs" id="1_rqtsv"]
|
||||||
|
|
||||||
@@ -9,19 +9,24 @@ albedo_color = Color(0.137255, 0.447059, 0.796078, 1)
|
|||||||
radial_segments = 4
|
radial_segments = 4
|
||||||
rings = 1
|
rings = 1
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_xe0sc"]
|
||||||
|
|
||||||
[node name="Blizzard" type="Node3D"]
|
[node name="Blizzard" type="Node3D"]
|
||||||
script = ExtResource("1_rqtsv")
|
script = ExtResource("1_rqtsv")
|
||||||
Cooldown = 1.0
|
|
||||||
_projectileSpeed = 10.0
|
_projectileSpeed = 10.0
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
[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"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.11373, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.11373, 0)
|
||||||
material_override = SubResource("StandardMaterial3D_pd0mo")
|
material_override = SubResource("StandardMaterial3D_pd0mo")
|
||||||
mesh = SubResource("SphereMesh_g0pbs")
|
mesh = SubResource("SphereMesh_g0pbs")
|
||||||
|
skeleton = NodePath("../..")
|
||||||
|
|
||||||
[node name="TimeToLive" type="Timer" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D"]
|
||||||
wait_time = 2.5
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.11958, 0)
|
||||||
one_shot = true
|
shape = SubResource("SphereShape3D_xe0sc")
|
||||||
autostart = true
|
|
||||||
|
|
||||||
[connection signal="timeout" from="TimeToLive" to="." method="OnTimeToLiveTimeout"]
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=18 format=3 uid="uid://bcsgd8vxy43g2"]
|
[gd_scene load_steps=19 format=3 uid="uid://bcsgd8vxy43g2"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/Player.cs" id="1_8dc05"]
|
[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"]
|
[ext_resource type="PackedScene" uid="uid://d20uxkpid4ynd" path="res://Models/vivi1.gltf" id="1_mqt2m"]
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
[ext_resource type="Script" path="res://Scripts/NPCFollow.cs" id="4_o5mpp"]
|
[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="Script" path="res://Scripts/DebugText.cs" id="8_ksx3s"]
|
||||||
[ext_resource type="ArrayMesh" uid="uid://35saq7eyk446" path="res://Models/Cookie.obj" id="8_p45nj"]
|
[ext_resource type="ArrayMesh" uid="uid://35saq7eyk446" path="res://Models/Cookie.obj" id="8_p45nj"]
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Enemy.cs" id="9_0gfg2"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_8verc"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_8verc"]
|
||||||
size = Vector3(100, 2, 100)
|
size = Vector3(100, 2, 100)
|
||||||
@@ -116,22 +117,27 @@ material_override = SubResource("StandardMaterial3D_ultw4")
|
|||||||
use_collision = true
|
use_collision = true
|
||||||
size = Vector3(15.0266, 4.74018, 1)
|
size = Vector3(15.0266, 4.74018, 1)
|
||||||
|
|
||||||
[node name="CharacterBody3D" type="CharacterBody3D" parent="."]
|
|
||||||
collision_layer = 0
|
|
||||||
collision_mask = 16
|
|
||||||
|
|
||||||
[node name="Cookie" type="MeshInstance3D" parent="CharacterBody3D"]
|
|
||||||
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, -8.04457, -0.130408, -1.66095)
|
|
||||||
mesh = ExtResource("8_p45nj")
|
|
||||||
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="DebugUI" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="TextEdit" type="TextEdit" parent="DebugUI"]
|
[node name="TextEdit" type="TextEdit" parent="DebugUI"]
|
||||||
offset_right = 3468.0
|
offset_right = 3468.0
|
||||||
offset_bottom = 777.0
|
offset_bottom = 777.0
|
||||||
script = ExtResource("8_ksx3s")
|
script = ExtResource("8_ksx3s")
|
||||||
|
|
||||||
|
[node name="RigidBody3D" type="RigidBody3D" parent="."]
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 17
|
||||||
|
max_contacts_reported = 10
|
||||||
|
contact_monitor = true
|
||||||
|
script = ExtResource("9_0gfg2")
|
||||||
|
|
||||||
|
[node name="Cookie" type="MeshInstance3D" parent="RigidBody3D"]
|
||||||
|
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, -8.04457, -0.130408, -1.66095)
|
||||||
|
mesh = ExtResource("8_p45nj")
|
||||||
|
skeleton = NodePath("../..")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D"]
|
||||||
|
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, -8.04457, 0.690081, -1.66095)
|
||||||
|
shape = SubResource("CapsuleShape3D_y33ih")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="RigidBody3D" to="RigidBody3D" method="OnHit"]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://dg7731nx22ewp"]
|
[gd_scene load_steps=5 format=3 uid="uid://dg7731nx22ewp"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/Fireball.cs" id="1_4ipg4"]
|
[ext_resource type="Script" path="res://Scripts/Fireball.cs" id="1_4ipg4"]
|
||||||
|
|
||||||
@@ -7,19 +7,26 @@ albedo_color = Color(0.666667, 0, 0.239216, 1)
|
|||||||
|
|
||||||
[sub_resource type="SphereMesh" id="SphereMesh_6bhr7"]
|
[sub_resource type="SphereMesh" id="SphereMesh_6bhr7"]
|
||||||
|
|
||||||
[node name="Fireball" type="Node3D"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_64t08"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.916843, 0)
|
radius = 0.51754
|
||||||
script = ExtResource("1_4ipg4")
|
|
||||||
Cooldown = 0.3
|
|
||||||
_projectileSpeed = 20.0
|
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
[node name="RigidBody3D" type="RigidBody3D"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.00392, 0)
|
collision_layer = 16
|
||||||
|
gravity_scale = 0.0
|
||||||
|
max_contacts_reported = 5
|
||||||
|
contact_monitor = true
|
||||||
|
script = ExtResource("1_4ipg4")
|
||||||
|
_projectileSpeed = 10.0
|
||||||
|
|
||||||
|
[node name="Fireball" type="Node3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.916843, 0)
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="Fireball"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0870771, 0)
|
||||||
material_override = SubResource("StandardMaterial3D_jxwqo")
|
material_override = SubResource("StandardMaterial3D_jxwqo")
|
||||||
mesh = SubResource("SphereMesh_6bhr7")
|
mesh = SubResource("SphereMesh_6bhr7")
|
||||||
|
skeleton = NodePath("../../..")
|
||||||
|
|
||||||
[node name="TimeToLive" type="Timer" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
one_shot = true
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.00448, 0.081282)
|
||||||
autostart = true
|
shape = SubResource("SphereShape3D_64t08")
|
||||||
|
|
||||||
[connection signal="timeout" from="TimeToLive" to="." method="OnTimeToLiveTimeout"]
|
|
||||||
|
|||||||
@@ -2,49 +2,49 @@ using Godot;
|
|||||||
|
|
||||||
public partial class CameraSystem : SpringArm3D
|
public partial class CameraSystem : SpringArm3D
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
private float _sensitivityHorizontal = 0.05f;
|
private float _sensitivityHorizontal = 0.05f;
|
||||||
[Export]
|
[Export]
|
||||||
private float _sensitivityVertical = 0.05f;
|
private float _sensitivityVertical = 0.05f;
|
||||||
[Export]
|
[Export]
|
||||||
private float _joystickDeadZone = 0.5f;
|
private float _joystickDeadZone = 0.5f;
|
||||||
|
|
||||||
private Node3D _pivot;
|
private Node3D _pivot;
|
||||||
private CharacterBody3D _characterBody;
|
private CharacterBody3D _characterBody;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_pivot = GetNode<Node3D>("/root/Main/Player/Pivot");
|
_pivot = GetNode<Node3D>("/root/Main/Player/Pivot");
|
||||||
_characterBody = GetNode<CharacterBody3D>("/root/Main/Player");
|
_characterBody = GetNode<CharacterBody3D>("/root/Main/Player");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
var joyRightX = Input.GetJoyAxis(0, JoyAxis.RightX);
|
var joyRightX = Input.GetJoyAxis(0, JoyAxis.RightX);
|
||||||
var joyRightY = Input.GetJoyAxis(0, JoyAxis.RightY);
|
var joyRightY = Input.GetJoyAxis(0, JoyAxis.RightY);
|
||||||
|
|
||||||
if (Mathf.Abs(joyRightX) > _joystickDeadZone)
|
if (Mathf.Abs(joyRightX) > _joystickDeadZone)
|
||||||
{
|
{
|
||||||
var rotateAmount = joyRightX * _sensitivityHorizontal;
|
var rotateAmount = joyRightX * _sensitivityHorizontal;
|
||||||
_characterBody.RotateY(-rotateAmount);
|
_characterBody.RotateY(-rotateAmount);
|
||||||
_pivot.RotateY(rotateAmount);
|
_pivot.RotateY(rotateAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Mathf.Abs(joyRightY) > _joystickDeadZone)
|
if (Mathf.Abs(joyRightY) > _joystickDeadZone)
|
||||||
{
|
{
|
||||||
RotateX(joyRightY * _sensitivityVertical);
|
RotateX(joyRightY * _sensitivityVertical);
|
||||||
Rotation = new Vector3(Mathf.Clamp(Rotation.X, -0.7f, 0.7f), Rotation.Y, Rotation.Z);
|
Rotation = new Vector3(Mathf.Clamp(Rotation.X, -0.7f, 0.7f), Rotation.Y, Rotation.Z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Input(InputEvent @event)
|
public override void _Input(InputEvent @event)
|
||||||
{
|
{
|
||||||
if (@event is InputEventMouseMotion mouseMotion)
|
if (@event is InputEventMouseMotion mouseMotion)
|
||||||
{
|
{
|
||||||
_characterBody.RotateY(Mathf.DegToRad(-mouseMotion.Relative.X * _sensitivityHorizontal));
|
_characterBody.RotateY(Mathf.DegToRad(-mouseMotion.Relative.X * _sensitivityHorizontal));
|
||||||
_pivot.RotateY(Mathf.DegToRad(mouseMotion.Relative.X * _sensitivityHorizontal));
|
_pivot.RotateY(Mathf.DegToRad(mouseMotion.Relative.X * _sensitivityHorizontal));
|
||||||
RotateX(Mathf.DegToRad(mouseMotion.Relative.Y * _sensitivityVertical));
|
RotateX(Mathf.DegToRad(mouseMotion.Relative.Y * _sensitivityVertical));
|
||||||
Rotation = new Vector3(Mathf.Clamp(Rotation.X, -0.7f, 0.7f), Rotation.Y, Rotation.Z);
|
Rotation = new Vector3(Mathf.Clamp(Rotation.X, -0.7f, 0.7f), Rotation.Y, Rotation.Z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
[remap]
|
|
||||||
|
|
||||||
importer="wavefront_obj"
|
|
||||||
importer_version=1
|
|
||||||
type="Mesh"
|
|
||||||
uid="uid://cj246dmena0if"
|
|
||||||
path="res://.godot/imported/Cookie.obj-9c7fa2a3d48746d9f2fd322d3854502d.mesh"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
files=["res://.godot/imported/Cookie.obj-9c7fa2a3d48746d9f2fd322d3854502d.mesh"]
|
|
||||||
|
|
||||||
source_file="res://Scripts/Cookie.obj"
|
|
||||||
dest_files=["res://.godot/imported/Cookie.obj-9c7fa2a3d48746d9f2fd322d3854502d.mesh", "res://.godot/imported/Cookie.obj-9c7fa2a3d48746d9f2fd322d3854502d.mesh"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
generate_tangents=true
|
|
||||||
scale_mesh=Vector3(1, 1, 1)
|
|
||||||
offset_mesh=Vector3(0, 0, 0)
|
|
||||||
optimize_mesh=true
|
|
||||||
13
Scripts/Enemy.cs
Normal file
13
Scripts/Enemy.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class Enemy : Node
|
||||||
|
{
|
||||||
|
public void OnHit(Variant body)
|
||||||
|
{
|
||||||
|
if (body.Obj is Projectile)
|
||||||
|
{
|
||||||
|
GD.Print("Hit");
|
||||||
|
QueueFree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,8 @@ using Godot;
|
|||||||
|
|
||||||
public partial class Fireball : Projectile
|
public partial class Fireball : Projectile
|
||||||
{
|
{
|
||||||
public override void _PhysicsProcess(double delta)
|
public override void _PhysicsProcess(double delta)
|
||||||
{
|
{
|
||||||
Translate(new Vector3(0, 0, Speed * (float)delta));
|
Translate(new Vector3(0, 0, Speed * (float)delta));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,102 +4,102 @@ using Godot.Collections;
|
|||||||
|
|
||||||
public partial class Player : CharacterBody3D
|
public partial class Player : CharacterBody3D
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
private float _speed = 5.0f;
|
private float _speed = 5.0f;
|
||||||
[Export]
|
[Export]
|
||||||
private float _jumpVelocity = 4.5f;
|
private float _jumpVelocity = 4.5f;
|
||||||
[Export]
|
[Export]
|
||||||
private float _sensitivityHorizontal = 0.05f;
|
private float _sensitivityHorizontal = 0.05f;
|
||||||
[Export]
|
[Export]
|
||||||
private float _sensitivityVertical = 0.05f;
|
private float _sensitivityVertical = 0.05f;
|
||||||
[Export]
|
[Export]
|
||||||
private float _joystickDeadZone = 0.5f;
|
private float _joystickDeadZone = 0.5f;
|
||||||
[Export]
|
[Export]
|
||||||
private Array<PackedScene> _projectiles;
|
private Array<PackedScene> _projectiles;
|
||||||
|
|
||||||
public bool CanShoot { get; private set; }
|
public bool CanShoot { get; private set; }
|
||||||
|
|
||||||
private Node3D _cameraMount;
|
private Node3D _cameraMount;
|
||||||
private Node3D _pivot;
|
private Node3D _pivot;
|
||||||
private Node3D _camera;
|
private Node3D _camera;
|
||||||
private PackedScene _weaponType;
|
private PackedScene _weaponType;
|
||||||
|
|
||||||
// Get the _gravity from the project settings to be synced with RigidBody nodes.
|
// Get the _gravity from the project settings to be synced with RigidBody nodes.
|
||||||
public float _gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
|
public float _gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
Input.MouseMode = Input.MouseModeEnum.Captured;
|
Input.MouseMode = Input.MouseModeEnum.Captured;
|
||||||
_cameraMount = GetNode<Node3D>("/root/Main/Player/CameraMount");
|
_cameraMount = GetNode<Node3D>("/root/Main/Player/CameraMount");
|
||||||
_camera = GetNode<Node3D>("/root/Main/Player/CameraMount/Camera");
|
_camera = GetNode<Node3D>("/root/Main/Player/CameraMount/Camera");
|
||||||
_pivot = GetNode<Node3D>("/root/Main/Player/Pivot");
|
_pivot = GetNode<Node3D>("/root/Main/Player/Pivot");
|
||||||
_weaponType = _projectiles.First();
|
_weaponType = _projectiles.First();
|
||||||
CanShoot = true;
|
CanShoot = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
if (Input.IsActionJustPressed("quit"))
|
if (Input.IsActionJustPressed("quit"))
|
||||||
GetTree().Quit();
|
GetTree().Quit();
|
||||||
if (Input.IsActionJustPressed("shoot") && CanShoot)
|
if (Input.IsActionJustPressed("shoot") && CanShoot)
|
||||||
Shoot();
|
Shoot();
|
||||||
if (Input.IsActionJustPressed("switch"))
|
if (Input.IsActionJustPressed("switch"))
|
||||||
SwitchWeaponType();
|
SwitchWeaponType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _PhysicsProcess(double delta)
|
public override void _PhysicsProcess(double delta)
|
||||||
{
|
{
|
||||||
var gravityDelta = _gravity * (float)delta;
|
var gravityDelta = _gravity * (float)delta;
|
||||||
var velocity = CalculateMovement(Velocity, Transform, gravityDelta);
|
var velocity = CalculateMovement(Velocity, Transform, gravityDelta);
|
||||||
|
|
||||||
Velocity = velocity;
|
Velocity = velocity;
|
||||||
MoveAndSlide();
|
MoveAndSlide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Shoot()
|
private async void Shoot()
|
||||||
{
|
{
|
||||||
GD.Print("Shoot");
|
GD.Print("Shoot");
|
||||||
var projectile = _weaponType.Instantiate<Projectile>();
|
var projectile = _weaponType.Instantiate<Projectile>();
|
||||||
projectile.Position = Position;
|
projectile.Position = Position;
|
||||||
projectile.Rotation = Rotation;
|
projectile.Rotation = Rotation;
|
||||||
GetParent().AddChild(projectile);
|
GetParent().AddChild(projectile);
|
||||||
CanShoot = false;
|
CanShoot = false;
|
||||||
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
|
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
|
||||||
CanShoot = true;
|
CanShoot = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void SwitchWeaponType()
|
private async void SwitchWeaponType()
|
||||||
{
|
{
|
||||||
var index = _projectiles.IndexOf(_weaponType);
|
var index = _projectiles.IndexOf(_weaponType);
|
||||||
_weaponType = _projectiles[(index + 1) % _projectiles.Count];
|
_weaponType = _projectiles[(index + 1) % _projectiles.Count];
|
||||||
CanShoot = false;
|
CanShoot = false;
|
||||||
await ToSignal(GetTree().CreateTimer(.5), "timeout");
|
await ToSignal(GetTree().CreateTimer(.5), "timeout");
|
||||||
CanShoot = true;
|
CanShoot = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3 CalculateMovement(Vector3 velocity, Transform3D transform, float gravityDelta)
|
private Vector3 CalculateMovement(Vector3 velocity, Transform3D transform, float gravityDelta)
|
||||||
{
|
{
|
||||||
if (!IsOnFloor())
|
if (!IsOnFloor())
|
||||||
velocity.Y -= gravityDelta;
|
velocity.Y -= gravityDelta;
|
||||||
|
|
||||||
if (Input.IsActionJustPressed("jump") && IsOnFloor())
|
if (Input.IsActionJustPressed("jump") && IsOnFloor())
|
||||||
velocity.Y = _jumpVelocity;
|
velocity.Y = _jumpVelocity;
|
||||||
|
|
||||||
Vector2 inputDir = Input.GetVector("right", "left", "back", "forward");
|
Vector2 inputDir = Input.GetVector("right", "left", "back", "forward");
|
||||||
Vector3 direction = (transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
|
Vector3 direction = (transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
|
||||||
if (direction != Vector3.Zero)
|
if (direction != Vector3.Zero)
|
||||||
{
|
{
|
||||||
velocity.X = direction.X * _speed;
|
velocity.X = direction.X * _speed;
|
||||||
velocity.Z = direction.Z * _speed;
|
velocity.Z = direction.Z * _speed;
|
||||||
GetNode<Node3D>("Pivot").LookAt(Position + direction.Normalized(), Vector3.Up);
|
GetNode<Node3D>("Pivot").LookAt(Position + direction.Normalized(), Vector3.Up);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
velocity.X = Mathf.MoveToward(Velocity.X, 0, _speed);
|
velocity.X = Mathf.MoveToward(Velocity.X, 0, _speed);
|
||||||
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed);
|
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return velocity;
|
return velocity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,21 @@
|
|||||||
|
|
||||||
public partial class Projectile : Node3D
|
public partial class Projectile : Node3D
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
public double Cooldown { get; protected set; }
|
public double Cooldown { get; protected set; }
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
private float _projectileSpeed = 0.1f;
|
private float _projectileSpeed = 100f;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
Speed = _projectileSpeed;
|
Speed = _projectileSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float Speed { get; private set; }
|
public float Speed { get; private set; }
|
||||||
|
|
||||||
public void OnTimeToLiveTimeout()
|
public void OnTimeToLiveTimeout()
|
||||||
{
|
{
|
||||||
QueueFree();
|
QueueFree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user