fixed building walls and moving cassettes around
This commit is contained in:
@@ -129,10 +129,15 @@ func process_looking_at_tower() -> void:
|
||||
func build_wall() -> void:
|
||||
if point and valid_point and hero.currency >= Data.wall_cost:
|
||||
hero.currency -= Data.wall_cost
|
||||
level.set_wall(point, multiplayer.get_unique_id())
|
||||
networked_set_wall.rpc(point.node_id, multiplayer.get_unique_id())
|
||||
wall_preview.visible = false
|
||||
|
||||
|
||||
@rpc("reliable", "call_local")
|
||||
func networked_set_wall(node_id: int, peer_id: int) -> void:
|
||||
level.set_wall(node_id, peer_id)
|
||||
|
||||
|
||||
func refund_wall(wall: TowerBase) -> void:
|
||||
if !is_instance_valid(wall):
|
||||
return
|
||||
|
||||
@@ -32,7 +32,9 @@ func set_float(value: float) -> void:
|
||||
$MeshInstance3D.material_override.set("shader_parameter/Float", value)
|
||||
|
||||
|
||||
func add_card(card: Card, caller_id: int) -> void:
|
||||
@rpc("reliable", "call_local", "any_peer")
|
||||
func networked_spawn_tower(card_index: int, caller_id: int) -> void:
|
||||
var card: Card = Data.cards[card_index]
|
||||
inventory.add(card)
|
||||
tower = inventory.item_at(0).turret_scene.instantiate() as Tower
|
||||
tower.stats = inventory.item_at(0).tower_stats
|
||||
@@ -42,17 +44,16 @@ func add_card(card: Card, caller_id: int) -> void:
|
||||
tower.position = Vector3(0, 1.2, 0)
|
||||
minimap_icon.modulate = Color.RED
|
||||
duration = 999
|
||||
#enable_duration_sprites()
|
||||
add_child(tower)
|
||||
|
||||
|
||||
func remove_card() -> void:
|
||||
@rpc("reliable", "call_local", "any_peer")
|
||||
func networked_remove_tower() -> void:
|
||||
var card: Card = inventory.remove_at(0)
|
||||
if !game_manager.card_gameplay:
|
||||
game_manager.connected_players_nodes[tower.owner_id].add_card(card)
|
||||
game_manager.connected_players_nodes[tower.owner_id].unready_self()
|
||||
tower.queue_free()
|
||||
#disable_duration_sprites()
|
||||
tower = null
|
||||
minimap_icon.modulate = Color.GREEN
|
||||
|
||||
@@ -75,31 +76,3 @@ func enable_duration_sprites() -> void:
|
||||
func disable_duration_sprites() -> void:
|
||||
for sprite: Sprite3D in duration_sprites:
|
||||
sprite.visible = false
|
||||
|
||||
|
||||
@rpc("reliable", "call_local", "any_peer")
|
||||
func networked_spawn_tower(card_index: int, caller_id: int) -> void:
|
||||
var card: Card = Data.cards[card_index]
|
||||
inventory.add(card)
|
||||
tower = inventory.item_at(0).turret_scene.instantiate() as Tower
|
||||
tower.stats = inventory.item_at(0).tower_stats
|
||||
tower.name = "tower"
|
||||
tower.base_name = name
|
||||
tower.owner_id = caller_id
|
||||
tower.position = Vector3(0, 1.2, 0)
|
||||
minimap_icon.modulate = Color.RED
|
||||
duration = 999
|
||||
#enable_duration_sprites()
|
||||
add_child(tower)
|
||||
|
||||
|
||||
@rpc("reliable", "call_local", "any_peer")
|
||||
func networked_remove_tower() -> void:
|
||||
var card: Card = inventory.remove_at(0)
|
||||
if !game_manager.card_gameplay:
|
||||
game_manager.connected_players_nodes[tower.owner_id].add_card(card)
|
||||
game_manager.connected_players_nodes[tower.owner_id].unready_self()
|
||||
tower.queue_free()
|
||||
#disable_duration_sprites()
|
||||
tower = null
|
||||
minimap_icon.modulate = Color.GREEN
|
||||
|
||||
@@ -116,6 +116,7 @@ func spawn_level(scene: PackedScene) -> void:
|
||||
level = scene.instantiate() as Level
|
||||
var flow_field: FlowField = FlowField.new()
|
||||
level.flow_field = flow_field
|
||||
level.name = "level"
|
||||
level.add_child(flow_field)
|
||||
flow_field.data = FlowFieldTool.load_flow_field_from_disc(level_config.zone.flow_field_data_path)
|
||||
level.load_flow_field()
|
||||
|
||||
@@ -49,13 +49,16 @@ func disable_path_tower_frames() -> void:
|
||||
tower_frames[node].visible = false
|
||||
|
||||
|
||||
func set_wall(point: FlowNodeData, caller_id: int) -> void:
|
||||
func set_wall(node_id: int, caller_id: int) -> void:
|
||||
var point: FlowNodeData
|
||||
for node: FlowNodeData in flow_field.data.nodes:
|
||||
if node.node_id == node_id:
|
||||
point = node
|
||||
point.traversable = false
|
||||
flow_field.calculate()
|
||||
flow_field.path_updated.emit()
|
||||
if is_multiplayer_authority():
|
||||
spawn_wall(point, wall_id, caller_id)
|
||||
wall_id += 1
|
||||
spawn_wall(point, wall_id, caller_id)
|
||||
wall_id += 1
|
||||
|
||||
|
||||
func remove_wall(point: FlowNodeData) -> void:
|
||||
|
||||
@@ -54,7 +54,7 @@ func place_card(tower_base: TowerBase) -> void:
|
||||
hero.hand.remove_at(hero.hand.contents.find(card))
|
||||
hero.decrement_selected()
|
||||
hero.hud.hot_wheel.update_cassettes(hero.get_wheel_cards())
|
||||
tower_base.add_card(card, multiplayer.get_unique_id())
|
||||
tower_base.networked_spawn_tower.rpc(Data.cards.find(card), multiplayer.get_unique_id())
|
||||
hero.placed_tower.emit(tower_base.tower)
|
||||
hero.place_card_audio.play()
|
||||
if hero.game_manager.card_gameplay:
|
||||
@@ -64,7 +64,7 @@ func place_card(tower_base: TowerBase) -> void:
|
||||
|
||||
func remove_card(tower_base: TowerBase) -> void:
|
||||
if tower_base.has_card:
|
||||
tower_base.remove_card()
|
||||
tower_base.networked_remove_tower.rpc()
|
||||
|
||||
|
||||
func spawn_tower_preview() -> void:
|
||||
|
||||
Reference in New Issue
Block a user