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>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<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="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="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="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"]
|
||||
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"]
|
||||
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="StaticBody3D" type="StaticBody3D" parent="."]
|
||||
@@ -63,6 +52,7 @@ collision_layer = 2
|
||||
script = ExtResource("1_8dc05")
|
||||
_sensitivityHorizontal = 0.01
|
||||
_sensitivityVertical = 0.01
|
||||
_projectiles = Array[PackedScene]([ExtResource("2_bsaqu"), ExtResource("3_4rglj")])
|
||||
|
||||
[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)
|
||||
@@ -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")
|
||||
use_collision = true
|
||||
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;
|
||||
|
||||
public partial class Fireball : CsgSphere3D
|
||||
public partial class Fireball : Projectile
|
||||
{
|
||||
private float _speed = 80f;
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
Translate(new Vector3(0, 0, -Speed));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
public partial class Player : CharacterBody3D
|
||||
{
|
||||
@@ -12,9 +14,12 @@ public partial class Player : CharacterBody3D
|
||||
private float _sensitivityVertical = 0.05f;
|
||||
[Export]
|
||||
private float _joystickDeadZone = 0.5f;
|
||||
[Export]
|
||||
private Array<PackedScene> _projectiles;
|
||||
|
||||
private Node3D _cameraMount;
|
||||
private Node3D _pivot;
|
||||
private PackedScene _weaponType;
|
||||
|
||||
// Get the _gravity from the project settings to be synced with RigidBody nodes.
|
||||
public float _gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
|
||||
@@ -24,6 +29,7 @@ public partial class Player : CharacterBody3D
|
||||
Input.MouseMode = Input.MouseModeEnum.Captured;
|
||||
_cameraMount = GetNode<Node3D>("/root/Main/Player/CameraMount");
|
||||
_pivot = GetNode<Node3D>("/root/Main/Player/Pivot");
|
||||
_weaponType = _projectiles.First();
|
||||
}
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
@@ -32,10 +38,8 @@ public partial class Player : CharacterBody3D
|
||||
GetTree().Quit();
|
||||
if (Input.IsActionJustPressed("shoot"))
|
||||
Shoot();
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (Input.IsActionJustPressed("switch"))
|
||||
SwitchWeaponType();
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
@@ -50,9 +54,16 @@ public partial class Player : CharacterBody3D
|
||||
private void Shoot()
|
||||
{
|
||||
GD.Print("Shoot");
|
||||
var projectile = new Fireball();
|
||||
Owner.AddChild(projectile);
|
||||
projectile.Transform = Transform;
|
||||
var projectile = _weaponType.Instantiate<Node3D>();
|
||||
projectile.Position = Position;
|
||||
GetParent().AddChild(projectile);
|
||||
}
|
||||
|
||||
private void SwitchWeaponType()
|
||||
{
|
||||
var index = _projectiles.IndexOf(_weaponType);
|
||||
_weaponType = _projectiles[(index + 1) % _projectiles.Count];
|
||||
|
||||
}
|
||||
|
||||
private Vector3 CalculateMovement(Vector3 velocity, Transform3D transform, float gravityDelta)
|
||||
|
||||
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"
|
||||
run/main_scene="res://Scenes/Main.tscn"
|
||||
config/features=PackedStringArray("4.0", "C#", "Forward Plus")
|
||||
config/features=PackedStringArray("4.1", "C#", "Forward Plus")
|
||||
|
||||
[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)
|
||||
]
|
||||
}
|
||||
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