ajouts d'objectifs sur la carte, déplacements des icônes et divers changements

This commit is contained in:
Zacharie Guet 2025-09-13 12:48:52 +02:00
parent e56ec31069
commit 85cd832864
81 changed files with 983 additions and 307 deletions

View File

@ -1,5 +1,11 @@
extends Resource
class_name GameData
@export var currentTerrainData : TerrainData
@export var current_terrain_data : TerrainData
@export var unlocked_plant_types_path : Array[PlantType] = [
preload("res://entities/plants/resources/plant_types/champ.tres"),
preload("res://entities/plants/resources/plant_types/chardi.tres"),
preload("res://entities/plants/resources/plant_types/maias.tres"),
preload("res://entities/plants/resources/plant_types/pili.tres"),
]

View File

@ -1,24 +1,31 @@
extends Resource
class_name TerrainData
const TERRAIN_IMAGE_GAME_FACTOR = 40
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE = 300
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE = 50
const TERRAIN_IMAGE_GAME_FACTOR = 40.
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE = 400.
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE = 100.
const DEFAULT_TERRAIN_SIZE = Vector2(2000,2000)
@export var terrainSize : Vector2 = Vector2(1000,1000)
@export var terrain_size : Vector2
func _init(size : Vector2 = DEFAULT_TERRAIN_SIZE):
terrain_size = size
generate_default_contamination()
#region ------------------ Contamination ------------------
@export var contamination : Image = null
func generate_default_contamination(
central_zone_max_size : int = DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE,
central_zone_min_size : int = DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE,
central_zone_max_size : float = DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE,
central_zone_min_size : float = DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE,
):
var noise: Noise = FastNoiseLite.new()
noise.seed = randi()
noise.noise_type = FastNoiseLite.TYPE_CELLULAR
noise.frequency = 0.005 * TERRAIN_IMAGE_GAME_FACTOR
var imageSize = terrainSize / TERRAIN_IMAGE_GAME_FACTOR;
var imageSize = terrain_size / TERRAIN_IMAGE_GAME_FACTOR;
var noise_image = noise.get_image(
imageSize.x,
@ -68,19 +75,42 @@ func is_in_image(pixel_point : Vector2, image : Image):
and pixel_point.y < image.get_height())
func get_contamination(point : Vector2) -> float:
var pixel_point : Vector2 = get_pixel_point(point)
var pixel_point : Vector2i = get_pixel_point(point)
if (is_in_image(pixel_point, contamination)):
return contamination.get_pixel(
int(round(pixel_point.x)),
int(round(pixel_point.y))
pixel_point.x,
pixel_point.y
).r
return 0
func get_decontamination_coverage() -> float:
return ImageTools.get_color_coverage(contamination)
func get_pixel_point(point : Vector2) -> Vector2:
return (
func get_decontamination_surface() -> float:
return ImageTools.get_color_pixel_count(contamination)/TERRAIN_IMAGE_GAME_FACTOR * 10
func get_pixel_point(point : Vector2) -> Vector2i:
return Vector2i(
Vector2(point) / float(TERRAIN_IMAGE_GAME_FACTOR)
- Vector2.ONE / 2
)
#endregion
#region ------------------ Objectives ------------------
func generate_objective_rewards(level = 1, amount = 1) -> Array[ObjectiveReward]:
var possible_objective_rewards_path : Array[ObjectiveReward] = [
IncreaseDayLimitReward.new(randi_range(level + 1, level + 3)),
LootItemReward.new(load("res://common/inventory/resources/items/compost.tres")),
UpgradePlayerMaxEnergyReward.new(),
]
var objectives_reward : Array[ObjectiveReward] = []
var i = 0
while i < amount and len(possible_objective_rewards_path) > 0:
var r = possible_objective_rewards_path.pick_random()
possible_objective_rewards_path.erase(r)
objectives_reward.append(r)
i += 1
return objectives_reward

View File

@ -0,0 +1,7 @@
extends Node
var game_data : GameData
func _init():
if not game_data:
game_data = GameData.new()

View File

@ -0,0 +1 @@
uid://dcamb3xjyfqm1

View File

Before

Width:  |  Height:  |  Size: 887 B

After

Width:  |  Height:  |  Size: 887 B

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dcgnamu7sb3ov"
path="res://.godot/imported/bolt.svg-71cbe0c7c38f15f305dc23930d585037.ctex"
path="res://.godot/imported/bolt.svg-a559d5e701996c7d105fc68102331434.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gui/game/assets/icons/bolt.svg"
dest_files=["res://.godot/imported/bolt.svg-71cbe0c7c38f15f305dc23930d585037.ctex"]
source_file="res://common/icons/bolt.svg"
dest_files=["res://.godot/imported/bolt.svg-a559d5e701996c7d105fc68102331434.ctex"]
[params]
@ -32,6 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-hourglass-empty"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6 20v-2a6 6 0 1 1 12 0v2a1 1 0 0 1 -1 1h-10a1 1 0 0 1 -1 -1z" /><path d="M6 4v2a6 6 0 1 0 12 0v-2a1 1 0 0 0 -1 -1h-10a1 1 0 0 0 -1 1z" /></svg>

After

Width:  |  Height:  |  Size: 464 B

View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cxkmn71f8d2hy"
path="res://.godot/imported/hourglass-empty.svg-e7568d697204ad5aa1416ea495c59e73.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://common/icons/hourglass-empty.svg"
dest_files=["res://.godot/imported/hourglass-empty.svg-e7568d697204ad5aa1416ea495c59e73.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://djb52fosgmv4j"
path="res://.godot/imported/left_click.svg-163ab642e0d1ce655b5b40384b3f1392.ctex"
path="res://.godot/imported/left_click.svg-f515b89b9c254e1eacbc2bef4d187a50.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gui/pointer/assets/icons/left_click.svg"
dest_files=["res://.godot/imported/left_click.svg-163ab642e0d1ce655b5b40384b3f1392.ctex"]
source_file="res://common/icons/left_click.svg"
dest_files=["res://.godot/imported/left_click.svg-f515b89b9c254e1eacbc2bef4d187a50.ctex"]
[params]
@ -32,6 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 451 B

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dex283rx00fjb"
path="res://.godot/imported/logout.svg-adb7b7ff1fadfa9220dcf694870580b9.ctex"
path="res://.godot/imported/logout.svg-15891d2f0d875a13ef182339fdbc6039.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gui/game/pause/assets/icons/logout.svg"
dest_files=["res://.godot/imported/logout.svg-adb7b7ff1fadfa9220dcf694870580b9.ctex"]
source_file="res://common/icons/logout.svg"
dest_files=["res://.godot/imported/logout.svg-15891d2f0d875a13ef182339fdbc6039.ctex"]
[params]
@ -32,6 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

Before

Width:  |  Height:  |  Size: 468 B

After

Width:  |  Height:  |  Size: 468 B

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://0xg54agef5gh"
path="res://.godot/imported/package.svg-a9602fd424cfb199cd9405d02663e7df.ctex"
path="res://.godot/imported/package.svg-0d0e7de2f6c04b754487a1f6252ee2a1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://common/inventory/assets/icons/package.svg"
dest_files=["res://.godot/imported/package.svg-a9602fd424cfb199cd9405d02663e7df.ctex"]
source_file="res://common/icons/package.svg"
dest_files=["res://.godot/imported/package.svg-0d0e7de2f6c04b754487a1f6252ee2a1.ctex"]
[params]
@ -32,6 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

Before

Width:  |  Height:  |  Size: 412 B

After

Width:  |  Height:  |  Size: 412 B

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://b5cuxgisrsfgt"
path="res://.godot/imported/player-pause.svg-cb8236066c72679196b716c41226079f.ctex"
path="res://.godot/imported/player-pause.svg-8c388309845b649483858ace29fdf914.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gui/game/pause/assets/icons/player-pause.svg"
dest_files=["res://.godot/imported/player-pause.svg-cb8236066c72679196b716c41226079f.ctex"]
source_file="res://common/icons/player-pause.svg"
dest_files=["res://.godot/imported/player-pause.svg-8c388309845b649483858ace29fdf914.ctex"]
[params]
@ -32,6 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

Before

Width:  |  Height:  |  Size: 326 B

After

Width:  |  Height:  |  Size: 326 B

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://vmsn54d1ptih"
path="res://.godot/imported/player-play.svg-25043c6a392478c90f845ddfdfb35372.ctex"
path="res://.godot/imported/player-play.svg-230ff7b9a6c52930be11873163a0e7de.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gui/game/pause/assets/icons/player-play.svg"
dest_files=["res://.godot/imported/player-play.svg-25043c6a392478c90f845ddfdfb35372.ctex"]
source_file="res://common/icons/player-play.svg"
dest_files=["res://.godot/imported/player-play.svg-230ff7b9a6c52930be11873163a0e7de.ctex"]
[params]
@ -32,6 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://y3083o1fhgn0"
path="res://.godot/imported/right_click.svg-89ed358ede3244ca5dababdd0f091dae.ctex"
path="res://.godot/imported/right_click.svg-1adb207c34017f29e28afdeafbacdd7f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gui/pointer/assets/icons/right_click.svg"
dest_files=["res://.godot/imported/right_click.svg-89ed358ede3244ca5dababdd0f091dae.ctex"]
source_file="res://common/icons/right_click.svg"
dest_files=["res://.godot/imported/right_click.svg-1adb207c34017f29e28afdeafbacdd7f.ctex"]
[params]
@ -32,6 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

Before

Width:  |  Height:  |  Size: 357 B

After

Width:  |  Height:  |  Size: 357 B

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bewr0t1wi8pff"
path="res://.godot/imported/rotate.svg-af6a45b9d3420200a268c1390881e44f.ctex"
path="res://.godot/imported/rotate.svg-8b3d996ae2422076b9f55d10f0455aa8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gui/game/pause/assets/icons/rotate.svg"
dest_files=["res://.godot/imported/rotate.svg-af6a45b9d3420200a268c1390881e44f.ctex"]
source_file="res://common/icons/rotate.svg"
dest_files=["res://.godot/imported/rotate.svg-8b3d996ae2422076b9f55d10f0455aa8.ctex"]
[params]
@ -32,6 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

Before

Width:  |  Height:  |  Size: 524 B

After

Width:  |  Height:  |  Size: 524 B

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bo3o2qf3i20ke"
path="res://.godot/imported/scuba-diving-tank.svg-d6c94087bb8fe7a9f788baf1911a56a2.ctex"
path="res://.godot/imported/scuba-diving-tank.svg-2724f573f5956cc7af7dbc8616ac0aa4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://common/inventory/assets/icons/scuba-diving-tank.svg"
dest_files=["res://.godot/imported/scuba-diving-tank.svg-d6c94087bb8fe7a9f788baf1911a56a2.ctex"]
source_file="res://common/icons/scuba-diving-tank.svg"
dest_files=["res://.godot/imported/scuba-diving-tank.svg-2724f573f5956cc7af7dbc8616ac0aa4.ctex"]
[params]

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#ffffff" class="icon icon-tabler icons-tabler-filled icon-tabler-seedling"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6 3a7 7 0 0 1 6.95 6.155a6.97 6.97 0 0 1 5.05 -2.155h3a1 1 0 0 1 1 1v1a7 7 0 0 1 -7 7h-2v4a1 1 0 0 1 -2 0v-7h-2a7 7 0 0 1 -7 -7v-2a1 1 0 0 1 1 -1z" /></svg>

After

Width:  |  Height:  |  Size: 387 B

View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b0wy3dbpxbnt7"
path="res://.godot/imported/seedling.svg-86222438bce7bb2a4f266ea315728eb5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://common/icons/seedling.svg"
dest_files=["res://.godot/imported/seedling.svg-86222438bce7bb2a4f266ea315728eb5.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

Before

Width:  |  Height:  |  Size: 498 B

After

Width:  |  Height:  |  Size: 498 B

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bf6nw4onkhavr"
path="res://.godot/imported/shovel.svg-f17d484b3a88170abdf08077458176fb.ctex"
path="res://.godot/imported/shovel.svg-094c34e330000cc8ea425d6acf7556bd.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://common/inventory/assets/icons/shovel.svg"
dest_files=["res://.godot/imported/shovel.svg-f17d484b3a88170abdf08077458176fb.ctex"]
source_file="res://common/icons/shovel.svg"
dest_files=["res://.godot/imported/shovel.svg-094c34e330000cc8ea425d6acf7556bd.ctex"]
[params]

View File

Before

Width:  |  Height:  |  Size: 583 B

After

Width:  |  Height:  |  Size: 583 B

View File

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://b38hdpsvqcwg8"
path="res://.godot/imported/users-group.svg-65aad5cfa47be548675b81fab7ab9db6.ctex"
path="res://.godot/imported/users-group.svg-e8465fccc5e5f0e575fcbdabcdf52e8b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gui/menu/assets/icons/users-group.svg"
dest_files=["res://.godot/imported/users-group.svg-65aad5cfa47be548675b81fab7ab9db6.ctex"]
source_file="res://common/icons/users-group.svg"
dest_files=["res://.godot/imported/users-group.svg-e8465fccc5e5f0e575fcbdabcdf52e8b.ctex"]
[params]
@ -32,6 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
svg/scale=2.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="Package" load_steps=4 format=3 uid="uid://bya8sm6rm6747"]
[ext_resource type="Texture2D" uid="uid://0xg54agef5gh" path="res://common/inventory/assets/icons/package.svg" id="1_lhhdv"]
[ext_resource type="Texture2D" uid="uid://0xg54agef5gh" path="res://common/icons/package.svg" id="1_lhhdv"]
[ext_resource type="Script" uid="uid://b6kubqgq0k7vj" path="res://common/inventory/scripts/items/package.gd" id="1_x02bb"]
[ext_resource type="PackedScene" uid="uid://bkwh1ntvgkkrt" path="res://entities/interactables/machines/compost/compost.tscn" id="2_uulso"]
@ -8,7 +8,7 @@
script = ExtResource("1_x02bb")
scene = ExtResource("2_uulso")
name = "Compost"
description = "The compost allow you to upgrade your max energy when putting in it a certain amount of seeds."
description = "The compost allow you to generate one energy for a certain amount of seeds."
icon = ExtResource("1_lhhdv")
use_zone_radius = 5
use_energy = 1

View File

@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="Seed" load_steps=3 format=3 uid="uid://lrl2okkhyxmx"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/game/assets/icons/bolt.svg" id="1_dy25s"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="1_dy25s"]
[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed.gd" id="2_mgcdi"]
[resource]

View File

@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="Shovel" load_steps=3 format=3 uid="uid://ddqalo1k30i5x"]
[ext_resource type="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/inventory/assets/icons/shovel.svg" id="1_7g3xd"]
[ext_resource type="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/icons/shovel.svg" id="1_7g3xd"]
[ext_resource type="Script" uid="uid://dya38x1h1uiyg" path="res://common/inventory/scripts/items/shovel.gd" id="1_28h2r"]
[resource]

View File

@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="Item" load_steps=3 format=3 uid="uid://dbja8xm7ehw1v"]
[ext_resource type="Texture2D" uid="uid://bo3o2qf3i20ke" path="res://common/inventory/assets/icons/scuba-diving-tank.svg" id="1_sy4rh"]
[ext_resource type="Texture2D" uid="uid://bo3o2qf3i20ke" path="res://common/icons/scuba-diving-tank.svg" id="1_sy4rh"]
[ext_resource type="Script" uid="uid://bq7admu4ahs5r" path="res://common/inventory/scripts/item.gd" id="2_aikyk"]
[resource]

View File

@ -1,13 +1,15 @@
class_name ImageTools
static func get_color_coverage(image: Image, color: Color = Color.WHITE):
static func get_color_coverage(image: Image, color: Color = Color.WHITE) -> float:
return float(get_color_pixel_count(image, color))/(image.get_width()*image.get_height())
static func get_color_pixel_count(image: Image, color: Color = Color.WHITE) -> int:
var pixel_color_count = 0.
for x in range(image.get_width()):
for y in range(image.get_height()):
if image.get_pixel(x, y) == color:
pixel_color_count += 1.
return pixel_color_count/(image.get_width()*image.get_height())
return pixel_color_count
static func draw_circle(image: Image, center: Vector2i, length: int, color: Color = Color.WHITE):
for x in range(image.get_width()):

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=7 format=3 uid="uid://bcj812ox8xv2t"]
[ext_resource type="Script" uid="uid://reliyx2pg7kf" path="res://entities/interactables/item_object/script/item_object_sprite.gd" id="1_wing4"]
[ext_resource type="Texture2D" uid="uid://bo3o2qf3i20ke" path="res://common/inventory/assets/icons/scuba-diving-tank.svg" id="2_ng3e4"]
[ext_resource type="Texture2D" uid="uid://bo3o2qf3i20ke" path="res://common/icons/scuba-diving-tank.svg" id="2_ng3e4"]
[ext_resource type="Texture2D" uid="uid://c1eiu5ag7lcp8" path="res://entities/interactables/item_object/assets/sprites/shadow.svg" id="2_ng201"]
[sub_resource type="Animation" id="Animation_wing4"]

View File

@ -68,9 +68,10 @@ func generate_sprite() -> ItemObjectSprite:
var spriteNode = SPRITE_SCENE.instantiate() as ItemObjectSprite
add_child(spriteNode)
spriteNode.apply_texture_to_sprite(
item.icon,
ITEM_SPRITE_SIZE
)
if item:
spriteNode.apply_texture_to_sprite(
item.icon,
ITEM_SPRITE_SIZE
)
return spriteNode

View File

@ -1,7 +1,11 @@
[gd_scene load_steps=10 format=3 uid="uid://bkwh1ntvgkkrt"]
[gd_scene load_steps=11 format=3 uid="uid://bkwh1ntvgkkrt"]
[ext_resource type="Script" uid="uid://dw6jgsasb2fe1" path="res://entities/interactables/machines/compost/scripts/compost.gd" id="1_c0pig"]
[ext_resource type="Texture2D" uid="uid://f2rte5jc0psp" path="res://entities/interactables/machines/compost/assets/sprites/compost.svg" id="2_r6435"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="3_akkx7"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_akkx7"]
size = Vector2(66, 84)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_etofw"]
bg_color = Color(0.260098, 0.11665, 0.0419712, 0.231373)
@ -95,14 +99,14 @@ _data = {
&"fill": SubResource("Animation_etofw")
}
[sub_resource type="RectangleShape2D" id="RectangleShape2D_akkx7"]
size = Vector2(66, 84)
[node name="Compost" type="Area2D"]
script = ExtResource("1_c0pig")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_akkx7")
[node name="Compost" type="Sprite2D" parent="."]
modulate = Color(0.615686, 0.501961, 0.270588, 1)
self_modulate = Color(0.729698, 0.588265, 0.105405, 1)
scale = Vector2(0.291262, 0.291262)
texture = ExtResource("2_r6435")
@ -117,10 +121,13 @@ theme_override_styles/fill = SubResource("StyleBoxFlat_3ao1n")
fill_mode = 3
show_percentage = false
[node name="Bolt" type="Sprite2D" parent="Compost"]
z_index = 1
position = Vector2(0, 54.9334)
scale = Vector2(2.00278, 2.00278)
texture = ExtResource("3_akkx7")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_etofw")
}
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_akkx7")

View File

@ -1,22 +1,24 @@
extends Machine
class_name Compost
var value_per_seed : float = 0.5
var fill_value : float = 0.
@export var seed_needed : int = 2
@export var energy_production : int = 1
var containing_seed : int = 0
func _process(_delta):
%ProgressBar.value = lerp(%ProgressBar.value, fill_value * 100, 0.5)
%ProgressBar.value = lerp(%ProgressBar.value, float(containing_seed) / float(seed_needed) * 100, 0.5)
func pointer_text():
return "Compost"
func interact_text():
return "Put a seed ("+str(roundi((1-fill_value)/value_per_seed))+" left)"
return "Put a seed ("+str(seed_needed - containing_seed)+" left)"
func inspector_info() -> Inspector.Info:
return Inspector.Info.new(
pointer_text(),
"The compost allow you to upgrade your max energy when putting in it a certain amount of seeds."
"The compost allow you to generate one energy for " + str(seed_needed) + " seeds."
)
func can_interact(p : Player) -> bool:
@ -31,12 +33,11 @@ func interact(p : Player) -> bool:
p.play_sfx("harvest")
p.delete_item(p.inventory.get_item())
fill_value += value_per_seed
if fill_value >= 1.:
containing_seed += 1
if containing_seed >= seed_needed:
$AnimationPlayer.play("empty")
fill_value = 0
p.upgrade()
value_per_seed /= 1.5
containing_seed = 0
p.recharge(energy_production)
else:
$AnimationPlayer.play("fill")
return true

View File

@ -1,23 +1,29 @@
[gd_scene load_steps=4 format=3 uid="uid://d324mlmgls4fs"]
[gd_scene load_steps=5 format=3 uid="uid://d324mlmgls4fs"]
[ext_resource type="Script" uid="uid://bsrn3gd2a532q" path="res://entities/interactables/machines/recharge_station/scripts/recharge_station.gd" id="1_2ffjo"]
[ext_resource type="Texture2D" uid="uid://c82ljr3in67am" path="res://entities/interactables/machines/recharge_station/assets/sprites/recharge_station.svg" id="2_58ax0"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="3_3xua0"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bjhct"]
radius = 15.0
height = 72.0
[node name="RechargeStation" type="Area2D"]
modulate = Color(0.615686, 0.501961, 0.270588, 1)
script = ExtResource("1_2ffjo")
metadata/_custom_type_script = "uid://dyprcd68fjstf"
[node name="RechargeStation" type="Sprite2D" parent="."]
position = Vector2(0, -17)
scale = Vector2(0.3, 0.3)
texture = ExtResource("2_58ax0")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(1, -1)
rotation = -1.5708
shape = SubResource("CapsuleShape2D_bjhct")
[node name="RechargeStation" type="Sprite2D" parent="."]
self_modulate = Color(0.729412, 0.588235, 0.105882, 1)
position = Vector2(0, -17)
scale = Vector2(0.3, 0.3)
texture = ExtResource("2_58ax0")
[node name="Bolt" type="Sprite2D" parent="."]
position = Vector2(0, -40)
scale = Vector2(0.375, 0.375)
texture = ExtResource("3_3xua0")

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dbednu7eygtrf"
path="res://.godot/imported/arbre_mort.png-eea217ee3fbf6520e6fbde71f18bbeef.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/objectives/assets/sprites/arbre_mort.png"
dest_files=["res://.godot/imported/arbre_mort.png-eea217ee3fbf6520e6fbde71f18bbeef.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c4pv2o7crchc0"
path="res://.godot/imported/little_plant.png-e9ed84e9420c629c3911ff755b194643.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/objectives/assets/sprites/little_plant.png"
dest_files=["res://.godot/imported/little_plant.png-e9ed84e9420c629c3911ff755b194643.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -0,0 +1,281 @@
[gd_scene load_steps=11 format=3 uid="uid://djl2le58ckgdx"]
[ext_resource type="Script" uid="uid://j8fpi8rd8eyy" path="res://entities/objectives/scripts/objective.gd" id="1_3hqw5"]
[ext_resource type="Texture2D" uid="uid://dbednu7eygtrf" path="res://entities/objectives/assets/sprites/arbre_mort.png" id="2_3hqw5"]
[ext_resource type="Texture2D" uid="uid://c4pv2o7crchc0" path="res://entities/objectives/assets/sprites/little_plant.png" id="3_dulsb"]
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="4_6uhem"]
[ext_resource type="Texture2D" uid="uid://bo3o2qf3i20ke" path="res://common/icons/scuba-diving-tank.svg" id="5_6uhem"]
[sub_resource type="Animation" id="Animation_v08i5"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("ArbreMort:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(0.443137, 0.443137, 0.443137, 1)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("LittlePlant:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("LittlePlant:scale")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0.094358, 0.094358)]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("LittlePlant2:visible")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("LittlePlant2:scale")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0.094358, 0.094358)]
}
tracks/5/type = "value"
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/path = NodePath("LittlePlant3:visible")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/6/type = "value"
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/path = NodePath("LittlePlant3:scale")
tracks/6/interp = 1
tracks/6/loop_wrap = true
tracks/6/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0.094358, 0.094358)]
}
tracks/7/type = "value"
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/path = NodePath("ArbreMort:scale")
tracks/7/interp = 1
tracks/7/loop_wrap = true
tracks/7/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0.162791, 0.162791)]
}
[sub_resource type="Animation" id="Animation_6uhem"]
resource_name = "activate"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("ArbreMort:modulate")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.266667),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Color(0.443137, 0.443137, 0.443137, 1), Color(1, 1, 1, 1)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("LittlePlant:visible")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.0333333),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("LittlePlant:scale")
tracks/2/interp = 2
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0.433333, 0.6),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(0, 0), Vector2(0.094358, 0.094358)]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("LittlePlant2:visible")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0.0333333),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("LittlePlant2:scale")
tracks/4/interp = 2
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0.6, 0.8),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(0, 0), Vector2(0.094358, 0.094358)]
}
tracks/5/type = "value"
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/path = NodePath("LittlePlant3:visible")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/keys = {
"times": PackedFloat32Array(0.0333333),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/6/type = "value"
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/path = NodePath("LittlePlant3:scale")
tracks/6/interp = 2
tracks/6/loop_wrap = true
tracks/6/keys = {
"times": PackedFloat32Array(0.4, 0.533333),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(0, 0), Vector2(0.094358, 0.094358)]
}
tracks/7/type = "value"
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/path = NodePath("ArbreMort:scale")
tracks/7/interp = 2
tracks/7/loop_wrap = true
tracks/7/keys = {
"times": PackedFloat32Array(0, 0.1, 0.266667, 0.4),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Vector2(0.162791, 0.162791), Vector2(0.183, 0.093), Vector2(0.123, 0.178), Vector2(0.162791, 0.162791)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_047qm"]
_data = {
&"RESET": SubResource("Animation_v08i5"),
&"activate": SubResource("Animation_6uhem")
}
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bvagy"]
radius = 24.0
height = 160.0
[sub_resource type="LabelSettings" id="LabelSettings_v08i5"]
font = ExtResource("4_6uhem")
font_size = 18
[node name="Objective" type="Area2D"]
script = ExtResource("1_3hqw5")
metadata/_custom_type_script = "uid://d3bk52402ylvl"
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true
libraries = {
&"": SubResource("AnimationLibrary_047qm")
}
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -20)
rotation = 1.5708
shape = SubResource("CapsuleShape2D_bvagy")
[node name="ArbreMort" type="Sprite2D" parent="."]
modulate = Color(0.443137, 0.443137, 0.443137, 1)
position = Vector2(5, 4)
scale = Vector2(0.162791, 0.162791)
texture = ExtResource("2_3hqw5")
centered = false
offset = Vector2(-627.055, -607.11)
[node name="LittlePlant" type="Sprite2D" parent="."]
visible = false
position = Vector2(-22, -46)
scale = Vector2(0.094358, 0.094358)
texture = ExtResource("3_dulsb")
[node name="LittlePlant2" type="Sprite2D" parent="."]
visible = false
position = Vector2(39, -25)
scale = Vector2(0.094358, 0.094358)
texture = ExtResource("3_dulsb")
[node name="LittlePlant3" type="Sprite2D" parent="."]
visible = false
position = Vector2(-49, -14)
scale = Vector2(0.094358, 0.094358)
texture = ExtResource("3_dulsb")
[node name="RewardInfo" type="HBoxContainer" parent="."]
unique_name_in_owner = true
offset_left = -67.0
offset_top = -34.0
offset_right = 51.0
offset_bottom = -15.0
theme_override_constants/separation = 2
alignment = 1
[node name="RewardText" type="Label" parent="RewardInfo"]
unique_name_in_owner = true
layout_mode = 2
text = "bla"
label_settings = SubResource("LabelSettings_v08i5")
[node name="RewardIcon" type="TextureRect" parent="RewardInfo"]
unique_name_in_owner = true
layout_mode = 2
texture = ExtResource("5_6uhem")
expand_mode = 2

View File

@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="IncreaseDayLimitReward" load_steps=2 format=3 uid="uid://b11qyyi8k0mua"]
[ext_resource type="Script" uid="uid://df6i1hivw4ymn" path="res://entities/objectives/scripts/rewards/increase_day_limit_reward.gd" id="1_gt31s"]
[resource]
script = ExtResource("1_gt31s")
day_limit_increase = 5
metadata/_custom_type_script = "uid://df6i1hivw4ymn"

View File

@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="LootRandomSeedsReward" load_steps=2 format=3 uid="uid://ca62vcsijbxgc"]
[ext_resource type="Script" uid="uid://bcdilfb4j7f6d" path="res://entities/objectives/scripts/rewards/loot_random_seeds_reward.gd" id="1_yjhoy"]
[resource]
script = ExtResource("1_yjhoy")
seeds_number = 5
metadata/_custom_type_script = "uid://bcdilfb4j7f6d"

View File

@ -0,0 +1,21 @@
[gd_resource type="Resource" script_class="LootItemReward" load_steps=6 format=3 uid="uid://clmsn7r2shw6j"]
[ext_resource type="Script" uid="uid://dva05p817w00f" path="res://entities/objectives/scripts/rewards/loot_item_reward.gd" id="1_dyn78"]
[ext_resource type="Texture2D" uid="uid://0xg54agef5gh" path="res://common/icons/package.svg" id="1_gvg4i"]
[ext_resource type="PackedScene" uid="uid://bkwh1ntvgkkrt" path="res://entities/interactables/machines/compost/compost.tscn" id="2_22dgr"]
[ext_resource type="Script" uid="uid://b6kubqgq0k7vj" path="res://common/inventory/scripts/items/package.gd" id="3_0bwtl"]
[sub_resource type="Resource" id="Resource_00nan"]
script = ExtResource("3_0bwtl")
scene = ExtResource("2_22dgr")
name = "Compost"
description = "The compost allow you to upgrade your max energy when putting in it a certain amount of seeds."
icon = ExtResource("1_gvg4i")
use_zone_radius = 5
use_energy = 1
metadata/_custom_type_script = "uid://b6kubqgq0k7vj"
[resource]
script = ExtResource("1_dyn78")
item = SubResource("Resource_00nan")
metadata/_custom_type_script = "uid://dva05p817w00f"

View File

@ -0,0 +1,37 @@
extends InspectableEntity
class_name Objective
const RANDOM_MAX_OBJECTIVE_INTERVAL = 1.
var completed : bool = false
var planet : Planet
@export var reward : ObjectiveReward = null :
set(r):
reward = r
update_reward_info(r)
func _ready():
update_reward_info(reward)
func pointer_text():
return "Contamination Objective"
func inspector_info() -> Inspector.Info:
return Inspector.Info.new(
pointer_text(),
"If the zone around is decontaminated, give the following reward.\n\n" + reward.get_description(),
)
func _end_pass_day():
if planet and not completed:
if not planet.is_there_contamination(global_position):
reward.reward(self)
%AnimationPlayer.play("activate")
%RewardInfo.visible = false
completed = true
func update_reward_info(r : ObjectiveReward):
if r:
%RewardText.text = r.get_text()
%RewardIcon.texture = r.get_icon()
%RewardInfo.visible = r != null

View File

@ -0,0 +1 @@
uid://j8fpi8rd8eyy

View File

@ -0,0 +1,14 @@
extends Resource
class_name ObjectiveReward
func reward(_objective : Objective):
pass
func get_icon() -> Texture:
return null
func get_text() -> String:
return ""
func get_description() -> String:
return ""

View File

@ -0,0 +1 @@
uid://bsh4b8miag8w1

View File

@ -0,0 +1,19 @@
extends ObjectiveReward
class_name IncreaseDayLimitReward
@export var day_limit_increase = 5
func _init(_day_limit_increase : int):
day_limit_increase = _day_limit_increase
func reward(objective : Objective):
objective.planet.day_limit += day_limit_increase
func get_icon() -> Texture:
return preload("res://common/icons/hourglass-empty.svg")
func get_text() -> String:
return "+"+str(day_limit_increase)
func get_description() -> String:
return "Increase the day limitation by " + str(day_limit_increase)

View File

@ -0,0 +1 @@
uid://df6i1hivw4ymn

View File

@ -0,0 +1,25 @@
extends ObjectiveReward
class_name LootItemReward
const REWARD_ITEM_RANDOM_DISPLACEMENT_FACTOR = 100
@export var item : Item
func _init(i : Item):
item = i
func get_icon() -> Texture:
return preload("res://common/icons/package.svg")
func get_text() -> String:
return ""
func get_description() -> String:
return "Loot the following item: " + item.name + "."
func reward(objective : Objective):
objective.planet.drop_item(
item,
objective.global_position,
REWARD_ITEM_RANDOM_DISPLACEMENT_FACTOR
)

View File

@ -0,0 +1 @@
uid://dva05p817w00f

View File

@ -0,0 +1 @@
uid://dot5gfkbm7p6s

View File

@ -0,0 +1,26 @@
extends ObjectiveReward
class_name LootRandomSeedsReward
const REWARD_SEED_RANDOM_DISPLACEMENT_FACTOR = 100
@export var seeds_number : int
func _init(number : int):
seeds_number = number
func get_icon() -> Texture:
return preload("res://common/icons/seedling.svg")
func get_text() -> String:
return str(seeds_number)
func get_description() -> String:
return "Loot " + str(seeds_number) + " random seeds."
func reward(objective : Objective):
for i in range(seeds_number):
objective.planet.drop_item(
Seed.new(GameInfo.game_data.unlocked_plant_types_path.pick_random()),
objective.global_position,
REWARD_SEED_RANDOM_DISPLACEMENT_FACTOR
)

View File

@ -0,0 +1 @@
uid://bcdilfb4j7f6d

View File

@ -0,0 +1,19 @@
extends ObjectiveReward
class_name UpgradePlayerMaxEnergyReward
@export var upgrade_amount = 1
func _init(_upgrade_amount : int = 1):
upgrade_amount = _upgrade_amount
func reward(objective : Objective):
objective.planet.player.upgrade_max_energy(upgrade_amount)
func get_icon() -> Texture:
return preload("res://common/icons/bolt.svg")
func get_text() -> String:
return "+"+str(upgrade_amount)+" max"
func get_description() -> String:
return "Increase player max energy by " + str(upgrade_amount)

View File

@ -0,0 +1 @@
uid://cflvw3bfcocnn

View File

@ -2,7 +2,7 @@ extends InspectableEntity
class_name Plant
const PLANT_AREA_WIDTH = 20
const HARVESTED_SEED_POSITION_RANGE = 100
const HARVESTED_SEED_DISPLACEMENT_FACTOR = 100
const RANDOM_MAX_GROW_INTERVAL = Planet.PASS_DAY_ANIMATION_TIME/2. - 0.1
@ -88,24 +88,12 @@ func harvest():
var seed_plant_type : PlantType = plant_type
if len(plant_type.harvest_types_path):
seed_plant_type = load(plant_type.harvest_types_path.pick_random())
loot_seed(seed_plant_type)
planet.drop_item(
Seed.new(seed_plant_type),
global_position,
HARVESTED_SEED_DISPLACEMENT_FACTOR,
)
plant_sprite.start_harvest_animation()
await plant_sprite.harvest_animation_finished
queue_free()
func loot_seed(type : PlantType):
var item_object = planet.drop_item(
Seed.new(type),
global_position
)
var tween : Tween = get_tree().create_tween()
tween.tween_property(
item_object,
"position",
Vector2(
item_object.position.x + randi()%HARVESTED_SEED_POSITION_RANGE,
item_object.position.y + randi()%HARVESTED_SEED_POSITION_RANGE
),
0.2
)

View File

@ -5,7 +5,11 @@ class_name ProduceSeedsEffect
@export var produce_number : Array[int] = [1]
func effect(plant):
for _i in range(produce_number.pick_random()):
if len(produce_types_path):
var seed_plant_type = load(produce_types_path.pick_random())
plant.loot_seed(seed_plant_type)
for _i in range(produce_number.pick_random()):
if len(produce_types_path):
var seed_plant_type = load(produce_types_path.pick_random())
plant.planet.drop_item(
Seed.new(seed_plant_type),
plant.global_position,
plant.HARVESTED_SEED_DISPLACEMENT_FACTOR,
)

View File

@ -14,4 +14,4 @@ class_name PlantType
@export var cyclic_effect : PlantEffect
@export_file var harvest_types_path : Array[String] = []
@export var harvest_number : Array[int] = [1,2]
@export var harvest_number : Array[int] = [1,2]

View File

@ -3,7 +3,7 @@
[ext_resource type="Script" uid="uid://das7twcy5153p" path="res://entities/player/scripts/player.gd" id="1_abrql"]
[ext_resource type="Texture2D" uid="uid://c7ff87jniga5m" path="res://entities/player/assets/sprites/robot.png" id="1_symyc"]
[ext_resource type="AudioStream" uid="uid://dfrp66a4isnt6" path="res://entities/player/sounds/dig/dig_1.wav" id="3_gx6sm"]
[ext_resource type="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/inventory/assets/icons/shovel.svg" id="3_yqrof"]
[ext_resource type="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/icons/shovel.svg" id="3_yqrof"]
[ext_resource type="AudioStream" uid="uid://bdxkvaciw4mb3" path="res://entities/player/sounds/dig/dig_2.wav" id="4_yqrof"]
[ext_resource type="AudioStream" uid="uid://llxrlwfccywb" path="res://entities/player/sounds/dig/dig_3.wav" id="5_3wlsy"]
[ext_resource type="AudioStream" uid="uid://8nmr5vifkt1f" path="res://entities/player/sounds/harvest/harvest_1.wav" id="6_b2kln"]

View File

@ -41,7 +41,7 @@ func _start_pass_day():
# Méthode déclenchée par la classe planet
func _pass_day():
recharge()
full_recharge()
# Méthode déclenchée par la classe planet
func _end_pass_day():
@ -149,15 +149,19 @@ func use_item(item : Item):
if item.is_one_time_use():
delete_item(item)
func upgrade():
max_energy += 1
energy += 1
func upgrade_max_energy(amount = 1):
max_energy += amount
upgraded.emit()
player_updated.emit(self)
func recharge(amount : int = max_energy):
energy = min(energy + amount, max_energy)
energy = energy + amount
upgraded.emit()
func generate_action_area(radius : int = 0) -> Area2D:
func full_recharge():
energy = max(energy, max_energy)
func generate_action_zone(radius : int = 0) -> Area2D:
var area2D = Area2D.new()
var collision_shape = CollisionShape2D.new()
var circle_shape = CircleShape2D.new()
@ -173,13 +177,13 @@ func generate_action_area(radius : int = 0) -> Area2D:
func setup_preview_zone(zone_radius : int) -> Area2D:
if preview_zone:
preview_zone.queue_free()
preview_zone = generate_action_area(zone_radius)
preview_zone = generate_action_zone(zone_radius)
return preview_zone
func setup_action_zone(zone_position : Vector2, zone_radius : int) -> Area2D:
if action_zone:
action_zone.queue_free()
action_zone = generate_action_area(zone_radius)
action_zone = generate_action_zone(zone_radius)
action_zone.global_position = zone_position
return action_zone

136
game.tscn
View File

@ -1,136 +0,0 @@
[gd_scene load_steps=27 format=3 uid="uid://d28cp7a21kwou"]
[ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/game/game_gui.tscn" id="1_iotsf"]
[ext_resource type="PackedScene" uid="uid://csiacsndm62ll" path="res://gui/game/pause/pause.tscn" id="2_215e1"]
[ext_resource type="PackedScene" uid="uid://bgvbgeq46wee2" path="res://entities/player/player.tscn" id="2_lc2xo"]
[ext_resource type="PackedScene" uid="uid://v41hfc7haaye" path="res://gui/game/win/win.tscn" id="3_7sc4i"]
[ext_resource type="Script" uid="uid://dedg615xudpoq" path="res://entities/interactables/item_object/script/item_object.gd" id="3_215e1"]
[ext_resource type="PackedScene" uid="uid://tsi5j1uxppa4" path="res://stages/terrain/planet/planet.tscn" id="6_e8heu"]
[ext_resource type="Resource" uid="uid://ddqalo1k30i5x" path="res://common/inventory/resources/items/default_shovel.tres" id="6_lc2xo"]
[ext_resource type="Resource" uid="uid://bya8sm6rm6747" path="res://common/inventory/resources/items/compost.tres" id="7_215e1"]
[ext_resource type="Script" uid="uid://bq7admu4ahs5r" path="res://common/inventory/scripts/item.gd" id="7_rvswv"]
[ext_resource type="PackedScene" uid="uid://d324mlmgls4fs" path="res://entities/interactables/machines/recharge_station/recharge_station.tscn" id="8_7sc4i"]
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="8_boyg6"]
[ext_resource type="Resource" uid="uid://b04vho33bl52b" path="res://entities/plants/resources/plant_types/chardi.tres" id="9_e36ub"]
[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed.gd" id="10_hb5m1"]
[ext_resource type="Resource" uid="uid://dsctivn1vrem2" path="res://entities/plants/resources/plant_types/maias.tres" id="11_x5p1p"]
[ext_resource type="PackedScene" uid="uid://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="12_qhcbd"]
[ext_resource type="Resource" uid="uid://cxrc5wchpqm18" path="res://entities/plants/resources/plant_types/champ.tres" id="15_80cx4"]
[ext_resource type="Resource" uid="uid://c5oxxif3h5yxo" path="res://entities/plants/resources/plant_types/pili.tres" id="16_e8heu"]
[sub_resource type="AtlasTexture" id="AtlasTexture_qt76e"]
atlas = ExtResource("8_boyg6")
region = Rect2(1140, 345, 141, 128)
[sub_resource type="Resource" id="Resource_7sc4i"]
script = ExtResource("10_hb5m1")
plant_type = ExtResource("9_e36ub")
name = "Chardi"
description = "This plant remove a lot of contamination around when it becomes mature."
icon = SubResource("AtlasTexture_qt76e")
use_zone_radius = 5
use_energy = 1
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
[sub_resource type="Resource" id="Resource_80cx4"]
script = ExtResource("10_hb5m1")
plant_type = ExtResource("9_e36ub")
name = "Chardi"
description = "This plant remove a lot of contamination around when it becomes mature."
icon = SubResource("AtlasTexture_qt76e")
use_zone_radius = 5
use_energy = 1
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
[sub_resource type="AtlasTexture" id="AtlasTexture_sri3b"]
atlas = ExtResource("8_boyg6")
region = Rect2(1697, 331, 125, 158)
[sub_resource type="Resource" id="Resource_e8heu"]
script = ExtResource("10_hb5m1")
plant_type = ExtResource("11_x5p1p")
name = "Maias"
description = "This gorgeous flower produce a lot of seeds."
icon = SubResource("AtlasTexture_sri3b")
use_zone_radius = 5
use_energy = 1
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
[sub_resource type="AtlasTexture" id="AtlasTexture_my6by"]
atlas = ExtResource("8_boyg6")
region = Rect2(610, 315, 124, 180)
[sub_resource type="Resource" id="Resource_rvswv"]
script = ExtResource("10_hb5m1")
plant_type = ExtResource("15_80cx4")
name = "Champ"
description = "When mature, produce a seed every day"
icon = SubResource("AtlasTexture_my6by")
use_zone_radius = 5
use_energy = 1
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
[sub_resource type="AtlasTexture" id="AtlasTexture_kidty"]
atlas = ExtResource("8_boyg6")
region = Rect2(1415, 91, 149, 102)
[sub_resource type="Resource" id="Resource_boyg6"]
script = ExtResource("10_hb5m1")
plant_type = ExtResource("16_e8heu")
name = "Pili"
description = "Pili slowly decontaminate each day when mature."
icon = SubResource("AtlasTexture_kidty")
use_zone_radius = 5
use_energy = 1
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
[node name="Game" type="Node2D"]
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="RootGui" parent="CanvasLayer" instance=ExtResource("1_iotsf")]
metadata/_edit_use_anchors_ = true
[node name="Pause" parent="CanvasLayer" instance=ExtResource("2_215e1")]
process_mode = 3
visible = false
z_index = 1000
[node name="Win" parent="CanvasLayer" instance=ExtResource("3_7sc4i")]
visible = false
[node name="Entities" type="Node2D" parent="."]
y_sort_enabled = true
[node name="Player" parent="Entities" instance=ExtResource("2_lc2xo")]
[node name="ItemObject" type="Area2D" parent="Entities"]
position = Vector2(0, 129)
script = ExtResource("3_215e1")
item = ExtResource("6_lc2xo")
metadata/_custom_type_script = "uid://dedg615xudpoq"
[node name="ItemObject2" type="Area2D" parent="Entities"]
position = Vector2(-162, 23)
script = ExtResource("3_215e1")
item = ExtResource("7_215e1")
metadata/_custom_type_script = "uid://dedg615xudpoq"
[node name="RechargeStation" parent="Entities" instance=ExtResource("8_7sc4i")]
position = Vector2(-1, -217)
[node name="Planet" parent="." node_paths=PackedStringArray("import_entities_from_node") instance=ExtResource("6_e8heu")]
loot_items = Array[ExtResource("7_rvswv")]([SubResource("Resource_7sc4i"), SubResource("Resource_80cx4"), SubResource("Resource_e8heu"), SubResource("Resource_rvswv"), SubResource("Resource_boyg6")])
import_entities_from_node = NodePath("../Entities")
[node name="Camera" parent="." node_paths=PackedStringArray("following") instance=ExtResource("12_qhcbd")]
position = Vector2(2.22, 0)
following = NodePath("../Entities/Player")
[connection signal="pause_asked" from="CanvasLayer/RootGui" to="CanvasLayer/Pause" method="_on_root_gui_pause_asked"]
[connection signal="player_updated" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_updated"]
[connection signal="upgraded" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_upgraded"]
[connection signal="day_limit_exceed" from="Planet" to="CanvasLayer/Win" method="_on_planet_day_limit_exceed"]
[connection signal="pass_day_ended" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_pass_day_ended"]
[connection signal="pass_day_started" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_pass_day_started"]
[connection signal="planet_updated" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_updated"]

View File

@ -3,10 +3,10 @@
[ext_resource type="Script" uid="uid://cqao7n800qy40" path="res://gui/game/scripts/game_gui.gd" id="1_udau0"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="2_nq5i2"]
[ext_resource type="Texture2D" uid="uid://cm3ehinvvj52i" path="res://gui/game/assets/texture/Interface sans boutons.png" id="3_n4kem"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/game/assets/icons/bolt.svg" id="4_k4juk"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="4_k4juk"]
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="4_ujg5r"]
[ext_resource type="PackedScene" uid="uid://d3lff5fui1k0c" path="res://gui/game/inspector/inspector.tscn" id="6_dr1y2"]
[ext_resource type="Texture2D" uid="uid://b5cuxgisrsfgt" path="res://gui/game/pause/assets/icons/player-pause.svg" id="9_2wykm"]
[ext_resource type="Texture2D" uid="uid://b5cuxgisrsfgt" path="res://common/icons/player-pause.svg" id="9_2wykm"]
[sub_resource type="Gradient" id="Gradient_id0t5"]
interpolation_mode = 1
@ -279,10 +279,10 @@ stretch_mode = 5
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.281899
anchor_top = 0.384375
anchor_right = 0.281899
anchor_bottom = 0.584375
anchor_left = 0.267062
anchor_top = 0.453125
anchor_right = 0.267062
anchor_bottom = 0.496875
offset_left = -44.0
offset_top = -12.5
offset_right = 44.0
@ -296,6 +296,7 @@ metadata/_edit_use_anchors_ = true
custom_minimum_size = Vector2(36.64, 0)
layout_mode = 2
texture = ExtResource("4_k4juk")
expand_mode = 2
stretch_mode = 5
[node name="EnergyCount" type="Label" parent="MarginContainer/PlayerInfo/EnergyInfo"]

View File

@ -4,9 +4,9 @@
[ext_resource type="Script" uid="uid://crt2d4m5ba25i" path="res://gui/game/pause/scripts/pause.gd" id="1_he4ox"]
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="2_8d1kg"]
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="3_0pdto"]
[ext_resource type="Texture2D" uid="uid://vmsn54d1ptih" path="res://gui/game/pause/assets/icons/player-play.svg" id="5_apjlw"]
[ext_resource type="Texture2D" uid="uid://bewr0t1wi8pff" path="res://gui/game/pause/assets/icons/rotate.svg" id="6_58dya"]
[ext_resource type="Texture2D" uid="uid://dex283rx00fjb" path="res://gui/game/pause/assets/icons/logout.svg" id="7_yj6f1"]
[ext_resource type="Texture2D" uid="uid://vmsn54d1ptih" path="res://common/icons/player-play.svg" id="5_apjlw"]
[ext_resource type="Texture2D" uid="uid://bewr0t1wi8pff" path="res://common/icons/rotate.svg" id="6_58dya"]
[ext_resource type="Texture2D" uid="uid://dex283rx00fjb" path="res://common/icons/logout.svg" id="7_yj6f1"]
[sub_resource type="LabelSettings" id="LabelSettings_apjlw"]
font = ExtResource("2_8d1kg")

View File

@ -19,8 +19,8 @@ func _on_day_pass_pressed():
await $AnimationPlayer.animation_finished
func _on_planet_updated(planet:Planet):
%DayCount.text = "Day " + str(planet.day)
%DecontaminationCoverage.text = str(roundi(planet.decontamination_coverage * 100)) + "%"
%DayCount.text = "Day " + str(planet.day) + "/" + str(planet.day_limit)
%DecontaminationCoverage.text = str(roundi(planet.decontamination_surface)) + " m2"
func _on_player_action_tried_without_energy():

View File

@ -3,10 +3,10 @@ extends Control
func _ready():
visible = false
func win(decontamination_coverage : float):
func win(decontamination_surface : float):
visible = true
get_tree().paused = true
%WinTitle.text = "Score : " + str(roundi(decontamination_coverage * 100)) + "%"
%WinTitle.text = "Score : " + str(roundi(decontamination_surface)) + " m2"
func _on_restart_pressed():
get_tree().reload_current_scene()
@ -16,4 +16,4 @@ func _on_quit_pressed():
func _on_planet_day_limit_exceed(planet : Planet):
win(planet.decontamination_coverage)
win(planet.decontamination_surface)

View File

@ -4,8 +4,8 @@
[ext_resource type="Script" uid="uid://b3wuxv04clyed" path="res://gui/game/win/scripts/win.gd" id="1_sehw2"]
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="2_sehw2"]
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="3_0b3c6"]
[ext_resource type="Texture2D" uid="uid://bewr0t1wi8pff" path="res://gui/game/pause/assets/icons/rotate.svg" id="4_8p3aj"]
[ext_resource type="Texture2D" uid="uid://dex283rx00fjb" path="res://gui/game/pause/assets/icons/logout.svg" id="5_j3wid"]
[ext_resource type="Texture2D" uid="uid://bewr0t1wi8pff" path="res://common/icons/rotate.svg" id="4_8p3aj"]
[ext_resource type="Texture2D" uid="uid://dex283rx00fjb" path="res://common/icons/logout.svg" id="5_j3wid"]
[sub_resource type="LabelSettings" id="LabelSettings_eq457"]
font = ExtResource("2_sehw2")

View File

@ -6,4 +6,5 @@ func _ready():
%Version.text = ProjectSettings.get_setting("application/config/version")
func _on_start_pressed():
GameInfo.game_data.current_terrain_data = TerrainData.new()
get_tree().change_scene_to_file(start_scene_path)

View File

@ -3,8 +3,8 @@
[ext_resource type="Script" uid="uid://vhumsfntpqcl" path="res://gui/pointer/scripts/pointer.gd" id="1_1pe2k"]
[ext_resource type="Texture2D" uid="uid://bspffyprdywgc" path="res://gui/pointer/assets/cursors/pointer.svg" id="2_q4bvb"]
[ext_resource type="AudioStream" uid="uid://bym03qp4n6vep" path="res://gui/pointer/assets/sounds/click.wav" id="3_kj0cm"]
[ext_resource type="Texture2D" uid="uid://djb52fosgmv4j" path="res://gui/pointer/assets/icons/left_click.svg" id="3_pshoq"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/game/assets/icons/bolt.svg" id="4_b4uwv"]
[ext_resource type="Texture2D" uid="uid://djb52fosgmv4j" path="res://common/icons/left_click.svg" id="3_pshoq"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="4_b4uwv"]
[ext_resource type="Script" uid="uid://c2en2hc6a7ils" path="res://gui/pointer/scripts/action_zone.gd" id="4_pshoq"]
[node name="Pointer" type="Node"]
@ -46,11 +46,13 @@ layout_mode = 2
[node name="MouseImage" type="TextureRect" parent="CanvasLayer/Inspector/Container/Action"]
layout_mode = 2
texture = ExtResource("3_pshoq")
expand_mode = 2
[node name="ActionEnergyImage" type="TextureRect" parent="CanvasLayer/Inspector/Container/Action"]
unique_name_in_owner = true
layout_mode = 2
texture = ExtResource("4_b4uwv")
expand_mode = 2
[node name="ActionText" type="Label" parent="CanvasLayer/Inspector/Container/Action"]
unique_name_in_owner = true

View File

@ -21,6 +21,7 @@ config/icon="uid://df0y0s666ui4h"
Pointer="*res://gui/pointer/pointer.tscn"
Music="*res://common/music/music.tscn"
GameInfo="*res://common/game_info/game_info.gd"
[input]

View File

@ -6,7 +6,7 @@
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="4_gd4vy"]
[ext_resource type="Texture2D" uid="uid://nx4wxpr6mk8l" path="res://gui/menu/assets/texture/SeedingPlanetsLogo.png" id="5_qw60f"]
[ext_resource type="Texture2D" uid="uid://03ijmo6xlytu" path="res://gui/menu/assets/texture/abre1glow.png" id="6_eji0w"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/game/assets/icons/bolt.svg" id="7_qwhpj"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="7_qwhpj"]
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="8_bf3um"]
[node name="Root" type="Node2D"]

View File

@ -0,0 +1,59 @@
[gd_scene load_steps=10 format=3 uid="uid://d28cp7a21kwou"]
[ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/game/game_gui.tscn" id="1_yy1uy"]
[ext_resource type="PackedScene" uid="uid://csiacsndm62ll" path="res://gui/game/pause/pause.tscn" id="2_bt4fd"]
[ext_resource type="PackedScene" uid="uid://v41hfc7haaye" path="res://gui/game/win/win.tscn" id="3_6guxm"]
[ext_resource type="PackedScene" uid="uid://bgvbgeq46wee2" path="res://entities/player/player.tscn" id="4_g33f4"]
[ext_resource type="Script" uid="uid://dedg615xudpoq" path="res://entities/interactables/item_object/script/item_object.gd" id="5_kgrdw"]
[ext_resource type="Resource" uid="uid://ddqalo1k30i5x" path="res://common/inventory/resources/items/default_shovel.tres" id="6_4rjiq"]
[ext_resource type="PackedScene" uid="uid://d324mlmgls4fs" path="res://entities/interactables/machines/recharge_station/recharge_station.tscn" id="7_h4bgy"]
[ext_resource type="PackedScene" uid="uid://tsi5j1uxppa4" path="res://stages/terrain/planet/planet.tscn" id="8_t31p7"]
[ext_resource type="PackedScene" uid="uid://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="16_m18ms"]
[node name="PlanetRun" type="Node2D"]
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="RootGui" parent="CanvasLayer" instance=ExtResource("1_yy1uy")]
metadata/_edit_use_anchors_ = true
[node name="Pause" parent="CanvasLayer" instance=ExtResource("2_bt4fd")]
process_mode = 3
visible = false
z_index = 1000
[node name="Win" parent="CanvasLayer" instance=ExtResource("3_6guxm")]
visible = false
[node name="Entities" type="Node2D" parent="."]
y_sort_enabled = true
[node name="Player" parent="Entities" instance=ExtResource("4_g33f4")]
position = Vector2(0, 13.49)
[node name="ItemObject" type="Area2D" parent="Entities"]
position = Vector2(0, 129)
script = ExtResource("5_kgrdw")
item = ExtResource("6_4rjiq")
metadata/_custom_type_script = "uid://dedg615xudpoq"
[node name="RechargeStation" parent="Entities" instance=ExtResource("7_h4bgy")]
[node name="Planet" parent="." node_paths=PackedStringArray("import_entities_from_node") instance=ExtResource("8_t31p7")]
loot_number = Array[int]([1])
loot_item_number = Array[int]([1])
objective_first_distance = 150
objective_between_distance = 150
import_entities_from_node = NodePath("../Entities")
[node name="Camera" parent="." node_paths=PackedStringArray("following") instance=ExtResource("16_m18ms")]
position = Vector2(2.22, 0)
following = NodePath("../Entities/Player")
[connection signal="pause_asked" from="CanvasLayer/RootGui" to="CanvasLayer/Pause" method="_on_root_gui_pause_asked"]
[connection signal="player_updated" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_updated"]
[connection signal="upgraded" from="Entities/Player" to="CanvasLayer/RootGui" method="_on_player_upgraded"]
[connection signal="day_limit_exceed" from="Planet" to="CanvasLayer/Win" method="_on_planet_day_limit_exceed"]
[connection signal="pass_day_ended" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_pass_day_ended"]
[connection signal="pass_day_started" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_pass_day_started"]
[connection signal="planet_updated" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_updated"]

15
stages/scripts/game.gd Normal file
View File

@ -0,0 +1,15 @@
extends Node2D
class_name PlanetRun
@export var planet : Planet
@export var game_data : GameData
func _ready():
if not game_data:
game_data = GameData.new()
if not game_data.current_terrain_data:
game_data.current_terrain_data = TerrainData.new()
if planet:
planet.instant

View File

@ -0,0 +1 @@
uid://gn3dt881v5tk

View File

@ -8,14 +8,19 @@ signal pass_day_proceeded(planet : Planet)
signal pass_day_ended(planet : Planet)
const PASS_DAY_ANIMATION_TIME : float = 1.5
const DAY_LIMIT : int = 10
const DEFAULT_DAY_LIMIT : int = 10
const PLANET_TEXTURE_SCALE : float = 5.0
const OBJECTIVE_MAX_LEVEL : int = 10
const OBJECTIVE_MIN_ANGLE_DIFF = PI/2
@export_group("Loot")
@export var first_loot_number : int = 3
@export var loot_number : Array[int] = [0,1,2]
@export var loot_item_number : Array[int] = [1,2]
@export var loot_items : Array[Item] = []
@export_group("Objectives")
@export var objective_first_distance : int = 200
@export var objective_between_distance : int = 200
@export_group("Textures")
@export var background_texture : Texture2D
@ -23,20 +28,43 @@ const PLANET_TEXTURE_SCALE : float = 5.0
@onready var background_sprite : Polygon2D = generate_background_sprite()
@onready var contamination_sprite : Polygon2D = generate_contamination_terrain_sprite()
@onready var decontamination_coverage : float = terrainData.get_decontamination_coverage() :
@onready var decontamination_surface : float = terrain_data.get_decontamination_surface() :
set(v):
decontamination_coverage = v
print(v)
decontamination_surface = v
planet_updated.emit(self)
@onready var objective_scene : PackedScene = preload("res://entities/objectives/objective.tscn")
var contamination_texture : ImageTexture
var day : int = 1 :
set(v):
day = v
planet_updated.emit(self)
var day_limit = DEFAULT_DAY_LIMIT :
set(v):
day_limit = v
planet_updated.emit(self)
var player : Player
func _ready():
planet_updated.emit(self)
generate_loot(first_loot_number)
generate_objectives()
# queue_redraw()
# func _draw():
# var factor = 10
# for x in range(terrain_data.terrain_size.x / factor):
# for y in range(terrain_data.terrain_size.y / factor):
# var point = Vector2(x, y) * factor
# draw_circle(
# point,
# factor/10,
# Color.BLUE if is_there_contamination(point) else Color.RED,
# true
# )
#region ------------------ Generation ------------------
@ -53,12 +81,15 @@ func add_entity(e : Node2D, container : Node2D = entityContainer):
if "planet" in e:
e.planet = self
if e is Player:
player = e
container.add_child(e)
func generate_polygon_sprite(order : int = 0) -> Polygon2D:
var sprite = Polygon2D.new()
var size = terrainData.terrainSize
var size = terrain_data.terrain_size
sprite.polygon = PackedVector2Array([
Vector2(0,0),
Vector2(size.x, 0),
@ -82,15 +113,15 @@ func generate_background_sprite() -> Polygon2D:
return sprite
func generate_contamination_terrain_sprite() -> Polygon2D:
if not terrainData.contamination:
terrainData.generate_default_contamination()
if not terrain_data.contamination:
terrain_data.generate_default_contamination()
var sprite :Polygon2D = generate_polygon_sprite(1)
contamination_texture = ImageTexture.create_from_image(terrainData.contamination)
contamination_texture = ImageTexture.create_from_image(terrain_data.contamination)
contamination_material.set_shader_parameter("data_texture", contamination_texture)
contamination_material.set_shader_parameter("data_texture_size", terrainData.terrainSize)
contamination_material.set_shader_parameter("data_texture_size", terrain_data.terrain_size)
contamination_material.set_shader_parameter("texture_scale", PLANET_TEXTURE_SCALE)
sprite.material = contamination_material
@ -117,15 +148,15 @@ func plant(
return true
func impact_contamination(impact_position : Vector2, impact_radius : int, contamination : bool = false):
terrainData.impact_contamination(impact_position, impact_radius, 0. if contamination else 1.)
terrain_data.impact_contamination(impact_position, impact_radius, 0. if contamination else 1.)
if contamination_texture:
contamination_texture.update(terrainData.contamination)
contamination_texture.update(terrain_data.contamination)
func is_in_zone(point : Vector2) -> bool:
return terrainData.is_in_image(terrainData.get_pixel_point(point), terrainData.contamination)
return terrain_data.is_in_image(terrain_data.get_pixel_point(point), terrain_data.contamination)
func is_there_contamination(point : Vector2) -> bool:
return terrainData.get_contamination(point) < 0.5
return terrain_data.get_contamination(point) < 0.5
func pass_day():
for e : Node2D in entityContainer.get_children():
@ -147,23 +178,50 @@ func pass_day():
if e.has_method("_end_pass_day"):
e._end_pass_day()
decontamination_coverage = terrainData.get_decontamination_coverage()
if day + 1 > DAY_LIMIT:
decontamination_surface = terrain_data.get_decontamination_surface()
if day + 1 > day_limit:
day_limit_exceed.emit(self)
func generate_loot(number : int = loot_number.pick_random()):
for i in range(number):
var loot = UndergroundLoot.new(self)
for j in range(loot_item_number.pick_random()):
loot.loot.append(loot_items.pick_random())
loot.loot.append(
Seed.new(GameInfo.game_data.unlocked_plant_types_path.pick_random())
)
add_entity(loot)
var loot_random_range = UndergroundLoot.LOOTED_ITEM_RANDOM_RANGE
loot.global_position = Vector2(
randf_range(loot_random_range, terrainData.terrainSize.x - loot_random_range),
randf_range(loot_random_range, terrainData.terrainSize.y - loot_random_range)
randf_range(loot_random_range, terrain_data.terrain_size.x - loot_random_range),
randf_range(loot_random_range, terrain_data.terrain_size.y - loot_random_range)
)
func generate_objectives():
var last_objective_angle = 10
for i in range(OBJECTIVE_MAX_LEVEL):
var objective_rewards : Array[ObjectiveReward] = terrain_data.generate_objective_rewards(i, 2)
for objective_reward in objective_rewards:
var objective_angle = randf_range(0, PI*2)
while abs(objective_angle - last_objective_angle) < OBJECTIVE_MIN_ANGLE_DIFF:
objective_angle = randf_range(0, PI*2)
last_objective_angle = objective_angle
generate_objective(
objective_first_distance + objective_between_distance * i,
objective_angle,
objective_reward,
)
func generate_objective(distance : int, angle : float, reward : ObjectiveReward):
var objective : Objective = objective_scene.instantiate() as Objective
add_entity(objective)
objective.reward = reward
objective.position = Vector2.ONE.rotated(angle) * distance
#endregion

View File

@ -5,15 +5,11 @@ const BORDER_WIDTH = 100
@export var import_entities_from_node : Node2D = null
@export var terrainData : TerrainData
@onready var terrain_data : TerrainData = GameInfo.game_data.current_terrain_data if GameInfo.game_data.current_terrain_data else TerrainData.new()
@onready var borderLimit : StaticBody2D = create_border_limit()
@onready var entityContainer : Node2D = create_entity_container()
func _init():
if not terrainData:
terrainData = TerrainData.new()
func add_entity(e : Node2D, container : Node2D = entityContainer):
if e.get_parent():
e.get_parent().remove_child(e)
@ -23,7 +19,7 @@ func add_entity(e : Node2D, container : Node2D = entityContainer):
func create_entity_container() -> Node2D:
var container = Node2D.new()
container.y_sort_enabled = true
container.position = terrainData.terrainSize/2
container.position = terrain_data.terrain_size/2
add_child(container)
@ -33,10 +29,22 @@ func create_entity_container() -> Node2D:
return container
func drop_item(item: Item, item_position : Vector2) -> ItemObject:
func drop_item(item: Item, item_position : Vector2, random_displacement_factor = 0) -> ItemObject:
var item_object = ItemObject.new(item)
add_entity(item_object)
item_object.global_position = item_position
if random_displacement_factor:
var displacement_direction = randf_range(0,2*PI)
var displacement = Vector2.ONE.rotated(displacement_direction) * randf_range(0, random_displacement_factor)
var tween : Tween = get_tree().create_tween()
tween.tween_property(
item_object,
"position",
item_object.position + displacement,
0.2
)
return item_object
func create_border_limit() -> StaticBody2D:
@ -46,7 +54,7 @@ func create_border_limit() -> StaticBody2D:
add_child(staticBody)
staticBody.add_child(staticBodyCollision)
var size = terrainData.terrainSize
var size = terrain_data.terrain_size
staticBodyCollision.polygon = PackedVector2Array([
Vector2(0,0),
Vector2(0, size.y),