Set Up Modifiers

main
Luna Brovchuk 2023-10-02 19:30:47 +02:00
parent e70e005230
commit bd0a0c2fc4
8 changed files with 66 additions and 26 deletions

View File

@ -89,6 +89,5 @@ common/enable_pause_aware_picking=true
[rendering]
quality/driver/driver_name="GLES2"
environment/default_clear_color=Color( 0, 0, 0, 1 )
environment/default_environment="res://default_env.tres"

View File

@ -15,5 +15,5 @@ void fragment(){
[resource]
shader = SubResource( 3 )
shader_param/active = false
shader_param/color = Color( 1, 1, 1, 1 )
shader_param/active = true
shader_param/color = Color( 1, 1, 1, 0 )

View File

@ -3,7 +3,6 @@
[ext_resource path="res://res/fonts/silkscreen/Silkscreen-Regular.ttf" type="DynamicFontData" id=1]
[sub_resource type="DynamicFont" id=1]
size = 8
font_data = ExtResource( 1 )
[resource]

View File

@ -2,13 +2,15 @@ extends KinematicBody2D
var velocity = Vector2.ZERO
var speed = 128
var poisoned = false
var poison_damage = 0
var damage = 5
var frozen = false
var bounced = false
var ricochet = false
var freeze_modifier = 1
var bounced = 0
var ricochet_count = 0
var prev_target
var target
var explosive_damage = 0
var speed_modifier = 1
func choose_target():
target = null
@ -29,7 +31,7 @@ func _physics_process(delta):
var target_center = target.global_position + (target_sprite_size / 2)
if target.is_in_group("rat"):
target_center = target.global_position + Vector2(0, 2)
self.global_position = self.global_position.move_toward(target_center, delta * speed)
self.global_position = self.global_position.move_toward(target_center, delta * speed * speed_modifier)
else:
self.call_deferred("free")
@ -38,9 +40,10 @@ func area_entered(area):
if parent.is_in_group("enemy") and parent != prev_target:
prev_target = parent
parent.deal_damage(damage)
parent.frozen = frozen
parent.poisoned = poisoned
if bounced or not ricochet:
parent.freeze_modifier = freeze_modifier
parent.poison_damage = poison_damage
if ricochet_count >= bounced:
call_deferred("free")
choose_target()
bounced = true
bounced += 1
damage *= 0.5

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://src/models/fireball/fireball.png" type="Texture" id=1]
[ext_resource path="res://src/models/fireball/fireball.gd" type="Script" id=2]
@ -6,7 +6,12 @@
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 2, 2 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 2, 2 )
[node name="Fireball" type="KinematicBody2D"]
collision_layer = 4
collision_mask = 4
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
@ -19,4 +24,7 @@ centered = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 2 )
[connection signal="area_entered" from="Area2D" to="." method="area_entered"]

View File

@ -2,8 +2,9 @@ extends KinematicBody2D
onready var fireball_preload = preload("res://src/models/fireball/Fireball.tscn")
onready var bullet_preload = preload("res://src/models/bullet/Bullet.tscn")
#var outline_material = load("res://res/shaders/outline_material.tres")
var outline_material = load("res://res/shaders/empty_material.tres")
onready var spell_holder = $"../../UIWrapper/UI/Center/SpellHolder"
var outline_material = load("res://res/shaders/outline_material.tres")
#var outline_material = load("res://res/shaders/empty_material.tres")
var speed_multiplier: float = 1.0
var invincibility_timer = .0
var velocity = Vector2.ZERO
@ -66,11 +67,41 @@ func area_entered(area):
get_tree().get_root().get_node("Game/View/Camera2D").current = true
func get_recharge():
return 2.0
var recharge = 2.0
for modifier in spell_holder.modifiers:
if modifier == "rapidfire":
recharge /= 2.0
return recharge
func _shoot():
var ricochet_count = 0
var dmg_multiplier = 1
var explosive_damage = 0
var fireball_amount = 0
var freeze_modifier = 1
var poison_damage = 0
var speed_modifier = 1
for modifier in spell_holder.modifiers:
match modifier:
"ricochet": ricochet_count += 1
"big_magic": dmg_multiplier *= 1.25
"explode": explosive_damage += 10
"fireball": fireball_amount += 1
"freeze": freeze_modifier /= 2.0
"poison": poison_damage += 5
"quick_magic": speed_modifier *= 1.5
bullet = bullet_preload.instance()
bullet.target = target
bullet.damage *= dmg_multiplier
bullet.scale = Vector2(dmg_multiplier, dmg_multiplier)
bullet.explosive_damage = explosive_damage
bullet.freeze_modifier = freeze_modifier
bullet.poison_damage = poison_damage
bullet.speed_modifier = speed_modifier
get_parent().add_child(bullet)
bullet.global_position.x = self.global_position.x + 8
bullet.global_position.y = self.global_position.y + 8

View File

@ -32,14 +32,14 @@ extents = Vector2( 140, 10.125 )
atlas = ExtResource( 6 )
region = Rect2( 155, 0, 31, 11 )
[sub_resource type="AtlasTexture" id=9]
atlas = ExtResource( 6 )
region = Rect2( 93, 0, 31, 11 )
[sub_resource type="AtlasTexture" id=8]
atlas = ExtResource( 6 )
region = Rect2( 124, 0, 31, 11 )
[sub_resource type="AtlasTexture" id=9]
atlas = ExtResource( 6 )
region = Rect2( 93, 0, 31, 11 )
[sub_resource type="AtlasTexture" id=10]
atlas = ExtResource( 6 )
region = Rect2( 62, 0, 31, 11 )
@ -54,10 +54,10 @@ region = Rect2( 0, 0, 31, 11 )
[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ SubResource( 7 ), SubResource( 9 ), SubResource( 8 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ) ],
"loop": false,
"name": "idle",
"speed": 0.0
"frames": [ SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="Animation" id=5]

View File

@ -66,6 +66,6 @@ func _physics_process(delta):
func select_card():
if selected_card != null:
$"../Center/SpellHolder".add_modifier(spells[selected_modifier])
$UIWrapper/UI/Center/SpellHolder.add_modifier(spells[selected_modifier])
Global.playing = true
$UIWrapper/UI/Cards.visible = false