Skip to content

Commit

Permalink
Rebalance the game a bit (#48)
Browse files Browse the repository at this point in the history
* Adjust pipette and watering can

* Adjust fert. and water can spray

* Manhole, sprinkler, other particle stuff

* Limit time to 3 minutes
  • Loading branch information
Xkonti authored Aug 20, 2024
1 parent 094764f commit dd09f49
Show file tree
Hide file tree
Showing 19 changed files with 161 additions and 84 deletions.
13 changes: 11 additions & 2 deletions scenes/levels/world.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=35 format=3 uid="uid://bg7g48sbn5na8"]
[gd_scene load_steps=36 format=3 uid="uid://bg7g48sbn5na8"]

[ext_resource type="PackedScene" uid="uid://fgpto6xwiehx" path="res://scenes/characters/plant.tscn" id="1_hy1fl"]
[ext_resource type="PackedScene" uid="uid://ethfqolg7tpy" path="res://assets/models/world/world_sphere.glb" id="1_w6odn"]
Expand All @@ -25,6 +25,7 @@
[ext_resource type="PackedScene" uid="uid://touox4x6ip7l" path="res://assets/models/city/city.glb" id="17_rp11v"]
[ext_resource type="PackedScene" path="res://scenes/props/tree.tscn" id="22_dqnln"]
[ext_resource type="PackedScene" uid="uid://dqxhamrsiplmr" path="res://assets/models/barrel/Empty Barrel.glb" id="25_rrnhn"]
[ext_resource type="PackedScene" uid="uid://btnpd8nq3wmio" path="res://scenes/objects/sprinkler.tscn" id="26_scyh7"]

[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_ngwyh"]
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
Expand Down Expand Up @@ -446,7 +447,10 @@ transform = Transform3D(-0.751966, 0, 0.659201, 0, 1, 0, -0.659201, 0, -0.751966
transform = Transform3D(-0.666129, 0, -0.745836, 0, 1, 0, 0.745836, 0, -0.666129, -2.29801, 0.224026, -2.40271)

[node name="Manhole" parent="Interactable" instance=ExtResource("7_cfvaw")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.7519, 0.128385, 6.74314)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12.4659, -0.046853, 6.10257)
direction = Vector3(-1, 1, -0.5)
force = 12.0
interval = 0.25

[node name="Ladybug2" parent="Interactable" instance=ExtResource("11_nn7mv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.515731, 0.209344, 0.12833)
Expand All @@ -470,3 +474,8 @@ pixel_size = 0.08

[node name="BarrelEmpty" parent="Interactable" instance=ExtResource("25_rrnhn")]
transform = Transform3D(6.47824, -0.00842768, 6.70653, -6.11579e-10, 9.32444, 0.0117174, -6.70654, -0.00814079, 6.47823, -90.0538, -0.735255, -61.1986)

[node name="Sprinkler" parent="Interactable" instance=ExtResource("26_scyh7")]
transform = Transform3D(-0.840784, 0, -0.541371, 0, 1, 0, 0.541371, 0, -0.840784, 2.68783, 0, 3.91572)
nutrient_volume = 0.002
launch_force = Vector2(7, 6)
4 changes: 2 additions & 2 deletions scenes/objects/droplet.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ nutrient_type = 0
volume = 0.2

[sub_resource type="BoxShape3D" id="BoxShape3D_o7exb"]
size = Vector3(0.02, 0.02, 0.02)
size = Vector3(0.04, 0.04, 0.04)

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_a5py2"]
albedo_color = Color(0.364706, 0.631373, 1, 1)

[sub_resource type="BoxMesh" id="BoxMesh_mtjpa"]
material = SubResource("StandardMaterial3D_a5py2")
size = Vector3(0.02, 0.02, 0.02)
size = Vector3(0.04, 0.04, 0.04)

[node name="Droplet" type="RigidBody3D"]
collision_layer = 0
Expand Down
3 changes: 3 additions & 0 deletions scenes/objects/fertilizer.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ size = Vector3(0.469727, 0.662354, 0.243408)
[node name="Fertilizer" type="RigidBody3D" node_paths=PackedStringArray("spawn_point", "spawn_point_target", "animatable", "collision_object")]
freeze_mode = 1
script = ExtResource("1_bikd7")
override_nutrient_value = 0.001
override_nutrient_type = 2
shake_factor = 1.8
particle = ExtResource("6_mwqe2")
spawn_point = NodePath("FertilizerSpawnPoint")
spawn_point_target = NodePath("FertilizerSpawnPointTarget")
animatable = NodePath("CollisionShape3D/Fertilizer")
speed = 0.15
collision_object = NodePath(".")

[node name="Clickable" type="Node3D" parent="."]
Expand Down
4 changes: 2 additions & 2 deletions scenes/objects/fertilizer_particle.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[sub_resource type="Resource" id="Resource_36ut0"]
script = ExtResource("2_6d4nn")
nutrient_type = 2
volume = 0.2
volume = 0.02

[sub_resource type="BoxShape3D" id="BoxShape3D_d0fx2"]
size = Vector3(0.06, 0.06, 0.06)
Expand All @@ -20,7 +20,7 @@ size = Vector3(0.06, 0.06, 0.06)

[node name="FertilizerParticle" type="RigidBody3D" groups=["Particle"]]
collision_layer = 256
collision_mask = 397
collision_mask = 388
script = ExtResource("1_510ek")
nutrient = SubResource("Resource_36ut0")

Expand Down
17 changes: 16 additions & 1 deletion scenes/objects/manhole.tscn
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
[gd_scene load_steps=6 format=3 uid="uid://c1icuiig1k6xn"]
[gd_scene load_steps=9 format=3 uid="uid://c1icuiig1k6xn"]

[ext_resource type="PackedScene" uid="uid://yoaubit78jdv" path="res://scenes/objects/clickable_object.tscn" id="1_7mg8k"]
[ext_resource type="Script" path="res://scripts/objects/manhole.gd" id="1_eet7d"]
[ext_resource type="PackedScene" uid="uid://bmyidg0rpcb4d" path="res://assets/models/sewer/Manhole.glb" id="2_0pdp8"]
[ext_resource type="PackedScene" uid="uid://c1mw82iu1ebpv" path="res://assets/models/sewer/Sewer entrance.glb" id="2_6eja0"]
[ext_resource type="PackedScene" uid="uid://bakw5x6pqj6pd" path="res://scenes/objects/nutrient_stream.tscn" id="5_avv6x"]
[ext_resource type="PackedScene" uid="uid://b54q5xk3084ih" path="res://scenes/objects/droplet.tscn" id="6_q1m56"]
[ext_resource type="PackedScene" uid="uid://djgadgaoeoss8" path="res://scenes/objects/fertilizer_particle.tscn" id="6_rf04n"]

[sub_resource type="BoxShape3D" id="BoxShape3D_dolpo"]
size = Vector3(0.909058, 0.178543, 0.911316)

[node name="Manhole" type="Node3D"]
script = ExtResource("1_eet7d")
interval = 0.5

[node name="ClickableObject" parent="." instance=ExtResource("1_7mg8k")]

Expand All @@ -26,4 +30,15 @@ visible = false
[node name="ClosedModel" parent="." instance=ExtResource("2_6eja0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.00284022, 0)

[node name="FertStream" parent="." instance=ExtResource("5_avv6x")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.132999, 0.269987, -0.190831)
nutrient_volume = 0.03
nutrient_type = 2
nutrient_scene = ExtResource("6_rf04n")

[node name="WaterStream" parent="." instance=ExtResource("5_avv6x")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.181884, 0.269987, -0.190831)
nutrient_volume = 0.015
nutrient_scene = ExtResource("6_q1m56")

[connection signal="clicked" from="ClickableObject" to="." method="on_click" flags=6]
12 changes: 12 additions & 0 deletions scenes/objects/nutrient_stream.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3 uid="uid://bakw5x6pqj6pd"]

[ext_resource type="Script" path="res://scripts/objects/nutrient_stream.gd" id="1_b4si6"]

[node name="NutrientStream" type="Node3D"]
script = ExtResource("1_b4si6")

[node name="Direction" type="Marker3D" parent="."]

[node name="ShootTimer" type="Timer" parent="."]

[connection signal="timeout" from="ShootTimer" to="." method="shoot"]
3 changes: 1 addition & 2 deletions scenes/objects/pipette.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ shape = SubResource("BoxShape3D_mk8fx")
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.00213623, 0.00177002, -0.877942)
script = ExtResource("3_dx5xx")
physic_body = NodePath("../..")
watering_power = null
magic_speed_number = null
watering_power = 0.02

[node name="DropletAudio" type="AudioStreamPlayer3D" parent="CollisionShape3D/Pipette"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.235809, -1.03075e-08)
Expand Down
32 changes: 23 additions & 9 deletions scenes/objects/sprinkler.tscn
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
[gd_scene load_steps=4 format=3 uid="uid://btnpd8nq3wmio"]
[gd_scene load_steps=8 format=3 uid="uid://btnpd8nq3wmio"]

[ext_resource type="PackedScene" uid="uid://daqbj6cvcg34r" path="res://assets/models/sprinkler/Small Sprinkler.glb" id="1_2ghv6"]
[ext_resource type="Script" path="res://scripts/objects/sprinkler.gd" id="1_tgsec"]
[ext_resource type="PackedScene" uid="uid://c52scekv4ff3l" path="res://scenes/objects/water_stream.tscn" id="2_dyvvl"]
[ext_resource type="Script" path="res://scripts/resources/nutrient.gd" id="3_w2bvh"]
[ext_resource type="PackedScene" uid="uid://yoaubit78jdv" path="res://scenes/objects/clickable_object.tscn" id="4_yfmh8"]

[sub_resource type="Resource" id="Resource_sp7of"]
script = ExtResource("3_w2bvh")
nutrient_type = 0
volume = 0.02

[sub_resource type="BoxShape3D" id="BoxShape3D_fob55"]
size = Vector3(0.12085, 0.314392, 0.12207)

[node name="Sprinkler" type="Node3D"]
script = ExtResource("1_tgsec")

[node name="WaterStream" parent="." instance=ExtResource("2_dyvvl")]
nutrient = SubResource("Resource_sp7of")
arch_in_degrees = 71.036
arch_speed = 30.0
arch_deviation = 0.4
tilt_deviation = 0.02

[node name="StaticBody3D" type="StaticBody3D" parent="."]
[node name="ClickableObject" parent="." instance=ExtResource("4_yfmh8")]

[node name="StaticBody3D" type="StaticBody3D" parent="ClickableObject"]
collision_layer = 3

[node name="SprinklerModel" parent="StaticBody3D" instance=ExtResource("1_2ghv6")]
[node name="SprinklerModel" parent="ClickableObject/StaticBody3D" instance=ExtResource("1_2ghv6")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0)

[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="ClickableObject/StaticBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00134277, 0.154205, 0.000488281)
shape = SubResource("BoxShape3D_fob55")

[node name="WaterStream" parent="." instance=ExtResource("2_dyvvl")]
arch_in_degrees = 71.036
arch_speed = 30.0
arch_deviation = 0.4
tilt_deviation = 0.02
[connection signal="clicked" from="ClickableObject" to="." method="on_clicked"]
17 changes: 13 additions & 4 deletions scenes/objects/watering_can.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ script/source = "extends Node3D
## Dependecy
@export var physics_body : PhysicsBody3D
@export var _holes : Array[Node]
@export var water_hole: Marker3D

#@export var drops_per_second := 6
@export var another_magic_number := 10
@export var watering_power: float
@export var another_magic_number := 10.0
var _velocity = Vector3.ZERO
var _watering = false: set = _set_watering

Expand All @@ -31,8 +33,9 @@ func _process(_delta: float) -> void:

var hole = _holes[randi_range(0, _holes.size()-1)]
var droplet = droplet_scene.instantiate() as NutrientParticle
physics_body.get_parent().add_child(droplet)
droplet.configure(_velocity * another_magic_number, hole, physics_body, 6)
get_tree().root.add_child(droplet)
var force_dir = water_hole.get_global_transform().basis.z
droplet.configure(_velocity + (force_dir * another_magic_number) + (Utils.rand_pos_in_sphere() * 0.3), hole, physics_body, watering_power, Nutrient.Nutrients.Water)


func _on_droped():
Expand Down Expand Up @@ -64,11 +67,14 @@ freeze_mode = 1
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000648499, 0.219836, 0.286344)
shape = SubResource("BoxShape3D_swr2n")
[node name="WateringCan" parent="." node_paths=PackedStringArray("physics_body", "_holes") instance=ExtResource("1_xnttj")]
[node name="WateringCan" parent="." node_paths=PackedStringArray("physics_body", "_holes", "water_hole") instance=ExtResource("1_xnttj")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0.25)
script = SubResource("GDScript_pe44m")
physics_body = NodePath("..")
_holes = [NodePath("CanHole"), NodePath("CanHole2"), NodePath("CanHole3"), NodePath("CanHole4"), NodePath("CanHole5")]
water_hole = NodePath("Hole")
watering_power = 0.008
another_magic_number = 1.6
[node name="CanHole" type="Node3D" parent="WateringCan"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.500037, 0.46332, 0.0586642)
Expand Down Expand Up @@ -109,6 +115,9 @@ mesh = SubResource("SphereMesh_ody2w")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.620137, 0.449778, -3.24976e-08)
stream = ExtResource("2_4pl00")
[node name="Hole" type="Marker3D" parent="WateringCan"]
transform = Transform3D(-3.26435e-08, -0.487006, 0.873398, -4.25754e-08, 0.873398, 0.487006, -1, -2.12877e-08, -4.92453e-08, 0.530061, 0.415897, 2.31697e-08)
[node name="Clickable" type="Node3D" parent="."]
script = ExtResource("2_20kk0")
Expand Down
2 changes: 1 addition & 1 deletion scripts/global/growth_timer.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends Node

## Total time available for growth (in seconds)
@export var total_time: float = 5.0 * 60
@export var total_time: float = 3.0 * 60

var time_left: float = total_time
var is_running: bool = false
Expand Down
4 changes: 4 additions & 0 deletions scripts/global/utils.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ static func screen_to_3d_object(node: Node3D, collision_mask: int = 4294967295)

## Query the 3d direct space state, retrives a dictionary with collision
return node.get_world_3d().direct_space_state.intersect_ray(query)

static func rand_pos_in_sphere():
var rand_vector = Vector3(randf_range(-1.0, 1.0), randf_range(-1.0, 1.0), randf_range(-1.0, 1.0))
return rand_vector * (1.0 / rand_vector.length())
2 changes: 1 addition & 1 deletion scripts/objects/components/nutrient_particle.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func _init() -> void:
max_contacts_reported = 1


func configure(initial_speed: Vector3, origin: Node3D, collision_exception: PhysicsBody3D = null, nutrient_value = 0.2, nutrient_type := Nutrient.Nutrients.Water):
func configure(initial_speed: Vector3, origin: Node3D, collision_exception: PhysicsBody3D, nutrient_value, nutrient_type):
if not nutrient:
nutrient = nut_source.new(nutrient_type, nutrient_value)

Expand Down
4 changes: 2 additions & 2 deletions scripts/objects/components/shakable.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extends Node3D

@export_category("Tuning")
@export_subgroup("Nutrient")
@export var override_nutrient_value := 10
@export var override_nutrient_value: float = 0.04
@export var override_nutrient_type := Nutrient.Nutrients.Water

@export_subgroup("Gameplay")
Expand Down Expand Up @@ -36,7 +36,7 @@ func _process(delta: float) -> void:
if _shaking <= 0:
return

_shaking = clampf(_shaking - delta, 0, 10)
_shaking = clampf(_shaking - (delta * 4), 0, 10)

# Call for do some animation considering _shaking as anim speed
_shake_animatable(delta)
Expand Down
20 changes: 11 additions & 9 deletions scripts/objects/components/water_stream.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ class_name Sprinkler
extends Node3D

#Dependency
@export var stream_target : Node3D
@export var stream_target: Node3D
@export var nutrient: Nutrient


@export_category("Tuning")
## Not very elegant, but min and max for the force applied to the water
@export var launch_force := Vector2.ZERO
@export_range(5.0, 90.0) var arch_in_degrees := 20.0
@export var arch_speed : float = 2
@export var arch_deviation : float
@export var tilt_deviation : float
@export var firing_rate : float
@export var firing_deviation : float
@export var arch_speed: float = 2
@export var arch_deviation: float
@export var tilt_deviation: float
@export var firing_rate: float
@export var firing_deviation: float

@onready var droplet_scene := preload("res://scenes/objects/droplet.tscn")

var _enabled := true
var _enabled := false
var _current_arch: float = 0
var _fired_delta: float = 0
var _arch_direction = 1
Expand All @@ -38,7 +40,7 @@ func _process(delta):
_fired_delta = 0

## Get all the variations
var force_v = randf_range(launch_force.x, launch_force.y)
var force_v = randf_range(launch_force.x, launch_force.y)
var arch_v = randf_range(-arch_deviation, arch_deviation) + _current_arch
var tilt_v = randf_range(-tilt_deviation, tilt_deviation)

Expand All @@ -48,7 +50,7 @@ func _process(delta):

var droplet = droplet_scene.instantiate() as NutrientParticle
owner.add_child(droplet)
droplet.configure(dir, self)
droplet.configure(dir, self, null, nutrient.volume, nutrient.nutrient_type)


func _on_enabled() -> void:
Expand Down
15 changes: 13 additions & 2 deletions scripts/objects/manhole.gd
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
extends Node3D

@export var direction: Vector3
@export var force: float
@export var interval: float

@onready var open_model: Node3D = $OpenModel
@onready var closed_model: Node3D = $ClosedModel

@onready var fert_stream: NutrientStream = $FertStream
@onready var water_stream: NutrientStream = $WaterStream
var is_open = false


Expand All @@ -14,4 +19,10 @@ func _ready():
func on_click():
open_model.visible = true
closed_model.visible = false
is_open = true
is_open = true
fert_stream.interval = interval
fert_stream.launch_force = direction.normalized() * force
fert_stream.toggle()
water_stream.interval = interval
water_stream.launch_force = direction.normalized() * force
water_stream.toggle()
Loading

0 comments on commit dd09f49

Please sign in to comment.