generated from krampus/template-godot4
makes post_office work
This commit is contained in:
parent
6921a1ff63
commit
688ffcbf47
@ -19,6 +19,7 @@ var is_destroying_building: bool = false
|
||||
var current_map_coord: Vector2i
|
||||
var prev_map_coord: Vector2i
|
||||
var is_controlling_camera: bool = false
|
||||
var is_placing_post_office: bool = false
|
||||
|
||||
@onready var tile_map: TileMapLayer = %Tiles
|
||||
@onready var board_state: Node2D = %BoardState
|
||||
@ -72,6 +73,7 @@ func set_active_building(building: Building) -> void:
|
||||
active_building.modulate = Color(1, 1, 1, 0.5)
|
||||
active_building.is_placing = true
|
||||
if active_building is PostOffice:
|
||||
is_placing_post_office = !is_placing_post_office
|
||||
active_building.place()
|
||||
|
||||
|
||||
@ -124,9 +126,6 @@ func place_active_building() -> void:
|
||||
for surr_coord in tile_map.get_surrounding_cells(coord):
|
||||
if buildings.has(surr_coord):
|
||||
return
|
||||
Globals.board_game.current_board_state.players[0].money -= active_building.cost
|
||||
if Globals.board_game.current_board_state.state != BoardState.State.INITIAL_SETUP:
|
||||
Globals.board_game.current_board_state.players[0].build_actions_taken += 1
|
||||
active_building.modulate = Color(1, 1, 1, 1)
|
||||
for coord in active_building.get_tile_coords():
|
||||
buildings[coord] = active_building
|
||||
@ -134,6 +133,12 @@ func place_active_building() -> void:
|
||||
tiles.erase(coord)
|
||||
if active_building is Spawn:
|
||||
Globals.board_game.current_board_state.spawn_placements -= 1
|
||||
if active_building is PostOffice and is_placing_post_office:
|
||||
set_active_building(Building.deserialize(active_building.serialize()))
|
||||
return
|
||||
Globals.board_game.current_board_state.players[0].money -= active_building.cost
|
||||
if Globals.board_game.current_board_state.state != BoardState.State.INITIAL_SETUP:
|
||||
Globals.board_game.current_board_state.players[0].build_actions_taken += 1
|
||||
board_state_changed.emit()
|
||||
active_building = null
|
||||
|
||||
@ -231,6 +236,8 @@ func set_board_state(bs: BoardState) -> void:
|
||||
buildings[coord] = building
|
||||
building.position = tile_map.map_to_local(building.starting_coord)
|
||||
building.rotation_degrees += 90 * building.get_rotation_count()
|
||||
if building is PostOffice:
|
||||
building.place()
|
||||
|
||||
|
||||
func initialize() -> void:
|
||||
|
||||
@ -24,8 +24,8 @@ func get_direction_queue(_citizen: Citizen) -> Array[Board.Direction]:
|
||||
func activate(citizen: Citizen) -> void:
|
||||
if citizen.get_status_count(Citizen.Status.PACKAGED) > 0:
|
||||
citizen.remove_all_statuses(Citizen.Status.PACKAGED)
|
||||
print("Citizen has delivered a package!")
|
||||
print("\tDistance: ", citizen.package_distance)
|
||||
citizen.money += ceili(citizen.package_distance / 2.0)
|
||||
citizen.play_money_animation()
|
||||
citizen.package_distance = 0
|
||||
else:
|
||||
citizen.add_status(Citizen.Status.PACKAGED)
|
||||
|
||||
@ -17,7 +17,7 @@ const SHOP_SCENE = preload("uid://dbn63mv0peqf")
|
||||
const CHURCH_SCENE = preload("uid://brn0nbkela0m4")
|
||||
const CITY_HALL_SCENE = preload("uid://dtnejoimqiu0o")
|
||||
const DEMOLITIONS_SCENE = preload("uid://dvmglvbersupv")
|
||||
#const POST_OFFICE_SCENE = preload("uid://bpi8owv5lxyjy")
|
||||
const POST_OFFICE_SCENE = preload("uid://bpi8owv5lxyjy")
|
||||
|
||||
const BASE_DECK = [
|
||||
BANK_SCENE,
|
||||
@ -30,7 +30,8 @@ const BASE_DECK = [
|
||||
SHOP_SCENE,
|
||||
CHURCH_SCENE,
|
||||
CITY_HALL_SCENE,
|
||||
DEMOLITIONS_SCENE
|
||||
DEMOLITIONS_SCENE,
|
||||
POST_OFFICE_SCENE
|
||||
]
|
||||
|
||||
const WINNING_MONEY_AMOUNT: int = 200
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user