refactor du code et ajouts des quotas, avec des récompense entre chaque quota #68
This commit is contained in:
parent
85cd832864
commit
43bdbc3581
@ -1,11 +1,15 @@
|
||||
extends Resource
|
||||
class_name GameData
|
||||
|
||||
@export var current_terrain_data : TerrainData
|
||||
@export var current_planet_data : PlanetData
|
||||
|
||||
@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"),
|
||||
]
|
||||
|
||||
@export var unlocked_machines : Array[MachineType] = [
|
||||
preload("res://entities/interactables/machines/compost/compost.tres")
|
||||
]
|
||||
81
common/game_data/scripts/planet_data.gd
Normal file
81
common/game_data/scripts/planet_data.gd
Normal file
@ -0,0 +1,81 @@
|
||||
extends Resource
|
||||
class_name PlanetData
|
||||
|
||||
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE = 400.
|
||||
const DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE = 100.
|
||||
const DEFAULT_BASE_SIZE = Vector2(2000,2000)
|
||||
|
||||
@export var base_size : Vector2 = Vector2(2000,2000)
|
||||
@export var contamination : TerrainData
|
||||
@export var quota_number : int = 0
|
||||
|
||||
func _init(_base_size : Vector2 = DEFAULT_BASE_SIZE):
|
||||
base_size = _base_size
|
||||
contamination = TerrainData.new(base_size)
|
||||
contamination.draw_random_zone(
|
||||
DEFAULT_CONTAMINATION_CENTRAL_ZONE_MAX_SIZE,
|
||||
DEFAULT_CONTAMINATION_CENTRAL_ZONE_MIN_SIZE,
|
||||
base_size/2
|
||||
)
|
||||
|
||||
|
||||
func impact_contamination(position : Vector2, impact_radius : float, to_value : float = 1.):
|
||||
contamination.draw_circle(
|
||||
position,
|
||||
impact_radius,
|
||||
to_value
|
||||
)
|
||||
|
||||
func is_in_base(point):
|
||||
return (
|
||||
point.x > 0
|
||||
and point.y > 0
|
||||
and point.x < base_size.x
|
||||
and point.y < base_size.y)
|
||||
|
||||
func get_contamination(point : Vector2) -> float:
|
||||
return contamination.get_value(point)
|
||||
|
||||
func get_decontamination_coverage() -> float:
|
||||
return contamination.get_value_coverage()
|
||||
|
||||
func get_decontamination_surface() -> float:
|
||||
return contamination.get_value_surface() * 10
|
||||
#endregion
|
||||
|
||||
#region ------------------ Objectives ------------------
|
||||
func generate_objective_rewards(level = 1) -> Array[ObjectiveReward]:
|
||||
var amount = level + 1
|
||||
|
||||
var possible_objective_rewards_path : Array[ObjectiveReward] = [
|
||||
IncreaseDayLimitReward.new(randi_range(level + 1, level + 3)),
|
||||
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
|
||||
|
||||
#endregion
|
||||
|
||||
#region ------------------ Quotas ------------------
|
||||
func get_quota(n = 0) -> int:
|
||||
var first_quota = 50
|
||||
var quota_adding = n * 50
|
||||
|
||||
if n == 0:
|
||||
return first_quota
|
||||
elif n < 0:
|
||||
return 0
|
||||
|
||||
return get_quota(n - 1) + quota_adding
|
||||
|
||||
#endregion
|
||||
|
||||
1
common/game_data/scripts/planet_data.gd.uid
Normal file
1
common/game_data/scripts/planet_data.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://cx30nvq8b34lj
|
||||
@ -1,116 +1,98 @@
|
||||
extends Resource
|
||||
class_name TerrainData
|
||||
|
||||
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)
|
||||
const UNIT_PER_PIXEL = 30
|
||||
|
||||
@export var terrain_size : Vector2
|
||||
@export var image : Image
|
||||
@export var image_size : Vector2i
|
||||
|
||||
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 : 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 = terrain_size / TERRAIN_IMAGE_GAME_FACTOR;
|
||||
|
||||
var noise_image = noise.get_image(
|
||||
imageSize.x,
|
||||
imageSize.y,
|
||||
1.0
|
||||
)
|
||||
|
||||
ImageTools.draw_gradient(
|
||||
noise_image,
|
||||
imageSize/2,
|
||||
central_zone_min_size / TERRAIN_IMAGE_GAME_FACTOR
|
||||
)
|
||||
|
||||
ImageTools.draw_gradient(
|
||||
noise_image,
|
||||
imageSize/2,
|
||||
central_zone_max_size / TERRAIN_IMAGE_GAME_FACTOR,
|
||||
Color.BLACK,
|
||||
true
|
||||
)
|
||||
|
||||
|
||||
ImageTools.flatten(noise_image, 0.5)
|
||||
|
||||
contamination = Image.create(
|
||||
imageSize.x,
|
||||
imageSize.y,
|
||||
func _init(terrain_size : Vector2):
|
||||
image_size = terrain_size / UNIT_PER_PIXEL
|
||||
image = Image.create(
|
||||
image_size.x,
|
||||
image_size.y,
|
||||
false,
|
||||
Image.Format.FORMAT_L8
|
||||
)
|
||||
|
||||
contamination.copy_from(noise_image)
|
||||
func draw_random_zone(
|
||||
zone_max_size : float,
|
||||
zone_min_size : float,
|
||||
zone_position : Vector2i
|
||||
):
|
||||
var noise: Noise = FastNoiseLite.new()
|
||||
noise.seed = randi()
|
||||
noise.noise_type = FastNoiseLite.TYPE_CELLULAR
|
||||
noise.frequency = 0.001 / UNIT_PER_PIXEL
|
||||
|
||||
func impact_contamination(position : Vector2, impact_radius : int, to_value : float = 1.):
|
||||
var noise_image_size : Vector2i = Vector2i.ONE * zone_max_size / UNIT_PER_PIXEL
|
||||
var noise_image_center = noise_image_size / 2
|
||||
|
||||
var noise_image = noise.get_image(
|
||||
noise_image_size.x,
|
||||
noise_image_size.y,
|
||||
1.0,
|
||||
)
|
||||
|
||||
ImageTools.draw_gradient(
|
||||
noise_image,
|
||||
noise_image_center,
|
||||
roundi(zone_min_size / UNIT_PER_PIXEL)
|
||||
)
|
||||
|
||||
ImageTools.draw_gradient(
|
||||
noise_image,
|
||||
noise_image_center,
|
||||
roundi(zone_max_size / UNIT_PER_PIXEL),
|
||||
Color.BLACK,
|
||||
true
|
||||
)
|
||||
|
||||
ImageTools.flatten(noise_image, 0.5)
|
||||
|
||||
image.blit_rect(
|
||||
noise_image,
|
||||
Rect2i(
|
||||
Vector2i.ZERO,
|
||||
noise_image_size
|
||||
),
|
||||
Vector2i(zone_position / UNIT_PER_PIXEL) - noise_image_size/2
|
||||
)
|
||||
|
||||
func draw_circle(position : Vector2, impact_radius : float, to_value : float = 1.):
|
||||
ImageTools.draw_circle(
|
||||
contamination,
|
||||
position / TERRAIN_IMAGE_GAME_FACTOR,
|
||||
impact_radius / TERRAIN_IMAGE_GAME_FACTOR,
|
||||
image,
|
||||
position / UNIT_PER_PIXEL,
|
||||
roundi(impact_radius / UNIT_PER_PIXEL),
|
||||
Color(1., 1., 1., to_value)
|
||||
)
|
||||
|
||||
func is_in_image(pixel_point : Vector2, image : Image):
|
||||
func is_in_image(pixel_point : Vector2i):
|
||||
return (
|
||||
pixel_point.x > 0
|
||||
and pixel_point.y > 0
|
||||
and pixel_point.x < image.get_width()
|
||||
and pixel_point.y < image.get_height())
|
||||
|
||||
func get_contamination(point : Vector2) -> float:
|
||||
func is_in_terrain(point : Vector2):
|
||||
return is_in_image(get_pixel_point(point))
|
||||
|
||||
func get_value(point : Vector2) -> float:
|
||||
var pixel_point : Vector2i = get_pixel_point(point)
|
||||
if (is_in_image(pixel_point, contamination)):
|
||||
return contamination.get_pixel(
|
||||
if (is_in_image(pixel_point)):
|
||||
return image.get_pixel(
|
||||
pixel_point.x,
|
||||
pixel_point.y
|
||||
).r
|
||||
return 0
|
||||
|
||||
func get_decontamination_coverage() -> float:
|
||||
return ImageTools.get_color_coverage(contamination)
|
||||
func get_value_coverage() -> float:
|
||||
return ImageTools.get_color_coverage(image)
|
||||
|
||||
func get_decontamination_surface() -> float:
|
||||
return ImageTools.get_color_pixel_count(contamination)/TERRAIN_IMAGE_GAME_FACTOR * 10
|
||||
func get_value_surface() -> float:
|
||||
return float(ImageTools.get_color_pixel_count(image)) / UNIT_PER_PIXEL
|
||||
|
||||
func get_pixel_point(point : Vector2) -> Vector2i:
|
||||
return Vector2i(
|
||||
Vector2(point) / float(TERRAIN_IMAGE_GAME_FACTOR)
|
||||
Vector2(point) / UNIT_PER_PIXEL
|
||||
)
|
||||
#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
|
||||
|
||||
|
||||
@ -1 +1 @@
|
||||
uid://cx30nvq8b34lj
|
||||
uid://we5pyyr1n06v
|
||||
|
||||
1
common/icons/cube-3d-sphere.svg
Normal file
1
common/icons/cube-3d-sphere.svg
Normal 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-cube-3d-sphere"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6 17.6l-2 -1.1v-2.5" /><path d="M4 10v-2.5l2 -1.1" /><path d="M10 4.1l2 -1.1l2 1.1" /><path d="M18 6.4l2 1.1v2.5" /><path d="M20 14v2.5l-2 1.12" /><path d="M14 19.9l-2 1.1l-2 -1.1" /><path d="M12 12l2 -1.1" /><path d="M18 8.6l2 -1.1" /><path d="M12 12l0 2.5" /><path d="M12 18.5l0 2.5" /><path d="M12 12l-2 -1.12" /><path d="M6 8.6l-2 -1.1" /></svg>
|
||||
|
After Width: | Height: | Size: 669 B |
37
common/icons/cube-3d-sphere.svg.import
Normal file
37
common/icons/cube-3d-sphere.svg.import
Normal file
@ -0,0 +1,37 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bsvxhafoxwmw0"
|
||||
path="res://.godot/imported/cube-3d-sphere.svg-f86899fe00f38af995e1752e193f1d54.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://common/icons/cube-3d-sphere.svg"
|
||||
dest_files=["res://.godot/imported/cube-3d-sphere.svg-f86899fe00f38af995e1752e193f1d54.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
|
||||
@ -1,15 +0,0 @@
|
||||
[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/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"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_x02bb")
|
||||
scene = ExtResource("2_uulso")
|
||||
name = "Compost"
|
||||
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
|
||||
metadata/_custom_type_script = "uid://b6kubqgq0k7vj"
|
||||
@ -1,13 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="Seed" load_steps=3 format=3 uid="uid://lrl2okkhyxmx"]
|
||||
|
||||
[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]
|
||||
script = ExtResource("2_mgcdi")
|
||||
name = "Boule"
|
||||
description = ""
|
||||
icon = ExtResource("1_dy25s")
|
||||
use_zone_radius = 5
|
||||
use_energy = 1
|
||||
metadata/_custom_type_script = "uid://bypjcvlc15gsm"
|
||||
@ -1,13 +0,0 @@
|
||||
[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/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]
|
||||
script = ExtResource("1_28h2r")
|
||||
name = "Shovel"
|
||||
description = "Can dig burried seed, and transform mature plants to seeds."
|
||||
icon = ExtResource("1_7g3xd")
|
||||
use_zone_radius = 50
|
||||
use_energy = 1
|
||||
metadata/_custom_type_script = "uid://dya38x1h1uiyg"
|
||||
@ -1,11 +0,0 @@
|
||||
[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/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]
|
||||
script = ExtResource("2_aikyk")
|
||||
name = "Water Can"
|
||||
description = "Water all plants"
|
||||
icon = ExtResource("1_sy4rh")
|
||||
metadata/_custom_type_script = "uid://bq7admu4ahs5r"
|
||||
@ -1,11 +1,26 @@
|
||||
extends Resource
|
||||
class_name Item
|
||||
|
||||
@export var name: String
|
||||
@export_multiline var description: String
|
||||
@export var icon: Texture2D
|
||||
@export var use_zone_radius: int = 5
|
||||
@export var use_energy: int = 1
|
||||
var name: String : get = get_item_name
|
||||
var description: String : get = get_description
|
||||
var icon: Texture2D : get = get_icon
|
||||
var usage_zone_radius: int = 5 : get = get_usage_zone_radius
|
||||
var energy_usage : int = 1 : get = get_energy_used
|
||||
|
||||
func get_item_name() -> String:
|
||||
return name
|
||||
|
||||
func get_description() -> String:
|
||||
return description
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return icon
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return energy_usage
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return usage_zone_radius
|
||||
|
||||
func is_one_time_use():
|
||||
return false
|
||||
@ -16,8 +31,5 @@ func can_use(_player : Player, zone: Area2D) -> bool:
|
||||
func use_text() -> String:
|
||||
return ""
|
||||
|
||||
func use_requirement_text() -> String:
|
||||
return ""
|
||||
|
||||
func use(_player : Player, zone: Area2D):
|
||||
return false
|
||||
|
||||
39
common/inventory/scripts/items/blueprint.gd
Normal file
39
common/inventory/scripts/items/blueprint.gd
Normal file
@ -0,0 +1,39 @@
|
||||
extends Item
|
||||
class_name Blueprint
|
||||
|
||||
@export var machine_type: MachineType
|
||||
@export var machine_level: int = 1
|
||||
|
||||
func _init(_machine_type : MachineType = null, _machine_level : int = 1):
|
||||
machine_type = _machine_type
|
||||
machine_level = _machine_level
|
||||
|
||||
func get_item_name() -> String:
|
||||
if machine_type:
|
||||
return machine_type.name + " level " + str(machine_level)
|
||||
return ""
|
||||
|
||||
func get_description() -> String:
|
||||
if machine_type:
|
||||
return machine_type.description
|
||||
return ""
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/cube-3d-sphere.svg")
|
||||
|
||||
func use_text() -> String:
|
||||
if machine_type:
|
||||
return "Build " + machine_type.name
|
||||
return ""
|
||||
|
||||
func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player, zone : Area2D) -> bool:
|
||||
return player.planet.is_in_base(zone.global_position)
|
||||
|
||||
func use(player : Player, zone : Area2D) -> bool:
|
||||
if machine_type and machine_level:
|
||||
player.planet.instantiate_machine(machine_type, machine_level, zone.global_position)
|
||||
return true
|
||||
return false
|
||||
1
common/inventory/scripts/items/blueprint.gd.uid
Normal file
1
common/inventory/scripts/items/blueprint.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dcowcvjk2m7va
|
||||
@ -2,18 +2,30 @@ extends Item
|
||||
class_name Package
|
||||
|
||||
@export var scene: PackedScene
|
||||
@export var package_name : String
|
||||
@export_multiline var package_description : String
|
||||
|
||||
|
||||
func _init(_scene : PackedScene = null):
|
||||
scene = _scene
|
||||
|
||||
func get_item_name() -> String:
|
||||
return package_name
|
||||
|
||||
func get_description() -> String:
|
||||
return package_description
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/package.svg")
|
||||
|
||||
func use_text() -> String:
|
||||
return "Build " + name
|
||||
return "Open"
|
||||
|
||||
func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player, zone : Area2D) -> bool:
|
||||
return player.planet.is_in_zone(zone.global_position)
|
||||
return true
|
||||
|
||||
func use(player : Player, zone : Area2D) -> bool:
|
||||
player.planet.instantiate_entity(scene, zone.global_position)
|
||||
|
||||
@ -1,14 +1,19 @@
|
||||
@tool
|
||||
extends Item
|
||||
class_name Seed
|
||||
|
||||
@export var plant_type: PlantType :
|
||||
set(v):
|
||||
plant_type = v
|
||||
if plant_type:
|
||||
name = plant_type.name
|
||||
description = plant_type.description
|
||||
icon = plant_type.seed_texture
|
||||
@export var plant_type: PlantType
|
||||
|
||||
func get_item_name() -> String:
|
||||
return plant_type.name
|
||||
|
||||
func get_description() -> String:
|
||||
return plant_type.description
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return plant_type.seed_texture
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
func _init(_plant_type : PlantType = null):
|
||||
plant_type = _plant_type
|
||||
|
||||
@ -2,6 +2,22 @@ extends Item
|
||||
class_name Shovel
|
||||
|
||||
const USE_INTERVAL = 0.15
|
||||
const SHOVEL_ZONE_RADIUS = 50
|
||||
|
||||
func get_item_name() -> String:
|
||||
return "Shovel"
|
||||
|
||||
func get_description() -> String:
|
||||
return "Can dig up buried seeds and can be used to harvest mature plants."
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/shovel.svg")
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return SHOVEL_ZONE_RADIUS
|
||||
|
||||
func use_text() -> String:
|
||||
return "Dig"
|
||||
|
||||
@ -4,11 +4,11 @@
|
||||
[ext_resource type="AudioStream" uid="uid://d1fyd5o331360" path="res://common/music/assets/vent.ogg" id="2_n52pk"]
|
||||
|
||||
[node name="Music" type="Node"]
|
||||
process_mode = 3
|
||||
|
||||
[node name="AudioStreamPlayer_music" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("1_stre8")
|
||||
autoplay = true
|
||||
stream_paused = true
|
||||
parameters/looping = false
|
||||
|
||||
[node name="AudioStreamPlayer2_ambient" type="AudioStreamPlayer" parent="."]
|
||||
|
||||
@ -1,63 +1,63 @@
|
||||
class_name ImageTools
|
||||
|
||||
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())
|
||||
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
|
||||
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
|
||||
|
||||
static func draw_circle(image: Image, center: Vector2i, length: int, color: Color = Color.WHITE):
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var center_distance = Vector2i(x, y).distance_to(center)
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var center_distance = Vector2i(x, y).distance_to(center)
|
||||
|
||||
if (center_distance <= length):
|
||||
image.set_pixel(x, y, color)
|
||||
|
||||
if (center_distance <= length):
|
||||
image.set_pixel(x, y, color)
|
||||
|
||||
|
||||
static func draw_gradient(image: Image, center: Vector2i, length: int, color: Color = Color.WHITE, inverse := false):
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var original_pixel_color = image.get_pixel(x, y)
|
||||
var center_distance = Vector2i(x, y).distance_to(center)
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var original_pixel_color = image.get_pixel(x, y)
|
||||
var center_distance = Vector2i(x, y).distance_to(center)
|
||||
|
||||
if (center_distance == 0):
|
||||
if not inverse:
|
||||
image.set_pixel(x, y, original_pixel_color.blend(color))
|
||||
else:
|
||||
var color_to_add = Color(color, 1 / (center_distance / length)) if not inverse else Color(color, center_distance / length)
|
||||
image.set_pixel(
|
||||
x,
|
||||
y,
|
||||
original_pixel_color.blend(color_to_add)
|
||||
)
|
||||
if (center_distance == 0):
|
||||
if not inverse:
|
||||
image.set_pixel(x, y, original_pixel_color.blend(color))
|
||||
else:
|
||||
var color_to_add = Color(color, 1 / (center_distance / length)) if not inverse else Color(color, center_distance / length)
|
||||
image.set_pixel(
|
||||
x,
|
||||
y,
|
||||
original_pixel_color.blend(color_to_add)
|
||||
)
|
||||
|
||||
static func flatten(image: Image, threshold := 0.5):
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var original_pixel_color = image.get_pixel(x, y)
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var original_pixel_color = image.get_pixel(x, y)
|
||||
|
||||
if original_pixel_color.r > threshold:
|
||||
image.set_pixel(
|
||||
x,
|
||||
y,
|
||||
Color.WHITE
|
||||
)
|
||||
else:
|
||||
image.set_pixel(
|
||||
x,
|
||||
y,
|
||||
Color.BLACK
|
||||
)
|
||||
if original_pixel_color.r > threshold:
|
||||
image.set_pixel(
|
||||
x,
|
||||
y,
|
||||
Color.WHITE
|
||||
)
|
||||
else:
|
||||
image.set_pixel(
|
||||
x,
|
||||
y,
|
||||
Color.BLACK
|
||||
)
|
||||
|
||||
static func copy(from: Image, to : Image):
|
||||
for x in range(from.get_width()):
|
||||
for y in range(from.get_height()):
|
||||
to.set_pixel(x, y, from.get_pixel(x, y))
|
||||
|
||||
|
||||
for x in range(from.get_width()):
|
||||
for y in range(from.get_height()):
|
||||
to.set_pixel(x, y, from.get_pixel(x, y))
|
||||
|
||||
|
||||
|
||||
10
entities/interactables/machines/compost/compost.tres
Normal file
10
entities/interactables/machines/compost/compost.tres
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_resource type="Resource" script_class="MachineType" load_steps=3 format=3 uid="uid://cv2tf0tydqj5v"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bkwh1ntvgkkrt" path="res://entities/interactables/machines/compost/compost.tscn" id="1_8ajib"]
|
||||
[ext_resource type="Script" uid="uid://bhncww816fjsb" path="res://entities/interactables/machines/scripts/machine_info.gd" id="1_vktn1"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_vktn1")
|
||||
name = "Compost"
|
||||
scene = ExtResource("1_8ajib")
|
||||
description = "Can generate temporary energy in exchange of seeds."
|
||||
@ -1,32 +1,30 @@
|
||||
extends Machine
|
||||
class_name Compost
|
||||
|
||||
@export var seed_needed : int = 2
|
||||
@export var energy_production : int = 1
|
||||
var containing_seed : int = 0
|
||||
|
||||
func get_seed_needed(l : int = level) -> int:
|
||||
match l:
|
||||
1: return 3
|
||||
2: return 2
|
||||
3: return 2
|
||||
_: return 1
|
||||
|
||||
func get_energy_production(l : int = level) -> int:
|
||||
match l:
|
||||
1: return 1
|
||||
2: return 1
|
||||
_: return 2
|
||||
|
||||
func _process(_delta):
|
||||
%ProgressBar.value = lerp(%ProgressBar.value, float(containing_seed) / float(seed_needed) * 100, 0.5)
|
||||
|
||||
func pointer_text():
|
||||
return "Compost"
|
||||
%ProgressBar.value = lerp(%ProgressBar.value, float(containing_seed) / float(get_seed_needed()) * 100, 0.5)
|
||||
|
||||
func interact_text():
|
||||
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 generate one energy for " + str(seed_needed) + " seeds."
|
||||
)
|
||||
return "Put a seed ("+str(get_seed_needed() - containing_seed)+" left)"
|
||||
|
||||
func can_interact(p : Player) -> bool:
|
||||
return p.inventory.get_item() and p.inventory.get_item() is Seed
|
||||
|
||||
func requirement_text() -> String:
|
||||
return "You must have a seed in hand"
|
||||
|
||||
func interact(p : Player) -> bool:
|
||||
if not can_interact(p):
|
||||
return false
|
||||
@ -34,10 +32,10 @@ func interact(p : Player) -> bool:
|
||||
p.play_sfx("harvest")
|
||||
p.delete_item(p.inventory.get_item())
|
||||
containing_seed += 1
|
||||
if containing_seed >= seed_needed:
|
||||
if containing_seed >= get_seed_needed():
|
||||
$AnimationPlayer.play("empty")
|
||||
containing_seed = 0
|
||||
p.recharge(energy_production)
|
||||
p.recharge(get_energy_production())
|
||||
else:
|
||||
$AnimationPlayer.play("fill")
|
||||
return true
|
||||
|
||||
@ -1,2 +1,22 @@
|
||||
extends Interactable
|
||||
class_name Machine
|
||||
class_name Machine
|
||||
|
||||
const MAX_MACHINE_LEVEL = 5
|
||||
|
||||
var level : int = 1
|
||||
var machine_name : String = ""
|
||||
var machine_desc : String = ""
|
||||
|
||||
func setup_machine_info(machine_type : MachineType, _level : int = 1):
|
||||
level = _level
|
||||
machine_name = machine_type.name
|
||||
machine_desc = machine_type.description
|
||||
|
||||
func pointer_text():
|
||||
return machine_name
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
pointer_text() + " level " + str(level),
|
||||
machine_desc
|
||||
)
|
||||
|
||||
6
entities/interactables/machines/scripts/machine_info.gd
Normal file
6
entities/interactables/machines/scripts/machine_info.gd
Normal file
@ -0,0 +1,6 @@
|
||||
extends Resource
|
||||
class_name MachineType
|
||||
|
||||
@export var name : String
|
||||
@export var scene : PackedScene
|
||||
@export_multiline var description : String
|
||||
@ -0,0 +1 @@
|
||||
uid://bhncww816fjsb
|
||||
@ -1,21 +0,0 @@
|
||||
[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"
|
||||
@ -68,7 +68,7 @@ func _process(_delta):
|
||||
|
||||
func _on_inventory_updated(_inventory: Inventory):
|
||||
if inventory.get_item():
|
||||
setup_preview_zone(inventory.get_item().use_zone_radius)
|
||||
setup_preview_zone(inventory.get_item().usage_zone_radius)
|
||||
var item_texture = inventory.get_item().icon
|
||||
%ItemSprite.texture = item_texture
|
||||
%ItemSprite.scale = Vector2(
|
||||
@ -125,7 +125,7 @@ func delete_item(item: Item):
|
||||
|
||||
func try_use_item(item : Item, use_position : Vector2):
|
||||
has_just_received_instruction = true
|
||||
setup_action_zone(use_position, item.use_zone_radius)
|
||||
setup_action_zone(use_position, item.usage_zone_radius)
|
||||
instruction = ItemActionInstruction.new(
|
||||
use_position,
|
||||
item
|
||||
@ -137,7 +137,7 @@ func preview_can_use_item(item : Item) -> bool:
|
||||
func can_use_item_on_zone(item : Item, zone: Area2D) -> bool:
|
||||
return (
|
||||
inventory.has_item(item)
|
||||
and (energy - item.use_energy) >= 0
|
||||
and (energy - item.energy_usage) >= 0
|
||||
and item.can_use(self, zone)
|
||||
)
|
||||
|
||||
@ -145,7 +145,7 @@ func use_item(item : Item):
|
||||
if can_use_item_on_zone(item, action_zone):
|
||||
var is_item_used = item.use(self, action_zone)
|
||||
if is_item_used:
|
||||
energy -= item.use_energy
|
||||
energy -= item.energy_usage
|
||||
if item.is_one_time_use():
|
||||
delete_item(item)
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=25 format=3 uid="uid://12nak7amd1uq"]
|
||||
[gd_scene load_steps=27 format=3 uid="uid://12nak7amd1uq"]
|
||||
|
||||
[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"]
|
||||
@ -55,6 +55,18 @@ _data = {
|
||||
&"default": SubResource("Animation_p6blc")
|
||||
}
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_dr1y2"]
|
||||
interpolation_mode = 1
|
||||
offsets = PackedFloat32Array(0, 0.697674)
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_h6540"]
|
||||
gradient = SubResource("Gradient_dr1y2")
|
||||
width = 50
|
||||
height = 50
|
||||
fill = 1
|
||||
fill_from = Vector2(0.504274, 0.5)
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_2wykm"]
|
||||
offsets = PackedFloat32Array(0, 0.279476, 1)
|
||||
colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1)
|
||||
@ -202,7 +214,7 @@ _data = {
|
||||
&"no_energy_left_appear": SubResource("Animation_w16yr")
|
||||
}
|
||||
|
||||
[node name="RootGui" type="Control"]
|
||||
[node name="GameGui" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@ -279,10 +291,10 @@ stretch_mode = 5
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.267062
|
||||
anchor_top = 0.453125
|
||||
anchor_right = 0.267062
|
||||
anchor_bottom = 0.496875
|
||||
anchor_left = 0.64095
|
||||
anchor_top = 0.640625
|
||||
anchor_right = 0.64095
|
||||
anchor_bottom = 0.684375
|
||||
offset_left = -44.0
|
||||
offset_top = -12.5
|
||||
offset_right = 44.0
|
||||
@ -308,13 +320,24 @@ label_settings = ExtResource("4_ujg5r")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="DecontaminationCoverage" type="Label" parent="MarginContainer/PlayerInfo"]
|
||||
unique_name_in_owner = true
|
||||
[node name="QuotaInfo" type="CenterContainer" parent="MarginContainer/PlayerInfo"]
|
||||
layout_mode = 0
|
||||
offset_left = 157.0
|
||||
offset_top = 86.0
|
||||
offset_right = 291.0
|
||||
offset_bottom = 126.0
|
||||
offset_left = 55.0
|
||||
offset_top = 51.0
|
||||
offset_right = 126.0
|
||||
offset_bottom = 101.0
|
||||
|
||||
[node name="QuotaProgressBar" type="TextureProgressBar" parent="MarginContainer/PlayerInfo/QuotaInfo"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.1801, 0.349497, 0.456794, 1)
|
||||
layout_mode = 2
|
||||
value = 83.0
|
||||
fill_mode = 4
|
||||
texture_progress = SubResource("GradientTexture2D_h6540")
|
||||
|
||||
[node name="QuotaProgressText" type="Label" parent="MarginContainer/PlayerInfo/QuotaInfo"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "100%"
|
||||
label_settings = ExtResource("4_ujg5r")
|
||||
horizontal_alignment = 1
|
||||
@ -370,6 +393,10 @@ layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 5.0
|
||||
offset_top = 2.0
|
||||
offset_right = 5.0
|
||||
offset_bottom = 2.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
|
||||
@ -1,18 +1,86 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://csiacsndm62ll"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://csiacsndm62ll"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_51ks3"]
|
||||
[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="Shader" uid="uid://cuni3ggtw2uuy" path="res://gui/game/pause/resources/blur.gdshader" id="2_apjlw"]
|
||||
[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://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="ShaderMaterial" id="ShaderMaterial_58dya"]
|
||||
shader = ExtResource("2_apjlw")
|
||||
shader_parameter/strength = 3.3
|
||||
shader_parameter/mix_percentage = 0.3
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_apjlw"]
|
||||
font = ExtResource("2_8d1kg")
|
||||
font_size = 50
|
||||
|
||||
[sub_resource type="Animation" id="Animation_58dya"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_apjlw"]
|
||||
resource_name = "pause"
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.0333333),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [false, true]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0.0333333, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_yj6f1"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_58dya"),
|
||||
&"pause": SubResource("Animation_apjlw")
|
||||
}
|
||||
|
||||
[node name="Pause" type="Control"]
|
||||
visible = false
|
||||
z_index = 10
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
@ -23,6 +91,7 @@ grow_vertical = 2
|
||||
script = ExtResource("1_he4ox")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
material = SubResource("ShaderMaterial_58dya")
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@ -101,6 +170,12 @@ layout_mode = 2
|
||||
text = "Quit"
|
||||
icon = ExtResource("7_yj6f1")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_yj6f1")
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="Tutorial/VBoxContainer/HBoxContainer/Resume" to="." method="_on_resume_pressed"]
|
||||
[connection signal="pressed" from="Tutorial/VBoxContainer/HBoxContainer/Restart" to="." method="_on_restart_pressed"]
|
||||
[connection signal="pressed" from="Tutorial/VBoxContainer/HBoxContainer/Quit" to="." method="_on_quit_pressed"]
|
||||
|
||||
44
gui/game/pause/resources/blur.gdshader
Normal file
44
gui/game/pause/resources/blur.gdshader
Normal file
@ -0,0 +1,44 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D SCREEN_TEXTURE: hint_screen_texture,repeat_disable, filter_nearest;
|
||||
/**
|
||||
* How blurry the result should be.
|
||||
* Limited to 20 because of performance, if you want feel free to break it.
|
||||
*/
|
||||
uniform float strength : hint_range(0.1, 20.0) = 3.3;
|
||||
/**
|
||||
* How dark the blur will be
|
||||
*/
|
||||
uniform float mix_percentage: hint_range(0.0, 1.0) = 0.3;
|
||||
|
||||
float gaussianDistribution(float x, float STD){ // STD stands for standard deviation
|
||||
return exp(-(x*x)/(2.*STD*STD))/(sqrt(2.*PI)*STD);
|
||||
}
|
||||
|
||||
vec3 gaussianblur(sampler2D sampler, vec2 pos, vec2 pixel_size, float sigmaUsed, int radius){
|
||||
vec3 blurredPixel = vec3(0.0);
|
||||
float total_weight = 0.0;
|
||||
// Loop over the radius (tecnically its a square)
|
||||
for(int i = -radius ; i <= radius; i++){
|
||||
for(int j = -radius; j <= radius; j++){
|
||||
// Calculate the offset from the current pixel
|
||||
vec2 offset = vec2(float(i), float(j))*pixel_size;
|
||||
vec2 changedPos = pos + offset;
|
||||
|
||||
// Calculate the weight based on the Gaussian distribution multiplying both dimentions (how far are X and Y form the center (pos))
|
||||
float weight = gaussianDistribution(float(i), sigmaUsed)*gaussianDistribution(float(j), sigmaUsed);
|
||||
// Add the weighted color value to the blurred pixel
|
||||
blurredPixel += texture(SCREEN_TEXTURE, changedPos).rgb * weight;
|
||||
total_weight += weight;
|
||||
}
|
||||
}
|
||||
// Normalize the blurred pixel color by the total weight
|
||||
blurredPixel/=total_weight;
|
||||
return blurredPixel;
|
||||
}
|
||||
void fragment() {
|
||||
vec3 PixelBlurred = gaussianblur(SCREEN_TEXTURE, SCREEN_UV, SCREEN_PIXEL_SIZE, strength, int(round(3.0 * strength)));
|
||||
vec3 color = mix(PixelBlurred, vec3(0.0), mix_percentage);
|
||||
// The radius is 3*strength because it is the point where the Gaussian weight is near zero.
|
||||
COLOR = vec4(color, 1.);
|
||||
}
|
||||
1
gui/game/pause/resources/blur.gdshader.uid
Normal file
1
gui/game/pause/resources/blur.gdshader.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://cuni3ggtw2uuy
|
||||
@ -1,13 +1,16 @@
|
||||
extends Control
|
||||
|
||||
var pause = false :
|
||||
set(v):
|
||||
pause = v
|
||||
visible = pause
|
||||
get_tree().paused = pause
|
||||
var pause = false : set = set_pause
|
||||
|
||||
func set_pause(p):
|
||||
if p != pause:
|
||||
if p:
|
||||
%AnimationPlayer.play("pause")
|
||||
else:
|
||||
%AnimationPlayer.play_backwards("pause")
|
||||
pause = p
|
||||
get_tree().paused = pause
|
||||
|
||||
func _ready():
|
||||
pause = true
|
||||
|
||||
func _input(_event):
|
||||
if Input.is_action_just_pressed("pause"):
|
||||
@ -17,6 +20,8 @@ func _on_resume_pressed():
|
||||
pause = false
|
||||
|
||||
func _on_restart_pressed():
|
||||
GameInfo.game_data.current_planet_data = null
|
||||
pause = false
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
func _on_quit_pressed():
|
||||
|
||||
177
gui/game/reward_choice/reward_choice.tscn
Normal file
177
gui/game/reward_choice/reward_choice.tscn
Normal file
@ -0,0 +1,177 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://doxm7uab8i3tq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://12kjdou2kp5y" path="res://gui/game/reward_choice/scripts/reward_choice.gd" id="1_4f1tl"]
|
||||
[ext_resource type="Shader" uid="uid://cuni3ggtw2uuy" path="res://gui/game/pause/resources/blur.gdshader" id="1_iykpa"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="2_c278i"]
|
||||
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="3_5sqh2"]
|
||||
[ext_resource type="Texture2D" uid="uid://0xg54agef5gh" path="res://common/icons/package.svg" id="4_qmlcw"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gy0la"]
|
||||
shader = ExtResource("1_iykpa")
|
||||
shader_parameter/strength = 3.3
|
||||
shader_parameter/mix_percentage = 0.3
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_4f1tl"]
|
||||
font = ExtResource("3_5sqh2")
|
||||
font_size = 50
|
||||
|
||||
[sub_resource type="Animation" id="Animation_4f1tl"]
|
||||
resource_name = "show"
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.0333333),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [false, true]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:modulate")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0.0333333, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_8323k"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_7fpy7"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_8323k"),
|
||||
&"show": SubResource("Animation_4f1tl")
|
||||
}
|
||||
|
||||
[node name="RewardChoice" type="Control"]
|
||||
process_mode = 3
|
||||
visible = false
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_4f1tl")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
material = SubResource("ShaderMaterial_gy0la")
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.0352941, 0.0196078, 0.12549, 0.705882)
|
||||
|
||||
[node name="Choice" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("2_c278i")
|
||||
|
||||
[node name="VSplitContainer" type="VBoxContainer" parent="Choice"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_c278i")
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="Choice/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
text = "You reached the quota !"
|
||||
label_settings = SubResource("LabelSettings_4f1tl")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Label2" type="Label" parent="Choice/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
text = "Choose a reward"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="Choice/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_c278i")
|
||||
columns = 2
|
||||
|
||||
[node name="Reward1" type="VBoxContainer" parent="Choice/VSplitContainer/GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Reward1Button" type="Button" parent="Choice/VSplitContainer/GridContainer/Reward1"]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Compost"
|
||||
icon = ExtResource("4_qmlcw")
|
||||
|
||||
[node name="Reward1Desc" type="Label" parent="Choice/VSplitContainer/GridContainer/Reward1"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "The Compost can do so mush things.... But it's a little gross !"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Reward2" type="VBoxContainer" parent="Choice/VSplitContainer/GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Reward2Button" type="Button" parent="Choice/VSplitContainer/GridContainer/Reward2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Compost"
|
||||
icon = ExtResource("4_qmlcw")
|
||||
|
||||
[node name="Reward2Desc" type="Label" parent="Choice/VSplitContainer/GridContainer/Reward2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "The Compost can do so mush things.... But it's a little gross !"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_7fpy7")
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="Choice/VSplitContainer/GridContainer/Reward1/Reward1Button" to="." method="_on_reward_1_button_pressed"]
|
||||
[connection signal="pressed" from="Choice/VSplitContainer/GridContainer/Reward2/Reward2Button" to="." method="_on_reward_2_button_pressed"]
|
||||
37
gui/game/reward_choice/scripts/reward_choice.gd
Normal file
37
gui/game/reward_choice/scripts/reward_choice.gd
Normal file
@ -0,0 +1,37 @@
|
||||
extends Control
|
||||
|
||||
var planet: Planet
|
||||
var item1: Item
|
||||
var item2: Item
|
||||
|
||||
func show_rewards():
|
||||
get_tree().paused = true
|
||||
%AnimationPlayer.play("show")
|
||||
|
||||
func hide_rewards():
|
||||
get_tree().paused = false
|
||||
%AnimationPlayer.play_backwards("show")
|
||||
|
||||
func _on_planet_quota_reward_asked(_planet:Planet, _item1:Item, _item2:Item):
|
||||
planet = _planet
|
||||
item1 = _item1
|
||||
item2 = _item2
|
||||
|
||||
%Reward1Button.text = item1.name
|
||||
%Reward1Button.icon = item1.icon
|
||||
%Reward1Desc.text = item1.description
|
||||
|
||||
%Reward2Button.text = item2.name
|
||||
%Reward2Button.icon = item2.icon
|
||||
%Reward2Desc.text = item2.description
|
||||
show_rewards()
|
||||
|
||||
func _on_reward_1_button_pressed():
|
||||
if planet:
|
||||
planet.choose_quota_reward(item1)
|
||||
hide_rewards()
|
||||
|
||||
func _on_reward_2_button_pressed():
|
||||
if planet:
|
||||
planet.choose_quota_reward(item2)
|
||||
hide_rewards()
|
||||
1
gui/game/reward_choice/scripts/reward_choice.gd.uid
Normal file
1
gui/game/reward_choice/scripts/reward_choice.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://12kjdou2kp5y
|
||||
@ -12,21 +12,21 @@ func _on_player_updated(player:Player):
|
||||
|
||||
update_no_energy_left_info(player.energy)
|
||||
|
||||
func _on_day_pass_pressed():
|
||||
|
||||
await $AnimationPlayer.animation_finished
|
||||
$AnimationPlayer.play("recharge_fade_out")
|
||||
await $AnimationPlayer.animation_finished
|
||||
|
||||
func _on_planet_updated(planet:Planet):
|
||||
%DayCount.text = "Day " + str(planet.day) + "/" + str(planet.day_limit)
|
||||
%DecontaminationCoverage.text = str(roundi(planet.decontamination_surface)) + " m2"
|
||||
|
||||
var quota_progression_percent : float = (planet.decontamination_surface - planet.surface_on_last_quota) / (planet.next_quota - planet.surface_on_last_quota) * 100
|
||||
%QuotaProgressText.text = str(roundi(quota_progression_percent)) + " %"
|
||||
get_tree().create_tween().tween_property(
|
||||
%QuotaProgressBar,
|
||||
"value",
|
||||
quota_progression_percent,
|
||||
0.5,
|
||||
)
|
||||
|
||||
func _on_player_action_tried_without_energy():
|
||||
$AnimationPlayer.play("no_energy_left")
|
||||
|
||||
|
||||
func _on_pause_pressed():
|
||||
pause_asked.emit()
|
||||
|
||||
|
||||
@ -1,12 +1,18 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://v41hfc7haaye"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://v41hfc7haaye"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_cl67j"]
|
||||
[ext_resource type="Script" uid="uid://b3wuxv04clyed" path="res://gui/game/win/scripts/win.gd" id="1_sehw2"]
|
||||
[ext_resource type="Shader" uid="uid://cuni3ggtw2uuy" path="res://gui/game/pause/resources/blur.gdshader" id="2_0b3c6"]
|
||||
[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://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="ShaderMaterial" id="ShaderMaterial_8p3aj"]
|
||||
shader = ExtResource("2_0b3c6")
|
||||
shader_parameter/strength = 3.3
|
||||
shader_parameter/mix_percentage = 0.3
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_eq457"]
|
||||
font = ExtResource("2_sehw2")
|
||||
font_size = 50
|
||||
@ -23,6 +29,7 @@ grow_vertical = 2
|
||||
script = ExtResource("1_sehw2")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
material = SubResource("ShaderMaterial_8p3aj")
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
||||
@ -6,5 +6,5 @@ func _ready():
|
||||
%Version.text = ProjectSettings.get_setting("application/config/version")
|
||||
|
||||
func _on_start_pressed():
|
||||
GameInfo.game_data.current_terrain_data = TerrainData.new()
|
||||
GameInfo.game_data.current_planet_data = PlanetData.new()
|
||||
get_tree().change_scene_to_file(start_scene_path)
|
||||
|
||||
@ -58,7 +58,7 @@ func _process(_delta):
|
||||
)
|
||||
|
||||
if current_selected_item:
|
||||
%ActionZone.radius = current_selected_item.use_zone_radius
|
||||
%ActionZone.radius = current_selected_item.usage_zone_radius
|
||||
%ActionZone.active = can_use_item
|
||||
else:
|
||||
%ActionZone.radius = 0
|
||||
@ -88,8 +88,8 @@ func update_inspector():
|
||||
elif can_use_item and current_selected_item:
|
||||
%Action.visible = true
|
||||
%ActionText.text = current_selected_item.use_text()
|
||||
%Action.modulate = DEFAULT_ACTION_COLOR if current_selected_item.use_energy == 0 else ENERGY_ACTION_COLOR
|
||||
%ActionEnergyImage.visible = current_selected_item.use_energy != 0
|
||||
%Action.modulate = DEFAULT_ACTION_COLOR if current_selected_item.energy_usage == 0 else ENERGY_ACTION_COLOR
|
||||
%ActionEnergyImage.visible = current_selected_item.energy_usage != 0
|
||||
else:
|
||||
%Action.visible = false
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[gd_resource type="Theme" load_steps=5 format=3 uid="uid://bgcmd213j6gk1"]
|
||||
[gd_resource type="Theme" load_steps=6 format=3 uid="uid://bgcmd213j6gk1"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="1_hv6r3"]
|
||||
|
||||
@ -38,14 +38,22 @@ corner_radius_top_right = 5
|
||||
corner_radius_bottom_right = 5
|
||||
corner_radius_bottom_left = 5
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_hv6r3"]
|
||||
|
||||
[resource]
|
||||
Button/font_sizes/font_size = 25
|
||||
Button/fonts/font = ExtResource("1_hv6r3")
|
||||
Button/styles/hover = SubResource("StyleBoxFlat_hv6r3")
|
||||
Button/styles/normal = SubResource("StyleBoxFlat_y48f0")
|
||||
Button/styles/pressed = SubResource("StyleBoxFlat_st1o2")
|
||||
GridContainer/constants/h_separation = 15
|
||||
GridContainer/constants/v_separation = 15
|
||||
HBoxContainer/constants/separation = 15
|
||||
MarginContainer/constants/margin_bottom = 15
|
||||
MarginContainer/constants/margin_left = 15
|
||||
MarginContainer/constants/margin_right = 15
|
||||
MarginContainer/constants/margin_top = 15
|
||||
VBoxContainer/constants/separation = 15
|
||||
VSeparator/constants/separation = 15
|
||||
VSeparator/styles/separator = SubResource("StyleBoxEmpty_hv6r3")
|
||||
VSplitContainer/constants/separation = 15
|
||||
|
||||
@ -1,15 +1,20 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://d28cp7a21kwou"]
|
||||
[gd_scene load_steps=12 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://doxm7uab8i3tq" path="res://gui/game/reward_choice/reward_choice.tscn" id="4_fbkgs"]
|
||||
[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="Script" uid="uid://dya38x1h1uiyg" path="res://common/inventory/scripts/items/shovel.gd" id="7_fbkgs"]
|
||||
[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"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_orelw"]
|
||||
script = ExtResource("7_fbkgs")
|
||||
metadata/_custom_type_script = "uid://dya38x1h1uiyg"
|
||||
|
||||
[node name="PlanetRun" type="Node2D"]
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
@ -17,9 +22,10 @@
|
||||
[node name="RootGui" parent="CanvasLayer" instance=ExtResource("1_yy1uy")]
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="RewardChoice" parent="CanvasLayer" instance=ExtResource("4_fbkgs")]
|
||||
|
||||
[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")]
|
||||
@ -34,7 +40,7 @@ position = Vector2(0, 13.49)
|
||||
[node name="ItemObject" type="Area2D" parent="Entities"]
|
||||
position = Vector2(0, 129)
|
||||
script = ExtResource("5_kgrdw")
|
||||
item = ExtResource("6_4rjiq")
|
||||
item = SubResource("Resource_orelw")
|
||||
metadata/_custom_type_script = "uid://dedg615xudpoq"
|
||||
|
||||
[node name="RechargeStation" parent="Entities" instance=ExtResource("7_h4bgy")]
|
||||
@ -53,7 +59,6 @@ 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"]
|
||||
[connection signal="quota_reward_asked" from="Planet" to="CanvasLayer/RewardChoice" method="_on_planet_quota_reward_asked"]
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
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
|
||||
@ -1 +0,0 @@
|
||||
uid://gn3dt881v5tk
|
||||
@ -6,6 +6,7 @@ signal day_limit_exceed(planet : Planet)
|
||||
signal pass_day_started(planet : Planet)
|
||||
signal pass_day_proceeded(planet : Planet)
|
||||
signal pass_day_ended(planet : Planet)
|
||||
signal quota_reward_asked(planet : Planet, item1 : Item, item2 : Item)
|
||||
|
||||
const PASS_DAY_ANIMATION_TIME : float = 1.5
|
||||
const DEFAULT_DAY_LIMIT : int = 10
|
||||
@ -26,37 +27,46 @@ const OBJECTIVE_MIN_ANGLE_DIFF = PI/2
|
||||
@export var background_texture : Texture2D
|
||||
@export var contamination_material : ShaderMaterial
|
||||
|
||||
@onready var background_sprite : Polygon2D = generate_background_sprite()
|
||||
@onready var contamination_sprite : Polygon2D = generate_contamination_terrain_sprite()
|
||||
@onready var decontamination_surface : float = terrain_data.get_decontamination_surface() :
|
||||
var background_sprite : Polygon2D
|
||||
var contamination_sprite : Polygon2D
|
||||
var decontamination_surface : float :
|
||||
set(v):
|
||||
print(v)
|
||||
decontamination_surface = v
|
||||
planet_updated.emit(self)
|
||||
@onready var objective_scene : PackedScene = preload("res://entities/objectives/objective.tscn")
|
||||
|
||||
var planet_data : PlanetData
|
||||
|
||||
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 day : int = 1
|
||||
var day_limit = DEFAULT_DAY_LIMIT
|
||||
var surface_on_last_quota : float = 0
|
||||
var next_quota : float = 1
|
||||
var player : Player
|
||||
|
||||
func _ready():
|
||||
planet_updated.emit(self)
|
||||
planet_data = GameInfo.game_data.current_planet_data if GameInfo.game_data.current_planet_data else PlanetData.new()
|
||||
terrain_size = planet_data.base_size
|
||||
entityContainer.position = terrain_size/2
|
||||
|
||||
background_sprite = generate_background_sprite()
|
||||
contamination_sprite = generate_contamination_terrain_sprite()
|
||||
decontamination_surface = planet_data.get_decontamination_surface()
|
||||
|
||||
next_quota = planet_data.get_quota()
|
||||
surface_on_last_quota = decontamination_surface
|
||||
|
||||
generate_loot(first_loot_number)
|
||||
generate_objectives()
|
||||
planet_updated.emit(self)
|
||||
|
||||
# queue_redraw()
|
||||
|
||||
# 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 factor = 20
|
||||
# for x in range(terrain_size.x / factor):
|
||||
# for y in range(terrain_size.y / factor):
|
||||
# var point = Vector2(x, y) * factor
|
||||
|
||||
# draw_circle(
|
||||
@ -75,6 +85,14 @@ func instantiate_entity(s: PackedScene, entity_position : Vector2):
|
||||
|
||||
entity.global_position = entity_position
|
||||
|
||||
func instantiate_machine(m_type : MachineType, level, machine_position : Vector2):
|
||||
var machine = m_type.scene.instantiate() as Machine
|
||||
machine.setup_machine_info(m_type, level)
|
||||
|
||||
add_entity(machine)
|
||||
|
||||
machine.global_position = machine_position
|
||||
|
||||
func add_entity(e : Node2D, container : Node2D = entityContainer):
|
||||
if e.get_parent():
|
||||
e.get_parent().remove_child(e)
|
||||
@ -89,7 +107,7 @@ func add_entity(e : Node2D, container : Node2D = entityContainer):
|
||||
|
||||
func generate_polygon_sprite(order : int = 0) -> Polygon2D:
|
||||
var sprite = Polygon2D.new()
|
||||
var size = terrain_data.terrain_size
|
||||
var size = terrain_size
|
||||
sprite.polygon = PackedVector2Array([
|
||||
Vector2(0,0),
|
||||
Vector2(size.x, 0),
|
||||
@ -113,15 +131,15 @@ func generate_background_sprite() -> Polygon2D:
|
||||
return sprite
|
||||
|
||||
func generate_contamination_terrain_sprite() -> Polygon2D:
|
||||
if not terrain_data.contamination:
|
||||
terrain_data.generate_default_contamination()
|
||||
if not planet_data.contamination:
|
||||
planet_data.generate_default_contamination()
|
||||
|
||||
var sprite :Polygon2D = generate_polygon_sprite(1)
|
||||
|
||||
contamination_texture = ImageTexture.create_from_image(terrain_data.contamination)
|
||||
contamination_texture = ImageTexture.create_from_image(planet_data.contamination.image)
|
||||
|
||||
contamination_material.set_shader_parameter("data_texture", contamination_texture)
|
||||
contamination_material.set_shader_parameter("data_texture_size", terrain_data.terrain_size)
|
||||
contamination_material.set_shader_parameter("data_texture_size", terrain_size)
|
||||
contamination_material.set_shader_parameter("texture_scale", PLANET_TEXTURE_SCALE)
|
||||
|
||||
sprite.material = contamination_material
|
||||
@ -148,15 +166,16 @@ func plant(
|
||||
return true
|
||||
|
||||
func impact_contamination(impact_position : Vector2, impact_radius : int, contamination : bool = false):
|
||||
terrain_data.impact_contamination(impact_position, impact_radius, 0. if contamination else 1.)
|
||||
planet_data.impact_contamination(impact_position, impact_radius, 0. if contamination else 1.)
|
||||
if contamination_texture:
|
||||
contamination_texture.update(terrain_data.contamination)
|
||||
contamination_texture.update(planet_data.contamination.image)
|
||||
planet_updated.emit(self)
|
||||
|
||||
func is_in_zone(point : Vector2) -> bool:
|
||||
return terrain_data.is_in_image(terrain_data.get_pixel_point(point), terrain_data.contamination)
|
||||
func is_in_base(point : Vector2) -> bool:
|
||||
return planet_data.is_in_base(point)
|
||||
|
||||
func is_there_contamination(point : Vector2) -> bool:
|
||||
return terrain_data.get_contamination(point) < 0.5
|
||||
return planet_data.get_contamination(point) < 0.5
|
||||
|
||||
func pass_day():
|
||||
for e : Node2D in entityContainer.get_children():
|
||||
@ -178,10 +197,15 @@ func pass_day():
|
||||
if e.has_method("_end_pass_day"):
|
||||
e._end_pass_day()
|
||||
|
||||
decontamination_surface = terrain_data.get_decontamination_surface()
|
||||
decontamination_surface = planet_data.get_decontamination_surface()
|
||||
if day + 1 > day_limit:
|
||||
day_limit_exceed.emit(self)
|
||||
|
||||
if decontamination_surface >= next_quota:
|
||||
ask_quota_reward()
|
||||
|
||||
planet_updated.emit(self)
|
||||
|
||||
func generate_loot(number : int = loot_number.pick_random()):
|
||||
for i in range(number):
|
||||
var loot = UndergroundLoot.new(self)
|
||||
@ -195,14 +219,14 @@ func generate_loot(number : int = loot_number.pick_random()):
|
||||
var loot_random_range = UndergroundLoot.LOOTED_ITEM_RANDOM_RANGE
|
||||
|
||||
loot.global_position = Vector2(
|
||||
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)
|
||||
randf_range(loot_random_range, terrain_size.x - loot_random_range),
|
||||
randf_range(loot_random_range, 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)
|
||||
var objective_rewards : Array[ObjectiveReward] = planet_data.generate_objective_rewards(i)
|
||||
|
||||
for objective_reward in objective_rewards:
|
||||
var objective_angle = randf_range(0, PI*2)
|
||||
@ -224,4 +248,31 @@ func generate_objective(distance : int, angle : float, reward : ObjectiveReward)
|
||||
|
||||
objective.position = Vector2.ONE.rotated(angle) * distance
|
||||
|
||||
func ask_quota_reward():
|
||||
planet_data.quota_number += 1
|
||||
next_quota = planet_data.get_quota(planet_data.quota_number)
|
||||
surface_on_last_quota = decontamination_surface
|
||||
|
||||
quota_reward_asked.emit(
|
||||
self,
|
||||
generate_quota_reward(),
|
||||
generate_quota_reward()
|
||||
)
|
||||
|
||||
|
||||
func generate_quota_reward() -> Item:
|
||||
var random_level = randi_range(
|
||||
max(planet_data.quota_number - 1, 1),
|
||||
min(planet_data.quota_number + 1, Machine.MAX_MACHINE_LEVEL),
|
||||
)
|
||||
var random_machine_type = GameInfo.game_data.unlocked_machines.pick_random()
|
||||
|
||||
return Blueprint.new(random_machine_type, random_level)
|
||||
|
||||
|
||||
func choose_quota_reward(item : Item):
|
||||
drop_item(item, player.global_position, 100)
|
||||
if decontamination_surface >= next_quota:
|
||||
ask_quota_reward()
|
||||
|
||||
#endregion
|
||||
|
||||
@ -5,7 +5,12 @@ const BORDER_WIDTH = 100
|
||||
|
||||
@export var import_entities_from_node : Node2D = null
|
||||
|
||||
@onready var terrain_data : TerrainData = GameInfo.game_data.current_terrain_data if GameInfo.game_data.current_terrain_data else TerrainData.new()
|
||||
var terrain_size = Vector2.ONE * 1000 :
|
||||
set(v):
|
||||
terrain_size = v
|
||||
if borderLimit:
|
||||
borderLimit.queue_free()
|
||||
borderLimit = create_border_limit()
|
||||
|
||||
@onready var borderLimit : StaticBody2D = create_border_limit()
|
||||
@onready var entityContainer : Node2D = create_entity_container()
|
||||
@ -19,7 +24,6 @@ func add_entity(e : Node2D, container : Node2D = entityContainer):
|
||||
func create_entity_container() -> Node2D:
|
||||
var container = Node2D.new()
|
||||
container.y_sort_enabled = true
|
||||
container.position = terrain_data.terrain_size/2
|
||||
|
||||
add_child(container)
|
||||
|
||||
@ -54,7 +58,7 @@ func create_border_limit() -> StaticBody2D:
|
||||
add_child(staticBody)
|
||||
staticBody.add_child(staticBodyCollision)
|
||||
|
||||
var size = terrain_data.terrain_size
|
||||
var size = terrain_size
|
||||
staticBodyCollision.polygon = PackedVector2Array([
|
||||
Vector2(0,0),
|
||||
Vector2(0, size.y),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user