Add Shop spawn station
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
[gd_scene format=3 uid="uid://dbgu4r127ke5v"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1cefhe3yyyds" path="res://scenes/multiplayer_world.gd" id="1_atgwk"]
|
||||
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://textures/sky/NightSkyHDRI009_16K.tres" id="2_1jq86"]
|
||||
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://prefabs/XROrigin.tscn" id="3_bryd6"]
|
||||
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://textures/dev_material_3d.tres" id="4_kpgm6"]
|
||||
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://stations/Hob.tscn" id="5_gfdi7"]
|
||||
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://stations/Counter.tscn" id="7_jnxsa"]
|
||||
[ext_resource type="PackedScene" uid="uid://drwuhqb3pjtiy" path="res://items/potato.tscn" id="8_1qeqw"]
|
||||
[ext_resource type="PackedScene" uid="uid://dlw5geheupgpt" path="res://stations/hatch.tscn" id="8_atgwk"]
|
||||
[ext_resource type="Script" uid="uid://bsdpd18i1i17s" path="res://prefabs/build_mode_controller.gd" id="9_atgwk"]
|
||||
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://stations/sink.tscn" id="10_dhas4"]
|
||||
[ext_resource type="PackedScene" uid="uid://caf0xanmxbshy" path="res://stations/table.tscn" id="11_gaw43"]
|
||||
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="12_n58f2"]
|
||||
[ext_resource type="PackedScene" uid="uid://xtcei2uvd5li" path="res://UI/game_over_panel.tscn" id="13_hooyg"]
|
||||
[ext_resource type="Script" uid="uid://cwijoksyou1ey" path="res://scenes/GameOvercontroler.gd" id="14_cqmpj"]
|
||||
|
||||
[sub_resource type="Environment" id="Environment_bvwq1"]
|
||||
background_mode = 2
|
||||
sky = ExtResource("2_1jq86")
|
||||
ambient_light_source = 3
|
||||
ambient_light_color = Color(1, 1, 1, 1)
|
||||
ambient_light_sky_contribution = 0.9
|
||||
reflected_light_source = 2
|
||||
ssr_enabled = true
|
||||
ssao_enabled = true
|
||||
ssil_enabled = true
|
||||
sdfgi_enabled = true
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
|
||||
size = Vector3(20, 0.1, 20)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
|
||||
material = ExtResource("4_kpgm6")
|
||||
size = Vector3(20, 0.1, 20)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
|
||||
size = Vector3(20, 10, 0.1)
|
||||
|
||||
[node name="Main" type="Node3D" unique_id=1312265607]
|
||||
script = ExtResource("1_atgwk")
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
|
||||
environment = SubResource("Environment_bvwq1")
|
||||
|
||||
[node name="XROrigin3D" parent="." unique_id=2055526621 instance=ExtResource("3_bryd6")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9667189, 2.4)
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1376644384]
|
||||
transform = Transform3D(-0.8660254, -0.43301278, 0.24999999, 0.3022632, -0.05510214, 0.9516306, -0.39829266, 0.8997021, 0.17860365, 0, 0, 0)
|
||||
|
||||
[node name="WorldContent" type="Node3D" parent="." unique_id=1945394545]
|
||||
|
||||
[node name="Players" type="Node3D" parent="." unique_id=177940558]
|
||||
|
||||
[node name="Stations" type="Node3D" parent="." unique_id=1243299496]
|
||||
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 1.8000001, 0, 1.8000001)
|
||||
|
||||
[node name="ItemsSpawner" type="MultiplayerSpawner" parent="." unique_id=201060343]
|
||||
spawn_path = NodePath("../WorldContent")
|
||||
|
||||
[node name="PlayersSpawner" type="MultiplayerSpawner" parent="." unique_id=1840881658]
|
||||
_spawnable_scenes = PackedStringArray("res://Player/net_player.tscn")
|
||||
spawn_path = NodePath("../Players")
|
||||
|
||||
[node name="Floor" type="StaticBody3D" parent="." unique_id=122279514]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.05, 0)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor" unique_id=958841648]
|
||||
shape = SubResource("BoxShape3D_vlqg6")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floor/CollisionShape3D" unique_id=1939997056]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00018164515, 0.0006352663, -0.002532661)
|
||||
mesh = SubResource("BoxMesh_24d3s")
|
||||
|
||||
[node name="InvisibleWalls" type="StaticBody3D" parent="." unique_id=315740174]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="InvisibleWalls" unique_id=33059670]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.688614, 8.838269)
|
||||
shape = SubResource("BoxShape3D_24d3s")
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="InvisibleWalls" unique_id=2018792171]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.688614, -10.243342)
|
||||
shape = SubResource("BoxShape3D_24d3s")
|
||||
|
||||
[node name="CollisionShape3D3" type="CollisionShape3D" parent="InvisibleWalls" unique_id=757662929]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -9.807113, 4.688614, -0.018813243)
|
||||
shape = SubResource("BoxShape3D_24d3s")
|
||||
|
||||
[node name="CollisionShape3D4" type="CollisionShape3D" parent="InvisibleWalls" unique_id=1468386997]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 9.934778, 4.297072, -0.018813023)
|
||||
shape = SubResource("BoxShape3D_24d3s")
|
||||
|
||||
[node name="Hob" parent="." unique_id=1687971542 instance=ExtResource("5_gfdi7")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.507, 0)
|
||||
|
||||
[node name="Counter" parent="." unique_id=1487893288 instance=ExtResource("7_jnxsa")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.6, 0.512, 0)
|
||||
|
||||
[node name="Potato" parent="." unique_id=962444046 instance=ExtResource("8_1qeqw")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.273382, 1.5940565, -0.036002517)
|
||||
|
||||
[node name="Hatch" parent="." unique_id=1341321603 instance=ExtResource("8_atgwk")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.2, 0, 0)
|
||||
|
||||
[node name="Hatch2" parent="." unique_id=1755144529 instance=ExtResource("8_atgwk")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.6, 0, 0)
|
||||
|
||||
[node name="BuildModeController" type="Node" parent="." unique_id=1876729190]
|
||||
script = ExtResource("9_atgwk")
|
||||
|
||||
[node name="Sink" parent="." unique_id=1559059799 instance=ExtResource("10_dhas4")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.2, 0.5, 0)
|
||||
|
||||
[node name="Table" parent="." unique_id=1863572470 instance=ExtResource("11_gaw43")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.4, 0.5, 1.8)
|
||||
|
||||
[node name="GameOverPanel" parent="." unique_id=522901881 instance=ExtResource("12_n58f2")]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -4.428178, 2.8122003, 3)
|
||||
scene = ExtResource("13_hooyg")
|
||||
viewport_size = Vector2(900, 600)
|
||||
transparent = 0
|
||||
filter = false
|
||||
scene_properties_keys = PackedStringArray("game_over_panel.gd")
|
||||
|
||||
[node name="controler" type="Node" parent="GameOverPanel" unique_id=1442195864]
|
||||
script = ExtResource("14_cqmpj")
|
||||
@@ -27,6 +27,10 @@ func set_move_handle_enabled(enabled: bool) -> void:
|
||||
func _on_game_state_changed(new_state: GameManager.GameState) -> void:
|
||||
set_move_handle_enabled(new_state == GameManager.GameState.BUILDING)
|
||||
|
||||
func _on_station_bought(_instance: Node3D):
|
||||
print("StationMovement _on_station_bought")
|
||||
if GameManager.game_state == GameManager.GameState.BUILDING:
|
||||
set_move_handle_enabled(true)
|
||||
|
||||
func _ready() -> void:
|
||||
if not station:
|
||||
@@ -42,6 +46,7 @@ func _ready() -> void:
|
||||
original_station_transform = station.global_transform
|
||||
move_handle.picked_up.connect(_handle_pickup)
|
||||
move_handle.dropped.connect(_handle_drop)
|
||||
Signals.station_bought.connect(_on_station_bought)
|
||||
|
||||
move_ghost.monitoring = true
|
||||
move_ghost.visible = false
|
||||
@@ -118,14 +123,8 @@ func _process(_delta: float) -> void:
|
||||
if not moving:
|
||||
return
|
||||
|
||||
var target_transform: Transform3D = move_handle.global_transform
|
||||
target_transform.origin.x = snappedf(target_transform.origin.x, snap_grid_size)
|
||||
target_transform.origin.z = snappedf(target_transform.origin.z, snap_grid_size)
|
||||
target_transform.origin.y = original_station_transform.origin.y
|
||||
var target_yaw: float = snappedf(move_handle.global_rotation_degrees.y, 90)
|
||||
target_transform.basis = Basis(Vector3.UP, deg_to_rad(target_yaw))
|
||||
|
||||
move_ghost.global_transform = target_transform
|
||||
move_ghost.global_transform = Helper.get_snapped_transform(move_handle)
|
||||
move_ghost.global_transform.origin.y = original_station_transform.origin.y
|
||||
if _is_move_position_valid():
|
||||
_set_ghost_color(GHOST_COLOR_VALID)
|
||||
else:
|
||||
|
||||
@@ -19,6 +19,16 @@ func _ready() -> void:
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
print("ShopStationButton buy ", station_name)
|
||||
_buy_station()
|
||||
|
||||
func _buy_station() -> void:
|
||||
GameManager.money -= cost
|
||||
var transform = Helper.get_snapped_transform(XRHelpers.get_xr_origin(self).get_node_or_null("PlayerBody"))
|
||||
var forward: Vector3 = -transform.basis.z.normalized()
|
||||
# TODO: Don't move up. Fix scenes.
|
||||
transform.origin += (forward * 0.6) + Vector3(0, 0.5, 0)
|
||||
var instance = NetworkManager.spawn_item(station_scene.resource_path, transform)
|
||||
Signals.station_bought.emit(instance)
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
button.disabled = GameManager.money < cost
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class_name GameManager
|
||||
extends Node
|
||||
|
||||
static var money: int = 35
|
||||
static var money: int = 100
|
||||
static var meals_in_play: Array[String]
|
||||
static var sides_in_play: Array[String]
|
||||
|
||||
|
||||
@@ -3,3 +3,4 @@ extends Node
|
||||
signal game_over
|
||||
signal restart_game
|
||||
signal game_state_changed(new_state: GameManager.GameState)
|
||||
signal station_bought(instance: Node3D)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
class_name Helper
|
||||
|
||||
const SNAP_GRID_SIZE = 0.6
|
||||
|
||||
|
||||
# Find a FoodItem among the direct children of [param node].
|
||||
static func find_food_item(node: Node) -> FoodItem:
|
||||
if not node:
|
||||
@@ -9,6 +12,7 @@ static func find_food_item(node: Node) -> FoodItem:
|
||||
return child
|
||||
return null
|
||||
|
||||
|
||||
static func find_first_child_of_type(node: Node, type: Variant) -> Node:
|
||||
for child in node.get_children():
|
||||
if is_instance_of(child, type):
|
||||
@@ -17,3 +21,14 @@ static func find_first_child_of_type(node: Node, type: Variant) -> Node:
|
||||
if nested:
|
||||
return nested
|
||||
return null
|
||||
|
||||
|
||||
# Returns a transform with position snapped to the 0.6 grid and rotation snapped to 90 degrees.
|
||||
static func get_snapped_transform(node: Node3D) -> Transform3D:
|
||||
var new_transform: Transform3D
|
||||
new_transform.origin.x = snappedf(node.global_position.x, SNAP_GRID_SIZE)
|
||||
new_transform.origin.z = snappedf(node.global_position.z, SNAP_GRID_SIZE)
|
||||
new_transform.origin.y = node.global_position.y
|
||||
var target_yaw: float = snappedf(node.global_rotation_degrees.y, 90)
|
||||
new_transform.basis = Basis(Vector3.UP, deg_to_rad(target_yaw))
|
||||
return new_transform
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ file_logging/enable_file_logging=true
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1800
|
||||
window/size/viewport_width=1000
|
||||
window/size/viewport_height=650
|
||||
window/stretch/mode="canvas_items"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
Reference in New Issue
Block a user