generated from krampus/template-godot4
way too many changes; multiplayer version, like, 0.6 or 0.7
Some checks failed
linting & formatting / build (push) Failing after 24s
Some checks failed
linting & formatting / build (push) Failing after 24s
This commit is contained in:
parent
ddd2fed714
commit
a9352d337d
@ -63,40 +63,40 @@ signal _peer_initiated(peer: TubePeer)
|
||||
enum State {
|
||||
## No active session. Can only create or join new session in this state.
|
||||
IDLE,
|
||||
|
||||
|
||||
## Attempting to create a session.
|
||||
CREATING_SESSION,
|
||||
|
||||
CREATING_SESSION,
|
||||
|
||||
## The session has been successfully created. Waiting for other player to join.
|
||||
SESSION_CREATED,
|
||||
|
||||
SESSION_CREATED,
|
||||
|
||||
## Attempting to join a session.
|
||||
JOINING_SESSION,
|
||||
|
||||
JOINING_SESSION,
|
||||
|
||||
## A session has been successfully joined. Connected to server.
|
||||
SESSION_JOINED,
|
||||
SESSION_JOINED,
|
||||
}
|
||||
|
||||
|
||||
enum SessionError {
|
||||
## Failed to create a session.
|
||||
CREATE_SESSION_FAILED,
|
||||
|
||||
CREATE_SESSION_FAILED,
|
||||
|
||||
## Failed to join a session.
|
||||
JOIN_SESSION_FAILED,
|
||||
|
||||
JOIN_SESSION_FAILED,
|
||||
|
||||
## Failed to kick a peer from the session.
|
||||
KICK_PEER_FAILED,
|
||||
|
||||
## Session signaling failed, only for server. Meaning new players will not be able to join the session. The session is still considerated open as communication will connected peer is still possible.
|
||||
|
||||
## Session signaling failed, only for server. Meaning new players will not be able to join the session. The session is still considerated open as communication will connected peer is still possible.
|
||||
## [br][br]
|
||||
## Signaling is composed of local and online signaling.
|
||||
SIGNALING_FAILED,
|
||||
|
||||
## Signaling is composed of local and online signaling.
|
||||
SIGNALING_FAILED,
|
||||
|
||||
## Session online signaling failed, only for server. Meaning new players will not be able to join the via Internet session. The session is still considerated open as communication will connected peer is still possible.
|
||||
## [br][br]
|
||||
## Local signaling is not available on Web platform, meaing if online signaling failed on Web platform there is no other way for player to join the session. [signal error_raised] will be emitted once with [enum SessionError.ONLINE_SIGNALING_FAILED] and a second time with [enum SessionError.SIGNALING_FAILED].
|
||||
ONLINE_SIGNALING_FAILED,
|
||||
ONLINE_SIGNALING_FAILED,
|
||||
}
|
||||
|
||||
const _SERVER_PEER_ID: int = 1
|
||||
@ -129,7 +129,7 @@ var is_server: bool:
|
||||
get:
|
||||
return _SERVER_PEER_ID == peer_id
|
||||
|
||||
## Instance of [MultiplayerAPI] used for High-level multiplayer
|
||||
## Instance of [MultiplayerAPI] used for High-level multiplayer
|
||||
var multiplayer_api := MultiplayerAPI.create_default_interface()
|
||||
|
||||
## Instance of [MultiplayerPeer] used for managing peer connections.
|
||||
@ -140,14 +140,14 @@ var refuse_new_connections: bool = false:
|
||||
get:
|
||||
if not is_server:
|
||||
return false
|
||||
|
||||
|
||||
return refuse_new_connections
|
||||
|
||||
|
||||
set(x):
|
||||
if not is_server:
|
||||
push_error("Cannot refuse new connections, not server")
|
||||
return
|
||||
|
||||
|
||||
refuse_new_connections = x
|
||||
multiplayer_peer.refuse_new_connections = x
|
||||
|
||||
@ -167,9 +167,9 @@ func _ready() -> void:
|
||||
var node_path := NodePath()
|
||||
if is_instance_valid(multiplayer_root_node):
|
||||
node_path = multiplayer_root_node.get_path()
|
||||
|
||||
|
||||
get_tree().set_multiplayer(multiplayer_api, node_path)
|
||||
|
||||
|
||||
if not multiplayer_api.peer_connected.is_connected(
|
||||
peer_connected.emit
|
||||
):
|
||||
@ -190,28 +190,28 @@ func create_session() -> void:
|
||||
_session_initiated.emit()
|
||||
_raise_error(SessionError.CREATE_SESSION_FAILED, "Session creation failed, client is not inside tree")
|
||||
return
|
||||
|
||||
|
||||
if State.IDLE != state:
|
||||
_session_initiated.emit()
|
||||
_raise_error(SessionError.CREATE_SESSION_FAILED, "Session creation failed, not in idle state")
|
||||
return
|
||||
|
||||
|
||||
if null == context:
|
||||
_session_initiated.emit()
|
||||
_raise_error(SessionError.CREATE_SESSION_FAILED, "Session creation failed, context is missing")
|
||||
return
|
||||
|
||||
|
||||
if not context.is_valid():
|
||||
_session_initiated.emit()
|
||||
_raise_error(SessionError.CREATE_SESSION_FAILED, "Session creation failed, context is invalid")
|
||||
return
|
||||
|
||||
|
||||
state = State.CREATING_SESSION
|
||||
session_id = context.generate_session_id()
|
||||
peer_id = _SERVER_PEER_ID
|
||||
refuse_new_connections = false
|
||||
_session_initiated.emit()
|
||||
|
||||
|
||||
var error := multiplayer_peer.create_server()
|
||||
if error:
|
||||
_terminate_session()
|
||||
@ -219,13 +219,13 @@ func create_session() -> void:
|
||||
"error": error_string(error),
|
||||
}))
|
||||
return
|
||||
|
||||
|
||||
multiplayer_api.multiplayer_peer = multiplayer_peer
|
||||
|
||||
|
||||
_initiate_local_signaling()
|
||||
for url in context.trackers_urls:
|
||||
_initiate_tracker(url)
|
||||
|
||||
|
||||
if _is_local_signaling() and not _is_online_signaling():
|
||||
state = State.SESSION_CREATED
|
||||
session_created.emit()
|
||||
@ -237,34 +237,34 @@ func join_session(p_session_id: String) -> void:
|
||||
_session_initiated.emit()
|
||||
_raise_error(SessionError.JOIN_SESSION_FAILED, "Joining session failed, client is not inside tree")
|
||||
return
|
||||
|
||||
|
||||
if State.IDLE != state:
|
||||
_session_initiated.emit()
|
||||
_raise_error(SessionError.JOIN_SESSION_FAILED, "Joining session failed, not in idle state")
|
||||
return
|
||||
|
||||
|
||||
if null == context:
|
||||
_session_initiated.emit()
|
||||
_raise_error(SessionError.JOIN_SESSION_FAILED, "Joining session failed, context is missing")
|
||||
return
|
||||
|
||||
|
||||
if not context.is_valid():
|
||||
_session_initiated.emit()
|
||||
_raise_error(SessionError.JOIN_SESSION_FAILED, "Joining session failed, context is invalid")
|
||||
return
|
||||
|
||||
|
||||
if not context.is_session_id_valid(p_session_id):
|
||||
_session_initiated.emit()
|
||||
_raise_error(SessionError.JOIN_SESSION_FAILED, "Joining session failed, session id invalid '{id}'".format({
|
||||
"id": p_session_id,
|
||||
}))
|
||||
return
|
||||
|
||||
|
||||
state = State.JOINING_SESSION
|
||||
session_id = p_session_id
|
||||
peer_id = multiplayer_peer.generate_unique_id()
|
||||
_session_initiated.emit()
|
||||
|
||||
|
||||
var error := multiplayer_peer.create_client(peer_id)
|
||||
if error:
|
||||
_terminate_session()
|
||||
@ -272,30 +272,30 @@ func join_session(p_session_id: String) -> void:
|
||||
"error": error_string(error),
|
||||
}))
|
||||
return
|
||||
|
||||
|
||||
multiplayer_api.multiplayer_peer = multiplayer_peer
|
||||
|
||||
|
||||
var peer := _initiate_peer(_SERVER_PEER_ID)
|
||||
if not peer.valid:
|
||||
return
|
||||
|
||||
|
||||
_initiate_local_signaling()
|
||||
for url in context.trackers_urls:
|
||||
_initiate_tracker(url)
|
||||
|
||||
## Attempts to remove a peer [param p_peer_id from the session.
|
||||
## Attempts to remove a peer [param p_peer_id from the session.
|
||||
## Emits [signal peer_disconnected] if successful [signal error_raised] with [code]SessionError.KICK_PEER_FAILED[/code] if the operation fails.
|
||||
func kick_peer(p_peer_id: int) -> void:
|
||||
if not is_server:
|
||||
_raise_error(SessionError.KICK_PEER_FAILED, "Kick peer failed, not server")
|
||||
return
|
||||
|
||||
|
||||
if not _peers.has(p_peer_id):
|
||||
_raise_error(SessionError.KICK_PEER_FAILED, "Kick peer failed, peer {peer_id}".format({
|
||||
"peer_id": p_peer_id
|
||||
}))
|
||||
return
|
||||
|
||||
|
||||
multiplayer_peer.disconnect_peer(p_peer_id)
|
||||
|
||||
|
||||
@ -312,7 +312,7 @@ func _terminate_signaling():
|
||||
if null != _local_signaling_peer:
|
||||
_local_signaling_peer.close()
|
||||
_local_signaling_peer = null
|
||||
|
||||
|
||||
for i_tracker in _trackers:
|
||||
i_tracker.close(
|
||||
context.get_info_hash(session_id),
|
||||
@ -323,20 +323,20 @@ func _terminate_signaling():
|
||||
func _terminate_session():
|
||||
state = State.IDLE
|
||||
_upnp.clear_port_mapping()
|
||||
|
||||
|
||||
if null != _local_signaling_peer:
|
||||
_local_signaling_peer.close()
|
||||
_local_signaling_peer = null
|
||||
|
||||
|
||||
for i_tracker in _trackers:
|
||||
i_tracker.close(
|
||||
context.get_info_hash(session_id),
|
||||
context.get_peer_id_hash(peer_id)
|
||||
)
|
||||
|
||||
|
||||
for i_peer: TubePeer in _peers.values():
|
||||
i_peer.close() # will be clean collected
|
||||
|
||||
|
||||
session_id = ""
|
||||
multiplayer_peer.close()
|
||||
|
||||
@ -344,7 +344,7 @@ func _terminate_session():
|
||||
func _is_local_signaling() -> bool:
|
||||
if null == _local_signaling_peer:
|
||||
return false
|
||||
|
||||
|
||||
return _local_signaling_peer.is_bound()
|
||||
|
||||
|
||||
@ -355,7 +355,7 @@ func _is_online_signaling() -> bool:
|
||||
func _initiate_local_signaling() -> void:
|
||||
if not TubeLocalSignalingPeer.is_local_signaling_available():
|
||||
return
|
||||
|
||||
|
||||
_local_signaling_peer = TubeLocalSignalingPeer.new()
|
||||
var error := _local_signaling_peer.bind(
|
||||
context.app_id,
|
||||
@ -365,11 +365,11 @@ func _initiate_local_signaling() -> void:
|
||||
_local_signaling_peer_initiated.emit(
|
||||
_local_signaling_peer
|
||||
)
|
||||
|
||||
|
||||
if error:
|
||||
_local_signaling_peer = null
|
||||
return
|
||||
|
||||
|
||||
_local_signaling_peer.received_signaling_data.connect(
|
||||
_handle_local_signaling_data
|
||||
)
|
||||
@ -379,10 +379,10 @@ func _initiate_tracker(p_url: String) -> void:
|
||||
var tracker := TubeTracker.new()
|
||||
var error := tracker.connect_to_url(p_url)
|
||||
_tracker_initiated.emit(tracker)
|
||||
|
||||
|
||||
if error:
|
||||
return
|
||||
|
||||
|
||||
_trackers.append(tracker)
|
||||
tracker.connected.connect(
|
||||
_on_tracker_connected.bind(tracker)
|
||||
@ -395,22 +395,22 @@ func _initiate_tracker(p_url: String) -> void:
|
||||
)
|
||||
|
||||
|
||||
func _on_tracker_connected(p_tracker: TubeTracker):
|
||||
func _on_tracker_connected(p_tracker: TubeTracker):
|
||||
p_tracker.send_announce(
|
||||
context.get_info_hash(session_id),
|
||||
context.get_peer_id_hash(peer_id),
|
||||
)
|
||||
|
||||
|
||||
if State.CREATING_SESSION == state:
|
||||
state = State.SESSION_CREATED
|
||||
session_created.emit()
|
||||
|
||||
|
||||
if is_server:
|
||||
return
|
||||
|
||||
|
||||
if not _peers.has(_SERVER_PEER_ID):
|
||||
return
|
||||
|
||||
|
||||
var server_peer := _peers[_SERVER_PEER_ID]
|
||||
if server_peer.is_signaling_ready():
|
||||
_send_signaling_data(server_peer, p_tracker)
|
||||
@ -424,26 +424,26 @@ func _all_trackers_disconnected(): # is_online_signaling false
|
||||
"Online signaling failed, cannot connect to any tracker"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
_raise_error(
|
||||
SessionError.CREATE_SESSION_FAILED,
|
||||
"Session creation failed, cannot connect to any tracker"
|
||||
)
|
||||
_terminate_session()
|
||||
|
||||
|
||||
elif State.SESSION_CREATED == state:
|
||||
_raise_error(
|
||||
SessionError.ONLINE_SIGNALING_FAILED,
|
||||
"Signaling failed, lost all trackers connections"
|
||||
)
|
||||
|
||||
|
||||
if not _is_local_signaling():
|
||||
_raise_error(
|
||||
SessionError.ONLINE_SIGNALING_FAILED,
|
||||
"Signaling failed, lost all trackers connections"
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
elif State.JOINING_SESSION == state:
|
||||
if _peers.has(_SERVER_PEER_ID):
|
||||
var peer = _peers[_SERVER_PEER_ID]
|
||||
@ -460,55 +460,55 @@ func _handle_local_signaling_data(p_data: Dictionary, p_address: String):
|
||||
if from_app_id != context.app_id:
|
||||
_local_signaling_peer.raise_warning("Received signaling data from other app ID")
|
||||
return
|
||||
|
||||
|
||||
var from_session_id := TubeLocalSignalingPeer.get_session_id_from_signaling_data(p_data)
|
||||
if from_session_id != session_id:
|
||||
_local_signaling_peer.raise_warning("Received signaling data from other session ID")
|
||||
return
|
||||
|
||||
|
||||
var from_peer_id := TubeLocalSignalingPeer.get_peer_id_from_signaling_data(p_data)
|
||||
if is_server and from_peer_id == _SERVER_PEER_ID:
|
||||
_local_signaling_peer.raise_warning("Received signaling data from peer id 1 as server")
|
||||
return
|
||||
|
||||
|
||||
if not is_server and from_peer_id != _SERVER_PEER_ID:
|
||||
_local_signaling_peer.raise_warning("Received signaling data from peer {peer_id}, but not as server".format({
|
||||
"peer_id": from_peer_id
|
||||
}))
|
||||
return
|
||||
|
||||
|
||||
if refuse_new_connections:
|
||||
peer_refused.emit(from_peer_id)
|
||||
return
|
||||
|
||||
|
||||
var peer: TubePeer = _peers.get(from_peer_id)
|
||||
if null == peer:
|
||||
peer = _initiate_peer(from_peer_id)
|
||||
if not peer.valid:
|
||||
return
|
||||
|
||||
|
||||
peer.local_address = p_address
|
||||
|
||||
|
||||
if WebRTCPeerConnection.ConnectionState.STATE_CONNECTED == peer.get_connection_state():
|
||||
peer.raise_warning(
|
||||
"Receive signaling data but already connected"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
if peer.remote_session_description.is_empty():
|
||||
var type := TubeLocalSignalingPeer.get_type_from_signaling_data(p_data)
|
||||
var sdp := TubeLocalSignalingPeer.get_sdp_from_signaling_data(p_data)
|
||||
if peer.set_remote_description(type, sdp): # error
|
||||
return
|
||||
|
||||
|
||||
for candidate_data in TubeLocalSignalingPeer.get_ice_candidates_from_signaling_data(p_data):
|
||||
|
||||
|
||||
if not TubeLocalSignalingPeer.is_ice_candidate_data_valid(candidate_data):
|
||||
peer.raise_warning(
|
||||
"Cannot add ice candidate, ice data invalid"
|
||||
)
|
||||
continue
|
||||
|
||||
|
||||
peer.add_ice_candidate(
|
||||
TubeLocalSignalingPeer.get_media_from_ice_candidate_data(
|
||||
candidate_data
|
||||
@ -527,39 +527,39 @@ func _handle_tracker_answer(data: Dictionary, p_tracker: TubeTracker):
|
||||
if not context.is_peer_id_hash_valid(from_peer_id_hash):
|
||||
p_tracker.raise_warning("answer peer id invalid")
|
||||
return
|
||||
|
||||
|
||||
var from_peer_id := context.get_peer_id(from_peer_id_hash)
|
||||
if refuse_new_connections:
|
||||
peer_refused.emit(from_peer_id)
|
||||
return
|
||||
|
||||
|
||||
var peer: TubePeer = _peers.get(from_peer_id)
|
||||
if null == peer:
|
||||
peer = _initiate_peer(from_peer_id)
|
||||
if not peer.valid:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
if WebRTCPeerConnection.ConnectionState.STATE_CONNECTED == peer.get_connection_state():
|
||||
peer.raise_warning(
|
||||
"Receive signaling data but already connected"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
if peer.remote_session_description.is_empty():
|
||||
var type := TubeTracker.get_type_from_answer_data(data)
|
||||
var sdp := TubeTracker.get_sdp_from_answer_data(data)
|
||||
if peer.set_remote_description(type, sdp): # error
|
||||
return
|
||||
|
||||
|
||||
for candidate_data in TubeTracker.get_ice_candidates_from_answer_data(data):
|
||||
|
||||
|
||||
if not TubeTracker.is_ice_candidate_data_valid(candidate_data):
|
||||
peer.raise_warning(
|
||||
"Cannot add ice candidate, ice data invalid"
|
||||
)
|
||||
continue
|
||||
|
||||
|
||||
peer.add_ice_candidate(
|
||||
TubeTracker.get_media_from_ice_candidate_data(
|
||||
candidate_data
|
||||
@ -581,7 +581,7 @@ func _on_tracker_interval_timeout(p_tracker: TubeTracker):
|
||||
|
||||
|
||||
func _send_signaling_data(p_peer: TubePeer, p_tracker: TubeTracker = null):
|
||||
|
||||
|
||||
if _local_signaling_peer:
|
||||
if is_server:
|
||||
_local_signaling_peer.send_signaling_data(
|
||||
@ -602,19 +602,19 @@ func _send_signaling_data(p_peer: TubePeer, p_tracker: TubeTracker = null):
|
||||
p_peer.local_session_description,
|
||||
p_peer.ice_candidates,
|
||||
)
|
||||
|
||||
|
||||
var info_hash := context.get_info_hash(session_id)
|
||||
var peer_id_hash := context.get_peer_id_hash(peer_id)
|
||||
var to_peer_id_hash := context.get_peer_id_hash(p_peer.id)
|
||||
|
||||
|
||||
var to_trackers = _trackers
|
||||
if p_tracker:
|
||||
to_trackers = [p_tracker]
|
||||
|
||||
|
||||
for i_tracker in to_trackers:
|
||||
if not i_tracker.is_open():
|
||||
continue
|
||||
|
||||
|
||||
i_tracker.send_answer(
|
||||
info_hash,
|
||||
peer_id_hash,
|
||||
@ -633,11 +633,11 @@ func _initiate_peer(p_peer_id: int) -> TubePeer:
|
||||
var error := peer.initialize(
|
||||
context.get_ice_servers()
|
||||
)
|
||||
|
||||
|
||||
if error: # error raised with peer.failed
|
||||
return peer
|
||||
|
||||
|
||||
|
||||
|
||||
peer.signaling_readied.connect(
|
||||
_on_peer_signaling_readied.bind(peer)
|
||||
)
|
||||
@ -659,7 +659,7 @@ func _initiate_peer(p_peer_id: int) -> TubePeer:
|
||||
peer.port_mapped.connect(
|
||||
_upnp.add_port_mapping
|
||||
)
|
||||
|
||||
|
||||
_peers[p_peer_id] = peer
|
||||
_peer_initiated.emit(peer)
|
||||
error = multiplayer_peer.add_peer(peer, p_peer_id)
|
||||
@ -669,22 +669,22 @@ func _initiate_peer(p_peer_id: int) -> TubePeer:
|
||||
"error": error_string(error)
|
||||
})
|
||||
peer.failed.emit()
|
||||
|
||||
|
||||
if not is_server:
|
||||
error = peer.create_offer()
|
||||
if error: # error raised with peer.failed
|
||||
return peer
|
||||
|
||||
|
||||
return peer
|
||||
|
||||
|
||||
func _clean_peer(p_peer: TubePeer):
|
||||
if multiplayer_peer.has_peer(p_peer.id):
|
||||
multiplayer_peer.remove_peer(p_peer.id)
|
||||
|
||||
|
||||
for port in p_peer.mapped_ports:
|
||||
_upnp.delete_port_mapping(port)
|
||||
|
||||
|
||||
#if _peers.has(p_peer.id): # garbage collected
|
||||
#_peers.erase(p_peer.id)
|
||||
p_peer.has_joined_session = false
|
||||
@ -706,12 +706,12 @@ func _on_peer_connected(p_peer: TubePeer):
|
||||
if State.IDLE == state:
|
||||
_clean_peer(p_peer)
|
||||
return
|
||||
|
||||
|
||||
if State.JOINING_SESSION == state:
|
||||
state = State.SESSION_JOINED
|
||||
_terminate_signaling()
|
||||
session_joined.emit()
|
||||
|
||||
|
||||
if p_peer.has_joined_session:
|
||||
peer_stabilized.emit(p_peer.id)
|
||||
p_peer.has_joined_session = true
|
||||
@ -722,7 +722,7 @@ func _on_peer_disconnected(p_peer: TubePeer): # temporary disconnection
|
||||
if State.IDLE == state:
|
||||
_clean_peer(p_peer)
|
||||
return
|
||||
|
||||
|
||||
peer_unstabilized.emit(p_peer.id)
|
||||
|
||||
|
||||
@ -730,7 +730,7 @@ func _on_peer_failed(p_peer: TubePeer):
|
||||
_clean_peer(p_peer)
|
||||
if State.IDLE == state:
|
||||
return
|
||||
|
||||
|
||||
if not is_server:
|
||||
if State.JOINING_SESSION == state:
|
||||
_raise_error(
|
||||
@ -740,10 +740,10 @@ func _on_peer_failed(p_peer: TubePeer):
|
||||
"error": p_peer.error_message
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
elif State.SESSION_JOINED == state:
|
||||
session_left.emit()
|
||||
|
||||
|
||||
_terminate_session()
|
||||
|
||||
|
||||
@ -751,24 +751,24 @@ func _on_peer_closed(p_peer: TubePeer):
|
||||
_clean_peer(p_peer)
|
||||
if State.IDLE == state:
|
||||
return
|
||||
|
||||
|
||||
if not is_server:
|
||||
if State.SESSION_JOINED == state:
|
||||
session_left.emit()
|
||||
|
||||
|
||||
_terminate_session()
|
||||
|
||||
|
||||
# PROCESS ###
|
||||
|
||||
func _process(delta):
|
||||
|
||||
|
||||
if _upnp:
|
||||
_upnp._process(delta)
|
||||
|
||||
|
||||
if _local_signaling_peer:
|
||||
_local_signaling_peer._process(delta)
|
||||
|
||||
|
||||
var tracker_closed := false
|
||||
var updated_trackers: Array[TubeTracker] = []
|
||||
for i_tracker in _trackers:
|
||||
@ -776,14 +776,14 @@ func _process(delta):
|
||||
if i_tracker.is_close():
|
||||
tracker_closed = true
|
||||
continue
|
||||
|
||||
|
||||
updated_trackers.append(i_tracker)
|
||||
|
||||
|
||||
_trackers = updated_trackers
|
||||
if tracker_closed and not _is_online_signaling():
|
||||
_all_trackers_disconnected()
|
||||
|
||||
|
||||
|
||||
|
||||
var updated_peers: Dictionary[int, TubePeer] = {}
|
||||
for i_peer_id in _peers:
|
||||
var i_peer := _peers[i_peer_id]
|
||||
@ -791,7 +791,7 @@ func _process(delta):
|
||||
if WebRTCPeerConnection.STATE_CLOSED == i_peer.connection_state: # don't use is_close to use connection_state
|
||||
_clean_peer(i_peer)
|
||||
continue
|
||||
|
||||
|
||||
updated_peers[i_peer_id] = i_peer
|
||||
|
||||
|
||||
_peers = updated_peers
|
||||
|
||||
@ -36,7 +36,7 @@ var interval_time_left: float = -1.0
|
||||
|
||||
func _to_string() -> String:
|
||||
var string := socket.get_requested_url()
|
||||
|
||||
|
||||
if "Web" != OS.get_name():
|
||||
if WebSocketPeer.STATE_OPEN == socket.get_ready_state():
|
||||
string += "({protocol}://{address}:{port})".format({
|
||||
@ -44,7 +44,7 @@ func _to_string() -> String:
|
||||
"address": socket.get_connected_host(),
|
||||
"port": socket.get_connected_port(),
|
||||
})
|
||||
|
||||
|
||||
return string
|
||||
|
||||
|
||||
@ -57,10 +57,10 @@ func connect_to_url(p_url: String) -> Error:
|
||||
var error := socket.connect_to_url(p_url)
|
||||
if error:
|
||||
error_message = "connection failed: {error}".format({
|
||||
"error": error_string(error)
|
||||
"error": error_string(error)
|
||||
})
|
||||
failed.emit()
|
||||
|
||||
|
||||
return error
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ func close(p_info_hash: String, p_peer_id_hash: String):
|
||||
p_info_hash,
|
||||
p_peer_id_hash
|
||||
)
|
||||
|
||||
|
||||
if not is_close():
|
||||
socket.close(
|
||||
CLOSE_CODE_CLIENT,
|
||||
@ -92,19 +92,19 @@ func _socket_connection_opened():
|
||||
|
||||
func _socket_connection_closed(p_code: int, p_reason: String):
|
||||
#if -1 == p_code: # error
|
||||
|
||||
|
||||
if WebSocketPeer.State.STATE_CONNECTING == state:
|
||||
error_message = "connection impossible"
|
||||
|
||||
|
||||
p_reason = p_reason if p_reason else "Closed unexpectedly, code: {code}".format({
|
||||
"code": p_code,
|
||||
})
|
||||
|
||||
|
||||
if WebSocketPeer.State.STATE_OPEN == state:
|
||||
error_message = "connection failed: {reason}".format({
|
||||
"reason": p_reason,
|
||||
})
|
||||
|
||||
|
||||
disconnected.emit()
|
||||
|
||||
|
||||
@ -126,16 +126,16 @@ func send_data(p_data: Dictionary) -> Error:
|
||||
var error := socket.send_text(
|
||||
text
|
||||
)
|
||||
|
||||
|
||||
if error:
|
||||
raise_warning(
|
||||
"Cannot send text: {error}".format({
|
||||
"error": error_string(error)
|
||||
}))
|
||||
|
||||
|
||||
else:
|
||||
data_sent.emit(p_data)
|
||||
|
||||
|
||||
return error
|
||||
|
||||
|
||||
@ -144,7 +144,7 @@ func send_announce(p_info_hash: String, p_peer_id_hash: String) -> Error:
|
||||
"action": "announce",
|
||||
"info_hash": p_info_hash,
|
||||
"peer_id": p_peer_id_hash,
|
||||
|
||||
|
||||
"uploaded": 0,
|
||||
"downloaded": 0,
|
||||
})
|
||||
@ -161,7 +161,7 @@ func send_answer(
|
||||
"action": "announce",
|
||||
"info_hash": p_info_hash,
|
||||
"peer_id": p_peer_id_hash,
|
||||
|
||||
|
||||
"to_peer_id": p_to_peer_id_hash,
|
||||
"answer": {
|
||||
"type": description.type,
|
||||
@ -188,12 +188,12 @@ func _received_packet(p_packet: PackedByteArray):
|
||||
"packet": str(p_packet)
|
||||
}))
|
||||
return
|
||||
|
||||
|
||||
received_data.emit(data)
|
||||
if data.has("answer"):
|
||||
_handle_answer(data)
|
||||
return
|
||||
|
||||
|
||||
_handle_announce(data)
|
||||
|
||||
|
||||
@ -201,11 +201,11 @@ func _handle_announce(p_data: Dictionary):
|
||||
if not p_data.has("interval"):
|
||||
raise_warning("announce data has no interval")
|
||||
return
|
||||
|
||||
|
||||
if not p_data.interval is float:
|
||||
raise_warning("interval invalid data type")
|
||||
return
|
||||
|
||||
|
||||
interval_time = min(p_data.interval, MAX_INTERVAL)
|
||||
interval_time_left = interval_time
|
||||
|
||||
@ -214,47 +214,47 @@ func _handle_answer(p_data: Dictionary):
|
||||
if not p_data is Dictionary:
|
||||
raise_warning("answer data invalid data type")
|
||||
return
|
||||
|
||||
|
||||
if not p_data.has("peer_id"):
|
||||
raise_warning("answer data has no peer_id")
|
||||
return
|
||||
|
||||
|
||||
if not p_data.peer_id is String:
|
||||
raise_warning("peer_id invalid data type")
|
||||
return
|
||||
|
||||
|
||||
if not p_data.has("answer"):
|
||||
raise_warning("answer data has no answer")
|
||||
return
|
||||
|
||||
|
||||
if not p_data.answer is Dictionary:
|
||||
raise_warning("answer invalid data type")
|
||||
return
|
||||
|
||||
|
||||
var answer: Dictionary = p_data.answer
|
||||
if not answer.has("sdp"):
|
||||
raise_warning("answer data has no sdp")
|
||||
|
||||
|
||||
if not answer.sdp is String:
|
||||
raise_warning("sdp invalid data type")
|
||||
return
|
||||
|
||||
|
||||
if not answer.has("type"):
|
||||
raise_warning("answer data has no type")
|
||||
return
|
||||
|
||||
|
||||
if not answer.type is String:
|
||||
raise_warning("type invalid data type")
|
||||
return
|
||||
|
||||
|
||||
if not answer.has("ice_candidates"):
|
||||
raise_warning("answer data has no ice_candidates")
|
||||
return
|
||||
|
||||
|
||||
if not answer.ice_candidates is Array:
|
||||
raise_warning("ice_candidates invalid data type")
|
||||
return
|
||||
|
||||
|
||||
received_answer.emit(p_data)
|
||||
|
||||
|
||||
@ -278,31 +278,31 @@ static func is_ice_candidate_data_valid(p_data: Variant) -> bool:
|
||||
if not p_data is Dictionary:
|
||||
push_error("Ice candidate data invalid data type")
|
||||
return false
|
||||
|
||||
|
||||
if not p_data.has("media"):
|
||||
push_error("Ice candidate data has no media")
|
||||
return false
|
||||
|
||||
|
||||
if not p_data.media is String:
|
||||
push_error("media invalid data type")
|
||||
return false
|
||||
|
||||
|
||||
if not p_data.has("index"):
|
||||
push_error("Ice candidate has no index")
|
||||
return false
|
||||
|
||||
|
||||
if not (typeof(p_data.index) in [TYPE_INT, TYPE_FLOAT]):
|
||||
push_error("index invalid data type")
|
||||
return false
|
||||
|
||||
|
||||
if not p_data.has("sdp"):
|
||||
push_error("Ice candidate has no sdp")
|
||||
return false
|
||||
|
||||
|
||||
if not p_data.sdp is String:
|
||||
push_error("Ice candidate sdp invalid data type")
|
||||
return false
|
||||
|
||||
|
||||
return true
|
||||
|
||||
|
||||
@ -320,42 +320,42 @@ static func get_sdp_from_ice_candidate_data(p_data: Dictionary) -> String:
|
||||
|
||||
func _process(delta: float):
|
||||
socket.poll() # push error when 502 bad gateway, doesn't block anything
|
||||
|
||||
|
||||
var old_state := state
|
||||
state = socket.get_ready_state()
|
||||
if state != old_state:
|
||||
state_changed.emit()
|
||||
|
||||
|
||||
|
||||
|
||||
if WebSocketPeer.STATE_CONNECTING == state:
|
||||
connecting_time += delta
|
||||
|
||||
|
||||
if WebSocketPeer.STATE_OPEN == state:
|
||||
if WebSocketPeer.STATE_OPEN != old_state:
|
||||
_socket_connection_opened()
|
||||
|
||||
|
||||
while socket.get_available_packet_count():
|
||||
var packet := socket.get_packet()
|
||||
_received_packet(packet)
|
||||
|
||||
|
||||
up_time += delta
|
||||
|
||||
|
||||
if 0.0 < interval_time:
|
||||
interval_time_left -= delta
|
||||
if interval_time_left < 0.0:
|
||||
interval_time_left = interval_time
|
||||
interval_timeout.emit()
|
||||
|
||||
|
||||
|
||||
|
||||
elif WebSocketPeer.STATE_CLOSING == state:
|
||||
# Keep polling to achieve proper close.
|
||||
pass
|
||||
|
||||
|
||||
elif WebSocketPeer.STATE_CLOSED == state:
|
||||
var code = socket.get_close_code()
|
||||
var reason = socket.get_close_reason()
|
||||
_socket_connection_closed(code, reason)
|
||||
|
||||
|
||||
#
|
||||
#if WebRTCPeerConnection.STATE_CONNECTED == connection_state:
|
||||
#
|
||||
|
||||
BIN
assets/ui_buttons/button UI.png
(Stored with Git LFS)
Normal file
BIN
assets/ui_buttons/button UI.png
(Stored with Git LFS)
Normal file
Binary file not shown.
40
assets/ui_buttons/button UI.png.import
Normal file
40
assets/ui_buttons/button UI.png.import
Normal file
@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dalonthk63q26"
|
||||
path="res://.godot/imported/button UI.png-3eed35efdb4062b809cd0c3862f90e91.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/ui_buttons/button UI.png"
|
||||
dest_files=["res://.godot/imported/button UI.png-3eed35efdb4062b809cd0c3862f90e91.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
67
game.gd
67
game.gd
@ -1,67 +0,0 @@
|
||||
class_name Game extends Node
|
||||
|
||||
const DOWN_SPAWN_SCENE = preload("uid://d4ltd1geg7s2p")
|
||||
|
||||
var turn: int = 0:
|
||||
set(value):
|
||||
turn = value
|
||||
controls.set_turn(turn)
|
||||
var player: Player
|
||||
var citizen_count: int = 0:
|
||||
set(value):
|
||||
print(value)
|
||||
citizen_count = value
|
||||
if citizen_count == 0:
|
||||
handle_turn_over()
|
||||
|
||||
var spawn_placement_actions = 0
|
||||
|
||||
@onready var board: Board = %Board
|
||||
@onready var controls: Controls = %Controls
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
Globals.game = self
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
player = Player.new()
|
||||
controls.set_players([player])
|
||||
start_turn()
|
||||
|
||||
|
||||
func start_turn() -> void:
|
||||
turn += 1
|
||||
if spawn_placement_actions > 0:
|
||||
board.set_active_tile(DOWN_SPAWN_SCENE.instantiate())
|
||||
|
||||
|
||||
func select_tile(tile: Tile):
|
||||
board.set_active_tile(tile)
|
||||
|
||||
|
||||
func select_building(building: Building) -> void:
|
||||
if building is Home:
|
||||
board.set_active_building(building, player)
|
||||
else:
|
||||
board.set_active_building(building)
|
||||
|
||||
|
||||
func place_walls() -> void:
|
||||
board.is_placing_walls = !board.is_placing_walls
|
||||
|
||||
|
||||
func handle_turn_over() -> void:
|
||||
get_tree().call_group("PostTurnActions", "handle_post_turn_actions")
|
||||
controls.reset_turn()
|
||||
start_turn()
|
||||
|
||||
|
||||
func queue_spawn_placement(num: int) -> void:
|
||||
spawn_placement_actions += num
|
||||
|
||||
|
||||
func handle_spawn_placed() -> void:
|
||||
spawn_placement_actions = maxi(spawn_placement_actions - 1, 0)
|
||||
if spawn_placement_actions > 0:
|
||||
board.set_active_tile(DOWN_SPAWN_SCENE.instantiate())
|
||||
@ -1 +0,0 @@
|
||||
uid://p10j5v8tlyb
|
||||
82
game.tscn
82
game.tscn
@ -1,82 +0,0 @@
|
||||
[gd_scene format=3 uid="uid://fbdci3d048m7"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ct6tclctgdrkm" path="res://prefabs/board.tscn" id="1_e2o6t"]
|
||||
[ext_resource type="Script" uid="uid://p10j5v8tlyb" path="res://game.gd" id="1_fc0e3"]
|
||||
[ext_resource type="Script" uid="uid://c5vwubjdr23jr" path="res://prefabs/game_camera.gd" id="1_feb5d"]
|
||||
[ext_resource type="PackedScene" uid="uid://caq4f3l237i42" path="res://prefabs/ui/controls.tscn" id="4_fc0e3"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fc0e3"]
|
||||
content_margin_left = 10.0
|
||||
content_margin_top = 10.0
|
||||
content_margin_right = 10.0
|
||||
content_margin_bottom = 10.0
|
||||
bg_color = Color(1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7jktm"]
|
||||
bg_color = Color(0, 0, 0, 1)
|
||||
corner_radius_top_left = 16
|
||||
corner_radius_top_right = 16
|
||||
corner_radius_bottom_right = 16
|
||||
corner_radius_bottom_left = 16
|
||||
|
||||
[node name="Game" type="Node" unique_id=384379479]
|
||||
script = ExtResource("1_fc0e3")
|
||||
|
||||
[node name="Control" type="Control" parent="." unique_id=161820979]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Control" unique_id=1771672320]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_fc0e3")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Control/PanelContainer" unique_id=761660879]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Controls" parent="Control/PanelContainer/VBoxContainer" unique_id=1719205711 instance=ExtResource("4_fc0e3")]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 50)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Control/PanelContainer/VBoxContainer" unique_id=1428657222]
|
||||
process_mode = 3
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_7jktm")
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="Control/PanelContainer/VBoxContainer/PanelContainer" unique_id=444978634]
|
||||
process_mode = 3
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
stretch = true
|
||||
mouse_target = true
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Control/PanelContainer/VBoxContainer/PanelContainer/SubViewportContainer" unique_id=1761859829]
|
||||
process_mode = 3
|
||||
disable_3d = true
|
||||
transparent_bg = true
|
||||
handle_input_locally = false
|
||||
physics_object_picking = true
|
||||
size = Vector2i(1132, 574)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="Control/PanelContainer/VBoxContainer/PanelContainer/SubViewportContainer/SubViewport" unique_id=296841783]
|
||||
anchor_mode = 0
|
||||
zoom = Vector2(0.94, 0.94)
|
||||
position_smoothing_enabled = true
|
||||
drag_horizontal_enabled = true
|
||||
drag_vertical_enabled = true
|
||||
script = ExtResource("1_feb5d")
|
||||
|
||||
[node name="Board" parent="Control/PanelContainer/VBoxContainer/PanelContainer/SubViewportContainer/SubViewport" unique_id=752933545 instance=ExtResource("1_e2o6t")]
|
||||
unique_name_in_owner = true
|
||||
234
prefabs/board.gd
234
prefabs/board.gd
@ -1,124 +1,102 @@
|
||||
class_name Board extends Node2D
|
||||
|
||||
signal board_state_changed
|
||||
|
||||
enum Direction { NONE, UP, DOWN, LEFT, RIGHT }
|
||||
|
||||
const GROUND = preload("uid://c5y5ksmwhevd")
|
||||
const UP_SPAWN = preload("uid://6ywvgci44ttv")
|
||||
const RIGHT_SPAWN = preload("uid://c1y3s7daosghf")
|
||||
const DOWN_SPAWN = preload("uid://d4ltd1geg7s2p")
|
||||
const LEFT_SPAWN = preload("uid://noi2ko4hceus")
|
||||
|
||||
var tiles: Dictionary[Vector2i, Tile] = {}
|
||||
var buildings: Dictionary[Vector2i, Building] = {}
|
||||
var active_building: Building
|
||||
var active_tile_id: int = -1
|
||||
var active_tile: Tile
|
||||
var current_map_coord: Vector2i
|
||||
var prev_map_coord: Vector2i
|
||||
var is_placing_walls: bool = false:
|
||||
set(value):
|
||||
is_placing_walls = value
|
||||
if !is_placing_walls:
|
||||
_clear_wall_preview()
|
||||
var current_wall_direction: Direction = Direction.DOWN
|
||||
var real_wall_coords: Array[Vector2i] = []
|
||||
var is_controlling_camera: bool = false
|
||||
|
||||
@onready var tile_map: SceneTileMapLayer = %Tiles
|
||||
@onready var tile_preview_map: SceneTileMapLayer = %TilesPreview
|
||||
@onready var wall_map: SceneTileMapLayer = %Walls
|
||||
@onready var wall_preview_map: SceneTileMapLayer = %WallPreviews
|
||||
@onready var tile_map: TileMapLayer = %Tiles
|
||||
@onready var board_state: Node2D = %BoardState
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("camera_engage"):
|
||||
is_controlling_camera = true
|
||||
return
|
||||
if event.is_action_released("camera_engage"):
|
||||
is_controlling_camera = false
|
||||
if is_controlling_camera:
|
||||
return
|
||||
#if Globals.board_game.current_board_state.current_player != Globals.game.this_player:
|
||||
#return
|
||||
if event is InputEventMouseMotion:
|
||||
current_map_coord = tile_map.local_to_map(tile_map.get_local_mouse_position())
|
||||
_place_wall_preview()
|
||||
_place_tile_preview()
|
||||
if active_tile != null:
|
||||
active_tile.position = tile_map.map_to_local(current_map_coord)
|
||||
if active_building != null:
|
||||
active_building.position = tile_map.map_to_local(current_map_coord)
|
||||
prev_map_coord = current_map_coord
|
||||
if event.is_action_pressed("select"):
|
||||
if is_placing_walls:
|
||||
_place_wall(current_map_coord, current_wall_direction)
|
||||
match current_wall_direction:
|
||||
Direction.UP:
|
||||
_place_wall(current_map_coord + Vector2i.UP, Direction.DOWN)
|
||||
Direction.DOWN:
|
||||
_place_wall(current_map_coord + Vector2i.DOWN, Direction.UP)
|
||||
Direction.LEFT:
|
||||
_place_wall(current_map_coord + Vector2i.LEFT, Direction.RIGHT)
|
||||
Direction.RIGHT:
|
||||
_place_wall(current_map_coord + Vector2i.RIGHT, Direction.LEFT)
|
||||
elif active_tile_id != -1:
|
||||
tile_preview_map.set_cell(current_map_coord)
|
||||
tile_map.set_cell(current_map_coord, 0, Vector2i.ZERO, active_tile_id)
|
||||
if active_tile_id >= 7 and active_tile_id <= 10:
|
||||
active_tile_id = -1
|
||||
Globals.game.handle_spawn_placed()
|
||||
else:
|
||||
active_tile_id = -1
|
||||
if active_tile != null:
|
||||
place_active_tile()
|
||||
elif active_building != null:
|
||||
active_building.starting_coord = current_map_coord
|
||||
for coord in active_building.get_tile_coords():
|
||||
buildings[coord] = active_building
|
||||
active_building.position = tile_map.map_to_local(current_map_coord)
|
||||
active_building.modulate = Color(1, 1, 1, 1)
|
||||
active_building.is_placing = false
|
||||
active_building = null
|
||||
if event.is_action_pressed("rotate_wall_up") and is_placing_walls:
|
||||
current_wall_direction = get_next_direction(current_wall_direction)
|
||||
var wall_preview = wall_preview_map.get_cell_scene(current_map_coord)
|
||||
if is_instance_valid(wall_preview):
|
||||
wall_preview.set_wall(current_wall_direction)
|
||||
elif event.is_action_pressed("rotate_wall_down") and is_placing_walls:
|
||||
current_wall_direction = get_previous_direction(current_wall_direction)
|
||||
var wall_preview = wall_preview_map.get_cell_scene(current_map_coord)
|
||||
if is_instance_valid(wall_preview):
|
||||
wall_preview.set_wall(current_wall_direction)
|
||||
place_active_building()
|
||||
_handle_building_rotation(event)
|
||||
_handle_spawn_rotation(event)
|
||||
#_handle_spawn_rotation(event)
|
||||
|
||||
|
||||
func set_active_tile(tile: Tile) -> void:
|
||||
active_tile_id = tile_map.tile_set.get_tile_id(tile)
|
||||
if active_tile_id != -1:
|
||||
tile_preview_map.set_cell(current_map_coord, 0, Vector2i.ZERO, active_tile_id)
|
||||
active_tile = tile
|
||||
board_state.add_child(active_tile)
|
||||
active_tile.modulate = Color(1, 1, 1, 0.5)
|
||||
active_tile.is_placing = true
|
||||
|
||||
|
||||
func set_active_building(building: Building, player: Player = null) -> void:
|
||||
active_building = building.duplicate()
|
||||
add_child(active_building)
|
||||
active_building.is_placing = true
|
||||
func set_active_building(building: Building) -> void:
|
||||
active_building = building
|
||||
board_state.add_child(active_building)
|
||||
if active_building is Home:
|
||||
active_building.player = Globals.board_game.current_board_state.current_player
|
||||
active_building.modulate = Color(1, 1, 1, 0.5)
|
||||
if player != null:
|
||||
active_building.player = player
|
||||
active_building.is_placing = true
|
||||
|
||||
|
||||
func _place_wall(wall_coord: Vector2i, wall_direction: Direction) -> void:
|
||||
var current_wall = wall_map.get_cell_scene(wall_coord)
|
||||
if is_instance_valid(current_wall):
|
||||
current_wall.add_wall(wall_direction)
|
||||
else:
|
||||
var wall_preview = wall_map.get_cell_scene(wall_coord)
|
||||
if is_instance_valid(wall_preview):
|
||||
wall_preview.set_wall(wall_direction)
|
||||
func place_active_tile() -> void:
|
||||
if tiles.has(current_map_coord) and tiles[current_map_coord] is Ground:
|
||||
tiles[current_map_coord].queue_free()
|
||||
tiles.erase(current_map_coord)
|
||||
if !tiles.has(current_map_coord) and !buildings.has(current_map_coord):
|
||||
Globals.board_game.current_board_state.players[0].money -= active_tile.cost
|
||||
active_tile.modulate = Color(1, 1, 1, 1)
|
||||
active_tile.coords = current_map_coord
|
||||
tiles[current_map_coord] = active_tile
|
||||
active_tile = null
|
||||
board_state_changed.emit()
|
||||
|
||||
|
||||
func _place_wall_preview() -> void:
|
||||
if is_placing_walls:
|
||||
if prev_map_coord != current_map_coord:
|
||||
var previous_preview = wall_preview_map.get_cell_scene(prev_map_coord)
|
||||
if is_instance_valid(previous_preview):
|
||||
previous_preview.set_wall(Direction.NONE)
|
||||
var wall_preview = wall_preview_map.get_cell_scene(current_map_coord)
|
||||
if is_instance_valid(wall_preview):
|
||||
wall_preview.set_wall(current_wall_direction)
|
||||
|
||||
|
||||
func _clear_wall_preview() -> void:
|
||||
wall_preview_map.get_cell_scene(prev_map_coord).set_wall(Direction.NONE)
|
||||
wall_preview_map.get_cell_scene(current_map_coord).set_wall(Direction.NONE)
|
||||
|
||||
|
||||
func _place_tile_preview() -> void:
|
||||
if active_tile_id != -1:
|
||||
if prev_map_coord != current_map_coord:
|
||||
var prev_preview_tile_id = tile_preview_map.get_cell_alternative_tile(prev_map_coord)
|
||||
if prev_preview_tile_id != -1:
|
||||
tile_preview_map.set_cell(prev_map_coord)
|
||||
tile_preview_map.set_cell(current_map_coord, 0, Vector2i.ZERO, active_tile_id)
|
||||
func place_active_building() -> void:
|
||||
active_building.starting_coord = current_map_coord
|
||||
if active_building is Home:
|
||||
active_building.player = Globals.board_game.current_board_state.current_player
|
||||
for coord in active_building.get_tile_coords():
|
||||
if tiles.has(coord) and !(tiles[coord] is Ground):
|
||||
return
|
||||
if buildings.has(coord):
|
||||
return
|
||||
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
|
||||
active_building.modulate = Color(1, 1, 1, 1)
|
||||
for coord in active_building.get_tile_coords():
|
||||
buildings[coord] = active_building
|
||||
tiles[coord].queue_free()
|
||||
tiles.erase(coord)
|
||||
active_building = null
|
||||
board_state_changed.emit()
|
||||
|
||||
|
||||
func _handle_building_rotation(event: InputEvent) -> void:
|
||||
@ -132,19 +110,67 @@ func _handle_building_rotation(event: InputEvent) -> void:
|
||||
active_building.tile_rotation = get_previous_direction(active_building.tile_rotation)
|
||||
|
||||
|
||||
func _handle_spawn_rotation(event: InputEvent) -> void:
|
||||
if active_tile_id < 7 or active_tile_id > 10:
|
||||
return
|
||||
if event.is_action_pressed("rotate_tile_up"):
|
||||
active_tile_id += 1
|
||||
if active_tile_id > 10:
|
||||
active_tile_id = 7
|
||||
tile_preview_map.set_cell(current_map_coord, 0, Vector2i.ZERO, active_tile_id)
|
||||
elif event.is_action_pressed("rotate_tile_down"):
|
||||
active_tile_id -= 1
|
||||
if active_tile_id < 7:
|
||||
active_tile_id = 10
|
||||
tile_preview_map.set_cell(current_map_coord, 0, Vector2i.ZERO, active_tile_id)
|
||||
func reset() -> void:
|
||||
for child in board_state.get_children():
|
||||
child.queue_free()
|
||||
|
||||
|
||||
func set_board_state(bs: BoardState) -> void:
|
||||
for tile in bs.tiles:
|
||||
board_state.add_child(tile)
|
||||
tiles[tile.coords] = tile
|
||||
tile.position = tile_map.map_to_local(tile.coords)
|
||||
for building in bs.buildings:
|
||||
board_state.add_child(building)
|
||||
for coord in building.get_tile_coords():
|
||||
buildings[coord] = building
|
||||
building.position = tile_map.map_to_local(building.starting_coord)
|
||||
building.rotation_degrees += 90 * building.get_rotation_count()
|
||||
|
||||
|
||||
func initialize() -> void:
|
||||
var max_x: int = 0
|
||||
var max_y: int = 0
|
||||
for i in range(Globals.game.players.size()):
|
||||
var random_spawn = Vector2i(randi_range(0, 9), randi_range(0, 9))
|
||||
for x in range(10):
|
||||
for y in range(10):
|
||||
var coord = Vector2i(x, y)
|
||||
if i == 1:
|
||||
coord.x += 10
|
||||
if i == 2:
|
||||
coord.y += 10
|
||||
if i == 3:
|
||||
coord += Vector2i(10, 10)
|
||||
max_x = coord.x
|
||||
max_y = coord.y
|
||||
if x == random_spawn.x and y == random_spawn.y:
|
||||
var possible_spawns = [UP_SPAWN, RIGHT_SPAWN, DOWN_SPAWN, LEFT_SPAWN]
|
||||
if random_spawn.x == 9:
|
||||
possible_spawns.erase(RIGHT_SPAWN)
|
||||
elif random_spawn.x == 0:
|
||||
possible_spawns.erase(LEFT_SPAWN)
|
||||
if random_spawn.y == 9:
|
||||
possible_spawns.erase(DOWN_SPAWN)
|
||||
elif random_spawn.y == 0:
|
||||
possible_spawns.erase(UP_SPAWN)
|
||||
var spawn: Tile = possible_spawns.pick_random().instantiate()
|
||||
board_state.add_child(spawn)
|
||||
spawn.coords = coord
|
||||
spawn.position = tile_map.map_to_local(coord)
|
||||
tiles[coord] = spawn
|
||||
else:
|
||||
var ground: Tile = GROUND.instantiate()
|
||||
board_state.add_child(ground)
|
||||
ground.coords = coord
|
||||
ground.position = tile_map.map_to_local(coord)
|
||||
tiles[coord] = ground
|
||||
#var extra_spawn_coord := Vector2i(randi_range(1, max_x - 1), randi_range(1, max_y - 1))
|
||||
#var extra_spawn = [UP_SPAWN, RIGHT_SPAWN, DOWN_SPAWN, LEFT_SPAWN].pick_random().instantiate()
|
||||
#board_state.add_child(extra_spawn)
|
||||
#extra_spawn.coords = extra_spawn_coord
|
||||
#extra_spawn.position = tile_map.map_to_local(extra_spawn_coord)
|
||||
#tiles[extra_spawn_coord] = extra_spawn
|
||||
|
||||
|
||||
static func get_next_direction(direction: Direction, count: int = 1) -> Direction:
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[gd_scene format=4 uid="uid://ct6tclctgdrkm"]
|
||||
[gd_scene format=3 uid="uid://ct6tclctgdrkm"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://co23vrpegtru5" path="res://prefabs/board.gd" id="1_p0ybc"]
|
||||
[ext_resource type="Script" uid="uid://t838aqnm6t4" path="res://prefabs/tiles/scene_tile_set.gd" id="2_1v70o"]
|
||||
@ -8,10 +8,8 @@
|
||||
[ext_resource type="PackedScene" uid="uid://7jht5hlggey1" path="res://prefabs/tiles/turns/left_turn.tscn" id="5_o7qh5"]
|
||||
[ext_resource type="PackedScene" uid="uid://ce25rk1nl0pqn" path="res://prefabs/tiles/turns/right_turn.tscn" id="6_3lgej"]
|
||||
[ext_resource type="PackedScene" uid="uid://cisd4grq8kxqn" path="res://prefabs/tiles/turns/up_turn.tscn" id="7_yen83"]
|
||||
[ext_resource type="PackedScene" uid="uid://woxamn2574q" path="res://prefabs/tiles/walls.tscn" id="9_3lgej"]
|
||||
[ext_resource type="PackedScene" uid="uid://d4ltd1geg7s2p" path="res://prefabs/tiles/spawns/down_spawn.tscn" id="9_u033i"]
|
||||
[ext_resource type="PackedScene" uid="uid://noi2ko4hceus" path="res://prefabs/tiles/spawns/left_spawn.tscn" id="10_58ym1"]
|
||||
[ext_resource type="Script" uid="uid://cgu06uwnsod7u" path="res://prefabs/scene_tile_map_layer.gd" id="10_yen83"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1y3s7daosghf" path="res://prefabs/tiles/spawns/right_spawn.tscn" id="11_cxwd1"]
|
||||
|
||||
[sub_resource type="TileSetScenesCollectionSource" id="TileSetScenesCollectionSource_o7qh5"]
|
||||
@ -31,20 +29,6 @@ sources/0 = SubResource("TileSetScenesCollectionSource_o7qh5")
|
||||
script = ExtResource("2_1v70o")
|
||||
metadata/_custom_type_script = "uid://t838aqnm6t4"
|
||||
|
||||
[sub_resource type="TileSetScenesCollectionSource" id="TileSetScenesCollectionSource_wi6i1"]
|
||||
scenes/1/scene = ExtResource("9_3lgej")
|
||||
|
||||
[sub_resource type="TileSet" id="TileSet_6l02p"]
|
||||
tile_size = Vector2i(110, 110)
|
||||
sources/0 = SubResource("TileSetScenesCollectionSource_wi6i1")
|
||||
|
||||
[sub_resource type="TileSetScenesCollectionSource" id="TileSetScenesCollectionSource_yen83"]
|
||||
scenes/1/scene = ExtResource("9_3lgej")
|
||||
|
||||
[sub_resource type="TileSet" id="TileSet_wi6i1"]
|
||||
tile_size = Vector2i(110, 110)
|
||||
sources/0 = SubResource("TileSetScenesCollectionSource_yen83")
|
||||
|
||||
[node name="Board" type="Node2D" unique_id=752933545]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_p0ybc")
|
||||
@ -52,111 +36,7 @@ script = ExtResource("1_p0ybc")
|
||||
[node name="Tiles" type="TileMapLayer" parent="." unique_id=1799727608]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
tile_map_data = PackedByteArray("AAAAAAEAAAAAAAAAAQACAAMAAAAAAAAAAQACAAQAAAAAAAAAAQADAAQAAAAAAAAAAQABAAEAAAAAAAAAAQABAAIAAAAAAAAAAQABAAMAAAAAAAAAAQABAAAAAAAAAAAAAQACAAAAAAAAAAAABwADAAAAAAAAAAAAAQADAAEAAAAAAAAAAQADAAIAAAAAAAAAAQADAAMAAAAAAAAAAQACAAIAAAAAAAAAAQACAAEAAAAAAAAAAQAAAAMAAAAAAAAAAQAAAAQAAAAAAAAAAQABAAQAAAAAAAAAAQAEAAQAAAAAAAAAAQAEAAMAAAAAAAAAAQAEAAIAAAAAAAAAAQAEAAEAAAAAAAAAAQAEAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAQAAAAUAAAAAAAAAAQABAAUAAAAAAAAAAQACAAUAAAAAAAAAAQADAAUAAAAAAAAAAQAEAAUAAAAAAAAAAQAFAAUAAAAAAAAAAQAFAAQAAAAAAAAAAQAFAAMAAAAAAAAAAQAFAAIAAAAAAAAAAQAFAAEAAAAAAAAAAQAFAAAAAAAAAAAAAQAGAAAAAAAAAAAAAQAGAAEAAAAAAAAAAQAGAAIAAAAAAAAAAQAGAAMAAAAAAAAAAQAGAAQAAAAAAAAAAQAGAAUAAAAAAAAAAQA=")
|
||||
tile_set = SubResource("TileSet_87tqm")
|
||||
script = ExtResource("10_yen83")
|
||||
|
||||
[node name="TilesPreview" type="TileMapLayer" parent="." unique_id=34888141]
|
||||
[node name="BoardState" type="Node2D" parent="." unique_id=1744934972]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
modulate = Color(1, 1, 1, 0.5)
|
||||
tile_set = SubResource("TileSet_87tqm")
|
||||
script = ExtResource("10_yen83")
|
||||
|
||||
[node name="Walls" type="TileMapLayer" parent="." unique_id=2075701520]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
tile_map_data = PackedByteArray("AAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAQAAAAMAAAAAAAAAAQAAAAQAAAAAAAAAAQABAAAAAAAAAAAAAQABAAEAAAAAAAAAAQABAAIAAAAAAAAAAQABAAMAAAAAAAAAAQABAAQAAAAAAAAAAQACAAAAAAAAAAAAAQACAAEAAAAAAAAAAQACAAIAAAAAAAAAAQACAAMAAAAAAAAAAQACAAQAAAAAAAAAAQADAAAAAAAAAAAAAQADAAEAAAAAAAAAAQADAAIAAAAAAAAAAQADAAMAAAAAAAAAAQADAAQAAAAAAAAAAQAEAAAAAAAAAAAAAQAEAAEAAAAAAAAAAQAEAAIAAAAAAAAAAQAEAAMAAAAAAAAAAQAEAAQAAAAAAAAAAQAAAAUAAAAAAAAAAQABAAUAAAAAAAAAAQACAAUAAAAAAAAAAQADAAUAAAAAAAAAAQAEAAUAAAAAAAAAAQAFAAUAAAAAAAAAAQAGAAUAAAAAAAAAAQAGAAQAAAAAAAAAAQAGAAMAAAAAAAAAAQAGAAIAAAAAAAAAAQAGAAEAAAAAAAAAAQAGAAAAAAAAAAAAAQAFAAAAAAAAAAAAAQAFAAEAAAAAAAAAAQAFAAIAAAAAAAAAAQAFAAMAAAAAAAAAAQAFAAQAAAAAAAAAAQA=")
|
||||
tile_set = SubResource("TileSet_6l02p")
|
||||
script = ExtResource("10_yen83")
|
||||
|
||||
[node name="WallPreviews" type="TileMapLayer" parent="." unique_id=1643053787]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
modulate = Color(1, 1, 1, 0.5)
|
||||
tile_map_data = PackedByteArray("AAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAQAAAAMAAAAAAAAAAQAAAAQAAAAAAAAAAQABAAAAAAAAAAAAAQABAAEAAAAAAAAAAQABAAIAAAAAAAAAAQABAAMAAAAAAAAAAQABAAQAAAAAAAAAAQACAAAAAAAAAAAAAQACAAEAAAAAAAAAAQACAAIAAAAAAAAAAQACAAMAAAAAAAAAAQACAAQAAAAAAAAAAQADAAAAAAAAAAAAAQADAAEAAAAAAAAAAQADAAIAAAAAAAAAAQADAAMAAAAAAAAAAQADAAQAAAAAAAAAAQAEAAAAAAAAAAAAAQAEAAEAAAAAAAAAAQAEAAIAAAAAAAAAAQAEAAMAAAAAAAAAAQAEAAQAAAAAAAAAAQAAAAUAAAAAAAAAAQABAAUAAAAAAAAAAQACAAUAAAAAAAAAAQAGAAAAAAAAAAAAAQAGAAEAAAAAAAAAAQAGAAIAAAAAAAAAAQAGAAMAAAAAAAAAAQAGAAQAAAAAAAAAAQAGAAUAAAAAAAAAAQADAAUAAAAAAAAAAQAEAAUAAAAAAAAAAQAFAAUAAAAAAAAAAQAFAAAAAAAAAAAAAQAFAAEAAAAAAAAAAQAFAAIAAAAAAAAAAQAFAAMAAAAAAAAAAQAFAAQAAAAAAAAAAQA=")
|
||||
tile_set = SubResource("TileSet_wi6i1")
|
||||
script = ExtResource("10_yen83")
|
||||
|
||||
[connection signal="mouse_entered" from="Tiles/Ground" to="Tiles/Ground" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/Ground" to="Tiles/Ground" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521340" to="Tiles/@TextureRect@521340" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521340" to="Tiles/@TextureRect@521340" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521341" to="Tiles/@TextureRect@521341" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521341" to="Tiles/@TextureRect@521341" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521342" to="Tiles/@TextureRect@521342" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521342" to="Tiles/@TextureRect@521342" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521343" to="Tiles/@TextureRect@521343" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521343" to="Tiles/@TextureRect@521343" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521344" to="Tiles/@TextureRect@521344" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521344" to="Tiles/@TextureRect@521344" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521345" to="Tiles/@TextureRect@521345" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521345" to="Tiles/@TextureRect@521345" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521346" to="Tiles/@TextureRect@521346" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521346" to="Tiles/@TextureRect@521346" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521347" to="Tiles/@TextureRect@521347" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521347" to="Tiles/@TextureRect@521347" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521348" to="Tiles/@TextureRect@521348" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521348" to="Tiles/@TextureRect@521348" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521349" to="Tiles/@TextureRect@521349" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521349" to="Tiles/@TextureRect@521349" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521350" to="Tiles/@TextureRect@521350" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521350" to="Tiles/@TextureRect@521350" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521351" to="Tiles/@TextureRect@521351" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521351" to="Tiles/@TextureRect@521351" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521352" to="Tiles/@TextureRect@521352" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521352" to="Tiles/@TextureRect@521352" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521353" to="Tiles/@TextureRect@521353" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521353" to="Tiles/@TextureRect@521353" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521354" to="Tiles/@TextureRect@521354" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521354" to="Tiles/@TextureRect@521354" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521355" to="Tiles/@TextureRect@521355" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521355" to="Tiles/@TextureRect@521355" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521356" to="Tiles/@TextureRect@521356" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521356" to="Tiles/@TextureRect@521356" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521357" to="Tiles/@TextureRect@521357" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521357" to="Tiles/@TextureRect@521357" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521358" to="Tiles/@TextureRect@521358" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521358" to="Tiles/@TextureRect@521358" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521359" to="Tiles/@TextureRect@521359" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521359" to="Tiles/@TextureRect@521359" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521360" to="Tiles/@TextureRect@521360" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521360" to="Tiles/@TextureRect@521360" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521361" to="Tiles/@TextureRect@521361" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521361" to="Tiles/@TextureRect@521361" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521362" to="Tiles/@TextureRect@521362" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521362" to="Tiles/@TextureRect@521362" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521363" to="Tiles/@TextureRect@521363" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521363" to="Tiles/@TextureRect@521363" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521364" to="Tiles/@TextureRect@521364" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521364" to="Tiles/@TextureRect@521364" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521365" to="Tiles/@TextureRect@521365" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521365" to="Tiles/@TextureRect@521365" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521366" to="Tiles/@TextureRect@521366" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521366" to="Tiles/@TextureRect@521366" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521367" to="Tiles/@TextureRect@521367" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521367" to="Tiles/@TextureRect@521367" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521368" to="Tiles/@TextureRect@521368" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521368" to="Tiles/@TextureRect@521368" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521369" to="Tiles/@TextureRect@521369" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521369" to="Tiles/@TextureRect@521369" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521370" to="Tiles/@TextureRect@521370" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521370" to="Tiles/@TextureRect@521370" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521371" to="Tiles/@TextureRect@521371" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521371" to="Tiles/@TextureRect@521371" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521372" to="Tiles/@TextureRect@521372" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521372" to="Tiles/@TextureRect@521372" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521373" to="Tiles/@TextureRect@521373" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521373" to="Tiles/@TextureRect@521373" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521374" to="Tiles/@TextureRect@521374" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521374" to="Tiles/@TextureRect@521374" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521375" to="Tiles/@TextureRect@521375" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521375" to="Tiles/@TextureRect@521375" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521376" to="Tiles/@TextureRect@521376" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521376" to="Tiles/@TextureRect@521376" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521377" to="Tiles/@TextureRect@521377" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521377" to="Tiles/@TextureRect@521377" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521378" to="Tiles/@TextureRect@521378" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521378" to="Tiles/@TextureRect@521378" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@521379" to="Tiles/@TextureRect@521379" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@521379" to="Tiles/@TextureRect@521379" method="handle_ground_mouse_exited"]
|
||||
|
||||
274
prefabs/board_old.gd
Normal file
274
prefabs/board_old.gd
Normal file
@ -0,0 +1,274 @@
|
||||
class_name BoardOLD extends Node2D
|
||||
|
||||
enum Direction { NONE, UP, DOWN, LEFT, RIGHT }
|
||||
|
||||
var buildings: Dictionary[Vector2i, Building] = {}
|
||||
var active_building_id: int = -1
|
||||
var active_building: Building
|
||||
var active_tile_id: int = -1
|
||||
var current_map_coord: Vector2i
|
||||
var prev_map_coord: Vector2i
|
||||
var is_placing_walls: bool = false:
|
||||
set(value):
|
||||
is_placing_walls = value
|
||||
if !is_placing_walls:
|
||||
_clear_wall_preview()
|
||||
var current_wall_direction: Direction = Direction.DOWN
|
||||
var real_wall_coords: Array[Vector2i] = []
|
||||
var is_controlling_camera: bool = false
|
||||
|
||||
@onready var tile_map: SceneTileMapLayer = %Tiles
|
||||
@onready var tile_preview_map: TileMapLayer = %TilesPreview
|
||||
@onready var wall_map: SceneTileMapLayer = %Walls
|
||||
@onready var wall_preview_map: SceneTileMapLayer = %WallPreviews
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("camera_engage"):
|
||||
is_controlling_camera = true
|
||||
return
|
||||
if event.is_action_released("camera_engage"):
|
||||
is_controlling_camera = false
|
||||
if is_controlling_camera:
|
||||
return
|
||||
if Globals.board_game.current_player.id != Globals.game.this_player.id:
|
||||
return
|
||||
if event is InputEventMouseMotion:
|
||||
current_map_coord = tile_map.local_to_map(tile_map.get_local_mouse_position())
|
||||
_place_wall_preview()
|
||||
_place_tile_preview()
|
||||
if active_building != null:
|
||||
active_building.position = tile_map.map_to_local(current_map_coord)
|
||||
prev_map_coord = current_map_coord
|
||||
if event.is_action_pressed("select"):
|
||||
if is_placing_walls:
|
||||
_place_wall(current_map_coord, current_wall_direction)
|
||||
match current_wall_direction:
|
||||
Direction.UP:
|
||||
_place_wall(current_map_coord + Vector2i.UP, Direction.DOWN)
|
||||
Direction.DOWN:
|
||||
_place_wall(current_map_coord + Vector2i.DOWN, Direction.UP)
|
||||
Direction.LEFT:
|
||||
_place_wall(current_map_coord + Vector2i.LEFT, Direction.RIGHT)
|
||||
Direction.RIGHT:
|
||||
_place_wall(current_map_coord + Vector2i.RIGHT, Direction.LEFT)
|
||||
elif active_tile_id != -1:
|
||||
place_active_tile.rpc(current_map_coord, active_tile_id)
|
||||
active_tile_id = -1
|
||||
elif active_building != null:
|
||||
place_active_building.rpc(current_map_coord, active_building_id)
|
||||
active_building = null
|
||||
if event.is_action_pressed("rotate_wall_up") and is_placing_walls:
|
||||
current_wall_direction = get_next_direction(current_wall_direction)
|
||||
var wall_preview = wall_preview_map.get_cell_scene(current_map_coord)
|
||||
if is_instance_valid(wall_preview):
|
||||
wall_preview.set_wall(current_wall_direction)
|
||||
elif event.is_action_pressed("rotate_wall_down") and is_placing_walls:
|
||||
current_wall_direction = get_previous_direction(current_wall_direction)
|
||||
var wall_preview = wall_preview_map.get_cell_scene(current_map_coord)
|
||||
if is_instance_valid(wall_preview):
|
||||
wall_preview.set_wall(current_wall_direction)
|
||||
_handle_building_rotation(event)
|
||||
_handle_spawn_rotation(event)
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func place_active_building(coords: Vector2i, building_id: int) -> void:
|
||||
var building = Globals.board_game.building_id_array[building_id].duplicate()
|
||||
add_child(building)
|
||||
if building is Home:
|
||||
building.player = Globals.board_game.current_player
|
||||
building.starting_coord = coords
|
||||
for coord in building.get_tile_coords():
|
||||
buildings[coord] = building
|
||||
building.position = tile_map.map_to_local(coords)
|
||||
building.modulate = Color(1, 1, 1, 1)
|
||||
building.is_placing = false
|
||||
if active_building != null:
|
||||
Globals.game.add_player_money(Globals.board_game.current_player.id, -active_building.cost)
|
||||
if building is Home:
|
||||
print("here")
|
||||
Globals.board_game.place_home()
|
||||
if is_instance_valid(active_building):
|
||||
active_building.queue_free()
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func place_active_tile(coords: Vector2i, tile_id: int) -> void:
|
||||
tile_preview_map.set_cell(coords)
|
||||
tile_map.set_cell(coords)
|
||||
await tile_map.child_exiting_tree
|
||||
tile_map.set_cell(coords, 0, Vector2i.ZERO, tile_id)
|
||||
if tile_id >= 7 and tile_id <= 10:
|
||||
Globals.board_game.handle_spawn_placed()
|
||||
|
||||
|
||||
func set_active_tile(tile: Tile) -> void:
|
||||
active_tile_id = tile_map.tile_set.get_tile_id(tile)
|
||||
if active_tile_id != -1:
|
||||
tile_preview_map.set_cell(current_map_coord, 0, Vector2i.ZERO, active_tile_id)
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func set_active_building(building: Building, player: Player = null) -> void:
|
||||
active_building_id = Globals.board_game.get_id_for_building(building)
|
||||
active_building = building
|
||||
add_child(active_building)
|
||||
active_building.is_placing = true
|
||||
active_building.modulate = Color(1, 1, 1, 0.5)
|
||||
if building is Home:
|
||||
active_building.player = player
|
||||
|
||||
|
||||
func _place_wall(wall_coord: Vector2i, wall_direction: Direction) -> void:
|
||||
var current_wall = wall_map.get_cell_scene(wall_coord)
|
||||
if is_instance_valid(current_wall):
|
||||
current_wall.add_wall(wall_direction)
|
||||
else:
|
||||
var wall_preview = wall_map.get_cell_scene(wall_coord)
|
||||
if is_instance_valid(wall_preview):
|
||||
wall_preview.set_wall(wall_direction)
|
||||
|
||||
|
||||
func _place_wall_preview() -> void:
|
||||
if is_placing_walls:
|
||||
if prev_map_coord != current_map_coord:
|
||||
var previous_preview = wall_preview_map.get_cell_scene(prev_map_coord)
|
||||
if is_instance_valid(previous_preview):
|
||||
previous_preview.set_wall(Direction.NONE)
|
||||
var wall_preview = wall_preview_map.get_cell_scene(current_map_coord)
|
||||
if is_instance_valid(wall_preview):
|
||||
wall_preview.set_wall(current_wall_direction)
|
||||
|
||||
|
||||
func _clear_wall_preview() -> void:
|
||||
wall_preview_map.get_cell_scene(prev_map_coord).set_wall(Direction.NONE)
|
||||
wall_preview_map.get_cell_scene(current_map_coord).set_wall(Direction.NONE)
|
||||
|
||||
|
||||
func _place_tile_preview() -> void:
|
||||
if active_tile_id != -1:
|
||||
if prev_map_coord != current_map_coord:
|
||||
var prev_preview_tile_id = tile_preview_map.get_cell_alternative_tile(prev_map_coord)
|
||||
if prev_preview_tile_id != -1:
|
||||
tile_preview_map.set_cell(prev_map_coord)
|
||||
tile_preview_map.set_cell(current_map_coord, 0, Vector2i.ZERO, active_tile_id)
|
||||
|
||||
|
||||
func _handle_building_rotation(event: InputEvent) -> void:
|
||||
if active_building == null:
|
||||
return
|
||||
if event.is_action_pressed("rotate_tile_up"):
|
||||
active_building.rotation_degrees += 90
|
||||
active_building.tile_rotation = get_next_direction(active_building.tile_rotation)
|
||||
elif event.is_action_pressed("rotate_tile_down"):
|
||||
active_building.rotation_degrees -= 90
|
||||
active_building.tile_rotation = get_previous_direction(active_building.tile_rotation)
|
||||
|
||||
|
||||
func _handle_spawn_rotation(event: InputEvent) -> void:
|
||||
if active_tile_id < 7 or active_tile_id > 10:
|
||||
return
|
||||
if event.is_action_pressed("rotate_tile_up"):
|
||||
active_tile_id += 1
|
||||
if active_tile_id > 10:
|
||||
active_tile_id = 7
|
||||
tile_preview_map.set_cell(current_map_coord, 0, Vector2i.ZERO, active_tile_id)
|
||||
elif event.is_action_pressed("rotate_tile_down"):
|
||||
active_tile_id -= 1
|
||||
if active_tile_id < 7:
|
||||
active_tile_id = 10
|
||||
tile_preview_map.set_cell(current_map_coord, 0, Vector2i.ZERO, active_tile_id)
|
||||
|
||||
|
||||
func initialize() -> void:
|
||||
for i in range(Globals.game.players.size()):
|
||||
var random_spawn = Vector2i(randi_range(0, 9), randi_range(0, 9))
|
||||
for x in range(10):
|
||||
for y in range(10):
|
||||
var coord = Vector2i(x, y)
|
||||
if i == 1:
|
||||
coord.x += 10
|
||||
if i == 2:
|
||||
coord.y += 10
|
||||
if i == 3:
|
||||
coord += Vector2i(10, 10)
|
||||
tile_map.set_cell(coord)
|
||||
if x == random_spawn.x and y == random_spawn.y:
|
||||
var possible_spawns = [7, 8, 9, 10]
|
||||
if random_spawn.x == 9:
|
||||
possible_spawns.erase(9)
|
||||
elif random_spawn.x == 0:
|
||||
possible_spawns.erase(8)
|
||||
if random_spawn.y == 9:
|
||||
possible_spawns.erase(7)
|
||||
elif random_spawn.y == 0:
|
||||
possible_spawns.erase(10)
|
||||
tile_map.set_cell(coord, 0, Vector2i.ZERO, possible_spawns.pick_random())
|
||||
else:
|
||||
tile_map.set_cell(coord, 0, Vector2i.ZERO, 1)
|
||||
var extra_spawn_coord := Vector2i(
|
||||
randi_range(1, tile_map.get_used_rect().size.x - 1),
|
||||
randi_range(1, tile_map.get_used_rect().size.y - 1)
|
||||
)
|
||||
tile_map.set_cell(extra_spawn_coord, 0, Vector2i.ZERO, randi_range(7, 10))
|
||||
|
||||
|
||||
static func get_next_direction(direction: Direction, count: int = 1) -> Direction:
|
||||
var result := direction
|
||||
if count == 0:
|
||||
return result
|
||||
match direction:
|
||||
Direction.UP:
|
||||
result = Direction.RIGHT
|
||||
Direction.RIGHT:
|
||||
result = Direction.DOWN
|
||||
Direction.DOWN:
|
||||
result = Direction.LEFT
|
||||
Direction.LEFT:
|
||||
result = Direction.UP
|
||||
if count == 1:
|
||||
return result
|
||||
return get_next_direction(result, count - 1)
|
||||
|
||||
|
||||
static func get_previous_direction(direction: Direction) -> Direction:
|
||||
match direction:
|
||||
Direction.UP:
|
||||
return Direction.LEFT
|
||||
Direction.RIGHT:
|
||||
return Direction.UP
|
||||
Direction.DOWN:
|
||||
return Direction.RIGHT
|
||||
Direction.LEFT:
|
||||
return Direction.DOWN
|
||||
_:
|
||||
return direction
|
||||
|
||||
|
||||
static func get_direction_vector(direction: Direction) -> Vector2i:
|
||||
match direction:
|
||||
Direction.UP:
|
||||
return Vector2i.UP
|
||||
Direction.RIGHT:
|
||||
return Vector2i.RIGHT
|
||||
Direction.DOWN:
|
||||
return Vector2i.DOWN
|
||||
Direction.LEFT:
|
||||
return Vector2i.LEFT
|
||||
_:
|
||||
return Vector2i.ZERO
|
||||
|
||||
#func generate() -> void:
|
||||
#for child in get_children():
|
||||
#child.queue_free()
|
||||
#for x in range(width):
|
||||
#for y in range(height):
|
||||
#var tile: Control
|
||||
#if x == 1 and y == 1:
|
||||
#tile = spawn_scene.instantiate()
|
||||
#else:
|
||||
#tile = ground_scene.instantiate()
|
||||
#add_child(tile)
|
||||
#tile.position = get_coordinate(x, y)
|
||||
#tile.owner = self
|
||||
1
prefabs/board_old.gd.uid
Normal file
1
prefabs/board_old.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://cj1lvlyx2wc10
|
||||
161
prefabs/board_old.tscn
Normal file
161
prefabs/board_old.tscn
Normal file
@ -0,0 +1,161 @@
|
||||
[gd_scene format=4 uid="uid://ccrv2sslslv7e"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cj1lvlyx2wc10" path="res://prefabs/board_old.gd" id="1_s1yg0"]
|
||||
[ext_resource type="Script" uid="uid://t838aqnm6t4" path="res://prefabs/tiles/scene_tile_set.gd" id="2_ephv2"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5y5ksmwhevd" path="res://prefabs/tiles/ground.tscn" id="3_6cxcw"]
|
||||
[ext_resource type="PackedScene" uid="uid://6ywvgci44ttv" path="res://prefabs/tiles/spawns/up_spawn.tscn" id="4_hjct4"]
|
||||
[ext_resource type="PackedScene" uid="uid://2qudi2d82y73" path="res://prefabs/tiles/turns/down_turn.tscn" id="5_353j6"]
|
||||
[ext_resource type="PackedScene" uid="uid://7jht5hlggey1" path="res://prefabs/tiles/turns/left_turn.tscn" id="6_y0m14"]
|
||||
[ext_resource type="PackedScene" uid="uid://ce25rk1nl0pqn" path="res://prefabs/tiles/turns/right_turn.tscn" id="7_p8oxp"]
|
||||
[ext_resource type="PackedScene" uid="uid://cisd4grq8kxqn" path="res://prefabs/tiles/turns/up_turn.tscn" id="8_wac32"]
|
||||
[ext_resource type="PackedScene" uid="uid://d4ltd1geg7s2p" path="res://prefabs/tiles/spawns/down_spawn.tscn" id="9_a4q0p"]
|
||||
[ext_resource type="PackedScene" uid="uid://noi2ko4hceus" path="res://prefabs/tiles/spawns/left_spawn.tscn" id="10_qfwpr"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1y3s7daosghf" path="res://prefabs/tiles/spawns/right_spawn.tscn" id="11_w7tfe"]
|
||||
[ext_resource type="Script" uid="uid://cgu06uwnsod7u" path="res://prefabs/scene_tile_map_layer.gd" id="12_38qs2"]
|
||||
[ext_resource type="PackedScene" uid="uid://woxamn2574q" path="res://prefabs/tiles/walls.tscn" id="13_en8er"]
|
||||
|
||||
[sub_resource type="TileSetScenesCollectionSource" id="TileSetScenesCollectionSource_o7qh5"]
|
||||
scenes/1/scene = ExtResource("3_6cxcw")
|
||||
scenes/3/scene = ExtResource("5_353j6")
|
||||
scenes/4/scene = ExtResource("6_y0m14")
|
||||
scenes/5/scene = ExtResource("7_p8oxp")
|
||||
scenes/6/scene = ExtResource("8_wac32")
|
||||
scenes/7/scene = ExtResource("9_a4q0p")
|
||||
scenes/8/scene = ExtResource("10_qfwpr")
|
||||
scenes/9/scene = ExtResource("11_w7tfe")
|
||||
scenes/10/scene = ExtResource("4_hjct4")
|
||||
|
||||
[sub_resource type="TileSet" id="TileSet_87tqm"]
|
||||
tile_size = Vector2i(110, 110)
|
||||
sources/0 = SubResource("TileSetScenesCollectionSource_o7qh5")
|
||||
script = ExtResource("2_ephv2")
|
||||
metadata/_custom_type_script = "uid://t838aqnm6t4"
|
||||
|
||||
[sub_resource type="TileSetScenesCollectionSource" id="TileSetScenesCollectionSource_wi6i1"]
|
||||
scenes/1/scene = ExtResource("13_en8er")
|
||||
|
||||
[sub_resource type="TileSet" id="TileSet_6l02p"]
|
||||
tile_size = Vector2i(110, 110)
|
||||
sources/0 = SubResource("TileSetScenesCollectionSource_wi6i1")
|
||||
|
||||
[sub_resource type="TileSetScenesCollectionSource" id="TileSetScenesCollectionSource_yen83"]
|
||||
scenes/1/scene = ExtResource("13_en8er")
|
||||
|
||||
[sub_resource type="TileSet" id="TileSet_wi6i1"]
|
||||
tile_size = Vector2i(110, 110)
|
||||
sources/0 = SubResource("TileSetScenesCollectionSource_yen83")
|
||||
|
||||
[node name="Board" type="Node2D" unique_id=752933545]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_s1yg0")
|
||||
|
||||
[node name="Tiles" type="TileMapLayer" parent="." unique_id=1799727608]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
tile_map_data = PackedByteArray("AAAAAAEAAAAAAAAAAQACAAMAAAAAAAAAAQACAAQAAAAAAAAAAQADAAQAAAAAAAAAAQABAAEAAAAAAAAAAQABAAIAAAAAAAAAAQABAAMAAAAAAAAAAQABAAAAAAAAAAAAAQACAAAAAAAAAAAABwADAAAAAAAAAAAAAQADAAEAAAAAAAAAAQADAAIAAAAAAAAAAQADAAMAAAAAAAAAAQACAAIAAAAAAAAAAQACAAEAAAAAAAAAAQAAAAMAAAAAAAAAAQAAAAQAAAAAAAAAAQABAAQAAAAAAAAAAQAEAAQAAAAAAAAAAQAEAAMAAAAAAAAAAQAEAAIAAAAAAAAAAQAEAAEAAAAAAAAAAQAEAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAQAAAAUAAAAAAAAAAQABAAUAAAAAAAAAAQACAAUAAAAAAAAAAQADAAUAAAAAAAAAAQAEAAUAAAAAAAAAAQAFAAUAAAAAAAAAAQAFAAQAAAAAAAAAAQAFAAMAAAAAAAAAAQAFAAIAAAAAAAAAAQAFAAEAAAAAAAAAAQAFAAAAAAAAAAAAAQAGAAAAAAAAAAAAAQAGAAEAAAAAAAAAAQAGAAIAAAAAAAAAAQAGAAMAAAAAAAAAAQAGAAQAAAAAAAAAAQAGAAUAAAAAAAAAAQA=")
|
||||
tile_set = SubResource("TileSet_87tqm")
|
||||
script = ExtResource("12_38qs2")
|
||||
|
||||
[node name="TilesPreview" type="TileMapLayer" parent="." unique_id=34888141]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
modulate = Color(1, 1, 1, 0.5)
|
||||
tile_set = SubResource("TileSet_87tqm")
|
||||
|
||||
[node name="Walls" type="TileMapLayer" parent="." unique_id=2075701520]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
tile_map_data = PackedByteArray("AAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAQAAAAMAAAAAAAAAAQAAAAQAAAAAAAAAAQABAAAAAAAAAAAAAQABAAEAAAAAAAAAAQABAAIAAAAAAAAAAQABAAMAAAAAAAAAAQABAAQAAAAAAAAAAQACAAAAAAAAAAAAAQACAAEAAAAAAAAAAQACAAIAAAAAAAAAAQACAAMAAAAAAAAAAQACAAQAAAAAAAAAAQADAAAAAAAAAAAAAQADAAEAAAAAAAAAAQADAAIAAAAAAAAAAQADAAMAAAAAAAAAAQADAAQAAAAAAAAAAQAEAAAAAAAAAAAAAQAEAAEAAAAAAAAAAQAEAAIAAAAAAAAAAQAEAAMAAAAAAAAAAQAEAAQAAAAAAAAAAQAAAAUAAAAAAAAAAQABAAUAAAAAAAAAAQACAAUAAAAAAAAAAQADAAUAAAAAAAAAAQAEAAUAAAAAAAAAAQAFAAUAAAAAAAAAAQAGAAUAAAAAAAAAAQAGAAQAAAAAAAAAAQAGAAMAAAAAAAAAAQAGAAIAAAAAAAAAAQAGAAEAAAAAAAAAAQAGAAAAAAAAAAAAAQAFAAAAAAAAAAAAAQAFAAEAAAAAAAAAAQAFAAIAAAAAAAAAAQAFAAMAAAAAAAAAAQAFAAQAAAAAAAAAAQA=")
|
||||
tile_set = SubResource("TileSet_6l02p")
|
||||
script = ExtResource("12_38qs2")
|
||||
|
||||
[node name="WallPreviews" type="TileMapLayer" parent="." unique_id=1643053787]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
modulate = Color(1, 1, 1, 0.5)
|
||||
tile_map_data = PackedByteArray("AAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAQAAAAMAAAAAAAAAAQAAAAQAAAAAAAAAAQABAAAAAAAAAAAAAQABAAEAAAAAAAAAAQABAAIAAAAAAAAAAQABAAMAAAAAAAAAAQABAAQAAAAAAAAAAQACAAAAAAAAAAAAAQACAAEAAAAAAAAAAQACAAIAAAAAAAAAAQACAAMAAAAAAAAAAQACAAQAAAAAAAAAAQADAAAAAAAAAAAAAQADAAEAAAAAAAAAAQADAAIAAAAAAAAAAQADAAMAAAAAAAAAAQADAAQAAAAAAAAAAQAEAAAAAAAAAAAAAQAEAAEAAAAAAAAAAQAEAAIAAAAAAAAAAQAEAAMAAAAAAAAAAQAEAAQAAAAAAAAAAQAAAAUAAAAAAAAAAQABAAUAAAAAAAAAAQACAAUAAAAAAAAAAQAGAAAAAAAAAAAAAQAGAAEAAAAAAAAAAQAGAAIAAAAAAAAAAQAGAAMAAAAAAAAAAQAGAAQAAAAAAAAAAQAGAAUAAAAAAAAAAQADAAUAAAAAAAAAAQAEAAUAAAAAAAAAAQAFAAUAAAAAAAAAAQAFAAAAAAAAAAAAAQAFAAEAAAAAAAAAAQAFAAIAAAAAAAAAAQAFAAMAAAAAAAAAAQAFAAQAAAAAAAAAAQA=")
|
||||
tile_set = SubResource("TileSet_wi6i1")
|
||||
script = ExtResource("12_38qs2")
|
||||
|
||||
[connection signal="mouse_entered" from="Tiles/Ground" to="Tiles/Ground" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/Ground" to="Tiles/Ground" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136203" to="Tiles/@TextureRect@136203" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136203" to="Tiles/@TextureRect@136203" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136204" to="Tiles/@TextureRect@136204" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136204" to="Tiles/@TextureRect@136204" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136205" to="Tiles/@TextureRect@136205" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136205" to="Tiles/@TextureRect@136205" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136206" to="Tiles/@TextureRect@136206" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136206" to="Tiles/@TextureRect@136206" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136207" to="Tiles/@TextureRect@136207" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136207" to="Tiles/@TextureRect@136207" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136208" to="Tiles/@TextureRect@136208" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136208" to="Tiles/@TextureRect@136208" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136209" to="Tiles/@TextureRect@136209" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136209" to="Tiles/@TextureRect@136209" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136210" to="Tiles/@TextureRect@136210" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136210" to="Tiles/@TextureRect@136210" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136211" to="Tiles/@TextureRect@136211" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136211" to="Tiles/@TextureRect@136211" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136212" to="Tiles/@TextureRect@136212" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136212" to="Tiles/@TextureRect@136212" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136213" to="Tiles/@TextureRect@136213" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136213" to="Tiles/@TextureRect@136213" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136214" to="Tiles/@TextureRect@136214" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136214" to="Tiles/@TextureRect@136214" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136215" to="Tiles/@TextureRect@136215" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136215" to="Tiles/@TextureRect@136215" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136216" to="Tiles/@TextureRect@136216" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136216" to="Tiles/@TextureRect@136216" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136217" to="Tiles/@TextureRect@136217" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136217" to="Tiles/@TextureRect@136217" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136218" to="Tiles/@TextureRect@136218" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136218" to="Tiles/@TextureRect@136218" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136219" to="Tiles/@TextureRect@136219" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136219" to="Tiles/@TextureRect@136219" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136220" to="Tiles/@TextureRect@136220" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136220" to="Tiles/@TextureRect@136220" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136221" to="Tiles/@TextureRect@136221" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136221" to="Tiles/@TextureRect@136221" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136222" to="Tiles/@TextureRect@136222" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136222" to="Tiles/@TextureRect@136222" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136223" to="Tiles/@TextureRect@136223" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136223" to="Tiles/@TextureRect@136223" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136224" to="Tiles/@TextureRect@136224" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136224" to="Tiles/@TextureRect@136224" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136225" to="Tiles/@TextureRect@136225" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136225" to="Tiles/@TextureRect@136225" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136226" to="Tiles/@TextureRect@136226" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136226" to="Tiles/@TextureRect@136226" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136227" to="Tiles/@TextureRect@136227" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136227" to="Tiles/@TextureRect@136227" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136228" to="Tiles/@TextureRect@136228" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136228" to="Tiles/@TextureRect@136228" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136229" to="Tiles/@TextureRect@136229" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136229" to="Tiles/@TextureRect@136229" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136230" to="Tiles/@TextureRect@136230" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136230" to="Tiles/@TextureRect@136230" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136231" to="Tiles/@TextureRect@136231" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136231" to="Tiles/@TextureRect@136231" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136232" to="Tiles/@TextureRect@136232" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136232" to="Tiles/@TextureRect@136232" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136233" to="Tiles/@TextureRect@136233" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136233" to="Tiles/@TextureRect@136233" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136234" to="Tiles/@TextureRect@136234" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136234" to="Tiles/@TextureRect@136234" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136235" to="Tiles/@TextureRect@136235" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136235" to="Tiles/@TextureRect@136235" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136236" to="Tiles/@TextureRect@136236" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136236" to="Tiles/@TextureRect@136236" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136237" to="Tiles/@TextureRect@136237" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136237" to="Tiles/@TextureRect@136237" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136238" to="Tiles/@TextureRect@136238" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136238" to="Tiles/@TextureRect@136238" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136239" to="Tiles/@TextureRect@136239" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136239" to="Tiles/@TextureRect@136239" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136240" to="Tiles/@TextureRect@136240" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136240" to="Tiles/@TextureRect@136240" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136241" to="Tiles/@TextureRect@136241" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136241" to="Tiles/@TextureRect@136241" method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Tiles/@TextureRect@136242" to="Tiles/@TextureRect@136242" method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Tiles/@TextureRect@136242" to="Tiles/@TextureRect@136242" method="handle_ground_mouse_exited"]
|
||||
@ -23,7 +23,6 @@ var paused: bool:
|
||||
animated_sprite.play()
|
||||
|
||||
var speed: float = 50
|
||||
var board: Board
|
||||
var current_tile_coords: Vector2i
|
||||
var direction_queue: Array[Board.Direction] = []
|
||||
var money: int = 0
|
||||
@ -41,7 +40,7 @@ var _statuses: Array[Status] = []
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Globals.game.citizen_count += 1
|
||||
Globals.board_game.citizen_count += 1
|
||||
|
||||
|
||||
func pause() -> void:
|
||||
@ -120,14 +119,10 @@ func _physics_process(delta: float) -> void:
|
||||
#position = position.move_toward(position + Vector2.LEFT, speed * delta)
|
||||
motion = Vector2.LEFT * speed * delta
|
||||
move_and_collide(motion)
|
||||
var tile_map_coords := board.tile_map.local_to_map(animated_sprite.global_position)
|
||||
if board.tile_map.get_cell_alternative_tile(tile_map_coords) == -1:
|
||||
if !board.buildings.has(tile_map_coords):
|
||||
direction = Board.Direction.NONE
|
||||
|
||||
|
||||
func idle() -> void:
|
||||
Globals.game.citizen_count -= 1
|
||||
Globals.board_game.citizen_count -= 1
|
||||
animated_sprite.play("idle")
|
||||
|
||||
|
||||
@ -145,11 +140,11 @@ func walk() -> void:
|
||||
animated_sprite.play("walk_right")
|
||||
|
||||
|
||||
func check_for_wall() -> void:
|
||||
var tile_walls = board.wall_map.get_cell_scene(current_tile_coords).walls
|
||||
if tile_walls.has(direction):
|
||||
direction = Board.get_next_direction(direction)
|
||||
check_for_wall()
|
||||
#func check_for_wall() -> void:
|
||||
#var tile_walls = board.wall_map.get_cell_scene(current_tile_coords).walls
|
||||
#if tile_walls.has(direction):
|
||||
#direction = Board.get_next_direction(direction)
|
||||
#check_for_wall()
|
||||
|
||||
|
||||
func check_for_turn(tile: Tile) -> void:
|
||||
@ -161,32 +156,45 @@ func check_for_turn(tile: Tile) -> void:
|
||||
|
||||
|
||||
func check_for_building() -> void:
|
||||
if board.buildings.has(current_tile_coords + Board.get_direction_vector(direction)):
|
||||
var building = board.buildings[current_tile_coords + Board.get_direction_vector(direction)]
|
||||
if Globals.board_game.board.buildings.has(
|
||||
current_tile_coords + Board.get_direction_vector(direction)
|
||||
):
|
||||
var building = Globals.board_game.board.buildings[
|
||||
current_tile_coords + Board.get_direction_vector(direction)
|
||||
]
|
||||
if !building.can_citizen_enter(current_tile_coords, direction):
|
||||
direction = Board.get_next_direction(direction)
|
||||
check_for_building()
|
||||
|
||||
|
||||
func handle_tile_area_entered(area: Area2D):
|
||||
var tile = area.get_parent()
|
||||
current_tile_coords = board.tile_map.local_to_map(area.global_position)
|
||||
func handle_tile_area_exited(_area: Area2D):
|
||||
if is_queued_for_deletion():
|
||||
return
|
||||
current_tile_coords = Globals.board_game.board.tile_map.local_to_map(tile_area.global_position)
|
||||
if (
|
||||
!Globals.board_game.board.tiles.has(current_tile_coords)
|
||||
and !Globals.board_game.board.buildings.has(current_tile_coords)
|
||||
):
|
||||
if direction != Board.Direction.NONE:
|
||||
direction = Board.Direction.NONE
|
||||
return
|
||||
if !direction_queue.is_empty():
|
||||
direction = direction_queue.pop_front()
|
||||
elif tile is Building:
|
||||
if !buildings_visited.has(tile):
|
||||
buildings_visited.set(tile, 0)
|
||||
buildings_visited[tile as Building] += 1
|
||||
tile.activate(self)
|
||||
direction_queue = tile.get_direction_queue(self)
|
||||
elif Globals.board_game.board.buildings.has(current_tile_coords):
|
||||
var building = Globals.board_game.board.buildings[current_tile_coords]
|
||||
if !buildings_visited.has(building):
|
||||
buildings_visited.set(building, 0)
|
||||
buildings_visited[building] += 1
|
||||
building.activate(self)
|
||||
direction_queue = building.get_direction_queue(self)
|
||||
direction = direction_queue.pop_front()
|
||||
else:
|
||||
elif Globals.board_game.board.tiles.has(current_tile_coords):
|
||||
var tile = Globals.board_game.board.tiles[current_tile_coords]
|
||||
if !tiles_visited.has(tile):
|
||||
tiles_visited.set(tile, 0)
|
||||
tiles_visited[tile as Tile] += 1
|
||||
check_for_building()
|
||||
check_for_turn(tile)
|
||||
check_for_wall()
|
||||
if (
|
||||
buildings_visited.values().any(func(v: int): return v > 3)
|
||||
or tiles_visited.values().any(func(v: int): return v > 3)
|
||||
|
||||
@ -161,7 +161,7 @@ animations = [{
|
||||
size = Vector2(18, 18)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_f20g1"]
|
||||
size = Vector2(2, 2)
|
||||
size = Vector2(108, 108)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_f20g1"]
|
||||
font_color = Color(0, 1, 0, 1)
|
||||
@ -173,7 +173,6 @@ process_mode = 1
|
||||
z_index = 2
|
||||
y_sort_enabled = true
|
||||
collision_layer = 4
|
||||
collision_mask = 3
|
||||
script = ExtResource("1_noc4a")
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite2D" parent="." unique_id=53044239]
|
||||
@ -189,7 +188,6 @@ shape = SubResource("RectangleShape2D_noc4a")
|
||||
[node name="TileArea" type="Area2D" parent="." unique_id=1604684578]
|
||||
unique_name_in_owner = true
|
||||
collision_layer = 0
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TileArea" unique_id=1001840681]
|
||||
shape = SubResource("RectangleShape2D_f20g1")
|
||||
@ -222,4 +220,4 @@ offset_right = 26.0
|
||||
offset_bottom = 5.0
|
||||
theme_override_constants/separation = 1
|
||||
|
||||
[connection signal="area_entered" from="TileArea" to="." method="handle_tile_area_entered"]
|
||||
[connection signal="area_exited" from="TileArea" to="." method="handle_tile_area_exited"]
|
||||
|
||||
@ -1,20 +1,29 @@
|
||||
extends Camera2D
|
||||
|
||||
var is_controlling_camera: bool = false
|
||||
var is_dragging: bool = false
|
||||
|
||||
#func _input(event: InputEvent) -> void:
|
||||
#if event.is_action_pressed("camera_drag"):
|
||||
#Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
#is_dragging = true
|
||||
#elif event.is_action_released("camera_drag"):
|
||||
#Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
#is_dragging = false
|
||||
#
|
||||
#if event.is_action_pressed("zoom_in"):
|
||||
#zoom *= Vector2(1.25, 1.25)
|
||||
#elif event.is_action_pressed("zoom_out"):
|
||||
#zoom *= Vector2(0.75, 0.75)
|
||||
#
|
||||
#if is_dragging:
|
||||
#if event is InputEventMouseMotion:
|
||||
#position = lerp(position, event.screen_velocity, 0.01)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("camera_engage"):
|
||||
is_controlling_camera = true
|
||||
elif event.is_action_released("camera_engage"):
|
||||
is_controlling_camera = false
|
||||
return
|
||||
if !is_controlling_camera:
|
||||
return
|
||||
if event.is_action_pressed("camera_drag"):
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
is_dragging = true
|
||||
elif event.is_action_released("camera_drag"):
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
is_dragging = false
|
||||
|
||||
if event.is_action_pressed("zoom_in"):
|
||||
zoom *= Vector2(1.25, 1.25)
|
||||
elif event.is_action_pressed("zoom_out"):
|
||||
zoom *= Vector2(0.75, 0.75)
|
||||
|
||||
if is_dragging:
|
||||
if event is InputEventMouseMotion:
|
||||
position = lerp(position, event.screen_velocity, 0.01)
|
||||
|
||||
@ -1 +1,35 @@
|
||||
extends VBoxContainer
|
||||
|
||||
signal create_session(player: Player)
|
||||
|
||||
@onready var name_line_edit: LineEdit = %NameLineEdit
|
||||
@onready var player_color: ColorPickerButton = %PlayerColor
|
||||
@onready var create_session_button: Button = %CreateSession
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
player_color.color = Color(randf(), randf(), randf())
|
||||
var picker := player_color.get_picker()
|
||||
picker.picker_shape = ColorPicker.SHAPE_HSV_WHEEL
|
||||
picker.sampler_visible = false
|
||||
picker.edit_alpha = false
|
||||
picker.edit_intensity = false
|
||||
picker.color_modes_visible = false
|
||||
picker.sliders_visible = false
|
||||
picker.hex_visible = false
|
||||
picker.presets_visible = false
|
||||
picker.can_add_swatches = false
|
||||
|
||||
|
||||
func _on_name_line_edit_text_changed(new_text: String) -> void:
|
||||
if !new_text.is_empty():
|
||||
create_session_button.disabled = false
|
||||
else:
|
||||
create_session_button.disabled = true
|
||||
|
||||
|
||||
func _on_create_session_pressed():
|
||||
var player = Player.new()
|
||||
player.name = name_line_edit.text
|
||||
player.color = player_color.color
|
||||
create_session.emit(player)
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
[gd_scene format=3 uid="uid://b7rfnt0d4qoew"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cee85aokdb5ts" path="res://prefabs/lobby/create_session.gd" id="1_58eib"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_tftiq"]
|
||||
font_size = 32
|
||||
|
||||
@ -11,6 +13,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/separation = 20
|
||||
alignment = 1
|
||||
script = ExtResource("1_58eib")
|
||||
|
||||
[node name="Label" type="Label" parent="." unique_id=893154611]
|
||||
layout_mode = 2
|
||||
@ -27,7 +30,8 @@ alignment = 1
|
||||
layout_mode = 2
|
||||
text = "Player Name"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Name" unique_id=1835313745]
|
||||
[node name="NameLineEdit" type="LineEdit" parent="Name" unique_id=1835313745]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
|
||||
@ -40,12 +44,18 @@ alignment = 1
|
||||
layout_mode = 2
|
||||
text = "Player Color"
|
||||
|
||||
[node name="ColorPickerButton" type="ColorPickerButton" parent="Color" unique_id=1931635282]
|
||||
[node name="PlayerColor" type="ColorPickerButton" parent="Color" unique_id=1931635282]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Button" type="Button" parent="." unique_id=1053608712]
|
||||
[node name="CreateSession" type="Button" parent="." unique_id=1053608712]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
disabled = true
|
||||
text = "Create Session"
|
||||
|
||||
[connection signal="text_changed" from="Name/NameLineEdit" to="." method="_on_name_line_edit_text_changed"]
|
||||
[connection signal="pressed" from="CreateSession" to="." method="_on_create_session_pressed"]
|
||||
|
||||
43
prefabs/lobby/join_session.gd
Normal file
43
prefabs/lobby/join_session.gd
Normal file
@ -0,0 +1,43 @@
|
||||
extends VBoxContainer
|
||||
|
||||
signal join_session(session_id: String, player: Player)
|
||||
|
||||
@onready var session_id_line_edit: LineEdit = %SessionIdLineEdit
|
||||
@onready var name_line_edit: LineEdit = %NameLineEdit
|
||||
@onready var player_color: ColorPickerButton = %PlayerColor
|
||||
@onready var join_session_button: Button = %JoinSession
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
player_color.color = Color(randf(), randf(), randf())
|
||||
var picker := player_color.get_picker()
|
||||
picker.picker_shape = ColorPicker.SHAPE_HSV_WHEEL
|
||||
picker.sampler_visible = false
|
||||
picker.edit_alpha = false
|
||||
picker.edit_intensity = false
|
||||
picker.color_modes_visible = false
|
||||
picker.sliders_visible = false
|
||||
picker.hex_visible = false
|
||||
picker.presets_visible = false
|
||||
picker.can_add_swatches = false
|
||||
|
||||
|
||||
func _on_session_id_line_edit_text_changed(new_text: String) -> void:
|
||||
if !new_text.is_empty() and !name_line_edit.text.is_empty():
|
||||
join_session_button.disabled = false
|
||||
else:
|
||||
join_session_button.disabled = true
|
||||
|
||||
|
||||
func _on_name_line_edit_text_changed(new_text: String) -> void:
|
||||
if !new_text.is_empty() and !session_id_line_edit.text.is_empty():
|
||||
join_session_button.disabled = false
|
||||
else:
|
||||
join_session_button.disabled = true
|
||||
|
||||
|
||||
func _on_join_session_pressed():
|
||||
var player = Player.new()
|
||||
player.name = name_line_edit.text
|
||||
player.color = player_color.color
|
||||
join_session.emit(session_id_line_edit.text, player)
|
||||
1
prefabs/lobby/join_session.gd.uid
Normal file
1
prefabs/lobby/join_session.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://c3qxf3fy71710
|
||||
75
prefabs/lobby/join_session.tscn
Normal file
75
prefabs/lobby/join_session.tscn
Normal file
@ -0,0 +1,75 @@
|
||||
[gd_scene format=3 uid="uid://j3v0ad1b28il"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c3qxf3fy71710" path="res://prefabs/lobby/join_session.gd" id="1_i3e7f"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_ir4al"]
|
||||
font_size = 32
|
||||
|
||||
[node name="JoinSessionContainer" type="VBoxContainer" unique_id=1106179304]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
alignment = 1
|
||||
script = ExtResource("1_i3e7f")
|
||||
|
||||
[node name="Label" type="Label" parent="." unique_id=400290031]
|
||||
layout_mode = 2
|
||||
text = "Join Session"
|
||||
label_settings = SubResource("LabelSettings_ir4al")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Session" type="HBoxContainer" parent="." unique_id=1558660847]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="Session" unique_id=266353272]
|
||||
layout_mode = 2
|
||||
text = "Session ID"
|
||||
|
||||
[node name="SessionIdLineEdit" type="LineEdit" parent="Session" unique_id=2058870951]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Name" type="HBoxContainer" parent="." unique_id=1040827513]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="Name" unique_id=1431785707]
|
||||
layout_mode = 2
|
||||
text = "Player Name"
|
||||
|
||||
[node name="NameLineEdit" type="LineEdit" parent="Name" unique_id=660083812]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Color" type="HBoxContainer" parent="." unique_id=344337316]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="Color" unique_id=593000274]
|
||||
layout_mode = 2
|
||||
text = "Player Color"
|
||||
|
||||
[node name="PlayerColor" type="ColorPickerButton" parent="Color" unique_id=1063590661]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="JoinSession" type="Button" parent="." unique_id=1644825806]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
disabled = true
|
||||
text = "Join Session"
|
||||
|
||||
[connection signal="text_changed" from="Session/SessionIdLineEdit" to="." method="_on_session_id_line_edit_text_changed"]
|
||||
[connection signal="text_changed" from="Name/NameLineEdit" to="." method="_on_name_line_edit_text_changed"]
|
||||
[connection signal="pressed" from="JoinSession" to="." method="_on_join_session_pressed"]
|
||||
@ -1,27 +1,79 @@
|
||||
extends Node
|
||||
class_name Lobby extends VBoxContainer
|
||||
|
||||
@onready var session_label: Label = %SessionLabel
|
||||
@onready var join_session_id: LineEdit = %JoinSessionId
|
||||
@onready var tube_client: TubeClient = %TubeClient
|
||||
@onready var chat_log: RichTextLabel = %ChatLabel
|
||||
@onready var chat_text_input: LineEdit = %ChatTextInput
|
||||
const PLAYER_ENTRY_SCENE = preload("uid://c1wn1ghkp12hb")
|
||||
|
||||
@onready var session_id: LineEdit = %SessionId
|
||||
@onready var player_list: Container = %PlayerList
|
||||
|
||||
@onready var ready_button: Button = %ReadyButton
|
||||
@onready var unready_button: Button = %UnreadyButton
|
||||
|
||||
@onready var message_line_edit: LineEdit = %MessageLineEdit
|
||||
@onready var chat: RichTextLabel = %Chat
|
||||
|
||||
|
||||
func handle_create_session():
|
||||
tube_client.create_session()
|
||||
session_label.text = tube_client.session_id
|
||||
func set_session_id(id: String) -> void:
|
||||
session_id.text = id
|
||||
|
||||
|
||||
func handle_join_session():
|
||||
tube_client.join_session(join_session_id.text)
|
||||
session_label.text = tube_client.session_id
|
||||
#@rpc("any_peer", "call_local", "reliable")
|
||||
#func update_chat(text):
|
||||
#chat_log.text += text + "\n"
|
||||
|
||||
|
||||
func handle_chat_update(new_text):
|
||||
update_chat.rpc(new_text)
|
||||
chat_text_input.text = ""
|
||||
#@rpc("any_peer", "call_local", "reliable")
|
||||
func load_players(players: Array[Player]) -> void:
|
||||
for child in player_list.get_children():
|
||||
child.queue_free()
|
||||
for player in players:
|
||||
var player_entry: PlayerEntry = PLAYER_ENTRY_SCENE.instantiate()
|
||||
player_list.add_child(player_entry)
|
||||
player_entry.set_player(player)
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func update_chat(text):
|
||||
chat_log.text += text + "\n"
|
||||
func ready_player(player_data: Dictionary, is_ready: bool) -> void:
|
||||
for pe: PlayerEntry in player_list.get_children():
|
||||
if pe.player.id == player_data["id"]:
|
||||
if is_ready:
|
||||
pe.ready()
|
||||
else:
|
||||
pe.unready()
|
||||
_check_for_game_start()
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func update_chat(message: String, player_data: Dictionary) -> void:
|
||||
chat.push_color(player_data["color"])
|
||||
chat.add_text("%s: " % player_data["name"])
|
||||
chat.push_color(Color.WHITE)
|
||||
chat.add_text("%s\n" % message)
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func start_game() -> void:
|
||||
Globals.game.start_game()
|
||||
|
||||
|
||||
func _check_for_game_start() -> void:
|
||||
for pe: PlayerEntry in player_list.get_children():
|
||||
if !pe.is_ready:
|
||||
return
|
||||
start_game()
|
||||
|
||||
|
||||
func _handle_message_submitted() -> void:
|
||||
update_chat.rpc(message_line_edit.text, Globals.game.this_player.serialize())
|
||||
message_line_edit.text = ""
|
||||
|
||||
|
||||
func _on_ready_button_pressed():
|
||||
ready_button.hide()
|
||||
unready_button.show()
|
||||
ready_player.rpc(Globals.game.this_player.serialize(), true)
|
||||
|
||||
|
||||
func _on_unready_button_pressed():
|
||||
ready_button.show()
|
||||
unready_button.hide()
|
||||
ready_player.rpc(Globals.game.this_player.serialize(), false)
|
||||
|
||||
@ -1 +1 @@
|
||||
uid://ccycmp8aj70fe
|
||||
uid://lko2kbbcgy0u
|
||||
|
||||
@ -1,102 +1,117 @@
|
||||
[gd_scene format=3 uid="uid://dpuwsqorot65h"]
|
||||
[gd_scene format=3 uid="uid://cfci3j2ur3g31"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ccycmp8aj70fe" path="res://prefabs/lobby/lobby.gd" id="1_2wvic"]
|
||||
[ext_resource type="Script" uid="uid://cy006uvidc4y" path="res://addons/tube/tube_client.gd" id="2_tftiq"]
|
||||
[ext_resource type="Script" uid="uid://t4pe7yqc3pnt" path="res://addons/tube/tube_context.gd" id="3_1gg6n"]
|
||||
[ext_resource type="Script" uid="uid://lko2kbbcgy0u" path="res://prefabs/lobby/lobby.gd" id="1_2wvic"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_x4164"]
|
||||
script = ExtResource("3_1gg6n")
|
||||
app_id = "g^o#isR0W!x|+?8"
|
||||
trackers_urls = Array[String](["wss://tracker.openwebtorrent.com", "wss://tracker.files.fm:7073/announce", "wss://tracker.btorrent.xyz/", "wss://tracker.ghostchu-services.top:443/announce"])
|
||||
stun_servers_urls = Array[String](["stun:stun.l.google.com:19302", "stun:stun.cloudflare.com:3478", "stun:stun.bethesda.net:3478"])
|
||||
metadata/_custom_type_script = "uid://t4pe7yqc3pnt"
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_47oqe"]
|
||||
font_size = 24
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_2wvic"]
|
||||
font_size = 48
|
||||
[sub_resource type="SystemFont" id="SystemFont_47oqe"]
|
||||
font_names = PackedStringArray("Monospace")
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_tftiq"]
|
||||
font_size = 32
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pohc3"]
|
||||
bg_color = Color(0.60038817, 0.60038817, 0.60038817, 0)
|
||||
border_width_left = 2
|
||||
border_width_top = 2
|
||||
border_width_right = 2
|
||||
border_width_bottom = 2
|
||||
border_color = Color(0, 0, 0, 1)
|
||||
corner_radius_top_left = 8
|
||||
corner_radius_top_right = 8
|
||||
corner_radius_bottom_right = 8
|
||||
corner_radius_bottom_left = 8
|
||||
|
||||
[node name="Lobby" type="Node" unique_id=459413586]
|
||||
[node name="Lobby" type="VBoxContainer" unique_id=581427024]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_2wvic")
|
||||
|
||||
[node name="TubeClient" type="Node" parent="." unique_id=1351185338]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("2_tftiq")
|
||||
context = SubResource("Resource_x4164")
|
||||
metadata/_custom_type_script = "uid://cy006uvidc4y"
|
||||
[node name="Players" type="HBoxContainer" parent="." unique_id=722026949]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="MenuContainer" type="VBoxContainer" parent="." unique_id=1667537625]
|
||||
[node name="PlayerList" type="VBoxContainer" parent="Players" unique_id=619905746]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
alignment = 1
|
||||
|
||||
[node name="Info" type="VBoxContainer" parent="Players" unique_id=532914324]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 30
|
||||
alignment = 1
|
||||
|
||||
[node name="Session" type="HBoxContainer" parent="Players/Info" unique_id=444337944]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="Players/Info/Session" unique_id=842082166]
|
||||
layout_mode = 2
|
||||
text = "Session ID:"
|
||||
label_settings = SubResource("LabelSettings_47oqe")
|
||||
|
||||
[node name="SessionId" type="LineEdit" parent="Players/Info/Session" unique_id=1698107040]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_uneditable_color = Color(0.8750814, 0.8750814, 0.8750814, 1)
|
||||
theme_override_fonts/font = SubResource("SystemFont_47oqe")
|
||||
theme_override_font_sizes/font_size = 24
|
||||
alignment = 1
|
||||
editable = false
|
||||
|
||||
[node name="ReadyButton" type="Button" parent="Players/Info" unique_id=419988826]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Ready"
|
||||
|
||||
[node name="UnreadyButton" type="Button" parent="Players/Info" unique_id=757772261]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/separation = 20
|
||||
alignment = 1
|
||||
|
||||
[node name="Title" type="Label" parent="MenuContainer" unique_id=1959052214]
|
||||
layout_mode = 2
|
||||
text = "Clockwork City"
|
||||
label_settings = SubResource("LabelSettings_2wvic")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="CreateSession" type="Button" parent="MenuContainer" unique_id=1320477862]
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Create Session"
|
||||
text = "Ready"
|
||||
|
||||
[node name="JoinSession" type="Button" parent="MenuContainer" unique_id=897089302]
|
||||
[node name="Chat" type="VBoxContainer" parent="." unique_id=1295152456]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Join Session"
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 1
|
||||
|
||||
[node name="CreateSessionContainer" type="VBoxContainer" parent="." unique_id=1261110903]
|
||||
[node name="ChatContainer" type="PanelContainer" parent="Chat" unique_id=691964308]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_pohc3")
|
||||
|
||||
[node name="Chat" type="RichTextLabel" parent="Chat/ChatContainer" unique_id=1340192570]
|
||||
unique_name_in_owner = true
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/separation = 20
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="CreateSessionContainer" unique_id=1668422341]
|
||||
layout_mode = 2
|
||||
text = "Create Session"
|
||||
label_settings = SubResource("LabelSettings_tftiq")
|
||||
horizontal_alignment = 1
|
||||
size_flags_vertical = 3
|
||||
bbcode_enabled = true
|
||||
scroll_following = true
|
||||
|
||||
[node name="Name" type="HBoxContainer" parent="CreateSessionContainer" unique_id=1986198559]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Chat" unique_id=2121694632]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
alignment = 1
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="Label" type="Label" parent="CreateSessionContainer/Name" unique_id=2042865933]
|
||||
[node name="MessageLineEdit" type="LineEdit" parent="Chat/HBoxContainer" unique_id=2073316126]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Player Name"
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="CreateSessionContainer/Name" unique_id=1717454671]
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
[node name="MessageSubmit" type="Button" parent="Chat/HBoxContainer" unique_id=850033256]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "Submit"
|
||||
|
||||
[node name="Color" type="HBoxContainer" parent="CreateSessionContainer" unique_id=237702841]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="CreateSessionContainer/Color" unique_id=803879737]
|
||||
layout_mode = 2
|
||||
text = "Player Color"
|
||||
|
||||
[node name="ColorPickerButton" type="ColorPickerButton" parent="CreateSessionContainer/Color" unique_id=165152573]
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Button" type="Button" parent="CreateSessionContainer" unique_id=218018842]
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Create Session"
|
||||
[connection signal="pressed" from="Players/Info/ReadyButton" to="." method="_on_ready_button_pressed"]
|
||||
[connection signal="pressed" from="Players/Info/UnreadyButton" to="." method="_on_unready_button_pressed"]
|
||||
[connection signal="text_submitted" from="Chat/HBoxContainer/MessageLineEdit" to="." method="_handle_message_submitted" unbinds=1]
|
||||
[connection signal="pressed" from="Chat/HBoxContainer/MessageSubmit" to="." method="_handle_message_submitted"]
|
||||
|
||||
26
prefabs/lobby/player_entry.gd
Normal file
26
prefabs/lobby/player_entry.gd
Normal file
@ -0,0 +1,26 @@
|
||||
class_name PlayerEntry extends HBoxContainer
|
||||
|
||||
var player: Player
|
||||
var is_ready: bool = false
|
||||
|
||||
@onready var unready_icon: TextureRect = %UnreadyIcon
|
||||
@onready var ready_icon: TextureRect = %ReadyIcon
|
||||
@onready var player_name_label: Label = %PlayerName
|
||||
|
||||
|
||||
func ready() -> void:
|
||||
is_ready = true
|
||||
unready_icon.hide()
|
||||
ready_icon.show()
|
||||
|
||||
|
||||
func unready() -> void:
|
||||
is_ready = false
|
||||
unready_icon.show()
|
||||
ready_icon.hide()
|
||||
|
||||
|
||||
func set_player(p: Player) -> void:
|
||||
player = p
|
||||
player_name_label.text = player.name
|
||||
player_name_label.label_settings.font_color = player.color
|
||||
1
prefabs/lobby/player_entry.gd.uid
Normal file
1
prefabs/lobby/player_entry.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://cnyjvrs1iem5
|
||||
45
prefabs/lobby/player_entry.tscn
Normal file
45
prefabs/lobby/player_entry.tscn
Normal file
@ -0,0 +1,45 @@
|
||||
[gd_scene format=3 uid="uid://c1wn1ghkp12hb"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dalonthk63q26" path="res://assets/ui_buttons/button UI.png" id="1_8wymv"]
|
||||
[ext_resource type="Script" uid="uid://cnyjvrs1iem5" path="res://prefabs/lobby/player_entry.gd" id="1_41ya2"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_41ya2"]
|
||||
atlas = ExtResource("1_8wymv")
|
||||
region = Rect2(64, 64, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ysqhn"]
|
||||
atlas = ExtResource("1_8wymv")
|
||||
region = Rect2(80, 16, 16, 16)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_yycat"]
|
||||
resource_local_to_scene = true
|
||||
font_size = 32
|
||||
|
||||
[node name="PlayerEntry" type="HBoxContainer" unique_id=2138291579]
|
||||
theme_override_constants/separation = 20
|
||||
script = ExtResource("1_41ya2")
|
||||
|
||||
[node name="UnreadyIcon" type="TextureRect" parent="." unique_id=723007847]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
layout_mode = 2
|
||||
texture = SubResource("AtlasTexture_41ya2")
|
||||
expand_mode = 3
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="ReadyIcon" type="TextureRect" parent="." unique_id=710160353]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
texture_filter = 1
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
layout_mode = 2
|
||||
texture = SubResource("AtlasTexture_ysqhn")
|
||||
expand_mode = 3
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="PlayerName" type="Label" parent="." unique_id=689457220]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Player"
|
||||
label_settings = SubResource("LabelSettings_yycat")
|
||||
@ -5,12 +5,12 @@ signal child_registered
|
||||
var scene_coords: Dictionary[Vector2i, Node] = {}
|
||||
|
||||
|
||||
func _enter_tree():
|
||||
func _enter_tree() -> void:
|
||||
child_entered_tree.connect(_register_child)
|
||||
child_exiting_tree.connect(_unregister_child)
|
||||
|
||||
|
||||
func _register_child(child):
|
||||
func _register_child(child: Node) -> void:
|
||||
await child.ready
|
||||
var coords = local_to_map(to_local(child.global_position))
|
||||
scene_coords[coords] = child
|
||||
|
||||
@ -8,7 +8,7 @@ outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vwg8v"]
|
||||
size = Vector2(110, 110)
|
||||
size = Vector2(109, 109)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wwwaf"]
|
||||
atlas = ExtResource("2_68e07")
|
||||
@ -18,9 +18,6 @@ region = Rect2(16, 16, 16, 16)
|
||||
atlas = ExtResource("2_68e07")
|
||||
region = Rect2(0, 16, 16, 16)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wwwaf"]
|
||||
size = Vector2(1, 1)
|
||||
|
||||
[node name="Bank" type="Node2D" unique_id=746270571 groups=["PostTurnActions"]]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_q4p5y")
|
||||
@ -84,29 +81,41 @@ label_settings = SubResource("LabelSettings_vwg8v")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="BuildingArea" type="Area2D" parent="." unique_id=333775731]
|
||||
unique_name_in_owner = true
|
||||
[node name="Square1" type="Area2D" parent="." unique_id=333775731]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
collision_layer = 0
|
||||
collision_mask = 5
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="BuildingArea" unique_id=1122204523]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square1" unique_id=1122204523]
|
||||
process_mode = 3
|
||||
position = Vector2(55, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="BuildingArea" unique_id=1773735924]
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=1695837302]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Square2" unique_id=451761201]
|
||||
position = Vector2(165, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="BuildingArea" unique_id=1677987437]
|
||||
position = Vector2(165, 55)
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=1667620998]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="Square3" unique_id=636207289]
|
||||
position = Vector2(55, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="BuildingArea" unique_id=1638062176]
|
||||
position = Vector2(55, 55)
|
||||
[node name="Square4" type="Area2D" parent="." unique_id=2144774838]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="Square4" unique_id=847000506]
|
||||
position = Vector2(165, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1585332168]
|
||||
@ -139,35 +148,17 @@ scale = Vector2(2, 2)
|
||||
texture = SubResource("AtlasTexture_fupku")
|
||||
flip_v = true
|
||||
|
||||
[node name="Square" type="Area2D" parent="." unique_id=1309579334]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
[node name="Size" type="Control" parent="." unique_id=1957708982]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -55.0
|
||||
offset_top = -205.0
|
||||
offset_right = 165.0
|
||||
offset_bottom = 55.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square" unique_id=2040153103]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=2142538939]
|
||||
position = Vector2(110, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square2" unique_id=2060476818]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=535904517]
|
||||
position = Vector2(110, 0)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square3" unique_id=1107926939]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square4" type="Area2D" parent="." unique_id=289882156]
|
||||
position = Vector2(0, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square4" unique_id=1476676009]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[connection signal="area_entered" from="BuildingArea" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square1" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square2" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square3" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square4" to="." method="_on_building_area_entered"]
|
||||
|
||||
@ -8,7 +8,7 @@ outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vwg8v"]
|
||||
size = Vector2(110, 110)
|
||||
size = Vector2(109, 109)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wwwaf"]
|
||||
atlas = ExtResource("2_iv3ev")
|
||||
@ -18,9 +18,6 @@ region = Rect2(16, 16, 16, 16)
|
||||
atlas = ExtResource("2_iv3ev")
|
||||
region = Rect2(0, 16, 16, 16)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wwwaf"]
|
||||
size = Vector2(1, 1)
|
||||
|
||||
[node name="Bar" type="Node2D" unique_id=746270571]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_cy06p")
|
||||
@ -54,20 +51,22 @@ label_settings = SubResource("LabelSettings_vwg8v")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="BuildingArea" type="Area2D" parent="." unique_id=333775731]
|
||||
unique_name_in_owner = true
|
||||
[node name="Square1" type="Area2D" parent="." unique_id=333775731]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
collision_layer = 0
|
||||
collision_mask = 5
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="BuildingArea" unique_id=1122204523]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square1" unique_id=1122204523]
|
||||
process_mode = 3
|
||||
position = Vector2(55, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="BuildingArea" unique_id=1638062176]
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=576493787]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Square2" unique_id=1628737156]
|
||||
position = Vector2(55, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
@ -101,19 +100,15 @@ scale = Vector2(2, 2)
|
||||
texture = SubResource("AtlasTexture_fupku")
|
||||
flip_v = true
|
||||
|
||||
[node name="Square" type="Area2D" parent="." unique_id=1309579334]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
[node name="Size" type="Control" parent="." unique_id=645153151]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -55.0
|
||||
offset_top = -205.0
|
||||
offset_right = 55.0
|
||||
offset_bottom = 95.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square" unique_id=2040153103]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=289882156]
|
||||
position = Vector2(0, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square2" unique_id=1476676009]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[connection signal="area_entered" from="BuildingArea" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square1" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square2" to="." method="_on_building_area_entered"]
|
||||
|
||||
@ -1,14 +1,18 @@
|
||||
class_name Building extends Node2D
|
||||
|
||||
@export var cost: int = 0
|
||||
|
||||
var is_placing: bool = false:
|
||||
set(value):
|
||||
is_placing = value
|
||||
building_area.monitoring = !is_placing
|
||||
for child in get_children():
|
||||
if child is Area2D:
|
||||
child.monitoring = !is_placing
|
||||
|
||||
var starting_coord: Vector2i
|
||||
var tile_rotation: Board.Direction = Board.Direction.UP
|
||||
|
||||
@onready var building_area: Area2D = %BuildingArea
|
||||
@onready var size_node: Control = %Size
|
||||
|
||||
|
||||
func building_entered(body: Node2D) -> void:
|
||||
@ -33,3 +37,25 @@ func get_rotation_count() -> int:
|
||||
elif tile_rotation == Board.Direction.LEFT:
|
||||
rotation_count = 3
|
||||
return rotation_count
|
||||
|
||||
|
||||
func serialize() -> Dictionary:
|
||||
var result = {}
|
||||
result["scene_file_path"] = scene_file_path
|
||||
result["starting_coord"] = starting_coord
|
||||
result["tile_rotation"] = tile_rotation
|
||||
result["cost"] = cost
|
||||
result["player"] = null
|
||||
if get("player") != null:
|
||||
result["player"] = get("player").serialize()
|
||||
return result
|
||||
|
||||
|
||||
static func deserialize(data: Dictionary) -> Building:
|
||||
var building: Building = load(data["scene_file_path"]).instantiate()
|
||||
building.tile_rotation = data["tile_rotation"]
|
||||
building.starting_coord = data["starting_coord"]
|
||||
building.cost = data["cost"]
|
||||
if data["player"] != null:
|
||||
building.player = Player.deserialize(data["player"])
|
||||
return building
|
||||
|
||||
@ -47,7 +47,7 @@ func get_tile_coords() -> Array[Vector2i]:
|
||||
|
||||
|
||||
func get_direction_queue(citizen: Citizen) -> Array[Board.Direction]:
|
||||
if (citizen.current_tile_coords - starting_coord) == Vector2i.ZERO:
|
||||
if citizen.current_tile_coords == starting_coord:
|
||||
return [
|
||||
Board.get_next_direction(Board.Direction.RIGHT, get_rotation_count()),
|
||||
Board.get_next_direction(Board.Direction.UP, get_rotation_count()),
|
||||
|
||||
@ -8,7 +8,7 @@ outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vwg8v"]
|
||||
size = Vector2(110, 110)
|
||||
size = Vector2(109, 109)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wwwaf"]
|
||||
atlas = ExtResource("2_721qv")
|
||||
@ -18,9 +18,6 @@ region = Rect2(16, 16, 16, 16)
|
||||
atlas = ExtResource("2_721qv")
|
||||
region = Rect2(0, 16, 16, 16)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wwwaf"]
|
||||
size = Vector2(1, 1)
|
||||
|
||||
[node name="Cafe" type="Node2D" unique_id=746270571]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_rc38y")
|
||||
@ -72,29 +69,41 @@ label_settings = SubResource("LabelSettings_vwg8v")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="BuildingArea" type="Area2D" parent="." unique_id=333775731]
|
||||
unique_name_in_owner = true
|
||||
[node name="Square1" type="Area2D" parent="." unique_id=333775731]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
collision_layer = 0
|
||||
collision_mask = 5
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="BuildingArea" unique_id=1122204523]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square1" unique_id=1122204523]
|
||||
process_mode = 3
|
||||
position = Vector2(55, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="BuildingArea" unique_id=1773735924]
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=1384097423]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Square2" unique_id=686018821]
|
||||
position = Vector2(165, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="BuildingArea" unique_id=1677987437]
|
||||
position = Vector2(165, 55)
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=837457110]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="Square3" unique_id=1976346563]
|
||||
position = Vector2(275, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="BuildingArea" unique_id=1638062176]
|
||||
position = Vector2(275, 55)
|
||||
[node name="Square4" type="Area2D" parent="." unique_id=1074092983]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="Square4" unique_id=442777190]
|
||||
position = Vector2(165, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1585332168]
|
||||
@ -129,35 +138,17 @@ scale = Vector2(2, 2)
|
||||
texture = SubResource("AtlasTexture_fupku")
|
||||
flip_v = true
|
||||
|
||||
[node name="Square" type="Area2D" parent="." unique_id=1309579334]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
[node name="Size" type="Control" parent="." unique_id=705793849]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -95.0
|
||||
offset_top = -165.0
|
||||
offset_right = 315.0
|
||||
offset_bottom = 55.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square" unique_id=2040153103]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=2142538939]
|
||||
position = Vector2(110, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square2" unique_id=2060476818]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=535904517]
|
||||
position = Vector2(110, 0)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square3" unique_id=1107926939]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square4" type="Area2D" parent="." unique_id=289882156]
|
||||
position = Vector2(220, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square4" unique_id=1476676009]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[connection signal="area_entered" from="BuildingArea" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square1" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square2" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square3" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square4" to="." method="_on_building_area_entered"]
|
||||
|
||||
@ -8,7 +8,7 @@ outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vwg8v"]
|
||||
size = Vector2(110, 110)
|
||||
size = Vector2(109, 109)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fupku"]
|
||||
atlas = ExtResource("2_rnjsh")
|
||||
@ -18,9 +18,6 @@ region = Rect2(0, 16, 16, 16)
|
||||
atlas = ExtResource("2_rnjsh")
|
||||
region = Rect2(16, 16, 16, 16)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wwwaf"]
|
||||
size = Vector2(1, 1)
|
||||
|
||||
[node name="Fork" type="Node2D" unique_id=746270571]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_pht35")
|
||||
@ -45,17 +42,12 @@ label_settings = SubResource("LabelSettings_vwg8v")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="BuildingArea" type="Area2D" parent="." unique_id=333775731]
|
||||
unique_name_in_owner = true
|
||||
[node name="Square1" type="Area2D" parent="." unique_id=333775731]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
collision_layer = 0
|
||||
collision_mask = 5
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="BuildingArea" unique_id=1122204523]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square1" unique_id=1122204523]
|
||||
process_mode = 3
|
||||
position = Vector2(55, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="Sprite2D2" type="Sprite2D" parent="." unique_id=1969702659]
|
||||
@ -82,19 +74,14 @@ scale = Vector2(2, 2)
|
||||
texture = SubResource("AtlasTexture_fupku")
|
||||
flip_v = true
|
||||
|
||||
[node name="Square" type="Area2D" parent="." unique_id=1309579334]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
[node name="Size" type="Control" parent="." unique_id=1036213581]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -95.0
|
||||
offset_top = -55.0
|
||||
offset_right = 95.0
|
||||
offset_bottom = 95.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square" unique_id=2040153103]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=289882156]
|
||||
position = Vector2(0, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square2" unique_id=1476676009]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[connection signal="area_entered" from="BuildingArea" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square1" to="." method="_on_building_area_entered"]
|
||||
|
||||
@ -8,7 +8,7 @@ outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vwg8v"]
|
||||
size = Vector2(110, 110)
|
||||
size = Vector2(109, 109)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wwwaf"]
|
||||
atlas = ExtResource("2_qam00")
|
||||
@ -18,9 +18,6 @@ region = Rect2(16, 16, 16, 16)
|
||||
atlas = ExtResource("2_qam00")
|
||||
region = Rect2(0, 16, 16, 16)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wwwaf"]
|
||||
size = Vector2(1, 1)
|
||||
|
||||
[node name="GunShop" type="Node2D" unique_id=746270571]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_llmep")
|
||||
@ -90,36 +87,58 @@ label_settings = SubResource("LabelSettings_vwg8v")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="BuildingArea" type="Area2D" parent="." unique_id=333775731]
|
||||
unique_name_in_owner = true
|
||||
[node name="Square1" type="Area2D" parent="." unique_id=333775731]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
collision_layer = 0
|
||||
collision_mask = 5
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="BuildingArea" unique_id=1122204523]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square1" unique_id=1122204523]
|
||||
process_mode = 3
|
||||
position = Vector2(55, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="BuildingArea" unique_id=1638062176]
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=1379529856]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Square2" unique_id=955594279]
|
||||
position = Vector2(55, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="BuildingArea" unique_id=1549040997]
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=1616965064]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="Square3" unique_id=298326013]
|
||||
position = Vector2(165, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="BuildingArea" unique_id=1578115167]
|
||||
[node name="Square4" type="Area2D" parent="." unique_id=2008550121]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="Square4" unique_id=2089225905]
|
||||
position = Vector2(55, -55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D5" type="CollisionShape2D" parent="BuildingArea" unique_id=1640076722]
|
||||
[node name="Square5" type="Area2D" parent="." unique_id=1035600618]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D5" type="CollisionShape2D" parent="Square5" unique_id=1170834008]
|
||||
position = Vector2(165, -55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D6" type="CollisionShape2D" parent="BuildingArea" unique_id=1850783102]
|
||||
[node name="Square6" type="Area2D" parent="." unique_id=567720258]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D6" type="CollisionShape2D" parent="Square6" unique_id=1706049840]
|
||||
position = Vector2(275, -55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
@ -154,51 +173,19 @@ scale = Vector2(2, 2)
|
||||
texture = SubResource("AtlasTexture_fupku")
|
||||
flip_v = true
|
||||
|
||||
[node name="Square" type="Area2D" parent="." unique_id=1309579334]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
[node name="Size" type="Control" parent="." unique_id=404984063]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -55.0
|
||||
offset_top = -275.0
|
||||
offset_right = 315.0
|
||||
offset_bottom = 95.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square" unique_id=2040153103]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=289882156]
|
||||
position = Vector2(0, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square2" unique_id=1476676009]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=520831463]
|
||||
position = Vector2(110, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square3" unique_id=309772651]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square4" type="Area2D" parent="." unique_id=229115924]
|
||||
position = Vector2(0, -220)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square4" unique_id=261500077]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square5" type="Area2D" parent="." unique_id=826236086]
|
||||
position = Vector2(110, -220)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square5" unique_id=1360179714]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square6" type="Area2D" parent="." unique_id=1250539767]
|
||||
position = Vector2(220, -220)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square6" unique_id=783421603]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[connection signal="area_entered" from="BuildingArea" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square1" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square2" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square3" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square4" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square5" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square6" to="." method="_on_building_area_entered"]
|
||||
|
||||
@ -8,6 +8,10 @@ var player: Player:
|
||||
@onready var border: PanelContainer = %Border
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_set_border_color()
|
||||
|
||||
|
||||
func activate(citizen: Citizen) -> void:
|
||||
player.money += citizen.money
|
||||
|
||||
@ -25,5 +29,7 @@ func get_tile_coords() -> Array[Vector2i]:
|
||||
|
||||
|
||||
func _set_border_color() -> void:
|
||||
if !is_node_ready() or player == null:
|
||||
return
|
||||
var style_box: StyleBoxFlat = border.get_theme_stylebox("panel")
|
||||
style_box.border_color = player.color
|
||||
|
||||
@ -25,11 +25,8 @@ font_size = 24
|
||||
outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_i0ot4"]
|
||||
size = Vector2(1, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ja20k"]
|
||||
size = Vector2(100, 100)
|
||||
size = Vector2(109, 109)
|
||||
|
||||
[node name="Home" type="Node2D" unique_id=1701297833]
|
||||
script = ExtResource("2_g5sxs")
|
||||
@ -90,20 +87,22 @@ label_settings = SubResource("LabelSettings_26feb")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." unique_id=2110660720]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" unique_id=2100290177]
|
||||
shape = SubResource("RectangleShape2D_i0ot4")
|
||||
|
||||
[node name="BuildingArea" type="Area2D" parent="." unique_id=812662804]
|
||||
unique_name_in_owner = true
|
||||
collision_layer = 0
|
||||
collision_mask = 5
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="BuildingArea" unique_id=660262437]
|
||||
shape = SubResource("RectangleShape2D_ja20k")
|
||||
|
||||
[node name="Size" type="Control" parent="." unique_id=1792197698]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -55.0
|
||||
offset_top = -55.0
|
||||
offset_right = 55.0
|
||||
offset_bottom = 55.0
|
||||
mouse_filter = 2
|
||||
|
||||
[connection signal="tree_entered" from="." to="." method="_on_tree_entered"]
|
||||
[connection signal="area_entered" from="BuildingArea" to="." method="_on_building_area_entered"]
|
||||
|
||||
@ -65,7 +65,7 @@ func get_direction_queue(citizen: Citizen) -> Array[Board.Direction]:
|
||||
|
||||
|
||||
func activate(citizen: Citizen) -> void:
|
||||
var new_citizen: Citizen = CITIZEN_SCENE.instantiate()
|
||||
var new_citizen: Citizen = load("uid://bwx0lqtkd2jd7").instantiate()
|
||||
citizen.call_deferred("add_sibling", new_citizen)
|
||||
await new_citizen.ready
|
||||
new_citizen.direction = citizen.direction
|
||||
@ -81,3 +81,4 @@ func activate(citizen: Citizen) -> void:
|
||||
new_citizen.current_tile_coords = starting_coord + Vector2i(1, -1)
|
||||
new_citizen.position = citizen.position - Vector2(110, 0)
|
||||
new_citizen.direction_queue = get_direction_queue(new_citizen)
|
||||
new_citizen.direction_queue.remove_at(0)
|
||||
|
||||
@ -8,7 +8,7 @@ outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vwg8v"]
|
||||
size = Vector2(110, 110)
|
||||
size = Vector2(109, 109)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wwwaf"]
|
||||
atlas = ExtResource("2_kp5oa")
|
||||
@ -18,9 +18,6 @@ region = Rect2(16, 16, 16, 16)
|
||||
atlas = ExtResource("2_kp5oa")
|
||||
region = Rect2(0, 16, 16, 16)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wwwaf"]
|
||||
size = Vector2(1, 1)
|
||||
|
||||
[node name="Hospital" type="Node2D" unique_id=746270571]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_sjpox")
|
||||
@ -90,39 +87,61 @@ label_settings = SubResource("LabelSettings_vwg8v")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="BuildingArea" type="Area2D" parent="." unique_id=333775731]
|
||||
unique_name_in_owner = true
|
||||
[node name="Square1" type="Area2D" parent="." unique_id=333775731]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
collision_layer = 0
|
||||
collision_mask = 5
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="BuildingArea" unique_id=1122204523]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square1" unique_id=1122204523]
|
||||
process_mode = 3
|
||||
position = Vector2(55, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="BuildingArea" unique_id=1773735924]
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=51068946]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Square2" unique_id=1785473598]
|
||||
position = Vector2(165, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="BuildingArea" unique_id=1677987437]
|
||||
position = Vector2(165, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=1451949629]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="BuildingArea" unique_id=1638062176]
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="Square3" unique_id=2080468580]
|
||||
position = Vector2(275, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D6" type="CollisionShape2D" parent="BuildingArea" unique_id=522644288]
|
||||
position = Vector2(385, 165)
|
||||
[node name="Square4" type="Area2D" parent="." unique_id=1551174518]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="Square4" unique_id=1859931627]
|
||||
position = Vector2(165, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D5" type="CollisionShape2D" parent="BuildingArea" unique_id=183896438]
|
||||
[node name="Square5" type="Area2D" parent="." unique_id=1045227304]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D5" type="CollisionShape2D" parent="Square5" unique_id=493084342]
|
||||
position = Vector2(275, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="Square6" type="Area2D" parent="." unique_id=1247523759]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D6" type="CollisionShape2D" parent="Square6" unique_id=1628210223]
|
||||
position = Vector2(385, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1585332168]
|
||||
texture_filter = 1
|
||||
position = Vector2(110, -190)
|
||||
@ -153,51 +172,19 @@ scale = Vector2(2, 2)
|
||||
texture = SubResource("AtlasTexture_fupku")
|
||||
flip_v = true
|
||||
|
||||
[node name="Square" type="Area2D" parent="." unique_id=1309579334]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
[node name="Size" type="Control" parent="." unique_id=1067155101]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -95.0
|
||||
offset_top = -205.0
|
||||
offset_right = 425.0
|
||||
offset_bottom = 55.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square" unique_id=2040153103]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=2142538939]
|
||||
position = Vector2(110, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square2" unique_id=2060476818]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=535904517]
|
||||
position = Vector2(110, 0)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square3" unique_id=1107926939]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square4" type="Area2D" parent="." unique_id=289882156]
|
||||
position = Vector2(220, 0)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square4" unique_id=1476676009]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square6" type="Area2D" parent="." unique_id=1663203880]
|
||||
position = Vector2(330, 0)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square6" unique_id=797794700]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square5" type="Area2D" parent="." unique_id=927113755]
|
||||
position = Vector2(220, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square5" unique_id=1982283119]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[connection signal="area_entered" from="BuildingArea" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square1" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square2" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square3" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square4" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square5" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square6" to="." method="_on_building_area_entered"]
|
||||
|
||||
@ -8,7 +8,7 @@ outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vwg8v"]
|
||||
size = Vector2(110, 110)
|
||||
size = Vector2(109, 109)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wwwaf"]
|
||||
atlas = ExtResource("1_fupku")
|
||||
@ -18,9 +18,6 @@ region = Rect2(16, 16, 16, 16)
|
||||
atlas = ExtResource("1_fupku")
|
||||
region = Rect2(0, 16, 16, 16)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wwwaf"]
|
||||
size = Vector2(1, 1)
|
||||
|
||||
[node name="Office" type="Node2D" unique_id=746270571]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_wwwaf")
|
||||
@ -72,28 +69,44 @@ label_settings = SubResource("LabelSettings_vwg8v")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="BuildingArea" type="Area2D" parent="." unique_id=333775731]
|
||||
[node name="Square1" type="Area2D" parent="." unique_id=333775731]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
collision_layer = 0
|
||||
collision_mask = 5
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="BuildingArea" unique_id=1122204523]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square1" unique_id=1122204523]
|
||||
process_mode = 3
|
||||
position = Vector2(55, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="BuildingArea" unique_id=1773735924]
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=1569010849]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Square2" unique_id=2062368795]
|
||||
position = Vector2(165, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="BuildingArea" unique_id=1677987437]
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=755825200]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="Square3" unique_id=1969675340]
|
||||
position = Vector2(165, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="BuildingArea" unique_id=1638062176]
|
||||
[node name="Square4" type="Area2D" parent="." unique_id=933131529]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="Square4" unique_id=2117224975]
|
||||
position = Vector2(275, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
@ -112,35 +125,17 @@ scale = Vector2(2, 2)
|
||||
texture = SubResource("AtlasTexture_fupku")
|
||||
flip_v = true
|
||||
|
||||
[node name="Square" type="Area2D" parent="." unique_id=1309579334]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
[node name="Size" type="Control" parent="." unique_id=300012791]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -55.0
|
||||
offset_top = -165.0
|
||||
offset_right = 275.0
|
||||
offset_bottom = 55.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square" unique_id=2040153103]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=2142538939]
|
||||
position = Vector2(110, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square2" unique_id=2060476818]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=535904517]
|
||||
position = Vector2(110, 0)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square3" unique_id=1107926939]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square4" type="Area2D" parent="." unique_id=289882156]
|
||||
position = Vector2(220, 0)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square4" unique_id=1476676009]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[connection signal="area_entered" from="BuildingArea" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square1" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square2" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square3" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square4" to="." method="_on_building_area_entered"]
|
||||
|
||||
@ -70,7 +70,7 @@ func activate(citizen: Citizen) -> void:
|
||||
|
||||
|
||||
func handle_post_turn_actions() -> void:
|
||||
Globals.game.queue_spawn_placement(floori(money / 15.0))
|
||||
Globals.board_game.queue_spawn_placement(floori(money / 15.0))
|
||||
money = money % 15
|
||||
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vwg8v"]
|
||||
size = Vector2(110, 110)
|
||||
size = Vector2(109, 109)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wwwaf"]
|
||||
atlas = ExtResource("2_6buuw")
|
||||
@ -18,9 +18,6 @@ region = Rect2(16, 16, 16, 16)
|
||||
atlas = ExtResource("2_6buuw")
|
||||
region = Rect2(0, 16, 16, 16)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wwwaf"]
|
||||
size = Vector2(1, 1)
|
||||
|
||||
[node name="Shop" type="Node2D" unique_id=746270571 groups=["PostTurnActions"]]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_cugdd")
|
||||
@ -75,24 +72,31 @@ label_settings = SubResource("LabelSettings_vwg8v")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="BuildingArea" type="Area2D" parent="." unique_id=333775731]
|
||||
unique_name_in_owner = true
|
||||
[node name="Square1" type="Area2D" parent="." unique_id=333775731]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
collision_layer = 0
|
||||
collision_mask = 5
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="BuildingArea" unique_id=1122204523]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square1" unique_id=1122204523]
|
||||
process_mode = 3
|
||||
position = Vector2(55, 165)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="BuildingArea" unique_id=1638062176]
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=1178103316]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Square2" unique_id=1888689165]
|
||||
position = Vector2(55, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="BuildingArea" unique_id=1549040997]
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=1807846223]
|
||||
process_mode = 3
|
||||
position = Vector2(-55, -165)
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="Square3" unique_id=1353761825]
|
||||
position = Vector2(165, 55)
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
@ -127,27 +131,16 @@ scale = Vector2(2, 2)
|
||||
texture = SubResource("AtlasTexture_fupku")
|
||||
flip_v = true
|
||||
|
||||
[node name="Square" type="Area2D" parent="." unique_id=1309579334]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
[node name="Size" type="Control" parent="." unique_id=732774293]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -55.0
|
||||
offset_top = -165.0
|
||||
offset_right = 205.0
|
||||
offset_bottom = 95.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square" unique_id=2040153103]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square2" type="Area2D" parent="." unique_id=289882156]
|
||||
position = Vector2(0, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square2" unique_id=1476676009]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[node name="Square3" type="Area2D" parent="." unique_id=520831463]
|
||||
position = Vector2(110, -110)
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Square3" unique_id=309772651]
|
||||
shape = SubResource("RectangleShape2D_wwwaf")
|
||||
|
||||
[connection signal="area_entered" from="BuildingArea" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square1" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square2" to="." method="_on_building_area_entered"]
|
||||
[connection signal="area_entered" from="Square3" to="." method="_on_building_area_entered"]
|
||||
|
||||
@ -16,13 +16,13 @@ load_path = "res://.godot/imported/Squares.png-fa45fbe99d22448c54fd764146a6d2d3.
|
||||
atlas = SubResource("CompressedTexture2D_fd67e")
|
||||
region = Rect2(50, 160, 10, 10)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_yeyfm"]
|
||||
size = Vector2(2, 2)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kmcv5"]
|
||||
size = Vector2(100, 100)
|
||||
size = Vector2(110, 110)
|
||||
|
||||
[node name="Ground" type="TextureRect" unique_id=1636895806]
|
||||
[node name="Ground" type="Node2D" unique_id=220734189]
|
||||
script = ExtResource("1_fd67e")
|
||||
|
||||
[node name="Lowlight" type="TextureRect" parent="." unique_id=1636895806]
|
||||
texture_filter = 1
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
anchors_preset = -1
|
||||
@ -34,9 +34,8 @@ pivot_offset = Vector2(50, 50)
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
texture = SubResource("AtlasTexture_kmcv5")
|
||||
script = ExtResource("1_fd67e")
|
||||
|
||||
[node name="Highlight" type="TextureRect" parent="." unique_id=1075021487]
|
||||
[node name="Highlight" type="TextureRect" parent="Lowlight" unique_id=1075021487]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
texture_filter = 1
|
||||
@ -46,21 +45,12 @@ offset_right = 100.0
|
||||
offset_bottom = 100.0
|
||||
texture = SubResource("AtlasTexture_unv4h")
|
||||
|
||||
[node name="CitizensArea" type="Area2D" parent="." unique_id=295299364]
|
||||
[node name="Area" type="Area2D" parent="." unique_id=499432344]
|
||||
process_mode = 3
|
||||
position = Vector2(50, 50)
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CitizensArea" unique_id=1296255500]
|
||||
shape = SubResource("RectangleShape2D_yeyfm")
|
||||
|
||||
[node name="TilesArea" type="Area2D" parent="." unique_id=499432344]
|
||||
process_mode = 3
|
||||
position = Vector2(50, 50)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TilesArea" unique_id=501086298]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area" unique_id=501086298]
|
||||
shape = SubResource("RectangleShape2D_kmcv5")
|
||||
|
||||
[connection signal="mouse_entered" from="." to="." method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="handle_ground_mouse_exited"]
|
||||
[connection signal="mouse_entered" from="Lowlight" to="." method="handle_ground_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Lowlight" to="." method="handle_ground_mouse_exited"]
|
||||
|
||||
@ -3,8 +3,9 @@
|
||||
[ext_resource type="PackedScene" uid="uid://cmx882wng57du" path="res://prefabs/tiles/spawns/spawn.tscn" id="1_8pp6a"]
|
||||
|
||||
[node name="DownSpawn" unique_id=189795230 instance=ExtResource("1_8pp6a")]
|
||||
direction = 2
|
||||
|
||||
[node name="TextureRect" parent="." index="2" unique_id=801970580]
|
||||
[node name="TextureRect" parent="Icon" parent_id_path=PackedInt32Array(189795230) index="2" unique_id=801970580]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
[node name="LeftSpawn" unique_id=189795230 instance=ExtResource("1_0mffo")]
|
||||
direction = 3
|
||||
|
||||
[node name="TextureRect" parent="." index="2" unique_id=801970580]
|
||||
[node name="TextureRect" parent="Icon" parent_id_path=PackedInt32Array(189795230) index="2" unique_id=801970580]
|
||||
layout_mode = 1
|
||||
offset_left = 10.565
|
||||
offset_top = 33.3
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
[node name="RightSpawn" unique_id=189795230 instance=ExtResource("1_0et8l")]
|
||||
direction = 4
|
||||
|
||||
[node name="TextureRect" parent="." index="2" unique_id=801970580]
|
||||
[node name="TextureRect" parent="Icon" parent_id_path=PackedInt32Array(189795230) index="2" unique_id=801970580]
|
||||
offset_left = 92.46
|
||||
offset_top = 69.315
|
||||
offset_right = 112.46
|
||||
|
||||
@ -10,15 +10,15 @@ const CITIZEN_SCENE = preload("uid://bwx0lqtkd2jd7")
|
||||
var spawn_time: float = 0.5
|
||||
var spawn_left: int
|
||||
var current_time: float = 0
|
||||
var board: Board
|
||||
var paused: bool = true
|
||||
|
||||
@onready var icon: ColorRect = %Icon
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
board = get_parent().get_parent()
|
||||
match spawn_size:
|
||||
Size.SMALL:
|
||||
spawn_left = 10
|
||||
spawn_left = 1
|
||||
|
||||
|
||||
func pause() -> void:
|
||||
@ -46,7 +46,6 @@ func _physics_process(delta: float) -> void:
|
||||
var citizen: Citizen = CITIZEN_SCENE.instantiate()
|
||||
add_sibling(citizen)
|
||||
citizen.add_to_group("Pausable")
|
||||
citizen.board = board
|
||||
citizen.position = position + (size / 2)
|
||||
citizen.position = position
|
||||
citizen.set_offset(Vector2(randf_range(-40, 40), randf_range(-40, 40)))
|
||||
citizen.direction = direction
|
||||
|
||||
@ -13,9 +13,13 @@ atlas = ExtResource("2_26feb")
|
||||
region = Rect2(20, 66, 7, 11)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bs4fa"]
|
||||
size = Vector2(1, 1)
|
||||
size = Vector2(110, 110)
|
||||
|
||||
[node name="Spawn" type="ColorRect" unique_id=189795230 groups=["Pausable", "PostTurnActions"]]
|
||||
[node name="Spawn" type="Node2D" unique_id=606603079 groups=["Pausable", "PostTurnActions"]]
|
||||
script = ExtResource("2_c3hvl")
|
||||
|
||||
[node name="Icon" type="ColorRect" parent="." unique_id=189795230]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 1
|
||||
texture_filter = 1
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
@ -24,10 +28,8 @@ offset_top = -50.0
|
||||
offset_right = 50.0
|
||||
offset_bottom = 50.0
|
||||
color = Color(0, 0, 1, 1)
|
||||
script = ExtResource("2_c3hvl")
|
||||
direction = 2
|
||||
|
||||
[node name="Label" type="Label" parent="." unique_id=134308374]
|
||||
[node name="Label" type="Label" parent="Icon" unique_id=134308374]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
@ -46,7 +48,7 @@ label_settings = SubResource("LabelSettings_26feb")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Amount" type="Label" parent="." unique_id=1728513182]
|
||||
[node name="Amount" type="Label" parent="Icon" unique_id=1728513182]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
@ -66,7 +68,7 @@ label_settings = SubResource("LabelSettings_26feb")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="." unique_id=801970580]
|
||||
[node name="TextureRect" type="TextureRect" parent="Icon" unique_id=801970580]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
@ -75,9 +77,7 @@ expand_mode = 5
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." unique_id=1478096785]
|
||||
position = Vector2(50, 50)
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" unique_id=2097036302]
|
||||
shape = SubResource("RectangleShape2D_bs4fa")
|
||||
|
||||
@ -3,9 +3,8 @@
|
||||
[ext_resource type="PackedScene" uid="uid://cmx882wng57du" path="res://prefabs/tiles/spawns/spawn.tscn" id="1_lqvn7"]
|
||||
|
||||
[node name="UpSpawn" unique_id=189795230 instance=ExtResource("1_lqvn7")]
|
||||
direction = 1
|
||||
|
||||
[node name="TextureRect" parent="." index="2" unique_id=801970580]
|
||||
[node name="TextureRect" parent="Icon" parent_id_path=PackedInt32Array(189795230) index="2" unique_id=801970580]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
class_name Tile extends Control
|
||||
class_name Tile extends Node2D
|
||||
|
||||
@warning_ignore("unused_signal")
|
||||
signal tile_selected(tile: Tile)
|
||||
|
||||
@export var coords: Vector2i
|
||||
@export var cost: int = 0
|
||||
|
||||
var highlighted: bool = false
|
||||
var is_placing: bool = false
|
||||
|
||||
|
||||
func handle_mouse_entered() -> void:
|
||||
@ -12,3 +16,18 @@ func handle_mouse_entered() -> void:
|
||||
|
||||
func handle_mouse_exited() -> void:
|
||||
highlighted = false
|
||||
|
||||
|
||||
func serialize() -> Dictionary:
|
||||
var result = {}
|
||||
result["scene_file_path"] = scene_file_path
|
||||
result["coords"] = coords
|
||||
result["cost"] = cost
|
||||
return result
|
||||
|
||||
|
||||
static func deserialize(data: Dictionary) -> Tile:
|
||||
var tile: Tile = load(data["scene_file_path"]).instantiate()
|
||||
tile.coords = data["coords"]
|
||||
tile.cost = data["cost"]
|
||||
return tile
|
||||
|
||||
@ -3,11 +3,11 @@
|
||||
[ext_resource type="Texture2D" uid="uid://8b86ftb4iwfj" path="res://assets/Pattern-Panic-10x10/no-background/Points-and-Pulses.png" id="1_s65nw"]
|
||||
[ext_resource type="PackedScene" uid="uid://cdb6bf7dat3bw" path="res://prefabs/tiles/turns/turn.tscn" id="1_xxpct"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dxc6q"]
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_s65nw"]
|
||||
atlas = ExtResource("1_s65nw")
|
||||
region = Rect2(0, 11, 9, 9)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_s65nw"]
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_xxpct"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(1, 1, 1, 0)
|
||||
border_width_left = 5
|
||||
@ -21,8 +21,10 @@ expand_margin_right = 8.0
|
||||
expand_margin_bottom = 8.0
|
||||
|
||||
[node name="DownTurn" unique_id=1363157270 instance=ExtResource("1_xxpct")]
|
||||
texture = SubResource("AtlasTexture_dxc6q")
|
||||
direction = 2
|
||||
|
||||
[node name="Highlight" parent="." index="0" unique_id=715172504]
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_s65nw")
|
||||
[node name="Icon" parent="." index="0" unique_id=1363157270]
|
||||
texture = SubResource("AtlasTexture_s65nw")
|
||||
|
||||
[node name="Highlight" parent="Icon" index="0" unique_id=715172504]
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_xxpct")
|
||||
|
||||
@ -3,11 +3,29 @@
|
||||
[ext_resource type="PackedScene" uid="uid://cdb6bf7dat3bw" path="res://prefabs/tiles/turns/turn.tscn" id="1_exig8"]
|
||||
[ext_resource type="Texture2D" uid="uid://8b86ftb4iwfj" path="res://assets/Pattern-Panic-10x10/no-background/Points-and-Pulses.png" id="2_4tde2"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_41d4x"]
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4tde2"]
|
||||
atlas = ExtResource("2_4tde2")
|
||||
region = Rect2(1, 1, 9, 9)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_41d4x"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(1, 1, 1, 0)
|
||||
border_width_left = 5
|
||||
border_width_top = 5
|
||||
border_width_right = 5
|
||||
border_width_bottom = 5
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
expand_margin_left = 8.0
|
||||
expand_margin_top = 8.0
|
||||
expand_margin_right = 8.0
|
||||
expand_margin_bottom = 8.0
|
||||
|
||||
[node name="LeftTurn" unique_id=1363157270 instance=ExtResource("1_exig8")]
|
||||
texture = SubResource("AtlasTexture_41d4x")
|
||||
flip_h = true
|
||||
direction = 3
|
||||
|
||||
[node name="Icon" parent="." index="0" unique_id=1363157270]
|
||||
texture = SubResource("AtlasTexture_4tde2")
|
||||
flip_h = true
|
||||
|
||||
[node name="Highlight" parent="Icon" index="0" unique_id=715172504]
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_41d4x")
|
||||
|
||||
@ -3,10 +3,28 @@
|
||||
[ext_resource type="PackedScene" uid="uid://cdb6bf7dat3bw" path="res://prefabs/tiles/turns/turn.tscn" id="1_2yiqp"]
|
||||
[ext_resource type="Texture2D" uid="uid://8b86ftb4iwfj" path="res://assets/Pattern-Panic-10x10/no-background/Points-and-Pulses.png" id="2_3t120"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dlxmt"]
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3t120"]
|
||||
atlas = ExtResource("2_3t120")
|
||||
region = Rect2(1, 1, 9, 9)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dlxmt"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(1, 1, 1, 0)
|
||||
border_width_left = 5
|
||||
border_width_top = 5
|
||||
border_width_right = 5
|
||||
border_width_bottom = 5
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
expand_margin_left = 8.0
|
||||
expand_margin_top = 8.0
|
||||
expand_margin_right = 8.0
|
||||
expand_margin_bottom = 8.0
|
||||
|
||||
[node name="RightTurn" unique_id=1363157270 instance=ExtResource("1_2yiqp")]
|
||||
texture = SubResource("AtlasTexture_dlxmt")
|
||||
direction = 4
|
||||
|
||||
[node name="Icon" parent="." index="0" unique_id=1363157270]
|
||||
texture = SubResource("AtlasTexture_3t120")
|
||||
|
||||
[node name="Highlight" parent="Icon" index="0" unique_id=715172504]
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_dlxmt")
|
||||
|
||||
@ -5,14 +5,14 @@ class_name Turn extends Tile
|
||||
@onready var highlight: Panel = %Highlight
|
||||
|
||||
|
||||
func handle_mouse_entered() -> void:
|
||||
func handle_turn_mouse_entered() -> void:
|
||||
highlight.show()
|
||||
|
||||
|
||||
func handle_mouse_exited() -> void:
|
||||
func handle_turn_mouse_exited() -> void:
|
||||
highlight.hide()
|
||||
|
||||
|
||||
func handle_gui_input(event: InputEvent):
|
||||
if event.is_action_pressed("select"):
|
||||
if event.is_action_pressed("select") and !is_placing:
|
||||
tile_selected.emit(self)
|
||||
|
||||
@ -21,9 +21,12 @@ expand_margin_right = 8.0
|
||||
expand_margin_bottom = 8.0
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qqie6"]
|
||||
size = Vector2(2, 2)
|
||||
size = Vector2(110, 110)
|
||||
|
||||
[node name="Turn" type="TextureRect" unique_id=1363157270]
|
||||
[node name="Turn" type="Node2D" unique_id=397844073]
|
||||
script = ExtResource("2_qqie6")
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="." unique_id=1363157270]
|
||||
texture_filter = 1
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
offset_left = -50.0
|
||||
@ -31,9 +34,8 @@ offset_top = -50.0
|
||||
offset_right = 50.0
|
||||
offset_bottom = 50.0
|
||||
texture = SubResource("AtlasTexture_x2hlk")
|
||||
script = ExtResource("2_qqie6")
|
||||
|
||||
[node name="Highlight" type="Panel" parent="." unique_id=715172504]
|
||||
[node name="Highlight" type="Panel" parent="Icon" unique_id=715172504]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
@ -47,13 +49,11 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_qqie6")
|
||||
|
||||
[node name="Area2D2" type="Area2D" parent="." unique_id=1370367200]
|
||||
process_mode = 3
|
||||
position = Vector2(50, 50)
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D2" unique_id=1032001784]
|
||||
shape = SubResource("RectangleShape2D_qqie6")
|
||||
|
||||
[connection signal="gui_input" from="." to="." method="handle_gui_input"]
|
||||
[connection signal="mouse_entered" from="." to="." method="handle_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="handle_mouse_exited"]
|
||||
[connection signal="gui_input" from="Icon" to="." method="handle_gui_input"]
|
||||
[connection signal="mouse_entered" from="Icon" to="." method="handle_turn_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Icon" to="." method="handle_turn_mouse_exited"]
|
||||
|
||||
@ -3,11 +3,29 @@
|
||||
[ext_resource type="PackedScene" uid="uid://cdb6bf7dat3bw" path="res://prefabs/tiles/turns/turn.tscn" id="1_3bmx7"]
|
||||
[ext_resource type="Texture2D" uid="uid://8b86ftb4iwfj" path="res://assets/Pattern-Panic-10x10/no-background/Points-and-Pulses.png" id="2_3ect2"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sl6be"]
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3bmx7"]
|
||||
atlas = ExtResource("2_3ect2")
|
||||
region = Rect2(0, 11, 9, 9)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3ect2"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(1, 1, 1, 0)
|
||||
border_width_left = 5
|
||||
border_width_top = 5
|
||||
border_width_right = 5
|
||||
border_width_bottom = 5
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
expand_margin_left = 8.0
|
||||
expand_margin_top = 8.0
|
||||
expand_margin_right = 8.0
|
||||
expand_margin_bottom = 8.0
|
||||
|
||||
[node name="UpTurn" unique_id=1363157270 instance=ExtResource("1_3bmx7")]
|
||||
texture = SubResource("AtlasTexture_sl6be")
|
||||
flip_v = true
|
||||
direction = 1
|
||||
|
||||
[node name="Icon" parent="." index="0" unique_id=1363157270]
|
||||
texture = SubResource("AtlasTexture_3bmx7")
|
||||
flip_v = true
|
||||
|
||||
[node name="Highlight" parent="Icon" index="0" unique_id=715172504]
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_3ect2")
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extends PanelContainer
|
||||
class_name BuildingSelector extends PanelContainer
|
||||
|
||||
signal select_building(building: Building)
|
||||
|
||||
@ -26,3 +26,12 @@ func _on_mouse_exited() -> void:
|
||||
func _on_gui_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("select"):
|
||||
select_building.emit(get_child(0))
|
||||
|
||||
|
||||
func _on_child_entered_tree(node: Node) -> void:
|
||||
if node is Building:
|
||||
await node.ready
|
||||
if is_instance_valid(node.size_node):
|
||||
custom_minimum_size = node.size_node.size + Vector2(10, 10)
|
||||
node.position = position - node.size_node.position
|
||||
node.position += Vector2(5, 5)
|
||||
|
||||
@ -10,9 +10,12 @@ border_color = Color(1, 1, 1, 1)
|
||||
[node name="BuildingSelector" type="PanelContainer" unique_id=133308872]
|
||||
offset_right = 310.0
|
||||
offset_bottom = 210.0
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_xurng")
|
||||
script = ExtResource("1_xurng")
|
||||
|
||||
[connection signal="child_entered_tree" from="." to="." method="_on_child_entered_tree"]
|
||||
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
|
||||
|
||||
@ -1,24 +1,46 @@
|
||||
class_name Controls extends Control
|
||||
|
||||
const DRAFT_BUILDING_SCENE = preload("uid://87u3upovcueb")
|
||||
|
||||
var rem_tween: Tween
|
||||
var hand_tween: Tween
|
||||
var es_tween: Tween
|
||||
|
||||
@onready var player_1_label: Label = %Player1Label
|
||||
@onready var player_1_money: Label = %Player1Money
|
||||
var draft_building: Building
|
||||
|
||||
@onready var turn_label: Label = %TurnLabel
|
||||
@onready var player_display: PlayerDisplay = %PlayerDisplay
|
||||
|
||||
@onready var submit_button: Button = %Submit
|
||||
@onready var pass_button: Button = %Pass
|
||||
@onready var undo_button: Button = %Undo
|
||||
@onready var pause_button: Button = %Pause
|
||||
@onready var play_button: Button = %Play
|
||||
@onready var blueprints_container: Container = %BlueprintsContainer
|
||||
@onready var rem_button: Button = %RealEstateMarket
|
||||
@onready var start_walls: Button = %StartWalls
|
||||
@onready var stop_walls: Button = %StopWalls
|
||||
@onready var cancel_placement_button: Button = %CancelPlacement
|
||||
|
||||
@onready var blueprints_container: Container = %BlueprintsContainer
|
||||
@onready var draft_container: Container = %DraftContainer
|
||||
@onready var hand: Hand = %Hand
|
||||
|
||||
@onready var fast_1: Button = %FastForward1
|
||||
@onready var fast_2: Button = %FastForward2
|
||||
@onready var fast_4: Button = %FastForward4
|
||||
@onready var fast_10: Button = %FastForward10
|
||||
|
||||
@onready var draft_cost_container: Container = %DraftCost
|
||||
@onready var draft_cost_spinner: SpinBox = %BuildingDraftCost
|
||||
|
||||
|
||||
func give_hand(buildings: Array[Building]) -> void:
|
||||
hand.give_buildings(buildings)
|
||||
print_debug("this sucks!")
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
_show_hand()
|
||||
|
||||
|
||||
func reset_turn() -> void:
|
||||
get_tree().call_group("Pausable", "pause")
|
||||
@ -27,24 +49,63 @@ func reset_turn() -> void:
|
||||
play_button.hide()
|
||||
|
||||
|
||||
func set_turn(turn: int) -> void:
|
||||
turn_label.text = str(turn)
|
||||
func set_info() -> void:
|
||||
turn_label.text = (
|
||||
"%d.%d"
|
||||
% [Globals.board_game.current_board_state.day, Globals.board_game.current_board_state.turn]
|
||||
)
|
||||
player_display.set_players(Globals.board_game.current_board_state.players)
|
||||
|
||||
|
||||
func set_players(players: Array[Player]) -> void:
|
||||
_update_player_info(players[0])
|
||||
players[0].changed.connect(_update_player_info)
|
||||
func check_controls_enabled() -> void:
|
||||
if Globals.board_game.current_board_state.current_player.id == Globals.game.this_player.id:
|
||||
if Globals.board_game.current_board_state.state != BoardState.State.PLAY:
|
||||
pass_button.hide()
|
||||
submit_button.show()
|
||||
rem_button.disabled = true
|
||||
submit_button.disabled = Globals.board_game.pending_board_state == null
|
||||
else:
|
||||
if Globals.board_game.pending_board_state != null:
|
||||
pass_button.hide()
|
||||
submit_button.show()
|
||||
submit_button.disabled = false
|
||||
undo_button.disabled = false
|
||||
rem_button.disabled = true
|
||||
else:
|
||||
pass_button.show()
|
||||
submit_button.hide()
|
||||
submit_button.disabled = true
|
||||
pass_button.disabled = false
|
||||
undo_button.disabled = true
|
||||
rem_button.disabled = false
|
||||
else:
|
||||
pass_button.show()
|
||||
submit_button.hide()
|
||||
rem_button.disabled = true
|
||||
pass_button.disabled = true
|
||||
undo_button.disabled = true
|
||||
submit_button.disabled = true
|
||||
|
||||
|
||||
func _update_player_info(player: Player) -> void:
|
||||
player_1_label.text = "%s:" % player.name
|
||||
player_1_money.text = "$%d" % player.money
|
||||
func end_day() -> void:
|
||||
undo_button.hide()
|
||||
play_button.hide()
|
||||
pause_button.show()
|
||||
pass_button.hide()
|
||||
submit_button.hide()
|
||||
rem_button.disabled = true
|
||||
|
||||
|
||||
func _on_pass_pressed():
|
||||
Globals.board_game.handle_pass()
|
||||
|
||||
|
||||
func _on_submit_pressed():
|
||||
get_tree().call_group("Pausable", "unpause")
|
||||
submit_button.hide()
|
||||
pause_button.show()
|
||||
Globals.board_game.handle_board_state_confirmed()
|
||||
|
||||
|
||||
func _on_undo_pressed():
|
||||
print("TODO: Handle undo!")
|
||||
|
||||
|
||||
func _on_pause_pressed():
|
||||
@ -65,16 +126,20 @@ func _on_blueprints_pressed():
|
||||
|
||||
func handle_tile_selected(tile: Tile):
|
||||
_hide_real_estate_market()
|
||||
Globals.game.select_tile(tile)
|
||||
Globals.board_game.select_tile(tile)
|
||||
|
||||
|
||||
func handle_building_selected(building: Building) -> void:
|
||||
_hide_real_estate_market()
|
||||
Globals.game.select_building(building)
|
||||
var db = building.get_parent().get_parent()
|
||||
if db is DraftBuilding:
|
||||
Globals.board_game.select_building(building, db.get_index())
|
||||
else:
|
||||
Globals.board_game.select_building(building)
|
||||
|
||||
|
||||
func _on_walls_pressed():
|
||||
Globals.game.place_walls()
|
||||
Globals.board_game.place_walls()
|
||||
if start_walls.visible:
|
||||
start_walls.hide()
|
||||
stop_walls.show()
|
||||
@ -90,7 +155,7 @@ func _hide_real_estate_market() -> void:
|
||||
rem_tween = create_tween()
|
||||
rem_tween.set_ignore_time_scale(true)
|
||||
rem_tween.set_trans(Tween.TRANS_BACK)
|
||||
rem_tween.tween_property(blueprints_container, "position:y", -450, 0.5)
|
||||
rem_tween.tween_property(blueprints_container, "offset_bottom", 0, 0.5)
|
||||
|
||||
|
||||
func _show_real_estate_market() -> void:
|
||||
@ -99,7 +164,27 @@ func _show_real_estate_market() -> void:
|
||||
rem_tween = create_tween()
|
||||
rem_tween.set_ignore_time_scale(true)
|
||||
rem_tween.set_trans(Tween.TRANS_BACK)
|
||||
rem_tween.tween_property(blueprints_container, "position:y", 0, 0.5)
|
||||
rem_tween.tween_property(
|
||||
blueprints_container, "offset_bottom", blueprints_container.size.y, 0.5
|
||||
)
|
||||
|
||||
|
||||
func _hide_hand() -> void:
|
||||
if is_instance_valid(hand_tween):
|
||||
hand_tween.kill()
|
||||
hand_tween = create_tween()
|
||||
hand_tween.set_ignore_time_scale(true)
|
||||
hand_tween.set_trans(Tween.TRANS_BACK)
|
||||
hand_tween.tween_property(hand, "offset_top", 0, 0.5)
|
||||
|
||||
|
||||
func _show_hand() -> void:
|
||||
if is_instance_valid(hand_tween):
|
||||
hand_tween.kill()
|
||||
hand_tween = create_tween()
|
||||
hand_tween.set_ignore_time_scale(true)
|
||||
hand_tween.set_trans(Tween.TRANS_BACK)
|
||||
hand_tween.tween_property(hand, "offset_top", -hand.size.y, 0.5)
|
||||
|
||||
|
||||
func _speed_up_engine(speed: float) -> void:
|
||||
@ -140,3 +225,37 @@ func _on_fast_forward_10_pressed():
|
||||
fast_2.hide()
|
||||
fast_4.hide()
|
||||
fast_10.hide()
|
||||
|
||||
|
||||
func _on_cancel_placement_pressed():
|
||||
_hide_real_estate_market()
|
||||
|
||||
|
||||
func _on_hand_building_selected(building: Building) -> void:
|
||||
for selector in hand.buildings_container.get_children():
|
||||
if selector.get_child(0) != building:
|
||||
selector.hide()
|
||||
draft_building = building
|
||||
draft_cost_container.show()
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func add_to_draft(building_data: Dictionary) -> void:
|
||||
Globals.board_game.add_building_to_draft.rpc()
|
||||
var db: DraftBuilding = DRAFT_BUILDING_SCENE.instantiate()
|
||||
draft_container.add_child(db)
|
||||
draft_building = Building.deserialize(building_data)
|
||||
db.set_building(draft_building)
|
||||
db.building_selector.select_building.connect(handle_building_selected)
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func remove_from_draft(draft_building_index: int) -> void:
|
||||
draft_container.get_child(draft_building_index).queue_free()
|
||||
|
||||
|
||||
func _on_set_draft_cost_pressed():
|
||||
_hide_hand()
|
||||
draft_cost_container.hide()
|
||||
draft_building.cost = roundi(draft_cost_spinner.value)
|
||||
add_to_draft.rpc(draft_building.serialize())
|
||||
|
||||
@ -2,19 +2,13 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://cuk0e8hibj3ag" path="res://prefabs/ui/controls.gd" id="1_qhv1l"]
|
||||
[ext_resource type="PackedScene" uid="uid://cisd4grq8kxqn" path="res://prefabs/tiles/turns/up_turn.tscn" id="2_eu1vu"]
|
||||
[ext_resource type="PackedScene" uid="uid://b83rx8vg6w5g2" path="res://prefabs/ui/player_display.tscn" id="2_x41uu"]
|
||||
[ext_resource type="PackedScene" uid="uid://ce25rk1nl0pqn" path="res://prefabs/tiles/turns/right_turn.tscn" id="3_7r4kk"]
|
||||
[ext_resource type="PackedScene" uid="uid://2qudi2d82y73" path="res://prefabs/tiles/turns/down_turn.tscn" id="4_c56vf"]
|
||||
[ext_resource type="PackedScene" uid="uid://7jht5hlggey1" path="res://prefabs/tiles/turns/left_turn.tscn" id="5_dxd6m"]
|
||||
[ext_resource type="PackedScene" uid="uid://cpmlj6muvdwix" path="res://prefabs/ui/building_selector.tscn" id="6_7r4kk"]
|
||||
[ext_resource type="PackedScene" uid="uid://mixrqf035krk" path="res://prefabs/tiles/buildings/office.tscn" id="7_c56vf"]
|
||||
[ext_resource type="PackedScene" uid="uid://bto4vblqk2inb" path="res://prefabs/tiles/buildings/home.tscn" id="7_dxd6m"]
|
||||
[ext_resource type="PackedScene" uid="uid://bytldu3y1jak3" path="res://prefabs/tiles/buildings/hospital.tscn" id="9_j4kb6"]
|
||||
[ext_resource type="PackedScene" uid="uid://c06fsqdixer1c" path="res://prefabs/tiles/buildings/bank.tscn" id="10_wxj2g"]
|
||||
[ext_resource type="PackedScene" uid="uid://cfk268flnsbhb" path="res://prefabs/tiles/buildings/bar.tscn" id="11_sttyi"]
|
||||
[ext_resource type="PackedScene" uid="uid://dbn63mv0peqf" path="res://prefabs/tiles/buildings/shop.tscn" id="12_w3n6g"]
|
||||
[ext_resource type="PackedScene" uid="uid://bgtw051fiveeo" path="res://prefabs/tiles/buildings/cafe.tscn" id="13_di23u"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1kyedmrep0tu" path="res://prefabs/tiles/buildings/gun_shop.tscn" id="14_hlhh6"]
|
||||
[ext_resource type="PackedScene" uid="uid://cphy0vtj14ob0" path="res://prefabs/tiles/buildings/fork.tscn" id="15_j8v8t"]
|
||||
[ext_resource type="Script" uid="uid://s7x0q87dps5d" path="res://prefabs/ui/hand.gd" id="17_r0188"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_qhv1l"]
|
||||
font_size = 24
|
||||
@ -39,55 +33,28 @@ font_size = 24
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_7r4kk"]
|
||||
font_size = 32
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_j8v8t"]
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_j4kb6"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(0, 0, 0, 0)
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_c56vf"]
|
||||
font_size = 32
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_wxj2g"]
|
||||
content_margin_left = 10.0
|
||||
content_margin_top = 10.0
|
||||
content_margin_right = 10.0
|
||||
content_margin_bottom = 10.0
|
||||
bg_color = Color(0, 0, 0, 0.5)
|
||||
corner_radius_top_left = 8
|
||||
corner_radius_top_right = 8
|
||||
expand_margin_bottom = 100.0
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_x41uu"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(0, 0, 0, 0)
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_sttyi"]
|
||||
bg_color = Color(0, 0, 0, 0.75000006)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_r0188"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(0, 0, 0, 0)
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
[sub_resource type="Theme" id="Theme_w3n6g"]
|
||||
LineEdit/font_sizes/font_size = 32
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5qo6s"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(0, 0, 0, 0)
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_uprus"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(0, 0, 0, 0)
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_uqvfp"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(0, 0, 0, 0)
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dp4q7"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(0, 0, 0, 0)
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qqsac"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(0, 0, 0, 0)
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pc2vv"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(0, 0, 0, 0)
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
|
||||
[node name="Info" type="Control" unique_id=1719205711]
|
||||
[node name="Controls" type="Control" unique_id=1719205711]
|
||||
process_mode = 3
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
@ -112,11 +79,25 @@ layout_mode = 2
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="Submit" type="Button" parent="HBoxContainer/Controls" unique_id=1480835490]
|
||||
[node name="Undo" type="Button" parent="HBoxContainer/Controls" unique_id=1480835490]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "End Turn"
|
||||
disabled = true
|
||||
text = "Undo"
|
||||
|
||||
[node name="Pass" type="Button" parent="HBoxContainer/Controls" unique_id=1183096687]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "Pass"
|
||||
|
||||
[node name="Submit" type="Button" parent="HBoxContainer/Controls" unique_id=122864337]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Confirm"
|
||||
|
||||
[node name="Pause" type="Button" parent="HBoxContainer/Controls" unique_id=262580515]
|
||||
unique_name_in_owner = true
|
||||
@ -181,72 +162,60 @@ layout_mode = 2
|
||||
text = "0"
|
||||
label_settings = SubResource("LabelSettings_qhv1l")
|
||||
|
||||
[node name="PlayersContainer" type="HBoxContainer" parent="HBoxContainer/Info" unique_id=1863734551]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="Player1" type="HBoxContainer" parent="HBoxContainer/Info/PlayersContainer" unique_id=810506541]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="Player1Label" type="Label" parent="HBoxContainer/Info/PlayersContainer/Player1" unique_id=227651304]
|
||||
[node name="PlayerDisplay" parent="HBoxContainer/Info" unique_id=1256387228 instance=ExtResource("2_x41uu")]
|
||||
unique_name_in_owner = true
|
||||
z_index = 1
|
||||
layout_mode = 2
|
||||
text = "Player:"
|
||||
label_settings = SubResource("LabelSettings_qhv1l")
|
||||
|
||||
[node name="Player1Money" type="Label" parent="HBoxContainer/Info/PlayersContainer/Player1" unique_id=1445460948]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "$0"
|
||||
label_settings = SubResource("LabelSettings_qhv1l")
|
||||
|
||||
[node name="TechTree" type="HBoxContainer" parent="HBoxContainer" unique_id=190914575]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 10
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="Blueprints" type="Button" parent="HBoxContainer/TechTree" unique_id=910784690]
|
||||
[node name="RealEstateMarket" type="Button" parent="HBoxContainer/TechTree" unique_id=910784690]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Real Estate Market"
|
||||
|
||||
[node name="BlueprintsContainer" type="PanelContainer" parent="." unique_id=203025650]
|
||||
unique_name_in_owner = true
|
||||
top_level = true
|
||||
z_index = 1
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchors_preset = -1
|
||||
anchor_right = 1.0
|
||||
offset_top = -450.0
|
||||
offset_bottom = -3.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_qhv1l")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="BlueprintsContainer" unique_id=760987938]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="BlueprintsContainer" unique_id=2121800615]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 40
|
||||
|
||||
[node name="Button" type="Button" parent="BlueprintsContainer/HBoxContainer" unique_id=1945532062]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="BlueprintsContainer/VBoxContainer" unique_id=760987938]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 50
|
||||
alignment = 1
|
||||
|
||||
[node name="CancelPlacement" type="Button" parent="BlueprintsContainer/VBoxContainer/HBoxContainer" unique_id=1945532062]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
text = "Cancel Placement"
|
||||
|
||||
[node name="Walls" type="VBoxContainer" parent="BlueprintsContainer/HBoxContainer" unique_id=412374904]
|
||||
[node name="Walls" type="VBoxContainer" parent="BlueprintsContainer/VBoxContainer/HBoxContainer" unique_id=412374904]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/HBoxContainer/Walls" unique_id=1668814316]
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/Walls" unique_id=1668814316]
|
||||
layout_mode = 2
|
||||
text = "Walls - $1"
|
||||
label_settings = SubResource("LabelSettings_eu1vu")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="StartWalls" type="Button" parent="BlueprintsContainer/HBoxContainer/Walls" unique_id=645460925]
|
||||
[node name="StartWalls" type="Button" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/Walls" unique_id=645460925]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(150, 150)
|
||||
layout_mode = 2
|
||||
@ -254,7 +223,7 @@ size_flags_vertical = 6
|
||||
theme_override_colors/font_color = Color(1, 0, 0, 1)
|
||||
text = "Place Walls"
|
||||
|
||||
[node name="StopWalls" type="Button" parent="BlueprintsContainer/HBoxContainer/Walls" unique_id=2066303633]
|
||||
[node name="StopWalls" type="Button" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/Walls" unique_id=2066303633]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(150, 150)
|
||||
@ -264,209 +233,145 @@ theme_override_colors/font_color = Color(1, 0, 0, 1)
|
||||
text = "Stop Placing
|
||||
Walls"
|
||||
|
||||
[node name="BasicTiles" type="VBoxContainer" parent="BlueprintsContainer/HBoxContainer" unique_id=1403203958]
|
||||
[node name="BasicTiles" type="VBoxContainer" parent="BlueprintsContainer/VBoxContainer/HBoxContainer" unique_id=1403203958]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 16
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/HBoxContainer/BasicTiles" unique_id=1978827830]
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles" unique_id=1978827830]
|
||||
layout_mode = 2
|
||||
text = "Basic Tiles - $1"
|
||||
label_settings = SubResource("LabelSettings_j4kb6")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="BlueprintsContainer/HBoxContainer/BasicTiles" unique_id=219963427]
|
||||
[node name="GridContainer" type="GridContainer" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles" unique_id=219963427]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 6
|
||||
theme_override_constants/h_separation = 10
|
||||
theme_override_constants/v_separation = 10
|
||||
columns = 2
|
||||
columns = 4
|
||||
|
||||
[node name="UpTurn" parent="BlueprintsContainer/HBoxContainer/BasicTiles/GridContainer" unique_id=1363157270 instance=ExtResource("2_eu1vu")]
|
||||
[node name="Up" type="Control" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer" unique_id=748424964]
|
||||
custom_minimum_size = Vector2(110, 110)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="RightTurn" parent="BlueprintsContainer/HBoxContainer/BasicTiles/GridContainer" unique_id=1688209745 instance=ExtResource("3_7r4kk")]
|
||||
[node name="UpTurn" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer/Up" unique_id=1363157270 instance=ExtResource("2_eu1vu")]
|
||||
position = Vector2(55, 55)
|
||||
cost = 1
|
||||
|
||||
[node name="Right" type="Control" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer" unique_id=1274279814]
|
||||
custom_minimum_size = Vector2(110, 110)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DownTurn" parent="BlueprintsContainer/HBoxContainer/BasicTiles/GridContainer" unique_id=269046840 instance=ExtResource("4_c56vf")]
|
||||
[node name="RightTurn" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer/Right" unique_id=1688209745 instance=ExtResource("3_7r4kk")]
|
||||
position = Vector2(55, 55)
|
||||
cost = 1
|
||||
|
||||
[node name="Down" type="Control" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer" unique_id=871055726]
|
||||
custom_minimum_size = Vector2(110, 110)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LeftTurn" parent="BlueprintsContainer/HBoxContainer/BasicTiles/GridContainer" unique_id=1788133401 instance=ExtResource("5_dxd6m")]
|
||||
[node name="DownTurn" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer/Down" unique_id=269046840 instance=ExtResource("4_c56vf")]
|
||||
position = Vector2(55, 55)
|
||||
cost = 1
|
||||
|
||||
[node name="Left" type="Control" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer" unique_id=496620027]
|
||||
custom_minimum_size = Vector2(110, 110)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Home" type="VBoxContainer" parent="BlueprintsContainer/HBoxContainer" unique_id=85382159]
|
||||
[node name="LeftTurn" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer/Left" unique_id=1788133401 instance=ExtResource("5_dxd6m")]
|
||||
position = Vector2(55, 55)
|
||||
cost = 1
|
||||
|
||||
[node name="Home" type="VBoxContainer" parent="BlueprintsContainer/VBoxContainer/HBoxContainer" unique_id=85382159]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/HBoxContainer/Home" unique_id=70473481]
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/Home" unique_id=70473481]
|
||||
layout_mode = 2
|
||||
text = "Home - $2"
|
||||
label_settings = SubResource("LabelSettings_7r4kk")
|
||||
|
||||
[node name="BuildingSelector" parent="BlueprintsContainer/HBoxContainer/Home" unique_id=133308872 instance=ExtResource("6_7r4kk")]
|
||||
custom_minimum_size = Vector2(110, 110)
|
||||
[node name="BuildingSelector" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/Home" unique_id=133308872 instance=ExtResource("6_7r4kk")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 6
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_j8v8t")
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_j4kb6")
|
||||
|
||||
[node name="Home" parent="BlueprintsContainer/HBoxContainer/Home/BuildingSelector" unique_id=1701297833 instance=ExtResource("7_dxd6m")]
|
||||
position = Vector2(55, 55)
|
||||
[node name="Home" parent="BlueprintsContainer/VBoxContainer/HBoxContainer/Home/BuildingSelector" unique_id=1701297833 instance=ExtResource("7_dxd6m")]
|
||||
cost = 2
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="BlueprintsContainer/HBoxContainer" unique_id=2014532559]
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="BlueprintsContainer/VBoxContainer" unique_id=2014532559]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
vertical_scroll_mode = 0
|
||||
|
||||
[node name="Buildings" type="HBoxContainer" parent="BlueprintsContainer/HBoxContainer/ScrollContainer" unique_id=86083788]
|
||||
[node name="DraftContainer" type="HBoxContainer" parent="BlueprintsContainer/VBoxContainer/ScrollContainer" unique_id=86083788]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 40
|
||||
alignment = 1
|
||||
|
||||
[node name="Building 1" type="VBoxContainer" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings" unique_id=1903803082]
|
||||
[node name="Hand" type="PanelContainer" parent="." unique_id=1020425982]
|
||||
unique_name_in_owner = true
|
||||
top_level = true
|
||||
z_index = 1
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_wxj2g")
|
||||
script = ExtResource("17_r0188")
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="Hand" unique_id=1666098920]
|
||||
layout_mode = 2
|
||||
vertical_scroll_mode = 0
|
||||
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 1" unique_id=1748038090]
|
||||
[node name="BuildingsContainer" type="HBoxContainer" parent="Hand/ScrollContainer" unique_id=1415065108]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "$4"
|
||||
label_settings = SubResource("LabelSettings_c56vf")
|
||||
horizontal_alignment = 1
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
alignment = 1
|
||||
|
||||
[node name="BuildingSelector" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 1" unique_id=360195179 instance=ExtResource("6_7r4kk")]
|
||||
custom_minimum_size = Vector2(340, 230)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 6
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_x41uu")
|
||||
[node name="DraftCost" type="PanelContainer" parent="." unique_id=598181961]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
top_level = true
|
||||
z_index = 1
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_sttyi")
|
||||
|
||||
[node name="Office" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 1/BuildingSelector" unique_id=746270571 instance=ExtResource("7_c56vf")]
|
||||
position = Vector2(60, 170)
|
||||
|
||||
[node name="Building 2" type="VBoxContainer" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings" unique_id=627681188]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 2" unique_id=1716667180]
|
||||
layout_mode = 2
|
||||
text = "$6"
|
||||
label_settings = SubResource("LabelSettings_c56vf")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="BuildingSelector" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 2" unique_id=307256822 instance=ExtResource("6_7r4kk")]
|
||||
custom_minimum_size = Vector2(530, 265)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 6
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_r0188")
|
||||
|
||||
[node name="Hospital" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 2/BuildingSelector" unique_id=1503172438 instance=ExtResource("9_j4kb6")]
|
||||
position = Vector2(100, 205)
|
||||
|
||||
[node name="Building 3" type="VBoxContainer" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings" unique_id=975407660]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 3" unique_id=795918073]
|
||||
layout_mode = 2
|
||||
text = "$4"
|
||||
label_settings = SubResource("LabelSettings_c56vf")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="BuildingSelector" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 3" unique_id=583706447 instance=ExtResource("6_7r4kk")]
|
||||
custom_minimum_size = Vector2(230, 270)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 6
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_5qo6s")
|
||||
|
||||
[node name="Bank" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 3/BuildingSelector" unique_id=973905773 instance=ExtResource("10_wxj2g")]
|
||||
position = Vector2(60, 210)
|
||||
|
||||
[node name="Building 4" type="VBoxContainer" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings" unique_id=1457851442]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 4" unique_id=350026086]
|
||||
layout_mode = 2
|
||||
text = "$8"
|
||||
label_settings = SubResource("LabelSettings_c56vf")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="BuildingSelector" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 4" unique_id=136723991 instance=ExtResource("6_7r4kk")]
|
||||
custom_minimum_size = Vector2(120, 310)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 6
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_uprus")
|
||||
|
||||
[node name="Bar" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 4/BuildingSelector" unique_id=2099013183 instance=ExtResource("11_sttyi")]
|
||||
position = Vector2(60, 210)
|
||||
|
||||
[node name="Building 5" type="VBoxContainer" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings" unique_id=547829632]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 5" unique_id=1524450412]
|
||||
layout_mode = 2
|
||||
text = "$8"
|
||||
label_settings = SubResource("LabelSettings_c56vf")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="BuildingSelector" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 5" unique_id=1337834576 instance=ExtResource("6_7r4kk")]
|
||||
custom_minimum_size = Vector2(270, 270)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 6
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_uqvfp")
|
||||
|
||||
[node name="Shop" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 5/BuildingSelector" unique_id=40225851 instance=ExtResource("12_w3n6g")]
|
||||
position = Vector2(60, 170)
|
||||
|
||||
[node name="Building 6" type="VBoxContainer" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings" unique_id=399299260]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 6" unique_id=1107358043]
|
||||
layout_mode = 2
|
||||
text = "$4"
|
||||
label_settings = SubResource("LabelSettings_c56vf")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="BuildingSelector" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 6" unique_id=329766743 instance=ExtResource("6_7r4kk")]
|
||||
custom_minimum_size = Vector2(420, 230)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 6
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_dp4q7")
|
||||
|
||||
[node name="Cafe" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 6/BuildingSelector" unique_id=1788365156 instance=ExtResource("13_di23u")]
|
||||
position = Vector2(100, 170)
|
||||
|
||||
[node name="Building 7" type="VBoxContainer" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings" unique_id=1881374967]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 7" unique_id=1332832346]
|
||||
layout_mode = 2
|
||||
text = "$4"
|
||||
label_settings = SubResource("LabelSettings_c56vf")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="BuildingSelector" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 7" unique_id=1207846400 instance=ExtResource("6_7r4kk")]
|
||||
custom_minimum_size = Vector2(380, 380)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 6
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_qqsac")
|
||||
|
||||
[node name="GunShop" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 7/BuildingSelector" unique_id=1685600790 instance=ExtResource("14_hlhh6")]
|
||||
position = Vector2(60, 280)
|
||||
|
||||
[node name="Building 8" type="VBoxContainer" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings" unique_id=1965375524]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 8" unique_id=2137971598]
|
||||
layout_mode = 2
|
||||
text = "$3"
|
||||
label_settings = SubResource("LabelSettings_7r4kk")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="BuildingSelector" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 8" unique_id=718642175 instance=ExtResource("6_7r4kk")]
|
||||
custom_minimum_size = Vector2(200, 155)
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="DraftCost" unique_id=1936528719]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 6
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_pc2vv")
|
||||
size_flags_vertical = 4
|
||||
alignment = 1
|
||||
|
||||
[node name="Fork" parent="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 8/BuildingSelector" unique_id=923842683 instance=ExtResource("15_j8v8t")]
|
||||
position = Vector2(100, 60)
|
||||
[node name="BuildingDraftCost" type="SpinBox" parent="DraftCost/VBoxContainer" unique_id=253715570]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_w3n6g")
|
||||
theme_override_constants/buttons_width = 32
|
||||
rounded = true
|
||||
alignment = 1
|
||||
prefix = "$"
|
||||
custom_arrow_step = 1.0
|
||||
|
||||
[node name="SetDraftCost" type="Button" parent="DraftCost/VBoxContainer" unique_id=1834900983]
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Set Cost"
|
||||
|
||||
[connection signal="pressed" from="HBoxContainer/Controls/Undo" to="." method="_on_undo_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/Controls/Pass" to="." method="_on_pass_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/Controls/Submit" to="." method="_on_submit_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/Controls/Pause" to="." method="_on_pause_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/Controls/Play" to="." method="_on_play_pressed"]
|
||||
@ -474,19 +379,14 @@ position = Vector2(100, 60)
|
||||
[connection signal="pressed" from="HBoxContainer/Controls/FastForward2" to="." method="_on_fast_forward_2_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/Controls/FastForward4" to="." method="_on_fast_forward_4_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/Controls/FastForward10" to="." method="_on_fast_forward_10_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/TechTree/Blueprints" to="." method="_on_blueprints_pressed"]
|
||||
[connection signal="pressed" from="BlueprintsContainer/HBoxContainer/Walls/StartWalls" to="." method="_on_walls_pressed"]
|
||||
[connection signal="pressed" from="BlueprintsContainer/HBoxContainer/Walls/StopWalls" to="." method="_on_walls_pressed"]
|
||||
[connection signal="tile_selected" from="BlueprintsContainer/HBoxContainer/BasicTiles/GridContainer/UpTurn" to="." method="handle_tile_selected"]
|
||||
[connection signal="tile_selected" from="BlueprintsContainer/HBoxContainer/BasicTiles/GridContainer/RightTurn" to="." method="handle_tile_selected"]
|
||||
[connection signal="tile_selected" from="BlueprintsContainer/HBoxContainer/BasicTiles/GridContainer/DownTurn" to="." method="handle_tile_selected"]
|
||||
[connection signal="tile_selected" from="BlueprintsContainer/HBoxContainer/BasicTiles/GridContainer/LeftTurn" to="." method="handle_tile_selected"]
|
||||
[connection signal="select_building" from="BlueprintsContainer/HBoxContainer/Home/BuildingSelector" to="." method="handle_building_selected"]
|
||||
[connection signal="select_building" from="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 1/BuildingSelector" to="." method="handle_building_selected"]
|
||||
[connection signal="select_building" from="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 2/BuildingSelector" to="." method="handle_building_selected"]
|
||||
[connection signal="select_building" from="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 3/BuildingSelector" to="." method="handle_building_selected"]
|
||||
[connection signal="select_building" from="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 4/BuildingSelector" to="." method="handle_building_selected"]
|
||||
[connection signal="select_building" from="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 5/BuildingSelector" to="." method="handle_building_selected"]
|
||||
[connection signal="select_building" from="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 6/BuildingSelector" to="." method="handle_building_selected"]
|
||||
[connection signal="select_building" from="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 7/BuildingSelector" to="." method="handle_building_selected"]
|
||||
[connection signal="select_building" from="BlueprintsContainer/HBoxContainer/ScrollContainer/Buildings/Building 8/BuildingSelector" to="." method="handle_building_selected"]
|
||||
[connection signal="pressed" from="HBoxContainer/TechTree/RealEstateMarket" to="." method="_on_blueprints_pressed"]
|
||||
[connection signal="pressed" from="BlueprintsContainer/VBoxContainer/HBoxContainer/CancelPlacement" to="." method="_on_cancel_placement_pressed"]
|
||||
[connection signal="pressed" from="BlueprintsContainer/VBoxContainer/HBoxContainer/Walls/StartWalls" to="." method="_on_walls_pressed"]
|
||||
[connection signal="pressed" from="BlueprintsContainer/VBoxContainer/HBoxContainer/Walls/StopWalls" to="." method="_on_walls_pressed"]
|
||||
[connection signal="tile_selected" from="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer/Up/UpTurn" to="." method="handle_tile_selected"]
|
||||
[connection signal="tile_selected" from="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer/Right/RightTurn" to="." method="handle_tile_selected"]
|
||||
[connection signal="tile_selected" from="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer/Down/DownTurn" to="." method="handle_tile_selected"]
|
||||
[connection signal="tile_selected" from="BlueprintsContainer/VBoxContainer/HBoxContainer/BasicTiles/GridContainer/Left/LeftTurn" to="." method="handle_tile_selected"]
|
||||
[connection signal="select_building" from="BlueprintsContainer/VBoxContainer/HBoxContainer/Home/BuildingSelector" to="." method="handle_building_selected"]
|
||||
[connection signal="building_selected" from="Hand" to="." method="_on_hand_building_selected"]
|
||||
[connection signal="pressed" from="DraftCost/VBoxContainer/SetDraftCost" to="." method="_on_set_draft_cost_pressed"]
|
||||
|
||||
9
prefabs/ui/draft_building.gd
Normal file
9
prefabs/ui/draft_building.gd
Normal file
@ -0,0 +1,9 @@
|
||||
class_name DraftBuilding extends VBoxContainer
|
||||
|
||||
@onready var cost_label: Label = %Cost
|
||||
@onready var building_selector: BuildingSelector = %BuildingSelector
|
||||
|
||||
|
||||
func set_building(building: Building) -> void:
|
||||
cost_label.text = "$%d" % building.cost
|
||||
building_selector.add_child(building)
|
||||
1
prefabs/ui/draft_building.gd.uid
Normal file
1
prefabs/ui/draft_building.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://b55t6tsxfbslo
|
||||
32
prefabs/ui/draft_building.tscn
Normal file
32
prefabs/ui/draft_building.tscn
Normal file
@ -0,0 +1,32 @@
|
||||
[gd_scene format=3 uid="uid://87u3upovcueb"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cpmlj6muvdwix" path="res://prefabs/ui/building_selector.tscn" id="1_4y2me"]
|
||||
[ext_resource type="Script" uid="uid://b55t6tsxfbslo" path="res://prefabs/ui/draft_building.gd" id="1_k5a3v"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_k5a3v"]
|
||||
font_size = 24
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_k5a3v"]
|
||||
resource_local_to_scene = true
|
||||
bg_color = Color(0, 0, 0, 0)
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
|
||||
[node name="DraftBuilding" type="VBoxContainer" unique_id=873203889]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_k5a3v")
|
||||
|
||||
[node name="Cost" type="Label" parent="." unique_id=935142686]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "$0"
|
||||
label_settings = SubResource("LabelSettings_k5a3v")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="BuildingSelector" parent="." unique_id=133308872 instance=ExtResource("1_4y2me")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_k5a3v")
|
||||
6
prefabs/ui/game_over.gd
Normal file
6
prefabs/ui/game_over.gd
Normal file
@ -0,0 +1,6 @@
|
||||
extends PanelContainer
|
||||
|
||||
|
||||
func set_winning_player(player: Player) -> void:
|
||||
get_child(0).get_child(0).text = player.name
|
||||
show()
|
||||
1
prefabs/ui/game_over.gd.uid
Normal file
1
prefabs/ui/game_over.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bye5rf7kk0qi7
|
||||
22
prefabs/ui/hand.gd
Normal file
22
prefabs/ui/hand.gd
Normal file
@ -0,0 +1,22 @@
|
||||
class_name Hand extends PanelContainer
|
||||
|
||||
signal building_selected(building: Building)
|
||||
|
||||
const BUILDING_SELECTOR_SCENE = preload("uid://cpmlj6muvdwix")
|
||||
|
||||
@onready var buildings_container: Container = %BuildingsContainer
|
||||
|
||||
|
||||
func give_buildings(buildings: Array[Building]) -> void:
|
||||
for child in buildings_container.get_children():
|
||||
child.free()
|
||||
for building in buildings:
|
||||
var selector: BuildingSelector = BUILDING_SELECTOR_SCENE.instantiate()
|
||||
selector.select_building.connect(building_selected.emit)
|
||||
selector.call_deferred("add_child", building.duplicate())
|
||||
buildings_container.call_deferred("add_child", selector)
|
||||
|
||||
|
||||
func _handle_building_selected(_building: Building) -> void:
|
||||
for child in buildings_container.get_children():
|
||||
child.queue_free()
|
||||
1
prefabs/ui/hand.gd.uid
Normal file
1
prefabs/ui/hand.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://s7x0q87dps5d
|
||||
66
prefabs/ui/player_display.gd
Normal file
66
prefabs/ui/player_display.gd
Normal file
@ -0,0 +1,66 @@
|
||||
class_name PlayerDisplay extends Control
|
||||
|
||||
const PLAYER_INFO_SCENE = preload("uid://8sd8fkx3hua0")
|
||||
|
||||
var reveal_tween: Tween
|
||||
|
||||
#func _ready() -> void:
|
||||
#var player_1 = Player.new()
|
||||
#player_1.name = "Duncan"
|
||||
#player_1.color = Color.AQUA
|
||||
#var player_2 = Player.new()
|
||||
#player_2.name = "Tyler"
|
||||
#player_2.color = Color.CHARTREUSE
|
||||
#var player_3 = Player.new()
|
||||
#player_3.name = "Rob"
|
||||
#player_3.color = Color.DARK_MAGENTA
|
||||
#var player_4 = Player.new()
|
||||
#player_4.name = "Lucas"
|
||||
#player_4.color = Color.YELLOW
|
||||
#set_players([player_1, player_2, player_3, player_4])
|
||||
|
||||
|
||||
func set_players(players: Array[Player]) -> void:
|
||||
for child in get_children():
|
||||
child.free()
|
||||
for player in players:
|
||||
var player_info: PlayerInfo = PLAYER_INFO_SCENE.instantiate()
|
||||
add_child(player_info)
|
||||
player_info.set_player(player)
|
||||
player_info.modulate = Color(1, 1, 1, 0)
|
||||
get_child(0).modulate = Color(1, 1, 1, 1)
|
||||
await get_tree().process_frame
|
||||
var max_child_size: float = 0
|
||||
for i in range(get_child_count() - 1):
|
||||
max_child_size = maxf(max_child_size, maxf(get_child(i).size.x, get_child(i + 1).size.x))
|
||||
custom_minimum_size = Vector2(max_child_size, get_child(0).size.y)
|
||||
|
||||
|
||||
func _on_mouse_entered():
|
||||
_reveal_players()
|
||||
|
||||
|
||||
func _on_mouse_exited():
|
||||
_hide_players()
|
||||
|
||||
|
||||
func _reveal_players() -> void:
|
||||
if get_child_count() <= 1:
|
||||
return
|
||||
if is_instance_valid(reveal_tween):
|
||||
reveal_tween.kill()
|
||||
reveal_tween = create_tween()
|
||||
for i in range(1, get_child_count()):
|
||||
reveal_tween.parallel().tween_property(get_child(i), "modulate", Color(1, 1, 1, 1), 0.25)
|
||||
reveal_tween.parallel().tween_property(get_child(i), "position", Vector2(0, 40 * i), 0.25)
|
||||
|
||||
|
||||
func _hide_players() -> void:
|
||||
if get_child_count() <= 1:
|
||||
return
|
||||
if is_instance_valid(reveal_tween):
|
||||
reveal_tween.kill()
|
||||
reveal_tween = create_tween()
|
||||
for i in range(1, get_child_count()):
|
||||
reveal_tween.parallel().tween_property(get_child(i), "modulate", Color(1, 1, 1, 0), 0.25)
|
||||
reveal_tween.parallel().tween_property(get_child(i), "position", Vector2(0, 0), 0.25)
|
||||
1
prefabs/ui/player_display.gd.uid
Normal file
1
prefabs/ui/player_display.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bq8y83dlpxlv
|
||||
12
prefabs/ui/player_display.tscn
Normal file
12
prefabs/ui/player_display.tscn
Normal file
@ -0,0 +1,12 @@
|
||||
[gd_scene format=3 uid="uid://b83rx8vg6w5g2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bq8y83dlpxlv" path="res://prefabs/ui/player_display.gd" id="1_kasli"]
|
||||
|
||||
[node name="PlayerDisplay" type="Control" unique_id=1256387228]
|
||||
custom_minimum_size = Vector2(0, 40)
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_kasli")
|
||||
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
|
||||
15
prefabs/ui/player_info.gd
Normal file
15
prefabs/ui/player_info.gd
Normal file
@ -0,0 +1,15 @@
|
||||
class_name PlayerInfo extends HBoxContainer
|
||||
|
||||
@onready var name_label: Label = %Name
|
||||
@onready var money_label: Label = %Money
|
||||
|
||||
|
||||
func set_player(player: Player) -> void:
|
||||
player.changed.connect(_update_player_info)
|
||||
name_label.text = player.name
|
||||
name_label.label_settings.font_color = player.color
|
||||
money_label.text = "$%s" % str(player.money)
|
||||
|
||||
|
||||
func _update_player_info(player: Player) -> void:
|
||||
money_label.text = "$%s" % str(player.money)
|
||||
1
prefabs/ui/player_info.gd.uid
Normal file
1
prefabs/ui/player_info.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://ccx3jyc31veok
|
||||
32
prefabs/ui/player_info.tscn
Normal file
32
prefabs/ui/player_info.tscn
Normal file
@ -0,0 +1,32 @@
|
||||
[gd_scene format=3 uid="uid://8sd8fkx3hua0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ccx3jyc31veok" path="res://prefabs/ui/player_info.gd" id="1_tautg"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_lpiko"]
|
||||
resource_local_to_scene = true
|
||||
font_size = 24
|
||||
outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_tautg"]
|
||||
font_size = 24
|
||||
font_color = Color(0, 0, 0, 1)
|
||||
outline_size = 4
|
||||
|
||||
[node name="PlayerInfo" type="HBoxContainer" unique_id=1335388560]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
theme_override_constants/separation = 16
|
||||
script = ExtResource("1_tautg")
|
||||
|
||||
[node name="Name" type="Label" parent="." unique_id=402118000]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Player"
|
||||
label_settings = SubResource("LabelSettings_lpiko")
|
||||
|
||||
[node name="Money" type="Label" parent="." unique_id=303974868]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "$0"
|
||||
label_settings = SubResource("LabelSettings_tautg")
|
||||
@ -23,6 +23,12 @@ Globals="*uid://by6sqqjd2g0ct"
|
||||
|
||||
enabled=PackedStringArray("res://addons/format_on_save/plugin.cfg", "res://addons/gdlint_plugin/plugin.cfg", "res://addons/tube/plugin.cfg")
|
||||
|
||||
[game]
|
||||
|
||||
config/use_web_tube_context=true
|
||||
config/use_web_tube_context.editor_hint=false
|
||||
config/use_web_tube_context.editor_runtime=false
|
||||
|
||||
[global_group]
|
||||
|
||||
Pausable="Only activates on turn end."
|
||||
@ -94,6 +100,12 @@ rotate_tile_down={
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":16,"position":Vector2(228, 11),"global_position":Vector2(237, 59),"factor":1.0,"button_index":5,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
camera_engage={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
||||
56
resources/board_state.gd
Normal file
56
resources/board_state.gd
Normal file
@ -0,0 +1,56 @@
|
||||
class_name BoardState
|
||||
|
||||
enum State { INITIAL_SETUP, DRAFT, PLAY }
|
||||
|
||||
var day: int = 0
|
||||
var turn: int = 0
|
||||
var state: State = State.INITIAL_SETUP
|
||||
var current_player: Player
|
||||
var players: Array[Player] = []
|
||||
var tiles: Array[Tile] = []
|
||||
var buildings: Array[Building] = []
|
||||
var players_passed: int = 0
|
||||
|
||||
|
||||
func get_this_player_index() -> int:
|
||||
return players.find_custom(func(p: Player) -> bool: return p.id == Globals.game.this_player.id)
|
||||
|
||||
|
||||
func get_current_player_index() -> int:
|
||||
return players.find_custom(func(p: Player) -> bool: return p.id == current_player.id)
|
||||
|
||||
|
||||
func serialize() -> Dictionary:
|
||||
var result = {}
|
||||
result["day"] = day
|
||||
result["turn"] = turn
|
||||
result["state"] = state
|
||||
result["players_passed"] = players_passed
|
||||
result["current_player"] = current_player.serialize()
|
||||
result["players"] = []
|
||||
for p in players:
|
||||
result["players"].append(p.serialize())
|
||||
result["tiles"] = []
|
||||
for t in tiles:
|
||||
if is_instance_valid(t):
|
||||
result["tiles"].append(t.serialize())
|
||||
result["buildings"] = []
|
||||
for b in buildings:
|
||||
result["buildings"].append(b.serialize())
|
||||
return result
|
||||
|
||||
|
||||
static func deserialize(data: Dictionary) -> BoardState:
|
||||
var result = BoardState.new()
|
||||
result.day = data["day"]
|
||||
result.turn = data["turn"]
|
||||
result.state = data["state"]
|
||||
result.players_passed = data["players_passed"]
|
||||
result.current_player = Player.deserialize(data["current_player"])
|
||||
for p in data["players"]:
|
||||
result.players.append(Player.deserialize(p))
|
||||
for t in data["tiles"]:
|
||||
result.tiles.append(Tile.deserialize(t))
|
||||
for b in data["buildings"]:
|
||||
result.buildings.append(Building.deserialize(b))
|
||||
return result
|
||||
1
resources/board_state.gd.uid
Normal file
1
resources/board_state.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bjr1m1p8m265o
|
||||
@ -1,3 +1,5 @@
|
||||
class_name GlobalController extends Node
|
||||
|
||||
var game: Game
|
||||
var main_menu: MainMenu
|
||||
var board_game: BoardGame
|
||||
|
||||
8
resources/local_tube_context.tres
Normal file
8
resources/local_tube_context.tres
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_resource type="Resource" script_class="TubeContext" format=3 uid="uid://c4wgewmmuj74g"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://t4pe7yqc3pnt" path="res://addons/tube/tube_context.gd" id="1_h3gtd"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_h3gtd")
|
||||
app_id = "g^o#isR0W!x|+?8"
|
||||
metadata/_custom_type_script = "uid://t4pe7yqc3pnt"
|
||||
@ -1,8 +1,27 @@
|
||||
class_name Player extends Resource
|
||||
|
||||
var id: int = randi()
|
||||
var name: String = "Player"
|
||||
var money: int = 10:
|
||||
set(value):
|
||||
money = value
|
||||
changed.emit(self)
|
||||
var color: Color = Color(0, 0, 1, 1)
|
||||
var color: Color = Color(randf(), randf(), randf())
|
||||
|
||||
|
||||
func serialize() -> Dictionary:
|
||||
var result = {}
|
||||
result["id"] = id
|
||||
result["name"] = name
|
||||
result["color"] = color
|
||||
result["money"] = money
|
||||
return result
|
||||
|
||||
|
||||
static func deserialize(data: Dictionary) -> Player:
|
||||
var result = Player.new()
|
||||
result.id = data["id"]
|
||||
result.name = data["name"]
|
||||
result.color = data["color"]
|
||||
result.money = data["money"]
|
||||
return result
|
||||
|
||||
10
resources/web_tube_context.tres
Normal file
10
resources/web_tube_context.tres
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_resource type="Resource" script_class="TubeContext" format=3 uid="uid://berd4vlwkh1no"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://t4pe7yqc3pnt" path="res://addons/tube/tube_context.gd" id="1_612oo"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_612oo")
|
||||
app_id = "g^o#isR0W!x|+?8"
|
||||
trackers_urls = Array[String](["wss://tracker.openwebtorrent.com", "wss://tracker.files.fm:7073/announce", "wss://tracker.btorrent.xyz/", "wss://tracker.ghostchu-services.top:443/announce"])
|
||||
stun_servers_urls = Array[String](["stun:stun.l.google.com:19302", "stun:stun.cloudflare.com:3478", "stun:stun.bethesda.net:3478"])
|
||||
metadata/_custom_type_script = "uid://t4pe7yqc3pnt"
|
||||
@ -1,67 +1,163 @@
|
||||
class_name BoardGame extends Control
|
||||
class_name BoardGame extends Node
|
||||
|
||||
const DOWN_SPAWN_SCENE = preload("uid://d4ltd1geg7s2p")
|
||||
const HOME_SCENE = preload("uid://bto4vblqk2inb")
|
||||
#const DOWN_SPAWN_SCENE = preload("uid://d4ltd1geg7s2p")
|
||||
|
||||
const BANK_SCENE = preload("uid://c06fsqdixer1c")
|
||||
const BAR_SCENE = preload("uid://cfk268flnsbhb")
|
||||
const CAFE_SCENE = preload("uid://bgtw051fiveeo")
|
||||
const FORK_SCENE = preload("uid://cphy0vtj14ob0")
|
||||
const GUN_SHOP_SCENE = preload("uid://c1kyedmrep0tu")
|
||||
const HOSPITAL_SCENE = preload("uid://bytldu3y1jak3")
|
||||
const OFFICE_SCENE = preload("uid://mixrqf035krk")
|
||||
const SHOP_SCENE = preload("uid://dbn63mv0peqf")
|
||||
|
||||
const BASE_DECK = [
|
||||
BANK_SCENE,
|
||||
BAR_SCENE,
|
||||
CAFE_SCENE,
|
||||
FORK_SCENE,
|
||||
GUN_SHOP_SCENE,
|
||||
HOSPITAL_SCENE,
|
||||
OFFICE_SCENE,
|
||||
SHOP_SCENE
|
||||
]
|
||||
|
||||
var turn: int = 0:
|
||||
set(value):
|
||||
turn = value
|
||||
controls.set_turn(turn)
|
||||
var player: Player
|
||||
var citizen_count: int = 0:
|
||||
set(value):
|
||||
print(value)
|
||||
#print(value)
|
||||
citizen_count = value
|
||||
if citizen_count == 0:
|
||||
handle_turn_over()
|
||||
handle_citizens_finished()
|
||||
|
||||
var spawn_placement_actions = 0
|
||||
var buildings_added_to_draft: int = 0
|
||||
var homes_placed: int = 0
|
||||
var spawn_placement_actions: int = 0
|
||||
var draft_index_to_be_deleted: int = -1
|
||||
|
||||
var current_board_state: BoardState:
|
||||
set(value):
|
||||
current_board_state = value
|
||||
controls.check_controls_enabled()
|
||||
controls.set_info()
|
||||
|
||||
var pending_board_state: BoardState:
|
||||
set(value):
|
||||
pending_board_state = value
|
||||
controls.check_controls_enabled()
|
||||
|
||||
var deck: Array[Building] = []
|
||||
|
||||
@onready var board: Board = %Board
|
||||
@onready var controls: Controls = %Controls
|
||||
@onready var game_over: Control = %GameOver
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
Globals.board_game = self
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
player = Player.new()
|
||||
controls.set_players([player])
|
||||
start_turn()
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func setup_building_deck() -> void:
|
||||
for i in range(current_board_state.players.size()):
|
||||
for scene in BASE_DECK:
|
||||
deck.append(scene.instantiate())
|
||||
|
||||
|
||||
func start_turn() -> void:
|
||||
turn += 1
|
||||
if spawn_placement_actions > 0:
|
||||
board.set_active_tile(DOWN_SPAWN_SCENE.instantiate())
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func set_board_state(board_state: Dictionary) -> void:
|
||||
current_board_state = BoardState.deserialize(board_state)
|
||||
board.reset()
|
||||
board.set_board_state(current_board_state)
|
||||
if current_board_state.state == BoardState.State.INITIAL_SETUP:
|
||||
if Globals.game.this_player.id == current_board_state.current_player.id:
|
||||
board.set_active_building(HOME_SCENE.instantiate())
|
||||
elif current_board_state.state == BoardState.State.DRAFT:
|
||||
start_day()
|
||||
if current_board_state.players_passed == Globals.game.players.size():
|
||||
end_day()
|
||||
|
||||
|
||||
func select_tile(tile: Tile):
|
||||
board.set_active_tile(tile)
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func add_building_to_draft() -> void:
|
||||
buildings_added_to_draft += 1
|
||||
if buildings_added_to_draft >= Globals.game.players.size():
|
||||
current_board_state.state = BoardState.State.PLAY
|
||||
controls.check_controls_enabled()
|
||||
|
||||
|
||||
func select_building(building: Building) -> void:
|
||||
if building is Home:
|
||||
board.set_active_building(building, player)
|
||||
func select_tile(tile: Tile) -> void:
|
||||
board.set_active_tile(tile.duplicate())
|
||||
|
||||
|
||||
func select_building(building: Building, delete_index: int = -1) -> void:
|
||||
board.set_active_building(building.duplicate())
|
||||
draft_index_to_be_deleted = delete_index
|
||||
|
||||
|
||||
func start_day() -> void:
|
||||
current_board_state.day += 1
|
||||
current_board_state.turn = 1
|
||||
seed(Globals.game.sum_player_ids())
|
||||
deck.shuffle()
|
||||
var turn_index := current_board_state.get_this_player_index()
|
||||
controls.give_hand(deck.slice(0 + (3 * turn_index), 3 + (3 * turn_index)))
|
||||
controls.set_info()
|
||||
|
||||
|
||||
func end_day() -> void:
|
||||
controls.end_day()
|
||||
get_tree().call_group("Pausable", "unpause")
|
||||
|
||||
|
||||
func handle_board_state_changed() -> void:
|
||||
pending_board_state = BoardState.new()
|
||||
pending_board_state.day = current_board_state.day
|
||||
pending_board_state.turn = current_board_state.turn + 1
|
||||
if pending_board_state.turn == 0:
|
||||
pending_board_state.state = BoardState.State.DRAFT
|
||||
else:
|
||||
board.set_active_building(building)
|
||||
pending_board_state.state = current_board_state.state
|
||||
pending_board_state.players = current_board_state.players
|
||||
pending_board_state.players.push_back(pending_board_state.players.pop_front())
|
||||
pending_board_state.current_player = current_board_state.players[0]
|
||||
pending_board_state.tiles = board.tiles.values()
|
||||
for building in board.buildings.values():
|
||||
if !pending_board_state.buildings.has(building):
|
||||
pending_board_state.buildings.append(building)
|
||||
controls.check_controls_enabled()
|
||||
|
||||
|
||||
func place_walls() -> void:
|
||||
board.is_placing_walls = !board.is_placing_walls
|
||||
func handle_board_state_confirmed() -> void:
|
||||
current_board_state.players_passed = 0
|
||||
set_board_state.rpc(pending_board_state.serialize())
|
||||
pending_board_state = null
|
||||
if draft_index_to_be_deleted != -1:
|
||||
controls.remove_from_draft.rpc(draft_index_to_be_deleted)
|
||||
draft_index_to_be_deleted = -1
|
||||
|
||||
|
||||
func handle_turn_over() -> void:
|
||||
get_tree().call_group("PostTurnActions", "handle_post_turn_actions")
|
||||
func handle_pass() -> void:
|
||||
current_board_state.players_passed += 1
|
||||
current_board_state.turn += 1
|
||||
current_board_state.players.push_back(current_board_state.players.pop_front())
|
||||
current_board_state.current_player = current_board_state.players[0]
|
||||
set_board_state.rpc(current_board_state.serialize())
|
||||
|
||||
|
||||
func handle_citizens_finished() -> void:
|
||||
for child in board.board_state.get_children():
|
||||
if child.get_groups().has("PostTurnActions"):
|
||||
child.handle_post_turn_actions()
|
||||
controls.reset_turn()
|
||||
start_turn()
|
||||
var winning_player_idx = current_board_state.players.find_custom(
|
||||
func(p: Player) -> bool: return p.money >= 100
|
||||
)
|
||||
if winning_player_idx != -1:
|
||||
game_over.set_winning_player(current_board_state.players[winning_player_idx])
|
||||
else:
|
||||
start_day()
|
||||
|
||||
|
||||
func queue_spawn_placement(num: int) -> void:
|
||||
spawn_placement_actions += num
|
||||
|
||||
|
||||
func handle_spawn_placed() -> void:
|
||||
spawn_placement_actions = maxi(spawn_placement_actions - 1, 0)
|
||||
if spawn_placement_actions > 0:
|
||||
board.set_active_tile(DOWN_SPAWN_SCENE.instantiate())
|
||||
func queue_spawn_placement(_num_placements: int) -> void:
|
||||
print("Handle queueing spawn placements")
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
[gd_scene format=3 uid="uid://dmqvnr7uev0i6"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://caq4f3l237i42" path="res://prefabs/ui/controls.tscn" id="1_8orke"]
|
||||
[ext_resource type="Script" uid="uid://p10j5v8tlyb" path="res://scenes/board_game.gd" id="1_v8odh"]
|
||||
[ext_resource type="Script" uid="uid://c5vwubjdr23jr" path="res://prefabs/game_camera.gd" id="2_v8odh"]
|
||||
[ext_resource type="PackedScene" uid="uid://ct6tclctgdrkm" path="res://prefabs/board.tscn" id="3_02cv7"]
|
||||
[ext_resource type="Script" uid="uid://bye5rf7kk0qi7" path="res://prefabs/ui/game_over.gd" id="5_02cv7"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fc0e3"]
|
||||
content_margin_left = 10.0
|
||||
@ -18,7 +20,10 @@ corner_radius_top_right = 16
|
||||
corner_radius_bottom_right = 16
|
||||
corner_radius_bottom_left = 16
|
||||
|
||||
[node name="GameContainer" type="PanelContainer" unique_id=1427225690]
|
||||
[node name="BoardGame" type="Node" unique_id=899693855]
|
||||
script = ExtResource("1_v8odh")
|
||||
|
||||
[node name="GameContainer" type="PanelContainer" parent="." unique_id=1427225690]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
@ -26,38 +31,38 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_fc0e3")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=348137536]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="GameContainer" unique_id=348137536]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Controls" parent="VBoxContainer" unique_id=1719205711 instance=ExtResource("1_8orke")]
|
||||
[node name="Controls" parent="GameContainer/VBoxContainer" unique_id=1719205711 instance=ExtResource("1_8orke")]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 50)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer" unique_id=511396372]
|
||||
[node name="PanelContainer" type="PanelContainer" parent="GameContainer/VBoxContainer" unique_id=511396372]
|
||||
process_mode = 3
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_7jktm")
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="VBoxContainer/PanelContainer" unique_id=758297429]
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="GameContainer/VBoxContainer/PanelContainer" unique_id=758297429]
|
||||
process_mode = 3
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
stretch = true
|
||||
mouse_target = true
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="VBoxContainer/PanelContainer/SubViewportContainer" unique_id=584942697]
|
||||
[node name="SubViewport" type="SubViewport" parent="GameContainer/VBoxContainer/PanelContainer/SubViewportContainer" unique_id=584942697]
|
||||
process_mode = 3
|
||||
disable_3d = true
|
||||
transparent_bg = true
|
||||
handle_input_locally = false
|
||||
physics_object_picking = true
|
||||
size = Vector2i(2, 2)
|
||||
size = Vector2i(1132, 574)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="VBoxContainer/PanelContainer/SubViewportContainer/SubViewport" unique_id=416785798]
|
||||
[node name="Camera2D" type="Camera2D" parent="GameContainer/VBoxContainer/PanelContainer/SubViewportContainer/SubViewport" unique_id=416785798]
|
||||
anchor_mode = 0
|
||||
zoom = Vector2(0.94, 0.94)
|
||||
position_smoothing_enabled = true
|
||||
@ -65,5 +70,24 @@ drag_horizontal_enabled = true
|
||||
drag_vertical_enabled = true
|
||||
script = ExtResource("2_v8odh")
|
||||
|
||||
[node name="Board" parent="VBoxContainer/PanelContainer/SubViewportContainer/SubViewport" unique_id=752933545 instance=ExtResource("3_02cv7")]
|
||||
[node name="Board" parent="GameContainer/VBoxContainer/PanelContainer/SubViewportContainer/SubViewport" unique_id=752933545 instance=ExtResource("3_02cv7")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="GameOver" type="PanelContainer" parent="." unique_id=1729030106]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("5_02cv7")
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="GameOver" unique_id=1471561381]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="GameOver/CenterContainer" unique_id=620824359]
|
||||
layout_mode = 2
|
||||
text = "Player Wins"
|
||||
|
||||
[connection signal="board_state_changed" from="GameContainer/VBoxContainer/PanelContainer/SubViewportContainer/SubViewport/Board" to="." method="handle_board_state_changed"]
|
||||
|
||||
@ -1,15 +1,100 @@
|
||||
class_name Game extends Node
|
||||
|
||||
signal players_changed(players: Array[Player])
|
||||
|
||||
const MAIN_MENU_SCENE = preload("uid://dpuwsqorot65h")
|
||||
const BOARD_GAME_SCENE = preload("uid://dmqvnr7uev0i6")
|
||||
|
||||
const WEB_TUBE_CONTEXT = preload("uid://berd4vlwkh1no")
|
||||
const LOCAL_TUBE_CONTEXT = preload("uid://c4wgewmmuj74g")
|
||||
|
||||
var this_player: Player
|
||||
#var players: Dictionary[int, Player] = {}
|
||||
var players: Array[Player] = []
|
||||
|
||||
@onready var tube_client: TubeClient = %TubeClient
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if ProjectSettings.get_setting_with_override("game/config/use_web_tube_context"):
|
||||
tube_client.context = WEB_TUBE_CONTEXT
|
||||
else:
|
||||
tube_client.context = LOCAL_TUBE_CONTEXT
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
Globals.game = self
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func add_player(player: Player) -> void:
|
||||
players.push_back(player)
|
||||
func add_player(player_data: Dictionary) -> void:
|
||||
if !players.any(func(p: Player) -> bool: return p.name == player_data["name"]):
|
||||
players.push_back(Player.deserialize(player_data))
|
||||
players_changed.emit(players)
|
||||
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
func sync_players() -> void:
|
||||
for player in players:
|
||||
add_player.rpc(player.serialize())
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func add_player_money(player_id: int, money: int) -> void:
|
||||
find_player_by_id(player_id).money += money
|
||||
|
||||
|
||||
func find_player_by_id(id: int) -> Player:
|
||||
var player_idx = players.find_custom(func(p: Player) -> bool: return p.id == id)
|
||||
return players[player_idx]
|
||||
|
||||
|
||||
func get_next_player(player: Player) -> Player:
|
||||
var player_idx = players.find_custom(func(p: Player) -> bool: return p.id == player.id)
|
||||
return players[(player_idx + 1) % players.size()]
|
||||
|
||||
|
||||
func get_this_player_turn_index() -> int:
|
||||
return players.find_custom(func(p: Player) -> bool: return p.id == this_player.id)
|
||||
|
||||
|
||||
func get_player_turn_index(player: Player) -> int:
|
||||
return players.find_custom(func(p: Player) -> bool: return p.id == player.id)
|
||||
|
||||
|
||||
func start_game() -> void:
|
||||
if is_instance_valid(Globals.main_menu):
|
||||
Globals.main_menu.queue_free()
|
||||
add_child(BOARD_GAME_SCENE.instantiate())
|
||||
if Globals.game.tube_client.is_server:
|
||||
Globals.game.create_initial_board_state()
|
||||
|
||||
|
||||
func create_initial_board_state() -> void:
|
||||
Globals.board_game.board.initialize()
|
||||
var board_state := BoardState.new()
|
||||
players.shuffle()
|
||||
board_state.turn = -players.size()
|
||||
board_state.players = players
|
||||
board_state.current_player = players[0]
|
||||
board_state.tiles = Globals.board_game.board.tiles.values()
|
||||
Globals.board_game.set_board_state.rpc(board_state.serialize())
|
||||
Globals.board_game.setup_building_deck.rpc()
|
||||
|
||||
|
||||
func shuffle_turn_order() -> void:
|
||||
var idx_arr: Array[int] = []
|
||||
for i in range(players.size()):
|
||||
idx_arr.push_back(i)
|
||||
seed(sum_player_ids())
|
||||
var new_order: Array[Player] = []
|
||||
idx_arr.shuffle()
|
||||
players.sort_custom(func(a: Player, b: Player) -> bool: return a.id > b.id)
|
||||
for idx in idx_arr:
|
||||
new_order.push_back(players[idx])
|
||||
players = new_order
|
||||
|
||||
|
||||
func sum_player_ids() -> int:
|
||||
var ids: Array = players.map(func(p: Player) -> int: return p.id)
|
||||
return ids.reduce(func(acc: int, id: int) -> int: return acc + id, 0)
|
||||
|
||||
@ -2,8 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://bg3v68a7qpt8t" path="res://scenes/game.gd" id="1_fc0e3"]
|
||||
[ext_resource type="Script" uid="uid://cy006uvidc4y" path="res://addons/tube/tube_client.gd" id="2_lnu2h"]
|
||||
[ext_resource type="Resource" uid="uid://c4wgewmmuj74g" path="res://resources/local_tube_context.tres" id="3_lbhrr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpuwsqorot65h" path="res://scenes/main_menu.tscn" id="4_lbhrr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpuwsqorot65h" path="res://scenes/main_menu.tscn" id="3_lnu2h"]
|
||||
|
||||
[node name="Game" type="Node" unique_id=384379479]
|
||||
script = ExtResource("1_fc0e3")
|
||||
@ -11,7 +10,6 @@ script = ExtResource("1_fc0e3")
|
||||
[node name="TubeClient" type="Node" parent="." unique_id=646833557]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("2_lnu2h")
|
||||
context = ExtResource("3_lbhrr")
|
||||
metadata/_custom_type_script = "uid://cy006uvidc4y"
|
||||
|
||||
[node name="MainMenu" parent="." unique_id=459413586 instance=ExtResource("4_lbhrr")]
|
||||
[node name="MainMenu" parent="." unique_id=459413586 instance=ExtResource("3_lnu2h")]
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extends Node
|
||||
class_name MainMenu extends Node
|
||||
|
||||
@onready var main_menu: Container = %MainMenu
|
||||
@onready var create_session: Container = %CreateSession
|
||||
@ -6,37 +6,34 @@ extends Node
|
||||
@onready var lobby: Lobby = %Lobby
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
Globals.main_menu = self
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Globals.game.players_changed.connect(lobby.load_players)
|
||||
|
||||
|
||||
func handle_create_session(player: Player) -> void:
|
||||
Globals.game.tube_client.create_session()
|
||||
Globals.game.this_player = player
|
||||
Globals.game.add_player.rpc(player)
|
||||
Globals.game.tube_client.create_session()
|
||||
Globals.game.this_player.id = Globals.game.tube_client.peer_id
|
||||
Globals.game.add_player.rpc(player.serialize())
|
||||
create_session.hide()
|
||||
lobby.show()
|
||||
lobby.set_session_id(Globals.game.tube_client.session_id)
|
||||
lobby.add_player(player)
|
||||
|
||||
|
||||
func handle_join_session(session_id: String, player: Player) -> void:
|
||||
Globals.game.this_player = player
|
||||
Globals.game.tube_client.join_session(session_id)
|
||||
await Globals.game.tube_client.peer_connected
|
||||
Globals.game.this_player = player
|
||||
Globals.game.add_player.rpc(player)
|
||||
Globals.game.this_player.id = Globals.game.tube_client.peer_id
|
||||
Globals.game.add_player.rpc(player.serialize())
|
||||
Globals.game.sync_players.rpc()
|
||||
join_session.hide()
|
||||
lobby.show()
|
||||
lobby.set_session_id(session_id)
|
||||
lobby.add_player(player)
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
#func handle_chat_update(new_text):
|
||||
#update_chat.rpc(new_text)
|
||||
#chat_text_input.text = ""
|
||||
#
|
||||
#
|
||||
#@rpc("any_peer", "call_local", "reliable")
|
||||
#func update_chat(text):
|
||||
#chat_log.text += text + "\n"
|
||||
|
||||
|
||||
func _on_create_session_pressed():
|
||||
@ -47,3 +44,20 @@ func _on_create_session_pressed():
|
||||
func _on_join_session_pressed():
|
||||
main_menu.hide()
|
||||
join_session.show()
|
||||
|
||||
|
||||
func _on_single_player_pressed():
|
||||
Globals.game.tube_client.create_session()
|
||||
Globals.game.this_player = Player.new()
|
||||
Globals.game.this_player.name = "one"
|
||||
Globals.game.add_player(Globals.game.this_player.serialize())
|
||||
#var two = Player.new()
|
||||
#two.name = "two"
|
||||
#var three = Player.new()
|
||||
#three.name = "three"
|
||||
#var four = Player.new()
|
||||
#four.name = "four"
|
||||
#Globals.game.add_player(two.serialize())
|
||||
#Globals.game.add_player(three.serialize())
|
||||
#Globals.game.add_player(four.serialize())
|
||||
Globals.game.start_game()
|
||||
|
||||
@ -27,12 +27,20 @@ text = "Clockwork City"
|
||||
label_settings = SubResource("LabelSettings_2wvic")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="SinglePlayer" type="Button" parent="MainMenu" unique_id=1318380325]
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Single Player"
|
||||
|
||||
[node name="CreateSession" type="Button" parent="MainMenu" unique_id=1320477862]
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Create Session"
|
||||
|
||||
[node name="JoinSession" type="Button" parent="MainMenu" unique_id=897089302]
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Join Session"
|
||||
@ -49,6 +57,7 @@ visible = false
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
||||
[connection signal="pressed" from="MainMenu/SinglePlayer" to="." method="_on_single_player_pressed"]
|
||||
[connection signal="pressed" from="MainMenu/CreateSession" to="." method="_on_create_session_pressed"]
|
||||
[connection signal="pressed" from="MainMenu/JoinSession" to="." method="_on_join_session_pressed"]
|
||||
[connection signal="create_session" from="CreateSession" to="." method="handle_create_session"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user