correct pass_day method name
This commit is contained in:
parent
3021567ecb
commit
352c49cefa
@ -45,7 +45,8 @@ func generate_collision_shape() -> CollisionShape2D:
|
|||||||
|
|
||||||
return collision
|
return collision
|
||||||
|
|
||||||
func pass_day():
|
# Méthode déclenchée par la classe planet
|
||||||
|
func _pass_day():
|
||||||
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
|
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
|
||||||
day += 1
|
day += 1
|
||||||
|
|
||||||
|
|||||||
@ -93,8 +93,8 @@ func use_item():
|
|||||||
if item.is_one_time_use():
|
if item.is_one_time_use():
|
||||||
delete_item()
|
delete_item()
|
||||||
|
|
||||||
|
# Méthode déclenchée par la classe planet
|
||||||
func pass_day():
|
func _pass_day():
|
||||||
energy = max_energy
|
energy = max_energy
|
||||||
|
|
||||||
func detect_closest_interactable():
|
func detect_closest_interactable():
|
||||||
|
|||||||
21
root.tscn
21
root.tscn
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=22 format=3 uid="uid://c5bruelvqbm1k"]
|
[gd_scene load_steps=19 format=3 uid="uid://c5bruelvqbm1k"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/root_gui.tscn" id="1_jnlp7"]
|
[ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/root_gui.tscn" id="1_jnlp7"]
|
||||||
[ext_resource type="PackedScene" uid="uid://tsi5j1uxppa4" path="res://stages/terrain/planet/planet.tscn" id="1_pyidc"]
|
[ext_resource type="PackedScene" uid="uid://tsi5j1uxppa4" path="res://stages/terrain/planet/planet.tscn" id="1_pyidc"]
|
||||||
@ -7,8 +7,6 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="3_vvh5c"]
|
[ext_resource type="PackedScene" uid="uid://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="3_vvh5c"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/inventory/assets/icons/shovel.svg" id="4_huihk"]
|
[ext_resource type="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/inventory/assets/icons/shovel.svg" id="4_huihk"]
|
||||||
[ext_resource type="Script" uid="uid://dya38x1h1uiyg" path="res://common/inventory/scripts/items/shovel.gd" id="5_qw60f"]
|
[ext_resource type="Script" uid="uid://dya38x1h1uiyg" path="res://common/inventory/scripts/items/shovel.gd" id="5_qw60f"]
|
||||||
[ext_resource type="Script" uid="uid://jom8ulyopso" path="res://common/inventory/scripts/tool_item.gd" id="5_tw3kd"]
|
|
||||||
[ext_resource type="Texture2D" uid="uid://bo3o2qf3i20ke" path="res://common/inventory/assets/icons/scuba-diving-tank.svg" id="6_gd4vy"]
|
|
||||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_tw3kd"]
|
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_tw3kd"]
|
||||||
[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed.gd" id="9_gd4vy"]
|
[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed.gd" id="9_gd4vy"]
|
||||||
[ext_resource type="Resource" uid="uid://b04vho33bl52b" path="res://entities/plants/resources/plants/default.tres" id="9_qw60f"]
|
[ext_resource type="Resource" uid="uid://b04vho33bl52b" path="res://entities/plants/resources/plants/default.tres" id="9_qw60f"]
|
||||||
@ -24,15 +22,6 @@ description = ""
|
|||||||
icon = ExtResource("4_huihk")
|
icon = ExtResource("4_huihk")
|
||||||
metadata/_custom_type_script = "uid://dya38x1h1uiyg"
|
metadata/_custom_type_script = "uid://dya38x1h1uiyg"
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_eji0w"]
|
|
||||||
script = ExtResource("5_tw3kd")
|
|
||||||
area_width = 100.0
|
|
||||||
area_distance = 90.0
|
|
||||||
name = "Arrosoir"
|
|
||||||
description = ""
|
|
||||||
icon = ExtResource("6_gd4vy")
|
|
||||||
metadata/_custom_type_script = "uid://jom8ulyopso"
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qt76e"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_qt76e"]
|
||||||
atlas = ExtResource("6_tw3kd")
|
atlas = ExtResource("6_tw3kd")
|
||||||
region = Rect2(1140, 345, 141, 128)
|
region = Rect2(1140, 345, 141, 128)
|
||||||
@ -77,17 +66,11 @@ y_sort_enabled = true
|
|||||||
[node name="Player" parent="Entities" instance=ExtResource("2_vvh5c")]
|
[node name="Player" parent="Entities" instance=ExtResource("2_vvh5c")]
|
||||||
|
|
||||||
[node name="ItemObject" type="Area2D" parent="Entities"]
|
[node name="ItemObject" type="Area2D" parent="Entities"]
|
||||||
position = Vector2(306, 0)
|
position = Vector2(2, 72)
|
||||||
script = ExtResource("3_bf3um")
|
script = ExtResource("3_bf3um")
|
||||||
item = SubResource("Resource_qt76e")
|
item = SubResource("Resource_qt76e")
|
||||||
metadata/_custom_type_script = "uid://dedg615xudpoq"
|
metadata/_custom_type_script = "uid://dedg615xudpoq"
|
||||||
|
|
||||||
[node name="ItemObject2" type="Area2D" parent="Entities"]
|
|
||||||
position = Vector2(-23, -242)
|
|
||||||
script = ExtResource("3_bf3um")
|
|
||||||
item = SubResource("Resource_eji0w")
|
|
||||||
metadata/_custom_type_script = "uid://dedg615xudpoq"
|
|
||||||
|
|
||||||
[node name="Planet" parent="." node_paths=PackedStringArray("import_entities_from_node") instance=ExtResource("1_pyidc")]
|
[node name="Planet" parent="." node_paths=PackedStringArray("import_entities_from_node") instance=ExtResource("1_pyidc")]
|
||||||
loot_items = Array[ExtResource("12_sq7yr")]([SubResource("Resource_sq7yr"), SubResource("Resource_blcw0"), SubResource("Resource_50g4q")])
|
loot_items = Array[ExtResource("12_sq7yr")]([SubResource("Resource_sq7yr"), SubResource("Resource_blcw0"), SubResource("Resource_50g4q")])
|
||||||
import_entities_from_node = NodePath("../Entities")
|
import_entities_from_node = NodePath("../Entities")
|
||||||
|
|||||||
@ -2,7 +2,9 @@ extends Terrain
|
|||||||
class_name Planet
|
class_name Planet
|
||||||
|
|
||||||
signal planet_updated(planet : Planet)
|
signal planet_updated(planet : Planet)
|
||||||
|
signal day_limit_exceed
|
||||||
|
|
||||||
|
const DAY_LIMIT : int = 3
|
||||||
const PLANET_TEXTURE_SCALE : float = 5.0
|
const PLANET_TEXTURE_SCALE : float = 5.0
|
||||||
|
|
||||||
@export_group("Loot")
|
@export_group("Loot")
|
||||||
@ -23,7 +25,7 @@ const PLANET_TEXTURE_SCALE : float = 5.0
|
|||||||
planet_updated.emit(self)
|
planet_updated.emit(self)
|
||||||
|
|
||||||
var contamination_texture : ImageTexture
|
var contamination_texture : ImageTexture
|
||||||
var day : int = 0 :
|
var day : int = 1 :
|
||||||
set(v):
|
set(v):
|
||||||
day = v
|
day = v
|
||||||
planet_updated.emit(self)
|
planet_updated.emit(self)
|
||||||
@ -113,12 +115,14 @@ func is_there_contamination(point : Vector2) -> bool:
|
|||||||
return terrainData.get_contamination(point) < 0.5
|
return terrainData.get_contamination(point) < 0.5
|
||||||
|
|
||||||
func pass_day():
|
func pass_day():
|
||||||
|
|
||||||
for e : Node2D in entityContainer.get_children():
|
|
||||||
if e.has_method("pass_day"):
|
|
||||||
e.pass_day()
|
|
||||||
day += 1
|
day += 1
|
||||||
generate_loot()
|
if day > DAY_LIMIT:
|
||||||
|
day_limit_exceed.emit()
|
||||||
|
else:
|
||||||
|
for e : Node2D in entityContainer.get_children():
|
||||||
|
if e.has_method("_pass_day"):
|
||||||
|
e._pass_day()
|
||||||
|
generate_loot()
|
||||||
|
|
||||||
func generate_loot(number : int = loot_number.pick_random()):
|
func generate_loot(number : int = loot_number.pick_random()):
|
||||||
for i in range(number):
|
for i in range(number):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user