added rewards for node completion
This commit is contained in:
parent
11aa2c458f
commit
3060273c1d
10 changed files with 639 additions and 41 deletions
|
|
@ -10,6 +10,7 @@ const StockfishController = preload("res://Systems/FairyStockfish/StockfishClien
|
|||
signal tile_pressed(location: String)
|
||||
signal send_location(location: String)
|
||||
signal map_open_requested(options)
|
||||
signal node_completed(options)
|
||||
signal turn_changed
|
||||
signal game_initialized
|
||||
|
||||
|
|
@ -42,6 +43,7 @@ var darkStyle = null
|
|||
var highlightStyle = null
|
||||
var cpuElo = 1500
|
||||
var is_initialized: bool = false
|
||||
var currentNode = null;
|
||||
|
||||
# Node references
|
||||
@onready var turnIndicator: ColorRect = $TurnIndicator
|
||||
|
|
@ -101,12 +103,13 @@ func _ready() -> void:
|
|||
func _on_new_game_requested(options = {}):
|
||||
print("ChessGame received new_game_requested signal ", is_initialized)
|
||||
turnIndicator.visible = true
|
||||
if options and "fen" in options:
|
||||
currentFen = options.fen
|
||||
if options and "fen" in options.metadata:
|
||||
currentFen = options.metadata.fen
|
||||
if "elo" in options:
|
||||
cpuElo = options.elo
|
||||
cpuElo = options.metadata.elo
|
||||
if cameraController:
|
||||
cameraController.reset_view()
|
||||
currentNode = options
|
||||
print("ChessGame FEN ", currentFen)
|
||||
print("ChessGame DIMENSIONS ", get_board_dimensions(currentFen))
|
||||
if is_initialized:
|
||||
|
|
@ -698,6 +701,11 @@ func updatePointsAndCapture(capturedPiece: Pawn, animate: bool = true) -> void:
|
|||
|
||||
if capturedPiece.name == "King":
|
||||
print("Game Over!")
|
||||
emit_signal("node_completed", {
|
||||
"node": currentNode,
|
||||
"completed": true,
|
||||
"success": true
|
||||
})
|
||||
gamecheckMate = true
|
||||
|
||||
func animatePieceCapture(capturedPiece: Pawn) -> void:
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ func generate_node_data(node):
|
|||
Utils.RoomType.NORMAL:
|
||||
data.metadata = generate_chess_data(data)
|
||||
Utils.RoomType.BOSS:
|
||||
data.metadata = generate_chess_data(data)
|
||||
data.metadata = generate_boss_data(data)
|
||||
Utils.RoomType.FINAL:
|
||||
data.metadata = { "is_escape": true}
|
||||
Utils.RoomType.SHOP:
|
||||
|
|
@ -260,36 +260,77 @@ func generate_node_data(node):
|
|||
data.metadata = {}
|
||||
return data
|
||||
|
||||
func generate_shop_data(node):
|
||||
|
||||
func generate_boss_data(node):
|
||||
# level_unit_distribution
|
||||
# current_max_level
|
||||
var rng = float(node.level) / int(current_max_level)
|
||||
# (current_value, min_value, max_value, min_index, max_index)
|
||||
var index = map_to_array_index(node.level, 2, current_max_level - 2, 1, level_unit_distribution.size() - 1);
|
||||
var unit_string = level_unit_distribution[index]
|
||||
var pawn_string = ""
|
||||
|
||||
for x in unit_string.length():
|
||||
pawn_string += "p"
|
||||
|
||||
var height = 6;
|
||||
# "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR"
|
||||
var fen = "";
|
||||
if node.level > 7 and node.level <= 10:
|
||||
height = node.level
|
||||
elif node.level > 10:
|
||||
height = 10
|
||||
for x in height - 2:
|
||||
if x == 0:
|
||||
fen += unit_string + "/"
|
||||
elif x == 1:
|
||||
fen += pawn_string + "/"
|
||||
# elif x == height - 3:
|
||||
# for y in unit_string.length() - 1:
|
||||
# fen += "*"
|
||||
# fen += "1/"
|
||||
else:
|
||||
fen += str(unit_string.length()) + "/"
|
||||
|
||||
fen += pawn_string.to_upper() + "/" + unit_string.to_upper()
|
||||
var fen_ending = " w KQkq - 0 1"
|
||||
# print("generate_chess_data ", fen + fen_ending)
|
||||
return {
|
||||
"is_escape": node.metadata.is_escape if node.metadata.has("is_escape") else false,
|
||||
"gold": 1000,
|
||||
"cards": generate_shop_cards(),
|
||||
"fen": fen + fen_ending,
|
||||
"game_type": "chess",
|
||||
"win_condition": Utils.WinCondition.King,
|
||||
"reward": {
|
||||
"gold": 50 * node.level,
|
||||
"cards": [],
|
||||
"selection": generate_shop_cards(3),
|
||||
"selection_limit": 2
|
||||
},
|
||||
"elo": node.elo,
|
||||
}
|
||||
func generate_shop_cards():
|
||||
|
||||
|
||||
|
||||
func generate_shop_data(node):
|
||||
var num_shop_cards = min(randi_range(5, 7), Utils.CardTypes.size())
|
||||
return {
|
||||
"is_escape": node.metadata.is_escape if node.metadata.has("is_escape") else false,
|
||||
"cards": generate_shop_cards(num_shop_cards),
|
||||
}
|
||||
func generate_shop_cards(num_shop_cards):
|
||||
var shop_cards = []
|
||||
|
||||
var all_cards = []
|
||||
var card_classes = [
|
||||
HopscotchCard,
|
||||
FieryCapeCard,
|
||||
FieryTrailCard,
|
||||
ExplosiveBootsCard,
|
||||
DoubleTimeCard,
|
||||
DrunkDrivingCard,
|
||||
SupernovaCard
|
||||
]
|
||||
|
||||
for card_class in card_classes:
|
||||
for card_class in Utils.CardTypes:
|
||||
var card = card_class.new()
|
||||
all_cards.append(card)
|
||||
|
||||
all_cards.shuffle()
|
||||
|
||||
var num_shop_cards = min(randi_range(5, 7), all_cards.size())
|
||||
|
||||
for i in range(num_shop_cards):
|
||||
shop_cards.append(all_cards[i % card_classes.size()])
|
||||
shop_cards.append(all_cards[i % Utils.CardTypes.size()])
|
||||
|
||||
return shop_cards
|
||||
|
||||
|
|
@ -349,6 +390,9 @@ func generate_chess_data(node):
|
|||
"game_type": "chess",
|
||||
"win_condition": Utils.WinCondition.King,
|
||||
"elo": node.elo,
|
||||
"reward": {
|
||||
"gold": 50 * node.level
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ const VERSION_FILE_PATH = "res://Game.json"
|
|||
# signal new_game_requested
|
||||
signal new_game_requested(options)
|
||||
signal shop_open_requested(options)
|
||||
signal reward_open_requested(options)
|
||||
signal deckmanager_open_requested(options)
|
||||
signal map_open_requested(options)
|
||||
signal node_completed(options)
|
||||
signal shop_closed
|
||||
signal card_purchased(card, price)
|
||||
@onready var newGameButton = $HBoxContainer/VBoxContainer/MenuOptions/NewGameText
|
||||
|
|
@ -21,6 +23,8 @@ signal card_purchased(card, price)
|
|||
@onready var mapScreen = get_node("/root/Board/MapScreen")
|
||||
@onready var stateMachine = get_node("/root/Board/StateMachine")
|
||||
@onready var shopScreen = get_node("/root/Board/ShopScreen")
|
||||
@onready var rewardScreen = get_node("/root/Board/RewardScreen")
|
||||
@onready var game = get_node_or_null("/root/Board") as ChessGame
|
||||
# back up if game isn't loaded yet?
|
||||
var player_gold = 10
|
||||
var back_to_map = false
|
||||
|
|
@ -36,10 +40,11 @@ func _ready():
|
|||
gameMenuScreen.connect("deckmanager_open_requested", Callable(self, "_on_deckmanager_open_requested"))
|
||||
gameMenuScreen.connect("map_open_requested", Callable(self, "_on_map_open_requested"))
|
||||
gameMenuScreen.connect("new_game_requested", Callable(self, "_on_start_game_pressed"))
|
||||
gameMenuScreen.connect("reward_open_requested", Callable(self, "_on_reward_open_requested"))
|
||||
gameMenuScreen.visible = false
|
||||
else:
|
||||
connect("map_open_requested", Callable(self, "_on_map_open_requested"))
|
||||
|
||||
game.connect("node_completed", Callable(self, "_on_node_completed"))
|
||||
if deckManagerScreen:
|
||||
deckManagerScreen.connect("back_pressed", Callable(self, "_on_deck_manager_back_pressed"))
|
||||
deckManagerScreen.visible = false
|
||||
|
|
@ -54,6 +59,10 @@ func _ready():
|
|||
shopScreen.connect("back_pressed", Callable(self, "_on_shop_back_pressed"))
|
||||
shopScreen.connect("card_purchased", Callable(self, "_on_shop_card_purchased"))
|
||||
shopScreen.visible = false
|
||||
if rewardScreen:
|
||||
rewardScreen.connect("back_pressed", Callable(self, "_on_reward_back_pressed"))
|
||||
rewardScreen.connect("card_purchased", Callable(self, "_on_reward_card"))
|
||||
rewardScreen.visible = false
|
||||
load_version()
|
||||
|
||||
|
||||
|
|
@ -126,8 +135,6 @@ func _on_shop_open_requested(options):
|
|||
if options == null:
|
||||
options = {}
|
||||
|
||||
var game = get_node_or_null("/root/Board") as ChessGame
|
||||
|
||||
if "gold" in options:
|
||||
if game and "gold" in game:
|
||||
options["gold"] = game.gold
|
||||
|
|
@ -139,7 +146,6 @@ func _on_shop_open_requested(options):
|
|||
emit_signal("shop_open_requested", options)
|
||||
|
||||
func _on_shop_back_pressed():
|
||||
var game = get_node_or_null("/root/Board") as ChessGame
|
||||
if shopScreen:
|
||||
shopScreen.visible = false
|
||||
if game and "gold" in game:
|
||||
|
|
@ -156,7 +162,6 @@ func _on_shop_back_pressed():
|
|||
emit_signal("shop_closed")
|
||||
|
||||
func _on_shop_card_purchased(card, price):
|
||||
var game = get_node_or_null("/root/Board") as ChessGame
|
||||
if game and "gold" in game:
|
||||
game.gold -= price
|
||||
else:
|
||||
|
|
@ -165,12 +170,55 @@ func _on_shop_card_purchased(card, price):
|
|||
emit_signal("card_purchased", card, price)
|
||||
|
||||
# Add the card to the player's bank
|
||||
var board = get_node_or_null("/root/Board") as ChessGame
|
||||
if board and "deckManager" in board:
|
||||
var deck_manager = board.deckManager
|
||||
if game and "deckManager" in game:
|
||||
var deck_manager = game.deckManager
|
||||
deck_manager.bank.append(card)
|
||||
print("Added purchased card to bank:", card.cardName)
|
||||
|
||||
|
||||
|
||||
func _on_reward_open_requested(options):
|
||||
print("Reward requested with options:", options)
|
||||
if shopScreen:
|
||||
shopScreen.visible = false
|
||||
|
||||
if options == null:
|
||||
options = {}
|
||||
|
||||
|
||||
if "gold" in options:
|
||||
if game and "gold" in game:
|
||||
options["gold"] = game.gold
|
||||
else:
|
||||
options["gold"] = player_gold
|
||||
if rewardScreen:
|
||||
rewardScreen.visible = true
|
||||
rewardScreen.initialize(options)
|
||||
emit_signal("reward_open_requested", options)
|
||||
|
||||
|
||||
func _on_reward_back_pressed():
|
||||
if rewardScreen:
|
||||
rewardScreen.visible = false
|
||||
|
||||
if not back_to_map and gameMenuScreen:
|
||||
gameMenuScreen.visible = true
|
||||
if back_to_map:
|
||||
mapScreen.visible = true
|
||||
# Emit signal that shop was closed
|
||||
emit_signal("reward_closed")
|
||||
|
||||
func _on_reward_card(card, price):
|
||||
# Forward the signal
|
||||
emit_signal("card_purchased", card, price)
|
||||
|
||||
# Add the card to the player's bank
|
||||
if game and "deckManager" in game:
|
||||
var deck_manager = game.deckManager
|
||||
deck_manager.bank.append(card)
|
||||
print("Added reward card to bank:", card.cardName)
|
||||
|
||||
|
||||
func _on_deckmanager_open_requested_from_map(options):
|
||||
print("Deck Manager requested with options:", options)
|
||||
|
||||
|
|
@ -241,9 +289,45 @@ func _on_map_node_selected(node_data):
|
|||
if mapScreen:
|
||||
mapScreen.visible = false
|
||||
back_to_map = true
|
||||
_on_start_game_pressed(node_data.metadata)
|
||||
# Implement logic for map node selection
|
||||
# For example, start a battle based on the node type
|
||||
_on_start_game_pressed(node_data)
|
||||
elif node_data.type == Utils.RoomType.BOSS:
|
||||
if gameMenuScreen:
|
||||
gameMenuScreen.visible = false
|
||||
if deckManagerScreen:
|
||||
deckManagerScreen.visible = false
|
||||
if mapScreen:
|
||||
mapScreen.visible = false
|
||||
back_to_map = true
|
||||
_on_start_game_pressed(node_data)
|
||||
|
||||
func _on_node_completed(options):
|
||||
var node_data = options.node
|
||||
var completed = options.completed
|
||||
var success = options.success
|
||||
if success:
|
||||
_on_reward_open_requested(node_data.metadata)
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
print("**************MATCH***************")
|
||||
print("**************OVER****************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
else:
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
print("**************GAME****************")
|
||||
print("**************OVER****************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
print("**********************************")
|
||||
|
||||
|
||||
# Public method to show the menu
|
||||
func show_menu():
|
||||
|
|
|
|||
|
|
@ -77,9 +77,15 @@ func set_card(card):
|
|||
|
||||
update_selected_state()
|
||||
|
||||
|
||||
func hide_price():
|
||||
if price_label:
|
||||
price_label.visible = false
|
||||
|
||||
func set_price(new_price):
|
||||
price = new_price
|
||||
if price_label:
|
||||
price_label.visible = true
|
||||
price_label.text = str(price) + " gold"
|
||||
|
||||
func set_selected(selected):
|
||||
|
|
|
|||
301
Systems/Game/Shop/RewardScreen.gd
Normal file
301
Systems/Game/Shop/RewardScreen.gd
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
extends Control
|
||||
class_name RewardScreen
|
||||
|
||||
signal back_pressed
|
||||
signal card_purchased(card, price)
|
||||
|
||||
# Node references
|
||||
@onready var card_carousel = $MainContainer/CardCarouselContainer/CardCarousel
|
||||
@onready var gold_label = $TopBar/GoldContainer/GoldLabel
|
||||
@onready var select_button = $SelectButton
|
||||
@onready var back_button = $BackButton
|
||||
@onready var card_preview = $CardPreviewPanel
|
||||
@onready var left_button = $MainContainer/CardCarouselContainer/LeftButton
|
||||
@onready var right_button = $MainContainer/CardCarouselContainer/RightButton
|
||||
@onready var screen_title = $TopBar/TitleLabel
|
||||
|
||||
# reward data
|
||||
var available_cards = [] # Cards available in the shop
|
||||
var player_gold = 1000
|
||||
var selected_card = null
|
||||
var selected_index = 0
|
||||
var is_escape = false # Is this reward event an escape option
|
||||
var carousel_page = 0
|
||||
var cards_per_page = 3
|
||||
var card_selection_counter = 0
|
||||
var card_selection_limit = 1
|
||||
var card_instance_map = {}
|
||||
var hovering_card_index = -1
|
||||
var mouse_over_any_card = false
|
||||
var deckManager: DeckManager
|
||||
|
||||
|
||||
func _ready():
|
||||
if back_button:
|
||||
if back_button.is_connected("pressed", Callable(self, "_on_back_button_pressed")):
|
||||
back_button.disconnect("pressed", Callable(self, "_on_back_button_pressed"))
|
||||
back_button.connect("pressed", Callable(self, "_on_back_button_pressed"))
|
||||
|
||||
if select_button:
|
||||
if select_button.is_connected("pressed", Callable(self, "_on_select_button_pressed")):
|
||||
select_button.disconnect("pressed", Callable(self, "_on_select_button_pressed"))
|
||||
select_button.connect("pressed", Callable(self, "_on_select_button_pressed"))
|
||||
|
||||
# Use direct connection for navigation buttons
|
||||
# This doesnt work for some reason use input below
|
||||
if left_button:
|
||||
if left_button.is_connected("pressed", Callable(self, "_on_left_button_pressed")):
|
||||
left_button.disconnect("pressed", Callable(self, "_on_left_button_pressed"))
|
||||
left_button.pressed.connect(_on_left_button_pressed)
|
||||
|
||||
if right_button:
|
||||
if right_button.is_connected("pressed", Callable(self, "_on_right_button_pressed")):
|
||||
right_button.disconnect("pressed", Callable(self, "_on_right_button_pressed"))
|
||||
right_button.pressed.connect(_on_right_button_pressed)
|
||||
|
||||
# Initialize with empty shop
|
||||
if card_preview:
|
||||
card_preview.visible = false
|
||||
|
||||
update_gold_display()
|
||||
update_select_button()
|
||||
update_navigation_buttons()
|
||||
|
||||
func initialize(options = null):
|
||||
print("RewardScreen ", options)
|
||||
carousel_page = 0
|
||||
selected_index = 0
|
||||
var board = get_node_or_null("/root/Board") as ChessGame
|
||||
if board and "deckManager" in board:
|
||||
deckManager = board.deckManager
|
||||
|
||||
# Process options if provided
|
||||
if options:
|
||||
if options.has("gold") and options.gold is int:
|
||||
player_gold = options.gold
|
||||
if options.has("reward") and options.reward.has("selection") and options.reward.selection is Array:
|
||||
available_cards = options.reward.selection.duplicate()
|
||||
if options.has("is_escape") and options.is_escape is bool:
|
||||
is_escape = options.is_escape
|
||||
if options.has("reward") and options.reward.has("gold") and options.reward.gold is int:
|
||||
board.gold += options.reward.gold
|
||||
player_gold = board.gold
|
||||
|
||||
if options.has("reward") and options.reward.has("selection_limit") and options.reward.selection_limit is int:
|
||||
card_selection_limit = options.reward.selection_limit
|
||||
screen_title.text = "Select Reward (" + str(options.reward.selection_limit) + ")"
|
||||
select_button.visible = true
|
||||
else:
|
||||
screen_title.text = "Reward :" + str(options.reward.gold) + " gold"
|
||||
select_button.visible = false
|
||||
card_selection_counter = 0
|
||||
|
||||
player_gold = board.gold
|
||||
# Update display
|
||||
update_gold_display()
|
||||
populate_carousel()
|
||||
update_navigation_buttons()
|
||||
|
||||
if not available_cards.is_empty():
|
||||
select_card(0)
|
||||
|
||||
|
||||
func populate_carousel():
|
||||
if card_carousel:
|
||||
for child in card_carousel.get_children():
|
||||
child.queue_free()
|
||||
|
||||
card_instance_map.clear()
|
||||
|
||||
var start_index = carousel_page * cards_per_page
|
||||
var end_index = min(start_index + cards_per_page, available_cards.size())
|
||||
|
||||
card_carousel.add_theme_constant_override("separation", 20)
|
||||
|
||||
for i in range(start_index, end_index):
|
||||
var card = available_cards[i]
|
||||
var card_visual = preload("res://card_visual.tscn").instantiate()
|
||||
|
||||
card_carousel.add_child(card_visual)
|
||||
card_visual.set_card(card)
|
||||
card_visual.hide_price()
|
||||
|
||||
var instance_id = card_visual.get_instance_id()
|
||||
|
||||
card_instance_map[instance_id] = {
|
||||
"card_index": i,
|
||||
"card": card
|
||||
}
|
||||
|
||||
update_navigation_buttons()
|
||||
|
||||
|
||||
func update_navigation_buttons():
|
||||
if left_button:
|
||||
left_button.disabled = (carousel_page <= 0)
|
||||
|
||||
if right_button:
|
||||
var max_page = ceil(float(available_cards.size()) / cards_per_page) - 1
|
||||
right_button.disabled = (carousel_page >= max_page or available_cards.size() <= cards_per_page)
|
||||
|
||||
|
||||
func select_card(index):
|
||||
if index < 0 or index >= available_cards.size():
|
||||
return
|
||||
|
||||
var page_for_index = int(index / cards_per_page)
|
||||
if page_for_index != carousel_page:
|
||||
carousel_page = page_for_index
|
||||
populate_carousel()
|
||||
|
||||
selected_index = index
|
||||
selected_card = available_cards[index]
|
||||
|
||||
var visual_index = index % cards_per_page
|
||||
|
||||
for i in range(card_carousel.get_child_count()):
|
||||
var card_visual = card_carousel.get_child(i)
|
||||
card_visual.set_selected(i == visual_index)
|
||||
|
||||
if card_preview and selected_card:
|
||||
card_preview.preview_card(selected_card)
|
||||
card_preview.visible = true
|
||||
|
||||
update_select_button()
|
||||
|
||||
func update_select_button():
|
||||
if not select_button or not selected_card:
|
||||
return
|
||||
|
||||
if card_selection_counter >= card_selection_limit:
|
||||
select_button.disabled = true
|
||||
|
||||
|
||||
func update_gold_display():
|
||||
if gold_label:
|
||||
gold_label.text = str(player_gold) + " GOLD"
|
||||
|
||||
func get_selected_card():
|
||||
if not selected_card:
|
||||
return false
|
||||
|
||||
var purchased_card = selected_card.duplicate()
|
||||
var old_page = carousel_page
|
||||
available_cards.remove_at(selected_index)
|
||||
emit_signal("card_purchased", purchased_card, 0)
|
||||
card_selection_counter += 1
|
||||
|
||||
var max_page = max(0, ceil(float(available_cards.size()) / cards_per_page) - 1)
|
||||
|
||||
if carousel_page > max_page:
|
||||
carousel_page = max_page
|
||||
|
||||
populate_carousel()
|
||||
|
||||
if not available_cards.is_empty():
|
||||
var new_index = min(selected_index, available_cards.size() - 1)
|
||||
select_card(new_index)
|
||||
else:
|
||||
selected_card = null
|
||||
selected_index = -1
|
||||
if card_preview:
|
||||
card_preview.hide_preview()
|
||||
|
||||
select_button.disabled = true
|
||||
|
||||
update_select_button()
|
||||
return true
|
||||
|
||||
# Signal handlers
|
||||
func _on_back_button_pressed():
|
||||
emit_signal("back_pressed")
|
||||
visible = false
|
||||
|
||||
func _on_select_button_pressed():
|
||||
get_selected_card()
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
# Check if click is within buttons
|
||||
if left_button and left_button.get_global_rect().has_point(event.position) and not left_button.disabled:
|
||||
# print("Left button clicked via _input")
|
||||
_on_left_button_pressed()
|
||||
get_viewport().set_input_as_handled()
|
||||
elif right_button and right_button.get_global_rect().has_point(event.position) and not right_button.disabled:
|
||||
# print("Right button clicked via _input")
|
||||
_on_right_button_pressed()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _on_left_button_pressed():
|
||||
if carousel_page > 0:
|
||||
carousel_page -= 1
|
||||
var new_index = carousel_page * cards_per_page
|
||||
populate_carousel()
|
||||
select_card(new_index)
|
||||
|
||||
|
||||
func _on_right_button_pressed():
|
||||
var max_page = ceil(float(available_cards.size()) / cards_per_page) - 1
|
||||
if carousel_page < max_page:
|
||||
carousel_page += 1
|
||||
var new_index = carousel_page * cards_per_page
|
||||
populate_carousel()
|
||||
select_card(new_index)
|
||||
|
||||
|
||||
func _on_card_visual_pressed(index):
|
||||
select_card(index)
|
||||
|
||||
func _on_card_visual_hover(card, index):
|
||||
if card_preview and card:
|
||||
card_preview.preview_card(card)
|
||||
card_preview.visible = true
|
||||
select_card(index)
|
||||
|
||||
func _on_card_visual_exit():
|
||||
|
||||
if card_preview and selected_card:
|
||||
card_preview.preview_card(selected_card)
|
||||
elif card_preview:
|
||||
card_preview.hide_preview()
|
||||
|
||||
func _process(delta):
|
||||
if not visible:
|
||||
return
|
||||
|
||||
var mouse_pos = get_viewport().get_mouse_position()
|
||||
|
||||
# Reset tracking
|
||||
var old_hovering_index = hovering_card_index
|
||||
hovering_card_index = -1
|
||||
mouse_over_any_card = false
|
||||
var mouse_clicked = Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT)
|
||||
|
||||
for i in range(card_carousel.get_child_count()):
|
||||
var card_visual = card_carousel.get_child(i)
|
||||
var card_rect = card_visual.get_global_rect()
|
||||
|
||||
if card_rect.has_point(mouse_pos) and mouse_clicked:
|
||||
# Get data from instance map
|
||||
var instance_id = card_visual.get_instance_id()
|
||||
if card_instance_map.has(instance_id):
|
||||
var data = card_instance_map[instance_id]
|
||||
hovering_card_index = data.card_index
|
||||
mouse_over_any_card = true
|
||||
|
||||
if old_hovering_index != hovering_card_index:
|
||||
_on_card_visual_hover(data.card, data.card_index)
|
||||
|
||||
card_visual._on_mouse_entered()
|
||||
|
||||
break
|
||||
|
||||
if old_hovering_index != -1 and hovering_card_index == -1:
|
||||
_on_card_visual_exit()
|
||||
for i in range(card_carousel.get_child_count()):
|
||||
var card_visual = card_carousel.get_child(i)
|
||||
var instance_id = card_visual.get_instance_id()
|
||||
if card_instance_map.has(instance_id) and card_instance_map[instance_id].card_index == old_hovering_index:
|
||||
card_visual._on_mouse_exited()
|
||||
break
|
||||
1
Systems/Game/Shop/RewardScreen.gd.uid
Normal file
1
Systems/Game/Shop/RewardScreen.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ccy6bx6kiejjy
|
||||
|
|
@ -71,6 +71,9 @@ func initialize(options = null):
|
|||
if options:
|
||||
if options.has("gold") and options.gold is int:
|
||||
player_gold = options.gold
|
||||
else:
|
||||
var board = get_node_or_null("/root/Board") as ChessGame
|
||||
player_gold = board.gold
|
||||
if options.has("cards") and options.cards is Array:
|
||||
available_cards = options.cards.duplicate()
|
||||
if options.has("is_escape") and options.is_escape is bool:
|
||||
|
|
@ -80,12 +83,11 @@ func initialize(options = null):
|
|||
for rank in card_prices:
|
||||
card_prices[rank] = int(card_prices[rank] * 1.5)
|
||||
|
||||
# Find the DeckManager instance if cards not provided in options
|
||||
if available_cards.is_empty():
|
||||
var board = get_node_or_null("/root/Board") as ChessGame
|
||||
if board and "deckManager" in board:
|
||||
var deck_manager = board.deckManager
|
||||
available_cards = generate_shop_cards(deck_manager)
|
||||
# if available_cards.is_empty():
|
||||
# var board = get_node_or_null("/root/Board") as ChessGame
|
||||
# if board and "deckManager" in board:
|
||||
# var deck_manager = board.deckManager
|
||||
# available_cards = generate_shop_cards(deck_manager)
|
||||
|
||||
# Update display
|
||||
update_gold_display()
|
||||
|
|
|
|||
|
|
@ -73,3 +73,15 @@ enum WinCondition{
|
|||
Clear,
|
||||
Tile,
|
||||
}
|
||||
|
||||
|
||||
|
||||
static var CardTypes = [
|
||||
HopscotchCard,
|
||||
FieryCapeCard,
|
||||
FieryTrailCard,
|
||||
ExplosiveBootsCard,
|
||||
DoubleTimeCard,
|
||||
DrunkDrivingCard,
|
||||
SupernovaCard
|
||||
]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=31 format=3 uid="uid://d0qyk6v20uief"]
|
||||
[gd_scene load_steps=32 format=3 uid="uid://d0qyk6v20uief"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cbcu68o863pfp" path="res://Systems/Game/ChessGame.gd" id="1_fkb2r"]
|
||||
[ext_resource type="Script" uid="uid://d2bfw6edgkhfa" path="res://Systems/StateMachine/GameStates/WhiteTurn.gd" id="3_276ip"]
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://c7uqbcxdjoais" path="res://deck_manager_screen.tscn" id="28_4nyv8"]
|
||||
[ext_resource type="PackedScene" uid="uid://dxiw67f3rrwue" path="res://map_screen.tscn" id="29_y7cv2"]
|
||||
[ext_resource type="PackedScene" uid="uid://djw7jhwtnycxq" path="res://shop_screen.tscn" id="30_5rfmq"]
|
||||
[ext_resource type="PackedScene" uid="uid://tmrvgfwodpno" path="res://reward_screen.tscn" id="31_d2oob"]
|
||||
|
||||
[node name="Board" type="Control"]
|
||||
layout_mode = 3
|
||||
|
|
@ -404,3 +405,7 @@ clip_contents = true
|
|||
custom_minimum_size = Vector2(800, 600)
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
|
||||
[node name="RewardScreen" parent="." instance=ExtResource("31_d2oob")]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
|
|
|||
135
reward_screen.tscn
Normal file
135
reward_screen.tscn
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://tmrvgfwodpno"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ccy6bx6kiejjy" path="res://Systems/Game/Shop/RewardScreen.gd" id="1_c5sfe"]
|
||||
[ext_resource type="PackedScene" uid="uid://xxxxxxxx" path="res://card_preview_panel.tscn" id="2_1dq2e"]
|
||||
[ext_resource type="Script" uid="uid://bfjmon81nckns" path="res://Systems/Game/GameMenuButton.gd" id="3_2qq52"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jk2fb"]
|
||||
bg_color = Color(0.14902, 0.14902, 0.2, 1)
|
||||
corner_radius_top_left = 5
|
||||
corner_radius_top_right = 5
|
||||
corner_radius_bottom_right = 5
|
||||
corner_radius_bottom_left = 5
|
||||
|
||||
[node name="RewardScreen" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_c5sfe")
|
||||
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.08, 0.08, 0.12, 1)
|
||||
|
||||
[node name="TopBar" type="HBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_top = 20.0
|
||||
offset_bottom = 80.0
|
||||
grow_horizontal = 2
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="TopBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 36
|
||||
text = "Select Reward"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GoldContainer" type="HBoxContainer" parent="TopBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
alignment = 2
|
||||
|
||||
[node name="GoldLabel" type="Label" parent="TopBar/GoldContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "100 GOLD"
|
||||
|
||||
[node name="Spacer" type="Control" parent="TopBar/GoldContainer"]
|
||||
custom_minimum_size = Vector2(20, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CardPreviewPanel" parent="." instance=ExtResource("2_1dq2e")]
|
||||
layout_mode = 1
|
||||
anchors_preset = 4
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = 20.0
|
||||
offset_top = -200.0
|
||||
offset_right = 320.0
|
||||
offset_bottom = 200.0
|
||||
grow_horizontal = 1
|
||||
|
||||
[node name="MainContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 340.0
|
||||
offset_top = 100.0
|
||||
offset_right = -20.0
|
||||
offset_bottom = -100.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="CardCarouselContainer" type="HBoxContainer" parent="MainContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
alignment = 1
|
||||
|
||||
[node name="LeftButton" type="Button" parent="MainContainer/CardCarouselContainer"]
|
||||
custom_minimum_size = Vector2(40, 0)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "←"
|
||||
|
||||
[node name="CardCarousel" type="HBoxContainer" parent="MainContainer/CardCarouselContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 20
|
||||
alignment = 1
|
||||
|
||||
[node name="RightButton" type="Button" parent="MainContainer/CardCarouselContainer"]
|
||||
custom_minimum_size = Vector2(40, 0)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "→"
|
||||
|
||||
[node name="BackButton" type="RichTextLabel" parent="."]
|
||||
custom_minimum_size = Vector2(100, 40)
|
||||
layout_mode = 2
|
||||
offset_top = 578.0
|
||||
offset_right = 100.0
|
||||
offset_bottom = 618.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 4
|
||||
text = "BACK"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 2
|
||||
script = ExtResource("3_2qq52")
|
||||
|
||||
[node name="SelectButton" type="Button" parent="."]
|
||||
custom_minimum_size = Vector2(200, 50)
|
||||
layout_mode = 2
|
||||
offset_left = 952.0
|
||||
offset_top = 573.0
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 623.0
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 4
|
||||
theme_override_font_sizes/font_size = 18
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_jk2fb")
|
||||
text = "Select"
|
||||
Loading…
Reference in a new issue