inching towards better class inheritence and multiplayer compatibility
This commit is contained in:
@ -1,19 +1,23 @@
|
||||
[gd_resource type="Resource" script_class="Card" load_steps=7 format=3 uid="uid://bmoreipvttks8"]
|
||||
[gd_resource type="Resource" script_class="Card" load_steps=8 format=3 uid="uid://deer0awg4d18o"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/card.gd" id="1_yqa4b"]
|
||||
[ext_resource type="Texture2D" uid="uid://ca4lwwd3e0y73" path="res://Assets/TextureAtlases/g_assault.tres" id="2_8j5h0"]
|
||||
[ext_resource type="PackedScene" uid="uid://fernyl7fsifv" path="res://PCs/Universal/ClassCards/Assault/tower_assault.tscn" id="3_0r6s7"]
|
||||
[ext_resource type="Resource" uid="uid://w15ojqyxd72q" path="res://Resources/WeaponStats/assault.tres" id="3_k2yr3"]
|
||||
[ext_resource type="Resource" uid="uid://cktq4o3yuxgsa" path="res://Resources/TurretStats/assault.tres" id="3_p4byc"]
|
||||
[ext_resource type="PackedScene" uid="uid://d1xe6hsq05110" path="res://PCs/Universal/ClassCards/Assault/weapon_assault.tscn" id="3_wj5gm"]
|
||||
[ext_resource type="Texture2D" uid="uid://celay30i4soud" path="res://PCs/Universal/ClassCards/Assault/g_assault.png" id="2_a8may"]
|
||||
[ext_resource type="PackedScene" uid="uid://2eehfcrsednw" path="res://PCs/Universal/ClassCards/Assault/weapon_assault.tscn" id="3_28y3b"]
|
||||
[ext_resource type="Resource" uid="uid://bdmsiw45xxhiv" path="res://PCs/Universal/ClassCards/Assault/tower_stats.tres" id="3_ks0jw"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbfm4i4xlkwdr" path="res://PCs/Universal/ClassCards/Assault/tower_assault.tscn" id="4_5nu32"]
|
||||
[ext_resource type="Resource" uid="uid://smctw4ogm4rx" path="res://PCs/Universal/ClassCards/Assault/weapon_stats.tres" id="4_est7t"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_q0mw6"]
|
||||
atlas = ExtResource("2_a8may")
|
||||
region = Rect2(0, 0, 64, 64)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_yqa4b")
|
||||
title = "Assault"
|
||||
rarity = 0
|
||||
faction = 0
|
||||
sprite = ExtResource("2_8j5h0")
|
||||
turret = ExtResource("3_0r6s7")
|
||||
weapon = ExtResource("3_wj5gm")
|
||||
weapon_stats = ExtResource("3_k2yr3")
|
||||
tower_stats = ExtResource("3_p4byc")
|
||||
sprite = SubResource("AtlasTexture_q0mw6")
|
||||
turret_scene = ExtResource("4_5nu32")
|
||||
weapon_scene = ExtResource("3_28y3b")
|
||||
weapon_stats = ExtResource("4_est7t")
|
||||
tower_stats = ExtResource("3_ks0jw")
|
||||
|
BIN
PCs/Universal/ClassCards/Assault/g_assault.png
Normal file
BIN
PCs/Universal/ClassCards/Assault/g_assault.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
34
PCs/Universal/ClassCards/Assault/g_assault.png.import
Normal file
34
PCs/Universal/ClassCards/Assault/g_assault.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://celay30i4soud"
|
||||
path="res://.godot/imported/g_assault.png-5ee2b44f3ff930af8f664652779a0f99.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://PCs/Universal/ClassCards/Assault/g_assault.png"
|
||||
dest_files=["res://.godot/imported/g_assault.png-5ee2b44f3ff930af8f664652779a0f99.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
|
@ -1,59 +0,0 @@
|
||||
extends Node3D
|
||||
class_name Tower
|
||||
|
||||
@export var stats : TowerStats
|
||||
@export var model : Node3D
|
||||
@export var range_sphere : CSGSphere3D
|
||||
@export var minimap_range_sphere : CSGSphere3D
|
||||
|
||||
var targeted_enemy
|
||||
var cooldown := 0.0
|
||||
var other_cooldown := 0.0
|
||||
|
||||
func _ready() -> void:
|
||||
cooldown = 1.0 / stats.fire_rate
|
||||
range_sphere.radius = stats.fire_range
|
||||
minimap_range_sphere.radius = stats.fire_range
|
||||
#minimap_range_sphere.set_visible(true)
|
||||
|
||||
|
||||
func preview_range(value):
|
||||
range_sphere.set_visible(value)
|
||||
minimap_range_sphere.set_visible(value)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
other_cooldown -= delta
|
||||
if !targeted_enemy:
|
||||
acquire_target()
|
||||
else:
|
||||
if model.global_position.distance_to(targeted_enemy.global_position) > stats.fire_range:
|
||||
targeted_enemy = null
|
||||
if targeted_enemy:
|
||||
aim()
|
||||
if other_cooldown <= 0:
|
||||
shoot()
|
||||
other_cooldown = cooldown
|
||||
|
||||
|
||||
func shoot():
|
||||
targeted_enemy.damage(stats.damage)
|
||||
|
||||
|
||||
func aim():
|
||||
model.look_at(targeted_enemy.global_position)
|
||||
|
||||
|
||||
func acquire_target():
|
||||
var most_progressed_enemy = null
|
||||
for enemy in get_tree().get_nodes_in_group("Enemies"):
|
||||
if model.global_position.distance_to(enemy.global_position) > stats.fire_range:
|
||||
continue
|
||||
var em_1 = enemy.movement_controller as EnemyMovement
|
||||
var em_2 : EnemyMovement
|
||||
if most_progressed_enemy != null:
|
||||
em_2 = most_progressed_enemy.movement_controller as EnemyMovement
|
||||
if (most_progressed_enemy == null or em_1.distance_remaining < em_2.distance_remaining) and enemy.stats.target_type & stats.can_target:
|
||||
most_progressed_enemy = enemy
|
||||
if most_progressed_enemy != null:
|
||||
targeted_enemy = most_progressed_enemy
|
2
PCs/Universal/ClassCards/Assault/tower_assault.gd
Normal file
2
PCs/Universal/ClassCards/Assault/tower_assault.gd
Normal file
@ -0,0 +1,2 @@
|
||||
extends HitscanTower
|
||||
class_name AssaultTower
|
@ -1,41 +1,9 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://fernyl7fsifv"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bbfm4i4xlkwdr"]
|
||||
|
||||
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/Assault/tower.gd" id="1_c2874"]
|
||||
[ext_resource type="Resource" uid="uid://cktq4o3yuxgsa" path="res://Resources/TurretStats/assault.tres" id="2_t516u"]
|
||||
[ext_resource type="PackedScene" uid="uid://dumiyjlnea4gq" path="res://Scenes/Towers/hitscan_tower.tscn" id="1_uadu5"]
|
||||
[ext_resource type="Resource" uid="uid://bdmsiw45xxhiv" path="res://PCs/Universal/ClassCards/Assault/tower_stats.tres" id="2_gg1gn"]
|
||||
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/Assault/tower_assault.gd" id="2_olbck"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_llb88"]
|
||||
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_c2874")
|
||||
stats = ExtResource("2_t516u")
|
||||
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, 2, 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.714825, 0, -0.423869)
|
||||
size = Vector3(0.481654, 0.427749, 1.38438)
|
||||
|
||||
[node name="CSGBox3D3" type="CSGBox3D" parent="Model"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.715, 0, -0.424)
|
||||
size = Vector3(0.481654, 0.427749, 1.38438)
|
||||
|
||||
[node name="CSGSphere3D" type="CSGSphere3D" parent="Model"]
|
||||
visible = false
|
||||
radius = 7.5
|
||||
material = SubResource("StandardMaterial3D_llb88")
|
||||
|
||||
[node name="CSGSphere3D2" type="CSGSphere3D" parent="Model"]
|
||||
visible = false
|
||||
layers = 4
|
||||
radius = 7.5
|
||||
material = SubResource("StandardMaterial3D_llb88")
|
||||
[node name="AssaultTower" instance=ExtResource("1_uadu5")]
|
||||
script = ExtResource("2_olbck")
|
||||
stats = ExtResource("2_gg1gn")
|
||||
|
25
PCs/Universal/ClassCards/Assault/tower_stats.tres
Normal file
25
PCs/Universal/ClassCards/Assault/tower_stats.tres
Normal file
@ -0,0 +1,25 @@
|
||||
[gd_resource type="Resource" script_class="CardText" load_steps=6 format=3 uid="uid://bdmsiw45xxhiv"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/card_text.gd" id="1_50mwk"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/stat_attribute.gd" id="1_cwxf1"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_bukji"]
|
||||
script = ExtResource("1_cwxf1")
|
||||
key = "Fire Delay"
|
||||
value = 1.0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_2e75s"]
|
||||
script = ExtResource("1_cwxf1")
|
||||
key = "Damage"
|
||||
value = 1.0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_1vpnf"]
|
||||
script = ExtResource("1_cwxf1")
|
||||
key = "Range"
|
||||
value = 10.0
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_50mwk")
|
||||
target_type = 1
|
||||
attributes = Array[ExtResource("1_cwxf1")]([SubResource("Resource_bukji"), SubResource("Resource_2e75s"), SubResource("Resource_1vpnf")])
|
||||
text = "Fires a shot every /Fire Delay\\ seconds dealing /Damage\\ damage at a range of /Range\\m"
|
@ -1,73 +0,0 @@
|
||||
extends Sprite3D
|
||||
class_name Weapon
|
||||
|
||||
@export var stats : WeaponStats
|
||||
@export var hero : Hero
|
||||
|
||||
var cooldown := 0.0
|
||||
var other_cooldown := 0.0
|
||||
var trigger_held := false
|
||||
var second_trigger_held := false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
cooldown = 1.0 / stats.fire_rate
|
||||
$RayCast3D.target_position = Vector3(0, 0, -stats.fire_range)
|
||||
|
||||
|
||||
func set_raycast_origin(node):
|
||||
$RayCast3D.global_position = node.global_position
|
||||
|
||||
|
||||
func set_hero(value):
|
||||
hero = value
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if stats != null:
|
||||
other_cooldown -= delta
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if trigger_held:
|
||||
shoot()
|
||||
|
||||
|
||||
func hold_trigger():
|
||||
trigger_held = true
|
||||
|
||||
|
||||
func release_trigger():
|
||||
trigger_held = false
|
||||
|
||||
|
||||
func hold_second_trigger():
|
||||
second_trigger_held = true
|
||||
|
||||
|
||||
func release_second_trigger():
|
||||
second_trigger_held = false
|
||||
|
||||
|
||||
func shoot():
|
||||
if other_cooldown <= 0 and stats != null:
|
||||
other_cooldown = cooldown
|
||||
$AnimationPlayer.play("shoot")
|
||||
if $RayCast3D.is_colliding():
|
||||
var target = $RayCast3D.get_collider()
|
||||
if target != null:
|
||||
var target_hitbox = target.shape_owner_get_owner($RayCast3D.get_collider_shape())
|
||||
if target_hitbox is Hitbox:
|
||||
target_hitbox.damage(stats.damage)
|
||||
networked_hit.rpc(get_tree().root.get_path_to(target_hitbox))
|
||||
|
||||
|
||||
@rpc
|
||||
func networked_shoot():
|
||||
$AnimationPlayer.play("shoot")
|
||||
|
||||
|
||||
@rpc("reliable")
|
||||
func networked_hit(target_node_path : String):
|
||||
var target_node = get_tree().root.get_node(target_node_path)
|
||||
target_node.damage(stats.damage)
|
2
PCs/Universal/ClassCards/Assault/weapon_assault.gd
Normal file
2
PCs/Universal/ClassCards/Assault/weapon_assault.gd
Normal file
@ -0,0 +1,2 @@
|
||||
extends HitscanWeapon
|
||||
class_name AssaultWeapon
|
@ -1,58 +1,15 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://d1xe6hsq05110"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://2eehfcrsednw"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://ca4lwwd3e0y73" path="res://Assets/TextureAtlases/g_assault.tres" id="1_117ne"]
|
||||
[ext_resource type="Script" path="res://PCs/Universal/ClassCards/Assault/weapon.gd" id="2_4ie8w"]
|
||||
[ext_resource type="Resource" uid="uid://w15ojqyxd72q" path="res://Resources/WeaponStats/assault.tres" id="3_s4ckt"]
|
||||
[ext_resource type="PackedScene" uid="uid://difwo7wlyqr3h" path="res://Scenes/Weapons/hitscan_weapon.tscn" id="1_wkxf7"]
|
||||
[ext_resource type="Resource" uid="uid://smctw4ogm4rx" path="res://PCs/Universal/ClassCards/Assault/weapon_stats.tres" id="2_fnp5x"]
|
||||
[ext_resource type="Texture2D" uid="uid://celay30i4soud" path="res://PCs/Universal/ClassCards/Assault/g_assault.png" id="3_kuj4t"]
|
||||
|
||||
[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="AtlasTexture" id="AtlasTexture_604rb"]
|
||||
atlas = ExtResource("3_kuj4t")
|
||||
region = 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)]
|
||||
}
|
||||
[node name="HitscanWeapon" instance=ExtResource("1_wkxf7")]
|
||||
stats = ExtResource("2_fnp5x")
|
||||
|
||||
[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_117ne")
|
||||
script = ExtResource("2_4ie8w")
|
||||
stats = ExtResource("3_s4ckt")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_ntl6p")
|
||||
}
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="."]
|
||||
collision_mask = 4
|
||||
[node name="Sprite3D" parent="." index="0"]
|
||||
texture = SubResource("AtlasTexture_604rb")
|
||||
|
25
PCs/Universal/ClassCards/Assault/weapon_stats.tres
Normal file
25
PCs/Universal/ClassCards/Assault/weapon_stats.tres
Normal file
@ -0,0 +1,25 @@
|
||||
[gd_resource type="Resource" script_class="CardText" load_steps=6 format=3 uid="uid://smctw4ogm4rx"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/card_text.gd" id="1_gk542"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/stat_attribute.gd" id="1_qt3yl"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_bcrtt"]
|
||||
script = ExtResource("1_qt3yl")
|
||||
key = "Damage"
|
||||
value = 3.0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_llper"]
|
||||
script = ExtResource("1_qt3yl")
|
||||
key = "Range"
|
||||
value = 15.0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_7i2dt"]
|
||||
script = ExtResource("1_qt3yl")
|
||||
key = "Fire Delay"
|
||||
value = 0.2
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_gk542")
|
||||
target_type = 0
|
||||
attributes = Array[ExtResource("1_qt3yl")]([SubResource("Resource_bcrtt"), SubResource("Resource_llper"), SubResource("Resource_7i2dt")])
|
||||
text = "Fires a shot every /Fire Delay\\ seconds dealing /Damage\\ damage at a range of /Range\\m"
|
Reference in New Issue
Block a user