parent
4b551023b7
commit
6799746466
|
@ -88,6 +88,9 @@ func delete_column(column: int) -> void:
|
||||||
var tile_map_cell_source_id = self.get_cell_source_id(tile_map_layer, tile_map_cell_position);
|
var tile_map_cell_source_id = self.get_cell_source_id(tile_map_layer, tile_map_cell_position);
|
||||||
var tile_map_cell_atlas_coords = self.get_cell_atlas_coords(tile_map_layer, tile_map_cell_position)
|
var tile_map_cell_atlas_coords = self.get_cell_atlas_coords(tile_map_layer, tile_map_cell_position)
|
||||||
var tile_map_cell_alternative = self.get_cell_alternative_tile(tile_map_layer, tile_map_cell_position)
|
var tile_map_cell_alternative = self.get_cell_alternative_tile(tile_map_layer, tile_map_cell_position)
|
||||||
|
print(tile_map_cell_source_id)
|
||||||
|
print(tile_map_cell_atlas_coords)
|
||||||
|
print(tile_map_cell_alternative)
|
||||||
var new_tile_map_cell_position = Vector2i(i, j + 1)
|
var new_tile_map_cell_position = Vector2i(i, j + 1)
|
||||||
self.set_cell(tile_map_layer, new_tile_map_cell_position, tile_map_cell_source_id, tile_map_cell_atlas_coords, tile_map_cell_alternative)
|
self.set_cell(tile_map_layer, new_tile_map_cell_position, tile_map_cell_source_id, tile_map_cell_atlas_coords, tile_map_cell_alternative)
|
||||||
if j == 0:
|
if j == 0:
|
||||||
|
|
24
game.gd
24
game.gd
|
@ -3,7 +3,9 @@ extends Node2D
|
||||||
var current_player: int = 0
|
var current_player: int = 0
|
||||||
var player_states := ["Circle", "Cross"]
|
var player_states := ["Circle", "Cross"]
|
||||||
var won := ""
|
var won := ""
|
||||||
var five_wins = false
|
var sequence_needed = 4
|
||||||
|
var _sequence = []
|
||||||
|
|
||||||
|
|
||||||
@onready var board := $Board as Board
|
@onready var board := $Board as Board
|
||||||
@onready var nextPlayer := $GUI/NextPlayer as Sprite2D
|
@onready var nextPlayer := $GUI/NextPlayer as Sprite2D
|
||||||
|
@ -41,6 +43,12 @@ func _process(_delta):
|
||||||
else:
|
else:
|
||||||
print("Winner: ", won)
|
print("Winner: ", won)
|
||||||
wonPlayer.region_rect.position.x = player_states.find(won) * 300
|
wonPlayer.region_rect.position.x = player_states.find(won) * 300
|
||||||
|
if won == player_states[0]:
|
||||||
|
for tile in _sequence:
|
||||||
|
board.set_cell(1, tile, 1, Vector2i(0, 2), 0)
|
||||||
|
else:
|
||||||
|
for tile in _sequence:
|
||||||
|
board.set_cell(1, tile, 1, Vector2i(3, 2), 0)
|
||||||
wonPlayer.show()
|
wonPlayer.show()
|
||||||
nextPlayer.hide()
|
nextPlayer.hide()
|
||||||
board.active = false
|
board.active = false
|
||||||
|
@ -61,19 +69,15 @@ var _checks = [
|
||||||
func _check_win() -> String:
|
func _check_win() -> String:
|
||||||
for cell in board.get_used_cells(board.layer_by_name[board.state_layer]):
|
for cell in board.get_used_cells(board.layer_by_name[board.state_layer]):
|
||||||
var state = board.get_state(cell)
|
var state = board.get_state(cell)
|
||||||
|
_sequence.clear()
|
||||||
for check in _checks:
|
for check in _checks:
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
var same = true
|
var same = true
|
||||||
if five_wins:
|
for j in range(sequence_needed):
|
||||||
for j in range(5):
|
|
||||||
if board.get_state(cell + check[0] * (i + j)) != state:
|
|
||||||
same = false
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
for j in range(4):
|
|
||||||
if board.get_state(cell + check[0] * (i + j)) != state:
|
if board.get_state(cell + check[0] * (i + j)) != state:
|
||||||
same = false
|
same = false
|
||||||
break
|
break
|
||||||
|
_sequence.append(Vector2i(cell + check[0] * (i + j)))
|
||||||
if same:
|
if same:
|
||||||
return state
|
return state
|
||||||
return ""
|
return ""
|
||||||
|
@ -137,7 +141,7 @@ func _get_dice_pos_y(result: int) -> int:
|
||||||
#Nach dem Glücksradereignis wird die Siegesbedingung auf 5 gewinnt geändert
|
#Nach dem Glücksradereignis wird die Siegesbedingung auf 5 gewinnt geändert
|
||||||
func _five_wins() -> void:
|
func _five_wins() -> void:
|
||||||
print("5 Gewinnt aktiv") #Debug
|
print("5 Gewinnt aktiv") #Debug
|
||||||
five_wins = true
|
sequence_needed = 5
|
||||||
|
|
||||||
#Nach dem Glücksradereignis tauschen die Spieler die Symbole
|
#Nach dem Glücksradereignis tauschen die Spieler die Symbole
|
||||||
func _change_symbols():
|
func _change_symbols():
|
||||||
|
@ -162,7 +166,7 @@ func _instant_win():
|
||||||
|
|
||||||
#Zum Testen der Events
|
#Zum Testen der Events
|
||||||
func _on_test_pressed():
|
func _on_test_pressed():
|
||||||
board.delete_column(2)
|
board.delete_column(6)
|
||||||
|
|
||||||
|
|
||||||
func _spin_the_wheel(result: int) -> void:
|
func _spin_the_wheel(result: int) -> void:
|
||||||
|
|
Loading…
Reference in New Issue