Character Roll prototype

This commit is contained in:
2024-06-11 10:23:43 -04:00
parent cdbba45795
commit 4312c044d3
210 changed files with 3633 additions and 180 deletions

View File

@@ -0,0 +1,12 @@
extends AspectRatioContainer
# Called when the node enters the scene tree for the first time.
func _ready():
#print(self.get_path())
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

16
User Interface/Boss1.gd Normal file
View File

@@ -0,0 +1,16 @@
extends TextureButton
# Called when the node enters the scene tree for the first time.
func _ready():
self.connect("pressed", Callable(self, "_on_Button_pressed"))
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
#func _on__Button_pressed():
#var character_manager = get_node("/root/@Control@14/UI/CharacterRoll")
#character_manager.roll_character()

View File

@@ -0,0 +1,42 @@
extends GridContainer
func _ready():
load_boss_buttons()
func load_boss_buttons():
if "bosses" in BossDatabase.boss_data:
for boss in BossDatabase.boss_data["bosses"]:
var button = create_boss_button(boss)
add_child(button)
else:
print("No bosses found in boss data.")
func create_boss_button(boss: Dictionary) -> TextureButton:
var button = TextureButton.new()
#Loads the texture specified in the memberData sheet
if boss.has("texturePath"):
button.texture_normal = load(boss["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, boss))
button.connect("mouse_entered", Callable(self, "_on_button_hovered").bind(button, boss))
button.connect("mouse_exited", Callable(self, "_on_button_exited").bind(button))
return button
func _on_button_hovered(button: TextureButton, boss: Dictionary):
#current_member = member
#The backslash \ allows you to continue to the next line while concatenating the string
var tooltip_text = "" + str(boss["name"]) + "\n" + "" + str(boss["description"]) + "\n" + "Total Health: " + str(boss["totalHealth"]) + "\n" + \
"Minimum DPS Required: " + str(boss["minDPS"])
button.tooltip_text = tooltip_text
# Function called when the mouse exits the button
func _on_button_exited(button: TextureButton):
button.tooltip_text = ""
func _on_button_pressed(button: TextureButton, boss: Dictionary):
var character_manager = get_node("/root/@Control@14/UI/CharacterRoll")
character_manager.roll_character()

View File

@@ -0,0 +1,17 @@
extends Button
# Called when the node enters the scene tree for the first time.
func _ready():
self.connect("pressed", Callable(self, "_on_Button_pressed"))
# Function to handle the button press
func _on_Button_pressed():
if Global.bossScreenVisible == false:
Global.bossScreenVisible = true
Global.teamScreenVisible = false
Global.teamSelectionVisible = false
else:
Global.bossScreenVisible = false

View File

@@ -0,0 +1,68 @@
extends PanelContainer
func _ready():
load_character_inventory()
#pass
var character_data = []
var getMembers = []
func load_character_inventory():
var file_path = "user://MemberDatabase/memberData.json"
if FileAccess.file_exists(file_path):
var file = FileAccess.open(file_path, FileAccess.READ)
if file:
var json_text = file.get_as_text()
file.close()
print("Loaded JSON text: ", json_text)
var json_parser = JSON.new()
var json_result = json_parser.parse(json_text)
if json_result == OK:
#character_data = json_result.result.get("members", [])
character_data = json_parser.get_data()
print("Loaded character data: ", character_data)
else:
print("Error parsing JSON: ", json_result.error_string)
else:
print("Failed to open file: ", file_path)
else:
print("File not found: ", file_path)
func save_character_inventory():
var file_path = "user://MemberDatabase/memberData.json"
var file = FileAccess.open(file_path, FileAccess.WRITE)
if file:
var json_text = JSON.stringify({ "members": getMembers })
file.store_string(json_text)
file.close()
print("Saved character data: ", json_text)
else:
print("Failed to open file: ", file_path)
func update_character(index, new_data):
if index >= 0 and index < character_data.size():
character_data[index] = new_data
save_character_inventory()
print("Updated character data: ", character_data[index])
else:
print("Invalid character index: ", index)
func roll_character():
if character_data.size() == 0:
print("No characters in inventory.")
return
getMembers = character_data["members"]
var random_index = randi() % getMembers.size()
var random_character = getMembers[random_index]
if not random_character["isObtained"]:
random_character["isObtained"] = true
random_character["memberAmount"] += 1
save_character_inventory()
print("Rolled character: ", random_character["name"])

View File

@@ -81,13 +81,6 @@ func _process(delta):
$PerSec.text = str(Global.globalDamagePerSec)
$Multiplier.text = str(Global.globalDamageMultiplier)
#Get the current status of any screens needed
var teamScreen = get_node(Global.teamScreenPath)
teamScreen.visible = Global.teamScreenVisible
var teamSelection = get_node(Global.teamSelectionPath)
teamSelection.visible = Global.teamSelectionVisible
#This checks any input that comes in
func _input(event):

View File

@@ -10,6 +10,7 @@ func _on_Button_pressed():
if Global.teamScreenVisible == false:
Global.teamSelectionVisible = false
Global.teamScreenVisible = true
Global.bossScreenVisible = false
else:
Global.teamScreenVisible = false

View File

@@ -1,27 +1,32 @@
[gd_scene load_steps=17 format=3 uid="uid://xh0p6v5ir05f"]
[gd_scene load_steps=22 format=3 uid="uid://xh0p6v5ir05f"]
[ext_resource type="Script" path="res://Root.gd" id="1_dtx5s"]
[ext_resource type="Script" path="res://User Interface/TeamButton.gd" id="3_g0muc"]
[ext_resource type="Script" path="res://User Interface/Header.gd" id="3_q5rri"]
[ext_resource type="Script" path="res://User Interface/Member1.gd" id="4_4xump"]
[ext_resource type="Script" path="res://User Interface/Bossbutton.gd" id="4_7wp2t"]
[ext_resource type="Script" path="res://User Interface/AspectRatioContainer.gd" id="5_priim"]
[ext_resource type="Script" path="res://TeamSelection.gd" id="6_1cnw8"]
[ext_resource type="Script" path="res://User Interface/Member2.gd" id="6_spk65"]
[ext_resource type="Script" path="res://User Interface/Member3.gd" id="6_tuvg4"]
[ext_resource type="Script" path="res://User Interface/Member4.gd" id="7_5ow7k"]
[ext_resource type="Texture2D" uid="uid://b1kl4huy0vnin" path="res://Member/#1 - Transparent Icons.png" id="7_s2y5l"]
[ext_resource type="Script" path="res://User Interface/Hank.gd" id="8_kx4m8"]
[ext_resource type="Script" path="res://User Interface/Member5.gd" id="8_n56qv"]
[ext_resource type="Script" path="res://User Interface/BossGrid.gd" id="12_16xc1"]
[ext_resource type="Script" path="res://User Interface/Boss1.gd" id="12_ullwe"]
[ext_resource type="Script" path="res://User Interface/CharacterRoll.gd" id="14_ox8ae"]
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_8gi0c"]
[sub_resource type="AtlasTexture" id="AtlasTexture_74gmg"]
atlas = ExtResource("7_s2y5l")
atlas = SubResource("CompressedTexture2D_8gi0c")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_xmmtg"]
atlas = ExtResource("7_s2y5l")
atlas = SubResource("CompressedTexture2D_8gi0c")
region = Rect2(96, 320, 32, 32)
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_pioex"]
load_path = "res://.godot/imported/#1 - Transparent Icons.png-075c51137bc59a17da3b30778a360723.ctex"
[sub_resource type="AtlasTexture" id="AtlasTexture_l5qwh"]
atlas = SubResource("CompressedTexture2D_pioex")
@@ -121,6 +126,13 @@ flat = true
alignment = 0
script = ExtResource("3_g0muc")
[node name="Bossbutton" type="Button" parent="UI/CanvasLayer/Header"]
layout_mode = 2
text = "Bosses"
flat = true
alignment = 0
script = ExtResource("4_7wp2t")
[node name="ClickAddLabel" type="Label" parent="UI/CanvasLayer/Header"]
layout_mode = 2
text = "ClickAdd:"
@@ -148,11 +160,13 @@ layout_mode = 2
text = "0"
[node name="AspectRatioContainer" type="AspectRatioContainer" parent="UI"]
visible = false
layout_mode = 0
offset_left = -2.60654
offset_top = 271.396
offset_right = 1917.39
offset_bottom = 800.396
script = ExtResource("5_priim")
[node name="TeamScreen" type="HBoxContainer" parent="UI/AspectRatioContainer"]
visibility_layer = 2
@@ -233,3 +247,27 @@ texture_normal = SubResource("AtlasTexture_l5qwh")
visible = false
layout_mode = 2
texture_normal = SubResource("AtlasTexture_t1ab2")
[node name="BossFights" type="PanelContainer" parent="UI"]
visible = false
layout_mode = 0
offset_left = 857.0
offset_top = 294.0
offset_right = 1049.0
offset_bottom = 422.0
[node name="BossGrid" type="GridContainer" parent="UI/BossFights"]
layout_mode = 2
script = ExtResource("12_16xc1")
[node name="Boss1" type="TextureButton" parent="UI/BossFights/BossGrid"]
layout_mode = 2
script = ExtResource("12_ullwe")
[node name="CharacterRoll" type="PanelContainer" parent="UI"]
visible = false
layout_mode = 0
offset_top = 31.0
offset_right = 1917.0
offset_bottom = 1080.0
script = ExtResource("14_ox8ae")