Added lightning texture. Reorganized images
This commit is contained in:
@@ -2,11 +2,6 @@ class_name AbstractTeslaProjectile
|
||||
extends AbstractDirectHitProjectile
|
||||
|
||||
|
||||
const SPIKE_WIDTH = 1
|
||||
const SPIKE_MIN_LENGTH = 10.0
|
||||
const SPIKE_MAX_LENGTH = 50.0
|
||||
|
||||
|
||||
@export_range(0.01, 0.5) var jink_min_delay: float = 0.01
|
||||
@export_range(0.01, 0.5) var jink_max_delay: float = 0.01
|
||||
@export_range(0, 360) var deviation_angle: int = 0
|
||||
@@ -15,22 +10,24 @@ const SPIKE_MAX_LENGTH = 50.0
|
||||
|
||||
var _collided_foes : Array[AbstractShip] = []
|
||||
|
||||
var _is_dead := false
|
||||
var _is_expanding := true
|
||||
var _removed_point_count := 0
|
||||
|
||||
var _spikes_by_point_count : Dictionary[int, Array] = {}
|
||||
@onready var jink_timer : Timer = $JinkTimer
|
||||
@onready var life_timer : Timer = $LifeTimer
|
||||
|
||||
|
||||
@onready var jinkTimer : Timer = $JinkTimer
|
||||
@onready var lifeTimer : Timer = $LifeTimer
|
||||
|
||||
@onready var line : Line2D = $Line2D
|
||||
@onready var line_thin : Line2D = $LineThin
|
||||
@onready var line_thick : Line2D = $LineThick
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
_start_jink_timer()
|
||||
|
||||
_prepare_line(line_thin)
|
||||
_prepare_line(line_thick)
|
||||
line_thin.hide()
|
||||
|
||||
|
||||
func _prepare_line(line: Line2D) -> void:
|
||||
line.reparent(get_tree().current_scene)
|
||||
line.global_position = Vector2.ZERO
|
||||
line.add_point(position)
|
||||
@@ -38,21 +35,8 @@ func _ready() -> void:
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
super._physics_process(delta)
|
||||
|
||||
if _is_dead:
|
||||
line.remove_point(0)
|
||||
_removed_point_count += 1
|
||||
|
||||
if _removed_point_count in _spikes_by_point_count:
|
||||
var lines := _spikes_by_point_count[_removed_point_count]
|
||||
for l : Line2D in lines:
|
||||
l.queue_free()
|
||||
|
||||
if line.get_point_count() == 0:
|
||||
delete()
|
||||
|
||||
if _is_expanding:
|
||||
line.add_point(position)
|
||||
line_thin.add_point(position)
|
||||
line_thick.add_point(position)
|
||||
|
||||
|
||||
func _process_hit_for_projectile(collided_body: Node2D) -> void:
|
||||
@@ -60,19 +44,22 @@ func _process_hit_for_projectile(collided_body: Node2D) -> void:
|
||||
_collided_foes.append(collided_body)
|
||||
|
||||
damage.value = floor(damage.value/2.0)
|
||||
if damage.value == 0:
|
||||
_start_fading()
|
||||
|
||||
_velocity = _apply_random_deviation(_velocity)
|
||||
_start_jink_timer()
|
||||
|
||||
|
||||
func delete() -> void:
|
||||
line.queue_free()
|
||||
line_thin.queue_free()
|
||||
line_thick.queue_free()
|
||||
super.delete()
|
||||
|
||||
|
||||
func _start_jink_timer() -> void:
|
||||
var random_delay := randf_range(jink_min_delay, jink_max_delay)
|
||||
jinkTimer.start(random_delay)
|
||||
jink_timer.start(random_delay)
|
||||
|
||||
|
||||
func _on_jink_timer_timeout() -> void:
|
||||
@@ -84,33 +71,9 @@ func _on_jink_timer_timeout() -> void:
|
||||
else:
|
||||
_velocity = _apply_random_deviation(_velocity)
|
||||
|
||||
_create_spike()
|
||||
|
||||
_start_jink_timer()
|
||||
|
||||
|
||||
func _create_spike() -> void:
|
||||
if _is_dead: return
|
||||
|
||||
var point_count := line.get_point_count()
|
||||
if not point_count in _spikes_by_point_count:
|
||||
_spikes_by_point_count[point_count] = []
|
||||
|
||||
var spike_direction := _apply_random_deviation(_velocity).normalized()
|
||||
var spike_length := randf_range(SPIKE_MIN_LENGTH, SPIKE_MAX_LENGTH)
|
||||
var second_point := position + spike_direction * spike_length
|
||||
|
||||
var spike : Line2D = line.duplicate()
|
||||
get_parent().add_child(spike)
|
||||
spike.clear_points()
|
||||
spike.add_point(position)
|
||||
spike.add_point(second_point)
|
||||
spike.width = SPIKE_WIDTH
|
||||
spike.width_curve = null
|
||||
|
||||
_spikes_by_point_count[point_count].append(spike)
|
||||
|
||||
|
||||
func _target_foe(foe: AbstractShip) -> void:
|
||||
var current_speed := _velocity.length()
|
||||
var foe_direction := position.direction_to(foe.position)
|
||||
@@ -119,13 +82,19 @@ func _target_foe(foe: AbstractShip) -> void:
|
||||
|
||||
func _apply_random_deviation(vector: Vector2) -> Vector2:
|
||||
var deviation_rad := deg_to_rad(deviation_angle)
|
||||
var random_angle := randfn(0.0, deviation_rad / 6.0)
|
||||
var random_angle := randfn(0.0, deviation_rad)
|
||||
return vector.rotated(random_angle)
|
||||
|
||||
|
||||
func _start_fading() -> void:
|
||||
line_thick.hide()
|
||||
line_thin.show()
|
||||
life_timer.start()
|
||||
|
||||
|
||||
func _on_life_timer_timeout() -> void:
|
||||
_is_dead = true
|
||||
delete()
|
||||
|
||||
|
||||
func _on_out_of_screen_timer_timeout() -> void:
|
||||
_is_expanding = false
|
||||
_start_fading()
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bi64687wtxi4d"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://bi64687wtxi4d"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cdv5n4t47hr8i" path="res://game/entities/weapons/abstract_direct_hit_projectile.tscn" id="1_1oexk"]
|
||||
[ext_resource type="Script" uid="uid://bxcoa2eps0tt1" path="res://game/entities/weapons/tesla/abstract_tesla_projectile.gd" id="2_q73is"]
|
||||
[ext_resource type="Script" uid="uid://c27v705giygv4" path="res://game/data/damage/energy_damage.gd" id="3_l65ib"]
|
||||
[ext_resource type="Texture2D" uid="uid://ym37tueldx8w" path="res://images/projectiles/lightning_thick.png" id="4_63xdp"]
|
||||
[ext_resource type="Texture2D" uid="uid://bw2k655gwkbec" path="res://images/projectiles/lightning_thin.png" id="5_5s0k0"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_1121u"]
|
||||
resource_local_to_scene = true
|
||||
@@ -13,20 +15,16 @@ metadata/_custom_type_script = "uid://c27v705giygv4"
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_l65ib"]
|
||||
radius = 5.0
|
||||
|
||||
[sub_resource type="Curve" id="Curve_ptgbh"]
|
||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.10909091, 0.31467384), 0.0, 0.0, 0, 0, Vector2(0.2090909, 0.88342386), 0.0, 0.0, 0, 0, Vector2(0.3181818, 0.29701078), 0.0, 0.0, 0, 0, Vector2(0.4113636, 0.92934775), 0.0, 0.0, 0, 0, Vector2(0.53636366, 0.28943247), 0.0, 0.0, 0, 0, Vector2(0.7113636, 0.9399456), 0.0, 0.0, 0, 0, Vector2(0.8090909, 0.2792815), 0.0, 0.0, 0, 0, Vector2(0.9090909, 0.9399456), 0.0, 0.0, 0, 0, Vector2(1, 0.21837574), 0.0, 0.0, 0, 0]
|
||||
point_count = 10
|
||||
|
||||
[node name="AbstractTeslaProjectile" instance=ExtResource("1_1oexk")]
|
||||
collision_layer = 0
|
||||
collision_mask = 0
|
||||
script = ExtResource("2_q73is")
|
||||
jink_min_delay = 0.02
|
||||
jink_max_delay = 0.05
|
||||
deviation_angle = 90
|
||||
deviation_angle = 30
|
||||
no_deviation_distance = 50
|
||||
damage = SubResource("Resource_1121u")
|
||||
speed = 900
|
||||
speed = 1800
|
||||
|
||||
[node name="CollisionShape2D" parent="." index="0"]
|
||||
shape = SubResource("CircleShape2D_l65ib")
|
||||
@@ -34,16 +32,20 @@ shape = SubResource("CircleShape2D_l65ib")
|
||||
[node name="JinkTimer" type="Timer" parent="." index="2"]
|
||||
one_shot = true
|
||||
|
||||
[node name="Line2D" type="Line2D" parent="." index="4"]
|
||||
z_index = 10
|
||||
width = 3.0
|
||||
width_curve = SubResource("Curve_ptgbh")
|
||||
default_color = Color(0.25490198, 0.6509804, 0.9647059, 1)
|
||||
joint_mode = 1
|
||||
[node name="LifeTimer" type="Timer" parent="." index="3"]
|
||||
wait_time = 0.1
|
||||
|
||||
[node name="LifeTimer" type="Timer" parent="." index="5"]
|
||||
wait_time = 0.5
|
||||
autostart = true
|
||||
[node name="LineThick" type="Line2D" parent="." index="5"]
|
||||
z_index = 10
|
||||
width = 32.0
|
||||
texture = ExtResource("4_63xdp")
|
||||
texture_mode = 1
|
||||
|
||||
[node name="LineThin" type="Line2D" parent="." index="6"]
|
||||
z_index = 10
|
||||
width = 32.0
|
||||
texture = ExtResource("5_5s0k0")
|
||||
texture_mode = 1
|
||||
|
||||
[connection signal="timeout" from="JinkTimer" to="." method="_on_jink_timer_timeout"]
|
||||
[connection signal="timeout" from="LifeTimer" to="." method="_on_life_timer_timeout"]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://1o2ta17yc5bp" path="res://game/entities/weapons/abstract_weapon.tscn" id="1_rpud7"]
|
||||
[ext_resource type="Script" uid="uid://ctv408wdwvttc" path="res://game/entities/weapons/tesla/abstract_tesla_weapon.gd" id="2_08si3"]
|
||||
[ext_resource type="Texture2D" uid="uid://dk3t14mrgjmma" path="res://particle_textures/energy_medium.tres" id="4_2dxgo"]
|
||||
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/weapons.png" id="7_ub67s"]
|
||||
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/ships/weapons.png" id="7_ub67s"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ucdpq"]
|
||||
atlas = ExtResource("7_ub67s")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://dyebeblayioji" path="res://game/entities/weapons/tesla/abstract_tesla_weapon.tscn" id="1_k6lmk"]
|
||||
[ext_resource type="Script" uid="uid://ermhuy56qrok" path="res://game/entities/weapons/tesla/enemy_tesla_weapon.gd" id="2_cxr41"]
|
||||
[ext_resource type="PackedScene" uid="uid://cpqpc1h3egvid" path="res://game/entities/weapons/tesla/enemy_tesla_projectile.tscn" id="3_i0gkc"]
|
||||
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/weapons.png" id="4_b2pb7"]
|
||||
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/ships/weapons.png" id="4_b2pb7"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ucdpq"]
|
||||
atlas = ExtResource("4_b2pb7")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://dyebeblayioji" path="res://game/entities/weapons/tesla/abstract_tesla_weapon.tscn" id="1_0i0tl"]
|
||||
[ext_resource type="Script" uid="uid://d2qtsjtu56c21" path="res://game/entities/weapons/tesla/player_tesla_weapon.gd" id="2_ve1yj"]
|
||||
[ext_resource type="PackedScene" uid="uid://bvrsk14t6m061" path="res://game/entities/weapons/tesla/player_tesla_projectile.tscn" id="3_io2od"]
|
||||
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/weapons.png" id="4_mjxwr"]
|
||||
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/ships/weapons.png" id="4_mjxwr"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7ksu7"]
|
||||
atlas = ExtResource("4_mjxwr")
|
||||
|
||||
Reference in New Issue
Block a user