diff --git a/behaviours/rewards.json b/behaviours/rewards.json new file mode 100644 index 0000000..d3f7aac --- /dev/null +++ b/behaviours/rewards.json @@ -0,0 +1,34 @@ +[ + { + "id": "FIRE_COOLDOWN", + "value": [-0.05, 0.5], + "title": "快速扳机", + "subtitle": "一切恐惧都来源于火力不足", + "description": "快速扳机是一项专为追求速度和灵活性的射手设计的装备。使用该扳机可以显著减少武器射击的冷却时间,每次触发可降低 0.05s 的等待时间,使你在紧急情况下更加迅速地进行连续射击。然而,为了追求这种敏捷性,你需要注意,快速扳机的使用会导致武器威力的降低,每次射击将减少 0.5 的伤害。在速度和威力之间做出明智选择,以确保在战斗中找到最佳平衡点,发挥出最大的战术优势。", + "weight": 0.2 + }, + { + "id": "BULLET_DAMAGE", + "value": 2, + "title": "子弹调整", + "subtitle": "更大、更强、更棒", + "description": "子弹调整服务是一项定制化的武器优化服务,旨在显著提升射击火力。通过增加子弹的火药量,这项服务将每次射击的伤害提升至新的高度,每发子弹额外增加 2 点伤害。这意味着你的武器在战场上将变得更加毁灭性,能够更迅速地摧毁敌人的防线。", + "weight": 0.1 + }, + { + "id": "BULLET_KNOCKBACK", + "value": 2, + "title": "强化枪机", + "subtitle": "把你的敌人弹向火星", + "description": "强化枪机是一项专为追求更强大战术控制的射手设计的武器升级服务。通过对武器的枪机系统进行增强,这项服务赋予了射击出的子弹更为强大的击退能力。每一发子弹都带有更大的冲击力,能够有效地推动目标并改变战场动态。", + "weight": 0.2 + }, + { + "id": "TOWER_HEALTH", + "value": 50, + "title": "修复套件", + "subtitle": "你的强大可靠后援", + "description": "修复套件是一项专门设计用于玩家的塔维护的服务。这个套件经过精心设计,能够快速而有效地修复你的塔,回复其50点的血量。无论是在激烈的战斗中受损还是在战局紧急情况下,这项服务都能确保你的塔保持在最佳状态,延长其在战场上的生存能力。", + "weight": 0.3 + } +] diff --git a/scenes/main.tscn b/scenes/main.tscn index 83ae678..0adc516 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://l4mybb2dw107"] +[gd_scene load_steps=11 format=3 uid="uid://l4mybb2dw107"] [ext_resource type="PackedScene" uid="uid://cwkcf8h5rspoh" path="res://scenes/objects/player.tscn" id="1_nq1ke"] [ext_resource type="PackedScene" uid="uid://cxlgt8h33u7os" path="res://scenes/objects/tower.tscn" id="2_betjv"] @@ -8,10 +8,11 @@ [ext_resource type="PackedScene" uid="uid://cjam63kp5sg2o" path="res://scenes/ui/stats_overlay.tscn" id="5_rymed"] [ext_resource type="PackedScene" uid="uid://dy51uqtr2ng32" path="res://scenes/ui/finish_screen.tscn" id="6_b264x"] [ext_resource type="PackedScene" uid="uid://5mt7abqkbpei" path="res://scenes/ui/reward_claim_screen.tscn" id="6_t43s0"] +[ext_resource type="JSON" path="res://behaviours/rewards.json" id="7_yubu4"] [sub_resource type="Curve2D" id="Curve2D_gwd20"] _data = { -"points": PackedVector2Array(0, 0, 0, 0, -309, -271, 0, 0, 0, 0, -309, 850, 0, 0, 0, 0, 1369, 849, 0, 0, 0, 0, 1368, -272, 0, 0, 0, 0, -309, -271) +"points": PackedVector2Array(0, 0, 0, 0, -174, -153, 0, 0, 0, 0, -170, 795, 0, 0, 0, 0, 1362, 801, 0, 0, 0, 0, 1358, -153, 0, 0, 0, 0, -174, -151) } point_count = 5 @@ -34,8 +35,8 @@ statistics = NodePath("../Statistics") curve = SubResource("Curve2D_gwd20") [node name="EnemySpawnPoint" type="PathFollow2D" parent="EnemySpawnPath"] -position = Vector2(-309, -271) -rotation = 1.5708 +position = Vector2(-174, -153) +rotation = 1.56658 [node name="StatsOverlay" parent="." node_paths=PackedStringArray("stats") instance=ExtResource("5_rymed")] stats = NodePath("../Statistics") @@ -44,6 +45,7 @@ stats = NodePath("../Statistics") visible = false tower = NodePath("../Tower") player = NodePath("../Player") +behaviour_asset = ExtResource("7_yubu4") [node name="FinishScreen" parent="." node_paths=PackedStringArray("stats") instance=ExtResource("6_b264x")] visible = false diff --git a/scenes/objects/player.tscn b/scenes/objects/player.tscn index 13fd70a..b853515 100644 --- a/scenes/objects/player.tscn +++ b/scenes/objects/player.tscn @@ -7,18 +7,17 @@ [sub_resource type="CircleShape2D" id="CircleShape2D_k56cq"] radius = 52.0096 -[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("dash_cooldown_timer", "weapon_bullet_parent", "fire_cooldown_timer")] +[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("dash_cooldown_timer", "fire_cooldown_timer")] collision_mask = 3 script = ExtResource("1_sa7t7") dash_cooldown_timer = NodePath("DashCooldown") weapon_bullet_scene = ExtResource("2_v83ov") -weapon_bullet_parent = NodePath("") fire_cooldown_timer = NodePath("ShootCooldown") [node name="DashCooldown" type="Timer" parent="."] [node name="ShootCooldown" type="Timer" parent="."] -wait_time = 0.2 +wait_time = 0.8 [node name="PlayerSprite" type="Sprite2D" parent="."] position = Vector2(1.90735e-06, 1.78814e-06) diff --git a/scenes/ui/reward_claim_screen.tscn b/scenes/ui/reward_claim_screen.tscn index 361b469..c32facf 100644 --- a/scenes/ui/reward_claim_screen.tscn +++ b/scenes/ui/reward_claim_screen.tscn @@ -25,10 +25,21 @@ offset_right = 1152.0 offset_bottom = 648.0 theme_override_styles/panel = SubResource("StyleBoxFlat_3xnq2") -[node name="RewardContainer" type="HBoxContainer" parent="Panel"] +[node name="Title" type="Label" parent="Panel"] layout_mode = 0 offset_left = 32.0 offset_top = 32.0 offset_right = 1120.0 +offset_bottom = 88.0 +theme_override_font_sizes/font_size = 28 +text = "Pick a Upgrade" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="RewardContainer" type="HBoxContainer" parent="Panel"] +layout_mode = 0 +offset_left = 32.0 +offset_top = 96.0 +offset_right = 1120.0 offset_bottom = 616.0 alignment = 1 diff --git a/scenes/ui/reward_item.tscn b/scenes/ui/reward_item.tscn index 5e74c83..7925d72 100644 --- a/scenes/ui/reward_item.tscn +++ b/scenes/ui/reward_item.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://scripts/ui/reward_item.gd" id="1_v4j3k"] [node name="RewardItem" type="Panel"] -custom_minimum_size = Vector2(360, 584) +custom_minimum_size = Vector2(360, 520) script = ExtResource("1_v4j3k") [node name="Title" type="Label" parent="."] @@ -29,15 +29,15 @@ layout_mode = 0 offset_left = 52.0 offset_top = 208.0 offset_right = 308.0 -offset_bottom = 504.0 +offset_bottom = 432.0 bbcode_enabled = true text = "This is the world most powerful reward. Trust me, choose this is a great choice." [node name="ClaimButton" type="Button" parent="."] offset_left = 52.0 -offset_top = 520.0 +offset_top = 448.0 offset_right = 308.0 -offset_bottom = 552.0 +offset_bottom = 480.0 text = "Claim" [connection signal="pressed" from="ClaimButton" to="." method="_on_claim"] diff --git a/scripts/bullet.gd b/scripts/bullet.gd index 93dd933..bab864e 100644 --- a/scripts/bullet.gd +++ b/scripts/bullet.gd @@ -1,6 +1,6 @@ extends CharacterBody2D -@export var damage = 12.0 +@export var damage = 4.0 @export var knockback = 4 func _physics_process(delta): diff --git a/scripts/enemy_farm.gd b/scripts/enemy_farm.gd index 421af36..99b8c9d 100644 --- a/scripts/enemy_farm.gd +++ b/scripts/enemy_farm.gd @@ -9,6 +9,8 @@ signal enemy_defeat @export var common_target: Node2D @export var respawn_timer: Timer +@export var respawn_duration = 2.0 +@export var respawn_multiplier = 0.25 func spawn(): var instance = target.instantiate() @@ -28,9 +30,14 @@ func spawn(): common_parent.add_child(instance) func _on_wave_finished(): + for child in common_parent.get_children(): + if not child is Timer: + child.queue_free() respawn_timer.stop() -func _on_wave_started(): +func _on_wave_started(count): + var additional = respawn_multiplier * (count - 1) + respawn_timer.wait_time = respawn_duration - additional respawn_timer.start() func _on_enemy_defeat(): diff --git a/scripts/player.gd b/scripts/player.gd index 9de5c91..35f9eb5 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -9,11 +9,13 @@ extends CharacterBody2D @export var dash_cooldown_duration = 1.0 @export var dash_cooldown_timer: Timer +@export var weapon_bullet_damage = 4.0 +@export var weapon_bullet_knockback = 4 @export var weapon_bullet_speed = 3200 @export var weapon_bullet_scene: PackedScene @export var weapon_bullet_parent: Node2D -@export var fire_cooldown_duration = 0.2 +@export var fire_cooldown_duration = 0.35 @export var fire_cooldown_timer: Timer @export var statistics: Statistics @@ -39,6 +41,8 @@ func deal_weapon_shoot(): bullet.global_position = global_position bullet.velocity = direction * weapon_bullet_speed + bullet.damage = weapon_bullet_damage + bullet.knockback = weapon_bullet_knockback statistics.bullet_shoot += 1 fire_cooldown_timer.start(fire_cooldown_duration) diff --git a/scripts/statistics.gd b/scripts/statistics.gd index fe00491..9ea4ccb 100644 --- a/scripts/statistics.gd +++ b/scripts/statistics.gd @@ -14,7 +14,7 @@ var in_wave_gap: bool var enemies_defeated: int var bullet_shoot: int -@export var wave_gap_duration = 10 +@export var wave_gap_duration = 3 @export var wave_duration = 10 @export var wave_multiplier = 1.5 @@ -66,6 +66,6 @@ func _on_wave_passed(): func _on_wave_gap_passed(): in_wave_gap = false - wave_started.emit() + wave_started.emit(get_current_wave()) wave_timer.wait_time = get_current_wave_duration() wave_timer.start() diff --git a/scripts/ui/reward_claim_screen.gd b/scripts/ui/reward_claim_screen.gd index ad4d380..135bc70 100644 --- a/scripts/ui/reward_claim_screen.gd +++ b/scripts/ui/reward_claim_screen.gd @@ -1,18 +1,16 @@ extends Control - @export var card: PackedScene @export var tower: Tower @export var player: Player -@export var items = [ - { - id = "QUICK_TRIGGER", - title = "Quick Trigger", - subtitle = "Save your finger", - description = "Reduce the delay between two shot.", - weight = 0.1, - } -] +@export var behaviour_asset: Resource + +var items = [] + +func _ready(): + var file = FileAccess.open(behaviour_asset.resource_path, FileAccess.READ) + var content = file.get_as_text() + items = JSON.parse_string(content) func pick_item() -> Dictionary: var total_weight: float = 0.0 @@ -33,7 +31,8 @@ func roll(): child.queue_free() var items = [] - for idx in range(3): + var count = randi_range(1, 3) + for idx in range(count): items.append(pick_item()) for item in items: @@ -41,6 +40,7 @@ func roll(): instance.tower = tower instance.player = player instance.id = item["id"] + instance.value = item["value"] instance.title = item["title"] instance.subtitle = item["subtitle"] instance.description = item["description"] diff --git a/scripts/ui/reward_item.gd b/scripts/ui/reward_item.gd index 6adf31f..81bd91c 100644 --- a/scripts/ui/reward_item.gd +++ b/scripts/ui/reward_item.gd @@ -5,6 +5,8 @@ signal claimed @export var tower: Tower @export var player: Player +var value + @export var id: String @export var title: String @export var subtitle: String @@ -16,7 +18,14 @@ func _ready(): $Description.text = description func _on_claim(): - if id == "QUICK_TRIGGER": - if player.fire_cooldown_duration > 0: - player.fire_cooldown_duration -= 0.05 + match id: + "FIRE_COOLDOWN" when player.fire_cooldown_duration > 0: + player.fire_cooldown_duration += value[0] + player.weapon_bullet_damage -= value[1] + "BULLET_DAMAGE": + player.weapon_bullet_damage += value + "BULLET_KNOCKBACK": + player.weapon_bullet_knockback += value + "TOWER_HEALTH": + tower.health += value claimed.emit()