This commit is contained in:
Dan Baker 2025-12-02 07:45:23 +00:00
parent 7a8ee29dcb
commit 0fe23420ab
800 changed files with 16547 additions and 0 deletions

21
scenes/scripts/arrow.gd Normal file
View file

@ -0,0 +1,21 @@
extends Sprite2D
@export var bounce_height: float = 10.0 # How high it bounces in pixels
@export var bounce_duration: float = 0.5 # Time for one bounce cycle
var tween: Tween
var start_position: Vector2
func _ready():
start_position = position
start_continuous_bounce()
func start_continuous_bounce():
tween = create_tween()
tween.set_loops() # Makes it loop infinitely
tween.tween_property(self, "position:y", start_position.y - bounce_height, bounce_duration / 2)
tween.tween_property(self, "position:y", start_position.y, bounce_duration / 2)
func stop_bounce():
if tween:
tween.kill()
position = start_position

View file

@ -0,0 +1 @@
uid://i6lg61o0jnkp

58
scenes/scripts/button.gd Normal file
View file

@ -0,0 +1,58 @@
extends TextureButton
@onready var label: Label = $CenterContainer/Label # Adjust path to your Label node
var unlock_id = "" # Store the unlock ID
func _ready():
label.visible = false # Hide label initially
adjust_label_font_size()
# Connect the pressed signal
pressed.connect(_on_button_pressed)
func setup(unlock_data):
Log.pr("Setting up button for unlock:", unlock_data.unlock_name)
unlock_id = unlock_data.unlock_id # Store the ID
if label:
label.visible = false
label.text = unlock_data.unlock_name + " " + str(unlock_data.get_next_rank())
label.text = label.text + " - " + Global.currency_symbol + str(unlock_data.get_next_cost())
label.text = label.text + "\n" + unlock_data.get_next_modifiers_string()
#self.disabled = unlock_data.is_unlocked
adjust_label_font_size()
else:
Log.pr("Warning: Label node not found in button.")
func _on_button_pressed():
Log.pr("Button pressed, unlocking item:", unlock_id)
Unlocks.unlock_item(unlock_id)
func adjust_label_font_size():
if not label:
return
var available_width = size.x - 10
var available_height = size.y - 10
# Start with a reasonable font size
var font_size = 32
var min_font_size = 8
# Get or create a font
var font = label.get_theme_font("font")
# Binary search for the optimal font size
while font_size > min_font_size:
label.add_theme_font_size_override("font_size", font_size)
# Force update and get the actual text size
await get_tree().process_frame
var text_size = font.get_string_size(label.text, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size)
# Check if it fits
if text_size.x <= available_width and text_size.y <= available_height:
break
# Reduce font size and try again
font_size -= 1
label.add_theme_font_size_override("font_size", font_size)
label.visible = true # Show label after resizing is complete
# Call this function whenever you change the label text
func set_label_text(new_text: String):
if label:
label.visible = false # Hide while resizing
label.text = new_text
adjust_label_font_size()

View file

@ -0,0 +1 @@
uid://dj7uoaxxat5n4

View file

@ -0,0 +1,25 @@
extends PointLight2D
# Flicker parameters
@export var flicker_speed: float = 10.0 # How fast the flicker changes
@export var flicker_intensity: float = 0.3 # How much it flickers (0-1)
@export var base_energy: float = 1.0 # Base brightness
# For smooth variation
var time_passed: float = 0.0
func _ready():
# Store the initial energy value
energy = base_energy
func _process(delta):
time_passed += delta * flicker_speed
# Use Perlin-like noise for natural flickering
var flicker = sin(time_passed) * 0.5 + 0.5 # 0 to 1
flicker += sin(time_passed * 2.3) * 0.3 # Add secondary variation
flicker += sin(time_passed * 4.7) * 0.2 # Add tertiary variation
flicker /= 2.0 # Normalize
# Apply flicker to energy
energy = base_energy + (flicker - 0.5) * flicker_intensity * 2.0

View file

@ -0,0 +1 @@
uid://cpimo8q5dcjxf

View file

@ -0,0 +1,101 @@
extends Control
@onready var currency_label: Label = %CurrencyLabel
@onready var wood_label: Label = %WoodLabel
@onready var stock_label: Label = %StockLabel
@onready var modifiers_label: Label = %ModifiersLabel
func _ready():
populate_modifiers_display()
populate_unlock_buttons()
update_currency_label()
update_wood_label()
update_stock_label()
currency_label.add_theme_color_override("font_color", Global.money_color)
wood_label.add_theme_color_override("font_color", Global.wood_color)
stock_label.add_theme_color_override("font_color", Global.stock_color)
Inventory.currency_changed.connect(_on_currency_changed)
Inventory.currency_added.connect(spawn_currency_increase)
Inventory.wood_changed.connect(_on_currency_changed)
Inventory.wood_added.connect(spawn_wood_increase)
Inventory.stock_added.connect(spawn_stock_increase)
Inventory.stock_changed.connect(_on_currency_changed)
Unlocks.item_unlocked.connect(populate_unlock_buttons)
func update_currency_label():
currency_label.text = Global.currency_symbol + " " + str(int(Inventory.get_currency()))
func update_wood_label():
wood_label.text = "W: " + str(int(Inventory.get_wood()))
func update_stock_label():
stock_label.text = "S: " + str(int(Inventory.get_stock()))
func spawn_currency_increase(value, _total):
spawn_inventory_change_value(value, _total, "+", Global.currency_symbol, Global.money_color)
func spawn_wood_increase(value, _total):
spawn_inventory_change_value(value, _total, "+", "", Global.wood_color)
func spawn_stock_increase(value, _total):
spawn_inventory_change_value(value, _total, "+", "", Global.stock_color)
func spawn_inventory_change_value(value, _total, display_sign: String = "+", symbol: String = "", label_color: Color = Color.WHITE):
var float_label = Label.new()
float_label.text = display_sign + symbol + str(int(abs(value)))
float_label.add_theme_font_size_override("font_size", 16)
float_label.modulate = label_color
# Add random offset around center
var random_x = randf_range(-60, 30)
var random_y = randf_range(-40, 20)
float_label.position = Vector2(random_x, random_y)
add_child(float_label)
# Animate the label
var tween = create_tween()
tween.set_parallel(true) # Run both animations simultaneously
# Move up
tween.tween_property(float_label, "position:y", float_label.position.y - 50, 1.0)
# Fade out
tween.tween_property(float_label, "modulate:a", 0.0, 1.0)
# Remove from scene when done
tween.chain().tween_callback(float_label.queue_free)
func populate_unlock_buttons():
var unlocks_container = $UnlockContainer
for child in unlocks_container.get_children():
child.free()
for unlock_data in Unlocks.unlocks.unlocks:
var unlock_button_scene = load("res://scenes/button.tscn")
var unlock_button = unlock_button_scene.instantiate()
unlocks_container.add_child(unlock_button)
unlock_button.setup(unlock_data)
func populate_modifiers_display():
var modifiers_text = ""
modifiers_text = modifiers_text + "Sale Price: " + Global.currency_symbol + str(Unlocks.get_sale_price_per_item()) + "\n"
modifiers_text = modifiers_text + "Items Produced Per Tick: " + str(Unlocks.get_items_produced_per_tick()) + "\n"
modifiers_text = modifiers_text + "Wood per Click: " + str(Unlocks.get_wood_per_click()) + "\n\n"
modifiers_text = modifiers_text + "Demand: " + str(int(Unlocks.get_sale_demand())) + "\n\n"
modifiers_text = modifiers_text + "Current Modifiers:\n"
for key in Unlocks.current_modifiers.keys():
var display_name = key.replace("_modifier", "").replace("_", " ").capitalize()
var percentage = int((Unlocks.current_modifiers[key] - 1.0) * 100)
modifiers_text += "%s: %s%%\n" % [display_name, str(percentage)]
modifiers_label.text = modifiers_text
func _on_currency_changed(_value):
populate_modifiers_display()
update_currency_label()
update_wood_label()
update_stock_label()

View file

@ -0,0 +1 @@
uid://cm84m3olmcc8o

View file

@ -0,0 +1,22 @@
extends Sprite2D
@export var fade_duration: float = 0.5
var tween: Tween
func _ready():
# Start with outline invisible
material.set_shader_parameter("outline_alpha", 0.0)
start_continuous_fade()
func start_continuous_fade():
tween = create_tween()
tween.set_loops() # Makes it loop infinitely
tween.tween_method(set_outline_alpha, 0.0, 1.0, fade_duration)
tween.tween_method(set_outline_alpha, 1.0, 0.0, fade_duration)
func set_outline_alpha(value: float):
material.set_shader_parameter("outline_alpha", value)
func stop_fade():
if tween:
tween.kill()

View file

@ -0,0 +1 @@
uid://nntb8jg35j6j

View file

@ -0,0 +1,93 @@
extends Node2D
@onready var area = $ClickArea
@onready var arrow = $Arrow
var respawn_timer: Timer
var original_y: float = 0.0
func _ready():
area.input_event.connect(_on_area_input_event)
area.mouse_entered.connect(_on_mouse_entered)
area.mouse_exited.connect(_on_mouse_exited)
# Create the respawn timer
respawn_timer = Timer.new()
respawn_timer.one_shot = true
respawn_timer.timeout.connect(_on_respawn_timer_timeout)
add_child(respawn_timer)
func _on_area_input_event(_viewport, event, _shape_idx):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
on_clicked()
func _on_mouse_entered():
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
func _on_mouse_exited():
Input.set_default_cursor_shape(Input.CURSOR_ARROW)
func on_clicked():
Audio.play_chop_sound()
Inventory.add_wood(Unlocks.get_wood_per_click())
play_pop_animation()
func play_pop_animation():
arrow.visible = false
# Store original position for reset
original_y = position.y
# Create a tween for smooth animation
var tween = create_tween()
tween.set_parallel(true) # Run animations simultaneously
# Scale up quickly (pop effect)
tween.tween_property(self, "scale", scale * 1.3, 0.1).set_ease(Tween.EASE_OUT)
# Fade out
tween.tween_property(self, "modulate:a", 0.0, 0.2)
# Optional: slight upward movement for extra effect
tween.tween_property(self, "position:y", position.y - 3, 0.2)
# Hide and disable, then start respawn timer
tween.finished.connect(func():
visible = false
area.monitoring = false
area.monitorable = false
# Start the respawn timer with the value from Unlocks
var respawn_time = Unlocks.get_wood_respawn_time()
respawn_timer.start(respawn_time)
)
func _on_respawn_timer_timeout():
pop_back_in()
func pop_back_in():
if visible:
return # Already visible
position.y = original_y
# Reset properties
visible = true
arrow.visible = true
area.monitoring = true
area.monitorable = true
# Create a tween for the pop-in animation
var tween = create_tween()
tween.set_parallel(true)
# Start from scaled down and transparent
scale = Vector2.ONE * 0.7
modulate.a = 0.0
# Scale up to normal
tween.tween_property(self, "scale", Vector2.ONE, 0.2).set_ease(Tween.EASE_OUT)
# Fade in
tween.tween_property(self, "modulate:a", 1.0, 0.2)

View file

@ -0,0 +1 @@
uid://dw8q7mx6co84v