inching towards better class inheritence and multiplayer compatibility

This commit is contained in:
2023-11-15 15:19:40 +11:00
parent f004f64b71
commit 1500c22ccc
204 changed files with 1920 additions and 1951 deletions

View File

@ -1,20 +0,0 @@
extends RigidBody3D
class_name Bomb
@export var max_bounces := 1
@export var damage := 10.0
@export var explosion_range := 3.0
var bounces := 0
func _on_body_entered(_body: Node) -> void:
bounces += 1
var collided_body = get_colliding_bodies()[0].get_collision_layer_value(3)
if bounces > max_bounces or collided_body:
explode()
func explode():
for enemy in get_tree().get_nodes_in_group("Enemies"):
if global_position.distance_to(enemy.global_position) <= explosion_range:
enemy.damage(damage)
queue_free()

Binary file not shown.

After

Width:  |  Height:  |  Size: 799 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b54d5dc4jmlau"
path="res://.godot/imported/bomb.png-487c0a83cb041cff7ffc29ecb2986a5b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://PCs/Universal/ClassCards/BombLauncher/bomb.png"
dest_files=["res://.godot/imported/bomb.png-487c0a83cb041cff7ffc29ecb2986a5b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@ -1,29 +0,0 @@
[gd_scene load_steps=5 format=3 uid="uid://d147iwg2wcqc5"]
[ext_resource type="Texture2D" uid="uid://b54d5dc4jmlau" path="res://Assets/Textures/bomb.png" id="1_u615o"]
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/BombLauncher/bomb.gd" id="1_vekqm"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_whkhx"]
bounce = 0.6
[sub_resource type="SphereShape3D" id="SphereShape3D_mi0in"]
radius = 0.2
[node name="RigidBody3D" type="RigidBody3D"]
collision_layer = 0
collision_mask = 5
physics_material_override = SubResource("PhysicsMaterial_whkhx")
max_contacts_reported = 1
contact_monitor = true
script = ExtResource("1_vekqm")
[node name="Node3D" type="Sprite3D" parent="."]
transform = Transform3D(1.4, 0, 0, 0, 1.4, 0, 0, 0, 1.4, 0, 0, 0)
billboard = 1
texture_filter = 0
texture = ExtResource("1_u615o")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_mi0in")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -0,0 +1,16 @@
extends ExplosiveProjectile
class_name BombProjectile
var max_bounces := 1
var bounces := 0
func _ready() -> void:
apply_central_impulse(direction * force)
func _on_body_entered(_body: Node) -> void:
bounces += 1
var collided_body = get_colliding_bodies()[0].get_collision_layer_value(3)
if bounces > max_bounces or collided_body:
explode()

View File

@ -0,0 +1,17 @@
[gd_scene load_steps=5 format=3 uid="uid://c8oq5unisjqne"]
[ext_resource type="PackedScene" uid="uid://7f4dfphgiswr" path="res://Scenes/Projectiles/explosive_projectile.tscn" id="1_kf2wi"]
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/BombLauncher/bomb_projectile.gd" id="2_qvo4u"]
[ext_resource type="Texture2D" uid="uid://b54d5dc4jmlau" path="res://PCs/Universal/ClassCards/BombLauncher/bomb.png" id="3_ilhep"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_bbpul"]
bounce = 0.3
[node name="Bomb" instance=ExtResource("1_kf2wi")]
physics_material_override = SubResource("PhysicsMaterial_bbpul")
gravity_scale = 1.0
script = ExtResource("2_qvo4u")
[node name="Sprite3D" parent="." index="1"]
pixel_size = 0.015
texture = ExtResource("3_ilhep")

View File

@ -1,21 +0,0 @@
extends Weapon
class_name BombWeapon
@export var bomb_scene: PackedScene
var firing_velocity
func _ready() -> void:
cooldown = 1.0 / stats.fire_rate
firing_velocity = sqrt((stats.fire_range * ProjectSettings.get_setting("physics/3d/default_gravity")) / sin(2 * 45))
$RayCast3D.target_position = Vector3(0, 0, -stats.fire_range)
func shoot():
if other_cooldown <= 0 and stats != null:
other_cooldown = cooldown
$AnimationPlayer.play("shoot")
var bomb = bomb_scene.instantiate() as Bomb
bomb.position = $RayCast3D.global_position
bomb.damage = stats.damage
get_tree().root.add_child(bomb)
bomb.apply_impulse(-global_transform.basis.z * firing_velocity)

View File

@ -0,0 +1,23 @@
[gd_resource type="Resource" script_class="Card" load_steps=8 format=3 uid="uid://blgngx360vff1"]
[ext_resource type="Script" path="res://Scripts/Resources/card.gd" id="1_qtxcq"]
[ext_resource type="Texture2D" uid="uid://3qcdx7n440sc" path="res://PCs/Universal/ClassCards/BombLauncher/grenade_launcher.png" id="2_qpxaq"]
[ext_resource type="Resource" uid="uid://8eaecilvan23" path="res://PCs/Universal/ClassCards/BombLauncher/tower_stats.tres" id="3_gknxe"]
[ext_resource type="PackedScene" uid="uid://c3fqlkytyc62u" path="res://PCs/Universal/ClassCards/BombLauncher/weapon_bomb_launcher.tscn" id="3_s56j6"]
[ext_resource type="Resource" uid="uid://co6eorobj1xuu" path="res://PCs/Universal/ClassCards/BombLauncher/weapon_stats.tres" id="4_s74ea"]
[ext_resource type="PackedScene" uid="uid://d2cch7qrwocg8" path="res://PCs/Universal/ClassCards/BombLauncher/tower_bomb_launcher.tscn" id="4_vc8pe"]
[sub_resource type="AtlasTexture" id="AtlasTexture_rat6o"]
atlas = ExtResource("2_qpxaq")
region = Rect2(0, 0, 64, 64)
[resource]
script = ExtResource("1_qtxcq")
title = "Bomb Launcher"
rarity = 0
faction = 0
sprite = SubResource("AtlasTexture_rat6o")
turret_scene = ExtResource("4_vc8pe")
weapon_scene = ExtResource("3_s56j6")
weapon_stats = ExtResource("4_s74ea")
tower_stats = ExtResource("3_gknxe")

View File

@ -1,19 +0,0 @@
[gd_resource type="Resource" script_class="Card" load_steps=7 format=3 uid="uid://bvpkvmda845o5"]
[ext_resource type="Script" path="res://Scripts/Resources/card.gd" id="1_bscy2"]
[ext_resource type="Texture2D" uid="uid://bwufgga1pjyt" path="res://Assets/TextureAtlases/g_grenade_launcher.tres" id="2_xtrq2"]
[ext_resource type="Resource" uid="uid://crmsk6lvp5i4e" path="res://Resources/TurretStats/bomblauncher.tres" id="3_c1c3t"]
[ext_resource type="PackedScene" uid="uid://6ckryuql3bh8" path="res://PCs/Universal/ClassCards/BombLauncher/weapon_bomb_launcher.tscn" id="4_iaadg"]
[ext_resource type="PackedScene" uid="uid://cwc8y1nv53btu" path="res://PCs/Universal/ClassCards/BombLauncher/tower_bomb_launcher.tscn" id="4_ux0v3"]
[ext_resource type="Resource" uid="uid://kbaiy5u6imtu" path="res://Resources/WeaponStats/bomblauncher.tres" id="5_mhhrq"]
[resource]
script = ExtResource("1_bscy2")
title = "Bomb Launcher"
rarity = 0
faction = 0
sprite = ExtResource("2_xtrq2")
turret = ExtResource("4_ux0v3")
weapon = ExtResource("4_iaadg")
weapon_stats = ExtResource("5_mhhrq")
tower_stats = ExtResource("3_c1c3t")

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://3qcdx7n440sc"
path="res://.godot/imported/grenade_launcher.png-1e7f404a8d0cf786acfd3eff044b4f0c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://PCs/Universal/ClassCards/BombLauncher/grenade_launcher.png"
dest_files=["res://.godot/imported/grenade_launcher.png-1e7f404a8d0cf786acfd3eff044b4f0c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@ -0,0 +1,20 @@
extends ProjectileTower
class_name BombLauncherTower
func _ready() -> void:
super._ready()
force = sqrt((target_range * ProjectSettings.get_setting("physics/3d/default_gravity")) / sin(2 * 45))
func aim():
super.aim()
var pos = Vector2(global_position.x, global_position.z)
var t_pos = Vector2(targeted_enemy.global_position.x, targeted_enemy.global_position.z)
var x = pos.distance_to(t_pos)
var y = targeted_enemy.global_position.y - (global_position.y + 1)
var v = force
var g = ProjectSettings.get_setting("physics/3d/default_gravity")
var v2 = pow(v, 2)
var angle = atan((v2 + sqrt(pow(v, 4) - g * ((g * pow(x, 2)) + (2 * y * v2)))) / (g * x))
yaw_model.look_at(Vector3(t_pos.x, yaw_model.global_position.y, t_pos.y))
yaw_model.rotate(yaw_model.global_transform.basis.x.normalized(), angle)

View File

@ -1,39 +1,11 @@
[gd_scene load_steps=5 format=3 uid="uid://cwc8y1nv53btu"]
[gd_scene load_steps=5 format=3 uid="uid://d2cch7qrwocg8"]
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/BombLauncher/bombtower.gd" id="1_u2hyk"]
[ext_resource type="PackedScene" uid="uid://d147iwg2wcqc5" path="res://PCs/Universal/ClassCards/BombLauncher/bomb.tscn" id="2_n307r"]
[ext_resource type="Resource" uid="uid://crmsk6lvp5i4e" path="res://Resources/TurretStats/bomblauncher.tres" id="3_xv5rx"]
[ext_resource type="PackedScene" uid="uid://t0b32qb8eub2" path="res://Scenes/Towers/projectile_tower.tscn" id="1_r8hbo"]
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/BombLauncher/tower_bomb_launcher.gd" id="2_vlaa6"]
[ext_resource type="PackedScene" uid="uid://c8oq5unisjqne" path="res://PCs/Universal/ClassCards/BombLauncher/bomb_projectile.tscn" id="3_562if"]
[ext_resource type="Resource" uid="uid://8eaecilvan23" path="res://PCs/Universal/ClassCards/BombLauncher/tower_stats.tres" id="4_xgwj1"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nr2od"]
transparency = 1
cull_mode = 2
shading_mode = 0
albedo_color = Color(0.686275, 0, 0, 0.278431)
[node name="Node3D" type="Node3D" node_paths=PackedStringArray("model", "range_sphere", "minimap_range_sphere")]
script = ExtResource("1_u2hyk")
bomb_scene = ExtResource("2_n307r")
stats = ExtResource("3_xv5rx")
model = NodePath("Model")
range_sphere = NodePath("Model/CSGSphere3D")
minimap_range_sphere = NodePath("Model/CSGSphere3D2")
[node name="Model" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.13842, 0)
[node name="CSGBox3D" type="CSGBox3D" parent="Model"]
[node name="CSGBox3D2" type="CSGBox3D" parent="Model"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.65)
size = Vector3(0.596453, 0.632841, 0.539216)
[node name="CSGSphere3D" type="CSGSphere3D" parent="Model"]
visible = false
radius = 7.5
material = SubResource("StandardMaterial3D_nr2od")
[node name="CSGSphere3D2" type="CSGSphere3D" parent="Model"]
visible = false
layers = 4
radius = 7.5
material = SubResource("StandardMaterial3D_nr2od")
[node name="BombLauncherTower" instance=ExtResource("1_r8hbo")]
script = ExtResource("2_vlaa6")
projectile_scene = ExtResource("3_562if")
stats = ExtResource("4_xgwj1")

View File

@ -0,0 +1,25 @@
[gd_resource type="Resource" script_class="CardText" load_steps=6 format=3 uid="uid://8eaecilvan23"]
[ext_resource type="Script" path="res://Scripts/Resources/stat_attribute.gd" id="1_gjldi"]
[ext_resource type="Script" path="res://Scripts/Resources/card_text.gd" id="2_jt2vs"]
[sub_resource type="Resource" id="Resource_yb48y"]
script = ExtResource("1_gjldi")
key = "Fire Delay"
value = 4.0
[sub_resource type="Resource" id="Resource_ewwvw"]
script = ExtResource("1_gjldi")
key = "Damage"
value = 10.0
[sub_resource type="Resource" id="Resource_qu5dv"]
script = ExtResource("1_gjldi")
key = "Range"
value = 8.0
[resource]
script = ExtResource("2_jt2vs")
target_type = 1
attributes = Array[ExtResource("1_gjldi")]([SubResource("Resource_yb48y"), SubResource("Resource_ewwvw"), SubResource("Resource_qu5dv")])
text = "Launch a bomb that deals /Damage\\ damage every /Fire Delay\\ seconds"

View File

@ -0,0 +1,8 @@
extends ProjectileWeapon
class_name BombLauncherWeapon
func _ready() -> void:
super._ready()
var launch_range = stats.get_attribute("Range")
force = sqrt((launch_range * ProjectSettings.get_setting("physics/3d/default_gravity")) / sin(2 * 45))

View File

@ -1,59 +1,11 @@
[gd_scene load_steps=8 format=3 uid="uid://6ckryuql3bh8"]
[gd_scene load_steps=5 format=3 uid="uid://c3fqlkytyc62u"]
[ext_resource type="Texture2D" uid="uid://bwufgga1pjyt" path="res://Assets/TextureAtlases/g_grenade_launcher.tres" id="1_n7mif"]
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/BombLauncher/bombweapon.gd" id="2_4iyo6"]
[ext_resource type="PackedScene" uid="uid://d147iwg2wcqc5" path="res://PCs/Universal/ClassCards/BombLauncher/bomb.tscn" id="3_506dv"]
[ext_resource type="Resource" uid="uid://kbaiy5u6imtu" path="res://Resources/WeaponStats/bomblauncher.tres" id="4_45cu2"]
[ext_resource type="PackedScene" uid="uid://bqdllitxbbpyp" path="res://Scenes/Weapons/projectile_weapon.tscn" id="1_gbycb"]
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/BombLauncher/weapon_bomb_launcher.gd" id="2_g5ihb"]
[ext_resource type="Resource" uid="uid://co6eorobj1xuu" path="res://PCs/Universal/ClassCards/BombLauncher/weapon_stats.tres" id="3_73ol1"]
[ext_resource type="PackedScene" uid="uid://c8oq5unisjqne" path="res://PCs/Universal/ClassCards/BombLauncher/bomb_projectile.tscn" id="3_jxt6m"]
[sub_resource type="Animation" id="Animation_n8b32"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:texture:region")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Rect2(0, 0, 64, 64)]
}
[sub_resource type="Animation" id="Animation_g0h8q"]
resource_name = "shoot"
length = 0.15
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:texture:region")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.15),
"transitions": PackedFloat32Array(0, 0),
"update": 0,
"values": [Rect2(64, 0, 64, 64), Rect2(0, 0, 64, 64)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ntl6p"]
_data = {
"RESET": SubResource("Animation_n8b32"),
"shoot": SubResource("Animation_g0h8q")
}
[node name="Weapon" type="Sprite3D"]
layers = 2
billboard = 1
texture_filter = 0
texture = ExtResource("1_n7mif")
script = ExtResource("2_4iyo6")
bomb_scene = ExtResource("3_506dv")
stats = ExtResource("4_45cu2")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_ntl6p")
}
[node name="RayCast3D" type="RayCast3D" parent="."]
[node name="BombLauncherWeapon" instance=ExtResource("1_gbycb")]
script = ExtResource("2_g5ihb")
projectile_scene = ExtResource("3_jxt6m")
stats = ExtResource("3_73ol1")

View File

@ -0,0 +1,25 @@
[gd_resource type="Resource" script_class="CardText" load_steps=6 format=3 uid="uid://co6eorobj1xuu"]
[ext_resource type="Script" path="res://Scripts/Resources/card_text.gd" id="1_8i32s"]
[ext_resource type="Script" path="res://Scripts/Resources/stat_attribute.gd" id="1_kj8v0"]
[sub_resource type="Resource" id="Resource_yb48y"]
script = ExtResource("1_kj8v0")
key = "Fire Delay"
value = 2.0
[sub_resource type="Resource" id="Resource_ewwvw"]
script = ExtResource("1_kj8v0")
key = "Damage"
value = 10.0
[sub_resource type="Resource" id="Resource_qu5dv"]
script = ExtResource("1_kj8v0")
key = "Range"
value = 10.0
[resource]
script = ExtResource("1_8i32s")
target_type = 0
attributes = Array[ExtResource("1_kj8v0")]([SubResource("Resource_yb48y"), SubResource("Resource_ewwvw"), SubResource("Resource_qu5dv")])
text = "Launch a bomb that deals /Damage\\ damage every /Fire Delay\\ seconds"