Add DMG Labels
parent
0f2ab4af47
commit
018267e152
|
@ -1,6 +1,7 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var explosion_preload = preload("res://src/models/explosion/Explosion.tscn")
|
||||
var dmg_label_preload = preload("res://src/models/dmg_label/DMGLabel.tscn")
|
||||
var explode = false
|
||||
var velocity = Vector2.ZERO
|
||||
var speed = 128
|
||||
|
@ -49,11 +50,20 @@ func area_entered(area):
|
|||
parent.frozen_timer = 0
|
||||
parent.poison_damage = poison_damage
|
||||
parent.poisoned_timer = 0
|
||||
|
||||
var dmg_label = dmg_label_preload.instance()
|
||||
dmg_label.dmg = damage * damage_multiplier
|
||||
if poison_damage != 0:
|
||||
dmg_label.modulate = Color("1E6945")
|
||||
if target_center != null:
|
||||
dmg_label.global_position = target_center + Vector2(-16, -16)
|
||||
get_parent().add_child(dmg_label)
|
||||
if not explode and explosive_damage != 0:
|
||||
explode = true
|
||||
var explosion = explosion_preload.instance()
|
||||
explosion.global_position = target_center + Vector2(0, -16)
|
||||
get_parent().add_child(explosion)
|
||||
if target_center != null:
|
||||
explosion.global_position = target_center + Vector2(-16, -16)
|
||||
if bounced >= ricochet_count:
|
||||
call_deferred("free")
|
||||
choose_target()
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://res/themes/8px.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://src/models/dmg_label/dmg_label.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Label:rect_position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Label:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 1 ) ]
|
||||
}
|
||||
tracks/2/type = "bezier"
|
||||
tracks/2/path = NodePath("Label:modulate:r")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"points": PoolRealArray( 1, -0.25, 0, 0.25, 0 ),
|
||||
"times": PoolRealArray( 0 )
|
||||
}
|
||||
tracks/3/type = "bezier"
|
||||
tracks/3/path = NodePath("Label:modulate:g")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/keys = {
|
||||
"points": PoolRealArray( 1, -0.25, 0, 0.25, 0 ),
|
||||
"times": PoolRealArray( 0 )
|
||||
}
|
||||
tracks/4/type = "bezier"
|
||||
tracks/4/path = NodePath("Label:modulate:b")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/keys = {
|
||||
"points": PoolRealArray( 1, -0.25, 0, 0.25, 0 ),
|
||||
"times": PoolRealArray( 0 )
|
||||
}
|
||||
tracks/5/type = "bezier"
|
||||
tracks/5/path = NodePath("Label:modulate:a")
|
||||
tracks/5/interp = 1
|
||||
tracks/5/loop_wrap = true
|
||||
tracks/5/imported = false
|
||||
tracks/5/enabled = true
|
||||
tracks/5/keys = {
|
||||
"points": PoolRealArray( 1, -0.25, 0, 0.25, 0 ),
|
||||
"times": PoolRealArray( 0 )
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "fadeout"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Label:rect_position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 1 ),
|
||||
"transitions": PoolRealArray( 1, 6.49801 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ), Vector2( 0, -20 ) ]
|
||||
}
|
||||
tracks/1/type = "bezier"
|
||||
tracks/1/path = NodePath("Label:modulate:r")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = false
|
||||
tracks/1/keys = {
|
||||
"points": PoolRealArray( 1, -0.25, 0, 0.25, 0 ),
|
||||
"times": PoolRealArray( 0 )
|
||||
}
|
||||
tracks/2/type = "bezier"
|
||||
tracks/2/path = NodePath("Label:modulate:g")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = false
|
||||
tracks/2/keys = {
|
||||
"points": PoolRealArray( 1, -0.25, 0, 0.25, 0 ),
|
||||
"times": PoolRealArray( 0 )
|
||||
}
|
||||
tracks/3/type = "bezier"
|
||||
tracks/3/path = NodePath("Label:modulate:b")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = false
|
||||
tracks/3/keys = {
|
||||
"points": PoolRealArray( 1, -0.25, 0, 0.25, 0 ),
|
||||
"times": PoolRealArray( 0 )
|
||||
}
|
||||
tracks/4/type = "bezier"
|
||||
tracks/4/path = NodePath("Label:modulate:a")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/keys = {
|
||||
"points": PoolRealArray( 1, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0 ),
|
||||
"times": PoolRealArray( 0, 1 )
|
||||
}
|
||||
|
||||
[node name="DMGLabel" type="KinematicBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
margin_right = 30.0
|
||||
margin_bottom = 13.0
|
||||
theme = ExtResource( 1 )
|
||||
text = "12DMG"
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
autoplay = "fadeout"
|
||||
anims/RESET = SubResource( 1 )
|
||||
anims/fadeout = SubResource( 2 )
|
||||
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="animation_finished"]
|
|
@ -0,0 +1,9 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var dmg = 10
|
||||
|
||||
func _ready():
|
||||
$Label.text = String(dmg)
|
||||
|
||||
func animation_finished(anim_name):
|
||||
call_deferred("free")
|
|
@ -1,16 +1,25 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://src/models/enemies/rat/sprites/rat_spriteframes.tres" type="SpriteFrames" id=1]
|
||||
[ext_resource path="res://src/models/enemies/rat/rat.gd" type="Script" id=2]
|
||||
[ext_resource path="res://src/models/shadow/shadow.png" type="Texture" id=3]
|
||||
[ext_resource path="res://res/sounds/rat/damaged.wav" type="AudioStream" id=4]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 8, 3.5 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 8, 3.5 )
|
||||
|
||||
[node name="Rat" type="KinematicBody2D" groups=["enemy", "rat"]]
|
||||
collision_layer = 8
|
||||
collision_mask = 8
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 11, 5.5 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Sprite" type="AnimatedSprite" parent="."]
|
||||
use_parent_material = true
|
||||
position = Vector2( -3, 0 )
|
||||
|
|
|
@ -6,7 +6,7 @@ var speed = 24
|
|||
func _ready():
|
||||
randomize()
|
||||
global_position = [Vector2(33, 50), Vector2(287, 70)][randi()%2]
|
||||
hp = 7
|
||||
hp = 15
|
||||
|
||||
func _physics_process(delta):
|
||||
global_position = global_position.move_toward(player.global_position + Vector2(8, 8), speed * delta * speed_multiplier)
|
||||
|
|
|
@ -24,11 +24,14 @@ script = ExtResource( 1 )
|
|||
[node name="Area2D" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 25, 20 )
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
frames = SubResource( 2 )
|
||||
frame = 3
|
||||
playing = true
|
||||
centered = false
|
||||
|
||||
[connection signal="animation_finished" from="AnimatedSprite" to="." method="animation_finished"]
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var dmg_label_preload = preload("res://src/models/dmg_label/DMGLabel.tscn")
|
||||
var velocity = Vector2.ZERO
|
||||
var sin_timer = .0
|
||||
var speed = 64
|
||||
var target_center
|
||||
var damage = 8
|
||||
var target
|
||||
|
||||
|
@ -11,7 +13,7 @@ func _physics_process(delta):
|
|||
if target != null and is_instance_valid(target) and not target.dead:
|
||||
var target_texture = target.get_node("Sprite").frames.get_frame("idle", 0)
|
||||
var target_sprite_size = Vector2(target_texture.get_width(), target_texture.get_width())
|
||||
var target_center = target.global_position + (target_sprite_size / 2)
|
||||
target_center = target.global_position + (target_sprite_size / 2)
|
||||
if target.is_in_group("rat"):
|
||||
target_center = target.global_position + Vector2(0, 2)
|
||||
var angle = global_position.angle_to_point(target_center)
|
||||
|
@ -22,5 +24,11 @@ func _physics_process(delta):
|
|||
func area_entered(area):
|
||||
var parent = area.get_parent()
|
||||
if parent.is_in_group("enemy"):
|
||||
var dmg_label = dmg_label_preload.instance()
|
||||
dmg_label.dmg = damage
|
||||
dmg_label.modulate = Color("F26038")
|
||||
if target_center != null:
|
||||
dmg_label.global_position = target_center + Vector2(-16, -16)
|
||||
get_parent().add_child(dmg_label)
|
||||
parent.deal_damage(damage)
|
||||
call_deferred("free")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=24 format=2]
|
||||
[gd_scene load_steps=25 format=2]
|
||||
|
||||
[ext_resource path="res://src/scenes/menu/background/background.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/scenes/game/sprites/background_houses.png" type="Texture" id=2]
|
||||
|
@ -14,6 +14,7 @@
|
|||
[ext_resource path="res://src/scenes/game/sprites/ui_background.png" type="Texture" id=12]
|
||||
[ext_resource path="res://src/scenes/game/sprites/hatch1.png" type="Texture" id=13]
|
||||
[ext_resource path="res://src/scenes/game/sprites/hatch2.png" type="Texture" id=14]
|
||||
[ext_resource path="res://src/models/enemies/rat/Rat.tscn" type="PackedScene" id=15]
|
||||
[ext_resource path="res://src/scenes/game/spell_recharge_bar.gd" type="Script" id=16]
|
||||
[ext_resource path="res://src/scenes/game/sprites/stun/stun_spriteframes.tres" type="SpriteFrames" id=17]
|
||||
[ext_resource path="res://src/models/card/Card.tscn" type="PackedScene" id=18]
|
||||
|
@ -86,6 +87,12 @@ z_index = 1
|
|||
|
||||
[node name="Enemies" type="Node2D" parent="View"]
|
||||
|
||||
[node name="Rat" parent="View/Enemies" instance=ExtResource( 15 )]
|
||||
position = Vector2( 237, 32 )
|
||||
|
||||
[node name="Rat3" parent="View/Enemies" instance=ExtResource( 15 )]
|
||||
position = Vector2( 183, 36 )
|
||||
|
||||
[node name="CPUParticles2D" type="CPUParticles2D" parent="View"]
|
||||
position = Vector2( 160, 90 )
|
||||
amount = 9
|
||||
|
@ -141,7 +148,7 @@ margin_right = 40.0
|
|||
margin_bottom = 40.0
|
||||
|
||||
[node name="Slowed" type="AnimatedSprite" parent="UIWrapper/UI/Left/Debuffs"]
|
||||
position = Vector2( 59, 144 )
|
||||
position = Vector2( 74, 144 )
|
||||
frames = ExtResource( 19 )
|
||||
animation = "idle"
|
||||
|
||||
|
@ -150,7 +157,7 @@ frames = ExtResource( 17 )
|
|||
animation = "idle"
|
||||
|
||||
[node name="Stun" type="AnimatedSprite" parent="UIWrapper/UI/Left/Debuffs"]
|
||||
position = Vector2( 76, 144 )
|
||||
position = Vector2( 91, 144 )
|
||||
frames = ExtResource( 19 )
|
||||
animation = "idle"
|
||||
|
||||
|
@ -164,16 +171,24 @@ margin_right = 40.0
|
|||
margin_bottom = 40.0
|
||||
|
||||
[node name="HealthSprite" type="AnimatedSprite" parent="UIWrapper/UI/Left/Health"]
|
||||
position = Vector2( 52, 156 )
|
||||
position = Vector2( 67, 156 )
|
||||
frames = ExtResource( 6 )
|
||||
animation = "idle"
|
||||
centered = false
|
||||
|
||||
[node name="PlayerIcon" type="Sprite" parent="UIWrapper/UI/Left"]
|
||||
position = Vector2( 10, 136 )
|
||||
position = Vector2( 25, 136 )
|
||||
texture = ExtResource( 10 )
|
||||
centered = false
|
||||
|
||||
[node name="LevelLabel" type="Label" parent="UIWrapper/UI/Left"]
|
||||
margin_left = 11.0
|
||||
margin_top = 126.0
|
||||
margin_right = 26.0
|
||||
margin_bottom = 140.0
|
||||
theme = ExtResource( 4 )
|
||||
text = "1"
|
||||
|
||||
[node name="Center" type="Control" parent="UIWrapper/UI"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
|
|
|
@ -3,7 +3,7 @@ extends Node
|
|||
var selected_card = null
|
||||
var selected_modifier = 0
|
||||
var difficulty = 0
|
||||
var last_diff = 0
|
||||
var last_diff = -1
|
||||
var mob_preloads = [
|
||||
preload("res://src/models/enemies/rat/Rat.tscn"),
|
||||
preload("res://src/models/enemies/bat/Bat.tscn"),
|
||||
|
@ -26,7 +26,7 @@ var spells = [
|
|||
|
||||
func _ready():
|
||||
Global.playing = true
|
||||
Global.play_time = 59.0
|
||||
Global.play_time = .0
|
||||
Global.health = 5
|
||||
Global.add_health(0)
|
||||
|
||||
|
@ -40,7 +40,7 @@ func _input(event):
|
|||
selected_card = null
|
||||
|
||||
func _physics_process(delta):
|
||||
if Global.playing:
|
||||
if Global.playing and difficulty < 4:
|
||||
Global.play_time += delta
|
||||
|
||||
difficulty = int(Global.play_time / 60)
|
||||
|
@ -67,7 +67,7 @@ func _physics_process(delta):
|
|||
|
||||
func select_card():
|
||||
if selected_card != null:
|
||||
$"UIWrapper/UI/Center/SpellHolder".add_modifier(spells[selected_modifier], selected_modifier)
|
||||
$UIWrapper/UI/Center/SpellHolder.add_modifier(spells[selected_modifier], selected_modifier)
|
||||
Global.playing = true
|
||||
$UIWrapper/UI/Cards.visible = false
|
||||
|
||||
|
@ -76,5 +76,6 @@ func _process(delta):
|
|||
|
||||
func update_ui():
|
||||
var player = $View/Player
|
||||
$"UIWrapper/UI/Right/CastTime/CastTimeLabel".text = String(player.get_recharge())
|
||||
$"UIWrapper/UI/Right/Damage/DamageLabel".text = String(player.get_damage())
|
||||
$UIWrapper/UI/Right/CastTime/CastTimeLabel.text = String(player.get_recharge())
|
||||
$UIWrapper/UI/Right/Damage/DamageLabel.text = String(player.get_damage())
|
||||
$UIWrapper/UI/Left/LevelLabel.text = String(difficulty + 1)
|
||||
|
|
|
@ -70,4 +70,6 @@ func _physics_process(delta):
|
|||
speed_multiplier = 1
|
||||
|
||||
if not Global.playing:
|
||||
if death_position == null:
|
||||
death_position = global_position
|
||||
self.global_position = death_position
|
||||
|
|
Loading…
Reference in New Issue