Big brain time
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Godot.NET.Sdk/4.0.3">
|
<Project Sdk="Godot.NET.Sdk/4.1.0">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
|||||||
9
Sandbox.csproj.old
Normal file
9
Sandbox.csproj.old
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Godot.NET.Sdk/4.0.3">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Scenes\" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
18
Scenes/Blizzard.tscn
Normal file
18
Scenes/Blizzard.tscn
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://ds2y8l8onrs4f"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Blizzard.cs" id="1_rqtsv"]
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pd0mo"]
|
||||||
|
albedo_color = Color(0.137255, 0.447059, 0.796078, 1)
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id="SphereMesh_g0pbs"]
|
||||||
|
radial_segments = 4
|
||||||
|
rings = 1
|
||||||
|
|
||||||
|
[node name="Blizzard" type="Node3D"]
|
||||||
|
script = ExtResource("1_rqtsv")
|
||||||
|
|
||||||
|
[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")
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
[gd_scene load_steps=16 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="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"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dg7731nx22ewp" path="res://Scenes/fireball.tscn" id="2_bsaqu"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ds2y8l8onrs4f" path="res://Scenes/Blizzard.tscn" id="3_4rglj"]
|
||||||
[ext_resource type="Script" path="res://Scripts/CameraSystem.cs" id="3_5ecw2"]
|
[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="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/NPCFollow.cs" id="4_o5mpp"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bwku8f676eq6j" path="res://Materials/Textures/caaf021ecac0f417e167b9184d45ae8e.png" id="6_7wayf"]
|
|
||||||
[ext_resource type="Script" path="res://Scripts/Fireball.cs" id="7_mkgs3"]
|
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_8verc"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_8verc"]
|
||||||
size = Vector3(100, 2, 100)
|
size = Vector3(100, 2, 100)
|
||||||
@@ -31,17 +31,6 @@ albedo_color = Color(0.509804, 0.584314, 1, 1)
|
|||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ultw4"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ultw4"]
|
||||||
albedo_color = Color(1, 1, 0, 1)
|
albedo_color = Color(1, 1, 0, 1)
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_njysa"]
|
|
||||||
cull_mode = 1
|
|
||||||
shading_mode = 0
|
|
||||||
specular_mode = 1
|
|
||||||
vertex_color_use_as_albedo = true
|
|
||||||
albedo_texture = ExtResource("6_7wayf")
|
|
||||||
billboard_mode = 3
|
|
||||||
particles_anim_h_frames = 1
|
|
||||||
particles_anim_v_frames = 1
|
|
||||||
particles_anim_loop = false
|
|
||||||
|
|
||||||
[node name="Main" type="Node"]
|
[node name="Main" type="Node"]
|
||||||
|
|
||||||
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||||
@@ -63,6 +52,7 @@ collision_layer = 2
|
|||||||
script = ExtResource("1_8dc05")
|
script = ExtResource("1_8dc05")
|
||||||
_sensitivityHorizontal = 0.01
|
_sensitivityHorizontal = 0.01
|
||||||
_sensitivityVertical = 0.01
|
_sensitivityVertical = 0.01
|
||||||
|
_projectiles = Array[PackedScene]([ExtResource("2_bsaqu"), ExtResource("3_4rglj")])
|
||||||
|
|
||||||
[node name="Pivot" type="Node3D" parent="Player"]
|
[node name="Pivot" type="Node3D" parent="Player"]
|
||||||
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0, 0)
|
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0, 0)
|
||||||
@@ -119,13 +109,3 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.54678, 0.383205, 4.07192)
|
|||||||
material_override = SubResource("StandardMaterial3D_ultw4")
|
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="Particles" type="Node3D" parent="."]
|
|
||||||
visible = false
|
|
||||||
|
|
||||||
[node name="Fireball" type="CSGSphere3D" parent="Particles"]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.07254, -1.49094)
|
|
||||||
radial_segments = 5
|
|
||||||
rings = 20
|
|
||||||
material = SubResource("StandardMaterial3D_njysa")
|
|
||||||
script = ExtResource("7_mkgs3")
|
|
||||||
|
|||||||
17
Scenes/fireball.tscn
Normal file
17
Scenes/fireball.tscn
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://dg7731nx22ewp"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Fireball.cs" id="1_4ipg4"]
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_jxwqo"]
|
||||||
|
albedo_color = Color(0.666667, 0, 0.239216, 1)
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id="SphereMesh_6bhr7"]
|
||||||
|
|
||||||
|
[node name="Fireball" type="Node3D"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.916843, 0)
|
||||||
|
script = ExtResource("1_4ipg4")
|
||||||
|
|
||||||
|
[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")
|
||||||
9
Scripts/Blizzard.cs
Normal file
9
Scripts/Blizzard.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class Blizzard : Projectile
|
||||||
|
{
|
||||||
|
public override void _PhysicsProcess(double delta)
|
||||||
|
{
|
||||||
|
Translate(new Vector3(0, 0, -Speed));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
public partial class Fireball : CsgSphere3D
|
public partial class Fireball : Projectile
|
||||||
{
|
{
|
||||||
private float _speed = 80f;
|
public override void _PhysicsProcess(double delta)
|
||||||
|
{
|
||||||
public override void _PhysicsProcess(double delta)
|
Translate(new Vector3(0, 0, -Speed));
|
||||||
{
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,82 +1,93 @@
|
|||||||
|
using System.Linq;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
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]
|
||||||
|
private Array<PackedScene> _projectiles;
|
||||||
|
|
||||||
private Node3D _cameraMount;
|
private Node3D _cameraMount;
|
||||||
private Node3D _pivot;
|
private Node3D _pivot;
|
||||||
|
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");
|
||||||
_pivot = GetNode<Node3D>("/root/Main/Player/Pivot");
|
_pivot = GetNode<Node3D>("/root/Main/Player/Pivot");
|
||||||
}
|
_weaponType = _projectiles.First();
|
||||||
|
}
|
||||||
|
|
||||||
public override void _UnhandledInput(InputEvent @event)
|
public override void _UnhandledInput(InputEvent @event)
|
||||||
{
|
{
|
||||||
if (Input.IsActionJustPressed("quit"))
|
if (Input.IsActionJustPressed("quit"))
|
||||||
GetTree().Quit();
|
GetTree().Quit();
|
||||||
if (Input.IsActionJustPressed("shoot"))
|
if (Input.IsActionJustPressed("shoot"))
|
||||||
Shoot();
|
Shoot();
|
||||||
}
|
if (Input.IsActionJustPressed("switch"))
|
||||||
|
SwitchWeaponType();
|
||||||
|
}
|
||||||
|
|
||||||
public override void _Input(InputEvent @event)
|
public override void _PhysicsProcess(double delta)
|
||||||
{
|
{
|
||||||
}
|
var gravityDelta = _gravity * (float)delta;
|
||||||
|
var velocity = CalculateMovement(Velocity, Transform, gravityDelta);
|
||||||
|
|
||||||
public override void _PhysicsProcess(double delta)
|
Velocity = velocity;
|
||||||
{
|
MoveAndSlide();
|
||||||
var gravityDelta = _gravity * (float)delta;
|
}
|
||||||
var velocity = CalculateMovement(Velocity, Transform, gravityDelta);
|
|
||||||
|
|
||||||
Velocity = velocity;
|
private void Shoot()
|
||||||
MoveAndSlide();
|
{
|
||||||
}
|
GD.Print("Shoot");
|
||||||
|
var projectile = _weaponType.Instantiate<Node3D>();
|
||||||
|
projectile.Position = Position;
|
||||||
|
GetParent().AddChild(projectile);
|
||||||
|
}
|
||||||
|
|
||||||
private void Shoot()
|
private void SwitchWeaponType()
|
||||||
{
|
{
|
||||||
GD.Print("Shoot");
|
var index = _projectiles.IndexOf(_weaponType);
|
||||||
var projectile = new Fireball();
|
_weaponType = _projectiles[(index + 1) % _projectiles.Count];
|
||||||
Owner.AddChild(projectile);
|
|
||||||
projectile.Transform = Transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Vector3 CalculateMovement(Vector3 velocity, Transform3D transform, float gravityDelta)
|
}
|
||||||
{
|
|
||||||
if (!IsOnFloor())
|
|
||||||
velocity.Y -= gravityDelta;
|
|
||||||
|
|
||||||
if (Input.IsActionJustPressed("jump") && IsOnFloor())
|
private Vector3 CalculateMovement(Vector3 velocity, Transform3D transform, float gravityDelta)
|
||||||
velocity.Y = _jumpVelocity;
|
{
|
||||||
|
if (!IsOnFloor())
|
||||||
|
velocity.Y -= gravityDelta;
|
||||||
|
|
||||||
Vector2 inputDir = Input.GetVector("right", "left", "back", "forward");
|
if (Input.IsActionJustPressed("jump") && IsOnFloor())
|
||||||
Vector3 direction = (transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
|
velocity.Y = _jumpVelocity;
|
||||||
if (direction != Vector3.Zero)
|
|
||||||
{
|
|
||||||
velocity.X = direction.X * _speed;
|
|
||||||
velocity.Z = direction.Z * _speed;
|
|
||||||
GetNode<Node3D>("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;
|
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<Node3D>("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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
Scripts/Projectile.cs
Normal file
14
Scripts/Projectile.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class Projectile : Node3D
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
private float _projectileSpeed = 0.1f;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
Speed = _projectileSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float Speed { get; private set; }
|
||||||
|
}
|
||||||
8
Scripts/WeaponType.cs
Normal file
8
Scripts/WeaponType.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Sandbox.Scripts
|
||||||
|
{
|
||||||
|
internal enum WeaponType
|
||||||
|
{
|
||||||
|
Fire = 0,
|
||||||
|
Blizzard = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ config_version=5
|
|||||||
|
|
||||||
config/name="Sandbox"
|
config/name="Sandbox"
|
||||||
run/main_scene="res://Scenes/Main.tscn"
|
run/main_scene="res://Scenes/Main.tscn"
|
||||||
config/features=PackedStringArray("4.0", "C#", "Forward Plus")
|
config/features=PackedStringArray("4.1", "C#", "Forward Plus")
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|
||||||
@@ -78,3 +78,8 @@ shoot={
|
|||||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":90,"key_label":0,"unicode":122,"echo":false,"script":null)
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":90,"key_label":0,"unicode":122,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
switch={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":120,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user