Compare commits
No commits in common. "16be17ba73caddb9ce8ae44cd0062d44af3afb3e" and "cda4b47ae95c908cafcc3c6295923fa9ded3f0ea" have entirely different histories.
16be17ba73
...
cda4b47ae9
@ -1,13 +0,0 @@
|
|||||||
[gd_resource type="Resource" script_class="InventoryItem" load_steps=3 format=3 uid="uid://dbxrlw5ggh67j"]
|
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://cb6qv3c0iojfl" path="res://icon.svg" id="1_eakc4"]
|
|
||||||
[ext_resource type="Script" path="res://src/lib/inventory_item.gd" id="2_lrh23"]
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
script = ExtResource("2_lrh23")
|
|
||||||
icon = ExtResource("1_eakc4")
|
|
||||||
name = "Coin"
|
|
||||||
id = &"coin"
|
|
||||||
stackable = true
|
|
||||||
stack_limit = 100
|
|
||||||
sells_for = 0
|
|
@ -9,5 +9,4 @@ icon = ExtResource("1_vrj0d")
|
|||||||
name = "Coin Flower"
|
name = "Coin Flower"
|
||||||
id = &"coin_flower"
|
id = &"coin_flower"
|
||||||
stackable = true
|
stackable = true
|
||||||
stack_limit = 9
|
stack_limit = 8
|
||||||
sells_for = 2
|
|
||||||
|
@ -10,6 +10,4 @@ icon = ExtResource("1_g8c3q")
|
|||||||
model = ExtResource("2_5cxkh")
|
model = ExtResource("2_5cxkh")
|
||||||
name = "Water Bomb"
|
name = "Water Bomb"
|
||||||
id = &"water_bomb"
|
id = &"water_bomb"
|
||||||
stackable = false
|
count = 0
|
||||||
stack_limit = 8
|
|
||||||
sells_for = 0
|
|
||||||
|
@ -28,7 +28,6 @@ window/stretch/aspect="expand"
|
|||||||
|
|
||||||
spawn_points=""
|
spawn_points=""
|
||||||
voids=""
|
voids=""
|
||||||
sell_boxes=""
|
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ func _input(event: InputEvent) -> void:
|
|||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
# this is fine but should this be done in response to a signal instead?
|
# this is fine but should this be done in response to a signal instead?
|
||||||
_coin_label.text = "COIN: %d" % GameState.get_item_count(&"coin")
|
_coin_label.text = "COINS: %d" % GameState.fetch().coins
|
||||||
|
|
||||||
|
|
||||||
func _activate_chat() -> void:
|
func _activate_chat() -> void:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=16 format=3 uid="uid://oyvhcwq60v2"]
|
[gd_scene load_steps=13 format=3 uid="uid://oyvhcwq60v2"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://src/ingame/ingame.gd" id="1_akuuj"]
|
[ext_resource type="Script" path="res://src/ingame/ingame.gd" id="1_akuuj"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cs8c570bxh6u" path="res://src/ingame/player.tscn" id="2_w1gjc"]
|
[ext_resource type="PackedScene" uid="uid://cs8c570bxh6u" path="res://src/ingame/player.tscn" id="2_w1gjc"]
|
||||||
@ -32,17 +32,6 @@ sky = SubResource("Sky_ygvd3")
|
|||||||
ambient_light_color = Color(0, 0.164706, 0.278431, 1)
|
ambient_light_color = Color(0, 0.164706, 0.278431, 1)
|
||||||
ambient_light_energy = 2.0
|
ambient_light_energy = 2.0
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_3215c"]
|
|
||||||
size = Vector3(3, 1, 3)
|
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_vx5ut"]
|
|
||||||
transparency = 1
|
|
||||||
albedo_color = Color(1, 1, 0, 0.698039)
|
|
||||||
|
|
||||||
[sub_resource type="BoxMesh" id="BoxMesh_gygr8"]
|
|
||||||
material = SubResource("StandardMaterial3D_vx5ut")
|
|
||||||
size = Vector3(3, 1, 3)
|
|
||||||
|
|
||||||
[node name="Ingame" type="Node3D" node_paths=PackedStringArray("_soundtrack", "_players", "_chat_panel", "_chat_input", "_chat_history_scroll", "_chat_history", "_chat_panel_inactive", "_chat_history_inactive", "_chat_history_scroll_inactive", "_coin_label")]
|
[node name="Ingame" type="Node3D" node_paths=PackedStringArray("_soundtrack", "_players", "_chat_panel", "_chat_input", "_chat_history_scroll", "_chat_history", "_chat_panel_inactive", "_chat_history_inactive", "_chat_history_scroll_inactive", "_coin_label")]
|
||||||
script = ExtResource("1_akuuj")
|
script = ExtResource("1_akuuj")
|
||||||
_player_scene = ExtResource("2_w1gjc")
|
_player_scene = ExtResource("2_w1gjc")
|
||||||
@ -314,17 +303,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.15702, 1.04855, 5.88574)
|
|||||||
[node name="SpawnPoint3" type="Marker3D" parent="SpawnPoints" groups=["spawn_points"]]
|
[node name="SpawnPoint3" type="Marker3D" parent="SpawnPoints" groups=["spawn_points"]]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.43229, 0.627689, 7.20138)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.43229, 0.627689, 7.20138)
|
||||||
|
|
||||||
[node name="SellBox" type="StaticBody3D" parent="." groups=["sell_boxes"]]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0)
|
|
||||||
collision_layer = 0
|
|
||||||
collision_mask = 4
|
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="SellBox"]
|
|
||||||
shape = SubResource("BoxShape3D_3215c")
|
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="SellBox"]
|
|
||||||
mesh = SubResource("BoxMesh_gygr8")
|
|
||||||
|
|
||||||
[connection signal="text_submitted" from="UI/ChatPanel/ChatInput" to="." method="_on_chat_message_submitted"]
|
[connection signal="text_submitted" from="UI/ChatPanel/ChatInput" to="." method="_on_chat_message_submitted"]
|
||||||
[connection signal="pressed" from="UI/ChatPanel/ChatSendButton" to="." method="_on_chat_message_submitted"]
|
[connection signal="pressed" from="UI/ChatPanel/ChatSendButton" to="." method="_on_chat_message_submitted"]
|
||||||
[connection signal="timeout" from="UI/ComboTimer" to="UI" method="_on_combo_timer_timeout"]
|
[connection signal="timeout" from="UI/ComboTimer" to="UI" method="_on_combo_timer_timeout"]
|
||||||
|
@ -19,10 +19,10 @@ func _ready() -> void:
|
|||||||
GameState.fetch().player_data[_id].water_combo_update.connect(
|
GameState.fetch().player_data[_id].water_combo_update.connect(
|
||||||
func(current: int):
|
func(current: int):
|
||||||
if current == 0:
|
if current == 0:
|
||||||
_combo_label.hide()
|
$Combo.hide()
|
||||||
else:
|
else:
|
||||||
_combo_label.show()
|
$Combo.show()
|
||||||
_combo_label.text = "+" + str(current) + "!"
|
$Combo.text = "+" + str(current) + "!"
|
||||||
_last_combo_time = Time.get_ticks_msec()
|
_last_combo_time = Time.get_ticks_msec()
|
||||||
_combo_timer.start()
|
_combo_timer.start()
|
||||||
)
|
)
|
||||||
@ -30,4 +30,4 @@ func _ready() -> void:
|
|||||||
|
|
||||||
func _on_combo_timer_timeout() -> void:
|
func _on_combo_timer_timeout() -> void:
|
||||||
GameState.fetch().player_data[_id].reset_water_combo()
|
GameState.fetch().player_data[_id].reset_water_combo()
|
||||||
_combo_label.hide()
|
$Combo.hide()
|
||||||
|
@ -40,12 +40,6 @@ func _disable_body() -> void:
|
|||||||
_picking_area.collision_layer = 0
|
_picking_area.collision_layer = 0
|
||||||
|
|
||||||
|
|
||||||
@rpc("authority", "call_local", "reliable")
|
|
||||||
func get_sold() -> void:
|
|
||||||
var item := GameState.fetch().INVENTORY_ITEM_DB[item_bundle["item_id"]]
|
|
||||||
get_node("/root/Main").add_inventory_item(&"coin", item.sells_for * item_bundle["count"])
|
|
||||||
|
|
||||||
|
|
||||||
func _on_body_entered(p_body: Node3D) -> void:
|
func _on_body_entered(p_body: Node3D) -> void:
|
||||||
if p_body == sender_body:
|
if p_body == sender_body:
|
||||||
return
|
return
|
||||||
@ -54,13 +48,6 @@ func _on_body_entered(p_body: Node3D) -> void:
|
|||||||
queue_free()
|
queue_free()
|
||||||
return
|
return
|
||||||
|
|
||||||
if p_body.is_in_group("sell_boxes"):
|
|
||||||
var item := GameState.fetch().INVENTORY_ITEM_DB[item_bundle["item_id"]]
|
|
||||||
if item.sells_for != 0:
|
|
||||||
queue_free()
|
|
||||||
get_sold.rpc()
|
|
||||||
return
|
|
||||||
|
|
||||||
for area: Area3D in _in_splash_range:
|
for area: Area3D in _in_splash_range:
|
||||||
area.get_parent_node_3d().water.rpc_id(1, sender_id)
|
area.get_parent_node_3d().water.rpc_id(1, sender_id)
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ const INVENTORY_ITEM_DB = {
|
|||||||
&"meat": preload("res://data/meat.tres"),
|
&"meat": preload("res://data/meat.tres"),
|
||||||
&"water_bomb": preload("res://data/water_bomb.tres"),
|
&"water_bomb": preload("res://data/water_bomb.tres"),
|
||||||
&"coin_flower": preload("res://data/coin_flower.tres"),
|
&"coin_flower": preload("res://data/coin_flower.tres"),
|
||||||
&"coin": preload("res://data/coin.tres"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## keys are multiplayer ID ints, values are PlayerData
|
## keys are multiplayer ID ints, values are PlayerData
|
||||||
@ -13,6 +12,7 @@ const INVENTORY_ITEM_DB = {
|
|||||||
## keys are InventoryItem resource IDs (from db),
|
## keys are InventoryItem resource IDs (from db),
|
||||||
## values are { "item": InventoryItem, "count": int }
|
## values are { "item": InventoryItem, "count": int }
|
||||||
@export var inventory := {}
|
@export var inventory := {}
|
||||||
|
@export var coins: int # TODO: might it make sense to have even them as items?
|
||||||
|
|
||||||
static var _instance := GameState.new()
|
static var _instance := GameState.new()
|
||||||
|
|
||||||
@ -25,13 +25,6 @@ static func fetch() -> GameState:
|
|||||||
return _instance
|
return _instance
|
||||||
|
|
||||||
|
|
||||||
static func get_item_count(p_item_id: StringName) -> int:
|
|
||||||
if GameState.fetch().inventory.has(p_item_id):
|
|
||||||
return GameState.fetch().inventory[p_item_id]["count"]
|
|
||||||
else:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: better place for those?
|
# TODO: better place for those?
|
||||||
static func are_bundles_stackable(p_a_bundle: Dictionary, p_b_bundle: Dictionary) -> bool:
|
static func are_bundles_stackable(p_a_bundle: Dictionary, p_b_bundle: Dictionary) -> bool:
|
||||||
var item = GameState.fetch().INVENTORY_ITEM_DB[p_a_bundle["item_id"]]
|
var item = GameState.fetch().INVENTORY_ITEM_DB[p_a_bundle["item_id"]]
|
||||||
|
@ -7,5 +7,3 @@ class_name InventoryItem extends Resource
|
|||||||
|
|
||||||
@export var stackable := false
|
@export var stackable := false
|
||||||
@export var stack_limit := 8
|
@export var stack_limit := 8
|
||||||
|
|
||||||
@export var sells_for := 0
|
|
||||||
|
@ -35,6 +35,8 @@ func _on_player_joined(id: int) -> void:
|
|||||||
_register_player.rpc_id(id, username)
|
_register_player.rpc_id(id, username)
|
||||||
|
|
||||||
if _game_started:
|
if _game_started:
|
||||||
|
set_coins.rpc_id(id, GameState.fetch().coins)
|
||||||
|
|
||||||
for item_id in GameState.fetch().inventory:
|
for item_id in GameState.fetch().inventory:
|
||||||
set_inventory_item_count.rpc_id(id, item_id, GameState.fetch().inventory[item_id].count)
|
set_inventory_item_count.rpc_id(id, item_id, GameState.fetch().inventory[item_id].count)
|
||||||
|
|
||||||
@ -178,6 +180,11 @@ func _on_chat_message_submitted(text := "") -> void:
|
|||||||
_chat_input.clear()
|
_chat_input.clear()
|
||||||
|
|
||||||
|
|
||||||
|
@rpc("authority", "call_local", "reliable")
|
||||||
|
func set_coins(value: int) -> void:
|
||||||
|
GameState.fetch().coins = value
|
||||||
|
|
||||||
|
|
||||||
## Make sure it exists and all.
|
## Make sure it exists and all.
|
||||||
func prepate_inventory_idem(item_id: StringName) -> void:
|
func prepate_inventory_idem(item_id: StringName) -> void:
|
||||||
if not GameState.fetch().inventory.has(item_id):
|
if not GameState.fetch().inventory.has(item_id):
|
||||||
|
Loading…
Reference in New Issue
Block a user