More upgrades

This commit is contained in:
LittleSheep 2024-02-17 12:04:43 +08:00
parent 8be0789b17
commit f8bb0d3975
11 changed files with 97 additions and 31 deletions

34
behaviours/rewards.json Normal file
View File

@ -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
}
]

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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"]

View File

@ -1,6 +1,6 @@
extends CharacterBody2D
@export var damage = 12.0
@export var damage = 4.0
@export var knockback = 4
func _physics_process(delta):

View File

@ -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():

View File

@ -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)

View File

@ -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()

View File

@ -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"]

View File

@ -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()