grow sprouts !
This commit is contained in:
@ -2,8 +2,11 @@ extends Node3D
|
||||
|
||||
@export var _need_water_drop: Sprite3D
|
||||
@export var _production_timer: Timer
|
||||
@export var _sprite: Sprite3D
|
||||
|
||||
var needs_water := true
|
||||
var stage: int = 1
|
||||
var final_stage: int = 3
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@ -17,16 +20,26 @@ func _on_production_timer_timeout() -> void:
|
||||
|
||||
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
func _reflect_combo() -> void:
|
||||
GameState.fetch().player_data[multiplayer.get_unique_id()].chain_water_combo(1)
|
||||
func _reflect_texture(p_stage: int) -> void:
|
||||
_sprite.texture = load("res://assets/sprout%s.png" % p_stage)
|
||||
|
||||
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
func _water_shared(sender_id: int) -> void:
|
||||
if stage >= final_stage:
|
||||
return
|
||||
stage += 1
|
||||
_sprite.texture = load("res://assets/sprout%s.png" % stage)
|
||||
if sender_id != 0:
|
||||
GameState.fetch().player_data[sender_id].chain_water_combo(1)
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func water(sender_id: int) -> void:
|
||||
if needs_water:
|
||||
needs_water = false
|
||||
_water_shared.rpc(sender_id)
|
||||
_need_water_drop.hide()
|
||||
if sender_id != 0:
|
||||
_reflect_combo.rpc_id(sender_id)
|
||||
|
||||
_production_timer.start()
|
||||
|
||||
if stage != final_stage:
|
||||
needs_water = false
|
||||
_production_timer.start()
|
||||
|
@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bysgtksvovyur"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/ingame/sprout.gd" id="1_snma1"]
|
||||
[ext_resource type="Texture2D" uid="uid://d35y5ckne72qe" path="res://assets/sprout.png" id="2_ipgad"]
|
||||
[ext_resource type="Texture2D" uid="uid://d35y5ckne72qe" path="res://assets/sprout1.png" id="2_ipgad"]
|
||||
[ext_resource type="Texture2D" uid="uid://cwbl0r1e26eja" path="res://assets/drop.png" id="3_kghdv"]
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_rs2qp"]
|
||||
@ -16,16 +16,18 @@ properties/1/replication_mode = 2
|
||||
radius = 0.3
|
||||
height = 0.8
|
||||
|
||||
[node name="Sprout" type="Node3D" node_paths=PackedStringArray("_need_water_drop", "_production_timer")]
|
||||
[node name="Sprout" type="Node3D" node_paths=PackedStringArray("_need_water_drop", "_production_timer", "_sprite")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00401986, -0.00383317, 0.00119042)
|
||||
script = ExtResource("1_snma1")
|
||||
_need_water_drop = NodePath("NeedWaterDrop")
|
||||
_production_timer = NodePath("ProductionTimer")
|
||||
_sprite = NodePath("Sprite3D")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_rs2qp")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.3, 0)
|
||||
pixel_size = 0.02
|
||||
billboard = 2
|
||||
shaded = true
|
||||
@ -49,6 +51,7 @@ monitoring = false
|
||||
shape = SubResource("CapsuleShape3D_cwbye")
|
||||
|
||||
[node name="ProductionTimer" type="Timer" parent="."]
|
||||
wait_time = 5.0
|
||||
one_shot = true
|
||||
|
||||
[connection signal="timeout" from="ProductionTimer" to="." method="_on_production_timer_timeout"]
|
||||
|
Reference in New Issue
Block a user