-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
451 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://b1j6h4bippirj"] | ||
[gd_resource type="Resource" script_class="MetaUpgrade" load_steps=2 format=3 uid="uid://b1j6h4bippirj"] | ||
|
||
[ext_resource type="Script" path="res://resources/meta_upgrade/meta_upgrade.gd" id="1_6epyd"] | ||
|
||
[resource] | ||
script = ExtResource("1_6epyd") | ||
id = "experience_gain" | ||
max_quantity = 1 | ||
experience_cost = 100 | ||
title = "Increase Experience" | ||
description = "Increases experience drop chance by 10%." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
extends CanvasLayer | ||
class_name MetaMenu | ||
|
||
@export var upgrades: Array[MetaUpgrade] = [] | ||
|
||
@onready var grid_container: GridContainer = %GridContainer | ||
@onready var back_button: Button = %BackButton | ||
|
||
var meta_upgrade_card_scene = preload("res://scenes/ui/meta_upgrade_card.tscn") | ||
|
||
|
||
func _ready(): | ||
back_button.pressed.connect(on_back_pressed) | ||
|
||
# remove debug childrens | ||
for child in grid_container.get_children(): | ||
child.queue_free() | ||
|
||
for u in upgrades: | ||
var meta_upgrade_card_instance = meta_upgrade_card_scene.instantiate() as MetaUpgradeCard | ||
grid_container.add_child(meta_upgrade_card_instance) | ||
meta_upgrade_card_instance.set_meta_upgrade(u) | ||
|
||
|
||
func on_back_pressed(): | ||
ScreenTransition.transition_to_scene("res://scenes/ui/main_menu.tscn") |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
extends PanelContainer | ||
class_name MetaUpgradeCard | ||
|
||
@onready var name_label: Label = %NameLabel | ||
@onready var description_label: Label = %DescriptionLabel | ||
@onready var progress_bar: ProgressBar = %ProgressBar | ||
@onready var purchase_button: Button = %PurchaseButton | ||
@onready var progress_label: Label = %ProgressLabel | ||
@onready var count_label: Label = %CountLabel | ||
|
||
var upgrade: MetaUpgrade | ||
|
||
|
||
func _ready(): | ||
purchase_button.pressed.connect(on_purchase_pressed) | ||
|
||
|
||
func set_meta_upgrade(upgrade: MetaUpgrade) -> void: | ||
self.upgrade = upgrade | ||
name_label.text = upgrade.title | ||
description_label.text = upgrade.description | ||
update_progress() | ||
|
||
|
||
func update_progress(): | ||
var current_quantity := 0 | ||
if MetaProgression.save_data["meta_upgrades"].has(upgrade.id): | ||
current_quantity = MetaProgression.save_data["meta_upgrades"][upgrade.id]["quantity"] | ||
|
||
var is_maxed: bool = current_quantity >= upgrade.max_quantity | ||
var currency = MetaProgression.save_data["meta_upgrade_currency"] | ||
var percent = currency / upgrade.experience_cost | ||
percent = min(percent, 1.0) | ||
progress_bar.value = percent | ||
purchase_button.disabled = percent < 1 || is_maxed | ||
if is_maxed: | ||
purchase_button.text = "Max" | ||
|
||
progress_label.text = "%d/%d" % [currency, upgrade.experience_cost] | ||
count_label.text = "x%d" % current_quantity | ||
|
||
|
||
func select_card(): | ||
$AnimationPlayer.play("selected") | ||
|
||
|
||
func on_purchase_pressed(): | ||
if upgrade == null: | ||
return | ||
MetaProgression.add_meta_upgrade(upgrade) | ||
MetaProgression.save_data["meta_upgrade_currency"] -= upgrade.experience_cost | ||
MetaProgression.save() | ||
get_tree().call_group("meta_upgrade_card", "update_progress") | ||
$AnimationPlayer.play("selected") |
Oops, something went wrong.