Team Selection, Damage Engine, Stat Allocation

This commit is contained in:
2024-06-05 12:05:12 -04:00
parent 341bf010d4
commit cdbba45795
93 changed files with 1996 additions and 210 deletions

View File

@@ -1,32 +1,90 @@
extends GridContainer
# Signal to send texture data back to the main scene
signal texture_selected(texture : AtlasTexture)
var target_buttons = [] # Array to hold target buttons
# Called when the node enters the scene tree for the first time.
func _ready():
load_character_buttons()
# Initialize or find the target buttons using their absolute paths
target_buttons = [
get_node("/root/Root/UI/AspectRatioContainer/TeamScreen/Member1"), # Replace with the actual path to your target button 1
get_node("/root/Root/UI/AspectRatioContainer/TeamScreen/Member2"), # Replace with the actual path to your target button 2
get_node("/root/Root/UI/AspectRatioContainer/TeamScreen/Member3"), # Replace with the actual path to your target button 3
get_node("/root/Root/UI/AspectRatioContainer/TeamScreen/Member4"), # Replace with the actual path to your target button 4
get_node("/root/Root/UI/AspectRatioContainer/TeamScreen/Member5") # Replace with the actual path to your target button 5
]
# Iterate over all children of the GridContainer
for button in get_children():
# Check if the child is a TextureButton
if button is TextureButton:
# Connect the pressed signal of the TextureButton to the handler function
button.connect("pressed", Callable(self, "_on_TextureButton_pressed").bind(button))
func load_character_buttons():
if "members" in MemberDatabase.character_data:
for character in MemberDatabase.character_data["members"]:
var button = create_character_button(character)
add_child(button)
else:
print("No characters found in character data.")
# Function to create a button for a character
# This builds out the character inventory
func create_character_button(member: Dictionary) -> TextureButton:
var button = TextureButton.new()
#Loads the texture specified in the memberData sheet
if member.has("texturePath"):
button.texture_normal = load(member["texturePath"])
else:
button.texture_normal = preload("res://Images/Members/Soldier.png") # Use a default texture if none is specified
button.connect("pressed", Callable(self, "_on_button_pressed").bind(button, member))
button.connect("mouse_entered", Callable(self, "_on_button_hovered").bind(button, member))
button.connect("mouse_exited", Callable(self, "_on_button_exited").bind(button))
return button
# Function called when a button is hovered over
func _on_button_hovered(button: TextureButton, member: Dictionary):
#current_member = member
#The backslash \ allows you to continue to the next line while concatenating the string
var tooltip_text = "" + str(member["name"]) + "\n" + "" + str(member["description"]) + "\n" + "Damage Per Second: " + str(member["perSec"]) + "\n" + \
"Damage Per Click: " + str(member["clickAdd"]) + "\n" + "Damage Multiplier: " + str(member["scoreMultiplier"])
button.tooltip_text = tooltip_text
# Handler function for the pressed signal
func _on_TextureButton_pressed(button):
# Print the name of the button
#print("Button pressed: ", button.name)
# Function called when the mouse exits the button
func _on_button_exited(button: TextureButton):
button.tooltip_text = ""
# Update the global singleton for the given index
func update_global_texture_singleton(texture: Texture):
match Global.currentMemberSelected:
0:
Global.set_texture1(texture)
1:
Global.set_texture2(texture)
2:
Global.set_texture3(texture)
3:
Global.set_texture4(texture)
4:
Global.set_texture5(texture)
## Handler function for the pressed signal
func _on_button_pressed(button: TextureButton, member: Dictionary):
## Print the name of the button
##print("Button pressed: ", button.name)
#Texture Variable
var texture : AtlasTexture = button.texture_normal
#Sets the selected texture on the team screen
Global.selected_texture = texture
var selected_texture = button.texture_normal
var texture = button.texture_normal
# Logic to determine which target button to update (this can be based on user selection or some other logic)
# For this example, we'll update the first available slot
update_global_texture_singleton(selected_texture)
#Adds the member stats into the global singletons
Global.set_damage_per_second(member["perSec"])
Global.set_damage_per_click(member["clickAdd"])
Global.set_damage_multiplier(member["scoreMultiplier"])
#For returning to the Team Selection Screen after selecting member
#Sets the global variable for the team selection screen to true so when you move back it's already open
##For returning to the Team Selection Screen after selecting member
##Sets the global variable for the team selection screen to true so when you move back it's already open
Global.teamScreenVisible = true
Global.teamSelectionVisible = false