gros dev pre proto
* Changement de l'UI, ajouts de l'inspecteur par carte et changement de police * Ajout d'un semblant d'exploration * Ajout de la sauvegarde des entités * Restructuration mineure de l'arborescence * Fix divers et réécriture des textes
This commit is contained in:
parent
ceae7af589
commit
ed7a8bcb6e
@ -4,48 +4,67 @@ class_name GameData
|
||||
signal current_planet_data_updated(p : PlanetData)
|
||||
|
||||
func _init():
|
||||
set_default_unlocked()
|
||||
set_default_unlocked()
|
||||
|
||||
@export var tutorial_done = false
|
||||
|
||||
@export var current_planet_data : PlanetData :
|
||||
set(v):
|
||||
current_planet_data = v
|
||||
current_planet_data_updated.emit(v)
|
||||
@export var current_planet_data : PlanetData = PlanetData.new() :
|
||||
set(v):
|
||||
current_planet_data = v
|
||||
current_planet_data_updated.emit(v)
|
||||
@export var player_data : PlayerData = PlayerData.new()
|
||||
|
||||
@export var unlocked_plant_types : Array[PlantType] = []
|
||||
@export var unlocked_plant_mutations : Array[PlantMutation] = []
|
||||
@export var unlocked_machines : Array[MachineType] = []
|
||||
|
||||
@export var truck_data : TruckData = TruckData.new()
|
||||
|
||||
func set_default_unlocked():
|
||||
unlocked_plant_types = all_plant_types()
|
||||
unlocked_plant_mutations = all_plant_mutations()
|
||||
unlocked_machines = all_machines()
|
||||
unlocked_plant_types = all_plant_types()
|
||||
unlocked_plant_mutations = all_plant_mutations()
|
||||
unlocked_machines = all_machines()
|
||||
|
||||
func reset_planet():
|
||||
current_planet_data = PlanetData.new()
|
||||
|
||||
func reset_player():
|
||||
player_data = PlayerData.new()
|
||||
|
||||
func reset_truck():
|
||||
truck_data = TruckData.new()
|
||||
|
||||
func reset_all():
|
||||
reset_planet()
|
||||
reset_player()
|
||||
reset_truck()
|
||||
|
||||
|
||||
|
||||
func all_plant_types() -> Array[PlantType]:
|
||||
return [
|
||||
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/ferno.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/maias.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/philea.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/pili.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/solita.tres"),
|
||||
]
|
||||
return [
|
||||
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/ferno.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/maias.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/philea.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/pili.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/solita.tres"),
|
||||
]
|
||||
|
||||
func all_machines() -> Array[MachineType]:
|
||||
return [
|
||||
preload("res://entities/interactables/machines/solar_pannel/solar_pannel.tres"),
|
||||
]
|
||||
return [
|
||||
preload("res://entities/interactables/machines/solar_pannel/solar_pannel.tres"),
|
||||
]
|
||||
|
||||
func all_plant_mutations() -> Array[PlantMutation]:
|
||||
return [
|
||||
preload("res://entities/plants/resources/plant_mutations/ancient_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/elitist_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/ermit_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/precocious_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/quality_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/quick_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/sociable_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/strong_mutation.tres"),
|
||||
]
|
||||
return [
|
||||
preload("res://entities/plants/resources/plant_mutations/ancient_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/elitist_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/ermit_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/precocious_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/quality_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/quick_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/sociable_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/strong_mutation.tres"),
|
||||
]
|
||||
|
||||
@ -1,88 +0,0 @@
|
||||
extends Resource
|
||||
class_name PlanetData
|
||||
|
||||
signal quota_number_updated(quota : int)
|
||||
signal contamination_updated(decontamination_surface : float)
|
||||
|
||||
const MAX_DEFAULT_CONTAMINATION_ZONE_SURFACE = 3000
|
||||
const DEFAULT_BASE_SIZE = Vector2(1500,1500)
|
||||
|
||||
@export var base_size : Vector2 = Vector2(2000,2000)
|
||||
@export var contamination : TerrainData
|
||||
@export var quota_number : int = 0 :
|
||||
set(v):
|
||||
quota_number = v
|
||||
quota_number_updated.emit(v)
|
||||
|
||||
func _init(_base_size : Vector2 = DEFAULT_BASE_SIZE):
|
||||
base_size = _base_size
|
||||
contamination = TerrainData.new(base_size)
|
||||
contamination.draw_random_zone(
|
||||
MAX_DEFAULT_CONTAMINATION_ZONE_SURFACE,
|
||||
base_size/2
|
||||
)
|
||||
contamination_updated.emit(get_decontamination_surface())
|
||||
|
||||
|
||||
func impact_contamination(position : Vector2, impact_radius : float, to_value : float = 1.):
|
||||
contamination.draw_circle(
|
||||
position,
|
||||
impact_radius,
|
||||
to_value
|
||||
)
|
||||
contamination_updated.emit(get_decontamination_surface())
|
||||
|
||||
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()
|
||||
#endregion
|
||||
|
||||
#region ------------------ Objectives ------------------
|
||||
func generate_objective_rewards(level = 0) -> Array[ObjectiveReward]:
|
||||
var amount = level + 1
|
||||
|
||||
var possible_objective_rewards_path : Array[ObjectiveReward] = [
|
||||
LootRandomSeedsReward.new(randi_range(4+level, 6+level))
|
||||
]
|
||||
|
||||
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_quotas = [
|
||||
5,
|
||||
10,
|
||||
20,
|
||||
50,
|
||||
]
|
||||
|
||||
if n >= len(first_quotas):
|
||||
return pow(n, 3)
|
||||
else:
|
||||
return first_quotas[n]
|
||||
|
||||
#endregion
|
||||
|
||||
1
common/icons/align-right.svg
Normal file
1
common/icons/align-right.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-align-right"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 6l16 0" /><path d="M10 12l10 0" /><path d="M6 18l14 0" /></svg>
|
||||
|
After Width: | Height: | Size: 372 B |
43
common/icons/align-right.svg.import
Normal file
43
common/icons/align-right.svg.import
Normal file
@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dth2mj0nh2q70"
|
||||
path="res://.godot/imported/align-right.svg-00a2b5131e77dace169169767ed900d3.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://common/icons/align-right.svg"
|
||||
dest_files=["res://.godot/imported/align-right.svg-00a2b5131e77dace169169767ed900d3.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
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/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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
common/icons/caret-down.svg
Normal file
1
common/icons/caret-down.svg
Normal 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-caret-down"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M18 9c.852 0 1.297 .986 .783 1.623l-.076 .084l-6 6a1 1 0 0 1 -1.32 .083l-.094 -.083l-6 -6l-.083 -.094l-.054 -.077l-.054 -.096l-.017 -.036l-.027 -.067l-.032 -.108l-.01 -.053l-.01 -.06l-.004 -.057v-.118l.005 -.058l.009 -.06l.01 -.052l.032 -.108l.027 -.067l.07 -.132l.065 -.09l.073 -.081l.094 -.083l.077 -.054l.096 -.054l.036 -.017l.067 -.027l.108 -.032l.053 -.01l.06 -.01l.057 -.004l12.059 -.002z" /></svg>
|
||||
|
After Width: | Height: | Size: 630 B |
@ -2,22 +2,24 @@
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://73topi3k4iia"
|
||||
path="res://.godot/imported/sol_gamejam_pollution_transparent.png-e0f6a469ee35256b6f08efb9025c9a38.ctex"
|
||||
uid="uid://deywxmh76nu5w"
|
||||
path="res://.godot/imported/caret-down.svg-5e12f7a0e24150592bca8fbef87f9420.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/resources/textures/sol_gamejam_pollution_transparent.png"
|
||||
dest_files=["res://.godot/imported/sol_gamejam_pollution_transparent.png-e0f6a469ee35256b6f08efb9025c9a38.ctex"]
|
||||
source_file="res://common/icons/caret-down.svg"
|
||||
dest_files=["res://.godot/imported/caret-down.svg-5e12f7a0e24150592bca8fbef87f9420.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
@ -25,6 +27,10 @@ mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
@ -32,3 +38,6 @@ 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
common/icons/circle-number-1.svg
Normal file
1
common/icons/circle-number-1.svg
Normal 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-circle-number-1"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 2c5.523 0 10 4.477 10 10s-4.477 10 -10 10s-10 -4.477 -10 -10s4.477 -10 10 -10zm.994 5.886c-.083 -.777 -1.008 -1.16 -1.617 -.67l-.084 .077l-2 2l-.083 .094a1 1 0 0 0 0 1.226l.083 .094l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l.293 -.293v5.586l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-8l-.006 -.114z" /></svg>
|
||||
|
After Width: | Height: | Size: 537 B |
43
common/icons/circle-number-1.svg.import
Normal file
43
common/icons/circle-number-1.svg.import
Normal file
@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b5it82pe130mw"
|
||||
path="res://.godot/imported/circle-number-1.svg-9130748c35c52e7585b27d380ce0d1a2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://common/icons/circle-number-1.svg"
|
||||
dest_files=["res://.godot/imported/circle-number-1.svg-9130748c35c52e7585b27d380ce0d1a2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
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/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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
common/icons/swipe-down.svg
Normal file
1
common/icons/swipe-down.svg
Normal 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-swipe-down"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 3a5 5 0 0 1 1.001 9.9l-.001 4.684l1.293 -1.291a1 1 0 0 1 1.32 -.083l.094 .083a1 1 0 0 1 0 1.414l-3 3a1 1 0 0 1 -.112 .097l-.11 .071l-.114 .054l-.105 .035l-.149 .03l-.117 .006l-.075 -.003l-.126 -.017l-.111 -.03l-.111 -.044l-.098 -.052l-.096 -.067l-.09 -.08l-3 -3a1 1 0 0 1 1.414 -1.414l1.293 1.292v-4.685a5.002 5.002 0 0 1 1 -9.9" /></svg>
|
||||
|
After Width: | Height: | Size: 568 B |
43
common/icons/swipe-down.svg.import
Normal file
43
common/icons/swipe-down.svg.import
Normal file
@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dqhqcplref0hc"
|
||||
path="res://.godot/imported/swipe-down.svg-65a44f5fb7f727b34db8ef80248316a5.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://common/icons/swipe-down.svg"
|
||||
dest_files=["res://.godot/imported/swipe-down.svg-65a44f5fb7f727b34db8ef80248316a5.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
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/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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,48 +0,0 @@
|
||||
extends Resource
|
||||
class_name Item
|
||||
|
||||
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 get_usage_object_affected(_i : InspectableEntity) -> bool:
|
||||
return false
|
||||
|
||||
func is_one_time_use():
|
||||
return false
|
||||
|
||||
func can_use(_player : Player, zone: Player.ActionZone) -> bool:
|
||||
return false
|
||||
|
||||
func use_text() -> String:
|
||||
return ""
|
||||
|
||||
func use(_player : Player, zone: Player.ActionZone):
|
||||
return false
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
get_item_name(),
|
||||
get_description(),
|
||||
get_icon()
|
||||
)
|
||||
|
||||
func get_particles() -> Array[Particles.Parameters]:
|
||||
return []
|
||||
@ -5,11 +5,11 @@
|
||||
[ext_resource type="AudioStream" uid="uid://bqwiaek5b5q00" path="res://common/music/assets/forest_phase_2.ogg" id="2_ji160"]
|
||||
[ext_resource type="AudioStream" uid="uid://d1fyd5o331360" path="res://common/music/assets/vent.ogg" id="2_n52pk"]
|
||||
|
||||
[node name="Music" type="Node" node_paths=PackedStringArray("decontamination_musics")]
|
||||
[node name="Music" type="Node" node_paths=PackedStringArray("garden_musics")]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_ji160")
|
||||
decontamination_musics = [NodePath("ForestPhase1"), NodePath("ForestPhase2")]
|
||||
decontamination_musics_levels = Array[float]([0.0, 100.0])
|
||||
garden_musics = [NodePath("ForestPhase1"), NodePath("ForestPhase2")]
|
||||
garden_score_musics_levels = Array[float]([0.0, 10.0])
|
||||
|
||||
[node name="ForestPhase1" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("1_stre8")
|
||||
|
||||
@ -2,8 +2,8 @@ extends Node
|
||||
|
||||
@export var default_fade_time = 1.0
|
||||
|
||||
@export var decontamination_musics : Array[AudioStreamPlayer]
|
||||
@export var decontamination_musics_levels : Array[float]
|
||||
@export var garden_musics : Array[AudioStreamPlayer]
|
||||
@export var garden_score_musics_levels : Array[float]
|
||||
|
||||
@onready var playing_music = null : set = play_music
|
||||
|
||||
@ -13,18 +13,18 @@ func _ready():
|
||||
func _on_current_planet_data_updated(planet_data : PlanetData):
|
||||
if planet_data:
|
||||
planet_data.contamination_updated.connect(_on_contamination_updated)
|
||||
if len(decontamination_musics):
|
||||
play_music(decontamination_musics[0])
|
||||
if len(garden_musics):
|
||||
play_music(garden_musics[0])
|
||||
|
||||
func _on_contamination_updated(decontamination_surface : float):
|
||||
func _on_contamination_updated(garden_score : float):
|
||||
var actual_level = 0
|
||||
if len(decontamination_musics_levels) and len(decontamination_musics):
|
||||
for level in range(1, len(decontamination_musics_levels)):
|
||||
if decontamination_surface > decontamination_musics_levels[level]:
|
||||
if len(garden_score_musics_levels) and len(garden_musics):
|
||||
for level in range(1, len(garden_score_musics_levels)):
|
||||
if garden_score > garden_score_musics_levels[level]:
|
||||
actual_level = level
|
||||
|
||||
if len(decontamination_musics) > actual_level:
|
||||
play_music(decontamination_musics[actual_level])
|
||||
if len(garden_musics) > actual_level:
|
||||
play_music(garden_musics[actual_level])
|
||||
|
||||
func stop_music():
|
||||
play_music(null)
|
||||
|
||||
@ -37,8 +37,8 @@ func pointer_text() -> String:
|
||||
func interact_text():
|
||||
return "Take"
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return item.inspector_info()
|
||||
func card_info() -> CardInfo:
|
||||
return item.card_info()
|
||||
|
||||
func interact(player : Player) -> bool:
|
||||
player.pick_item(item)
|
||||
@ -70,3 +70,6 @@ func generate_sprite() -> ItemObjectSprite:
|
||||
)
|
||||
|
||||
return sprite_node
|
||||
|
||||
func save() -> EntityData:
|
||||
return ItemObjectData.new(self)
|
||||
@ -0,0 +1,11 @@
|
||||
extends EntityData
|
||||
class_name ItemObjectData
|
||||
|
||||
@export var item : Item
|
||||
|
||||
func _init(e : ItemObject):
|
||||
position = e.global_position
|
||||
item = e.item
|
||||
|
||||
func load() -> Entity:
|
||||
return ItemObject.new(item)
|
||||
@ -0,0 +1 @@
|
||||
uid://brwd7adf8j7ff
|
||||
@ -4,30 +4,24 @@ class_name Machine
|
||||
const MAX_MACHINE_LEVEL = 3
|
||||
|
||||
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
|
||||
setup_machine_sprite()
|
||||
|
||||
func setup_machine_sprite():
|
||||
pass
|
||||
var type : MachineType
|
||||
|
||||
func pointer_text() -> String:
|
||||
return machine_name
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
pointer_text(),
|
||||
machine_desc
|
||||
)
|
||||
return type.name
|
||||
|
||||
static func get_level_color(l : int) -> Color:
|
||||
match l:
|
||||
1: return Color("4ed38a")
|
||||
2: return Color("4ec6ee")
|
||||
3: return Color("bd70e2")
|
||||
_: return Color("bd70e2")
|
||||
_: return Color("bd70e2")
|
||||
|
||||
static func instantiate_machine(machine_type : MachineType, machine_level = 1) -> Machine:
|
||||
var new_machine : Machine = machine_type.scene.instantiate() as Machine
|
||||
new_machine.level = machine_level
|
||||
new_machine.type = machine_type
|
||||
|
||||
return new_machine
|
||||
|
||||
func save() -> EntityData:
|
||||
return MachineData.new(self)
|
||||
13
entities/interactables/machines/scripts/machine_data.gd
Normal file
13
entities/interactables/machines/scripts/machine_data.gd
Normal file
@ -0,0 +1,13 @@
|
||||
extends EntityData
|
||||
class_name MachineData
|
||||
|
||||
@export var level : int
|
||||
@export var type : MachineType
|
||||
|
||||
func _init(m : Machine):
|
||||
position = m.global_position
|
||||
level = m.level
|
||||
type = m.type
|
||||
|
||||
func load() -> Entity:
|
||||
return Machine.instantiate_machine(type, level)
|
||||
@ -0,0 +1 @@
|
||||
uid://b24o2jgqvfact
|
||||
@ -1 +0,0 @@
|
||||
uid://bhncww816fjsb
|
||||
@ -0,0 +1 @@
|
||||
uid://bepx311a3f0o
|
||||
@ -1,7 +1,7 @@
|
||||
extends Machine
|
||||
class_name SolarPanel
|
||||
|
||||
var charged : bool = false : set = set_charged
|
||||
var charged : bool = false
|
||||
var recharge_days : int = 0
|
||||
|
||||
func get_days_to_recharge(l : int = level) -> int:
|
||||
@ -25,13 +25,18 @@ func _pass_day():
|
||||
if recharge_days >= get_days_to_recharge():
|
||||
set_charged(true)
|
||||
|
||||
func set_charged(_charged = true):
|
||||
func set_charged(_charged = true, with_anim : bool = true):
|
||||
charged = _charged
|
||||
recharge_days = 0
|
||||
if charged:
|
||||
%AnimationPlayer.play("charged")
|
||||
else :
|
||||
%AnimationPlayer.play_backwards("charged")
|
||||
if with_anim:
|
||||
if charged:
|
||||
%AnimationPlayer.play("charged")
|
||||
else :
|
||||
%AnimationPlayer.play_backwards("charged")
|
||||
await %AnimationPlayer.animation_finished
|
||||
%Flair.modulate = Color.WHITE if charged else Color.TRANSPARENT
|
||||
%Pannels.modulate = Color.WHITE if charged else Color("6c6c6c")
|
||||
|
||||
|
||||
func setup_machine_sprite():
|
||||
# %Base.self_modulate = Machine.get_level_color(level)
|
||||
@ -47,3 +52,6 @@ func interact(p : Player) -> bool:
|
||||
p.recharge(get_energy_production())
|
||||
set_charged(false)
|
||||
return true
|
||||
|
||||
func save() -> EntityData:
|
||||
return SolarPanelData.new(self)
|
||||
@ -0,0 +1,19 @@
|
||||
extends MachineData
|
||||
class_name SolarPanelData
|
||||
|
||||
@export var charged : bool = false
|
||||
@export var recharge_days : int = 0
|
||||
|
||||
func _init(m : SolarPanel):
|
||||
position = m.global_position
|
||||
level = m.level
|
||||
type = m.type
|
||||
charged = m.charged
|
||||
recharge_days = m.recharge_days
|
||||
|
||||
func load() -> Entity:
|
||||
var sp = Machine.instantiate_machine(type, level) as SolarPanel
|
||||
sp.set_charged(charged, false)
|
||||
sp.recharge_days = recharge_days
|
||||
|
||||
return sp
|
||||
@ -0,0 +1 @@
|
||||
uid://dv1tok0civrpp
|
||||
@ -1,11 +1,11 @@
|
||||
[gd_resource type="Resource" script_class="MachineType" load_steps=3 format=3 uid="uid://dew3p4fffjryo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bhncww816fjsb" path="res://entities/interactables/machines/scripts/machine_info.gd" id="1_ctita"]
|
||||
[ext_resource type="Script" uid="uid://bepx311a3f0o" path="res://entities/interactables/machines/scripts/machine_type.gd" id="1_ctita"]
|
||||
[ext_resource type="PackedScene" uid="uid://gwq2oos6ljyp" path="res://entities/interactables/machines/solar_pannel/solar_pannel.tscn" id="1_naexs"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ctita")
|
||||
name = "Solar Pannel"
|
||||
scene = ExtResource("1_naexs")
|
||||
description = "Produce energy every 2 days. When charged, can be used to recharge energy."
|
||||
metadata/_custom_type_script = "uid://bhncww816fjsb"
|
||||
description = "Charge every 2 days. When charged, can be used to recharge player energy."
|
||||
metadata/_custom_type_script = "uid://bepx311a3f0o"
|
||||
|
||||
@ -8,33 +8,6 @@
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_6utw7"]
|
||||
radius = 48.0
|
||||
|
||||
[sub_resource type="Animation" id="Animation_gal8b"]
|
||||
resource_name = "charged"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprites/Pannels:modulate")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0.033333335, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0.42365062, 0.42365065, 0.42365062, 1), Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprites/Flair:modulate")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_77hon"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
@ -62,6 +35,33 @@ tracks/1/keys = {
|
||||
"values": [Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_gal8b"]
|
||||
resource_name = "charged"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprites/Pannels:modulate")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0.033333335, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0.42365062, 0.42365065, 0.42365062, 1), Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprites/Flair:modulate")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_5vw1f"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_77hon"),
|
||||
@ -77,6 +77,7 @@ position = Vector2(15.999999, -16.999998)
|
||||
scale = Vector2(0.09, 0.09)
|
||||
|
||||
[node name="Pannels" type="Sprite2D" parent="Sprites"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.42352942, 0.42352942, 0.42352942, 1)
|
||||
texture = ExtResource("2_ny3sb")
|
||||
|
||||
@ -85,6 +86,7 @@ unique_name_in_owner = true
|
||||
texture = ExtResource("3_bml32")
|
||||
|
||||
[node name="Flair" type="Sprite2D" parent="Sprites"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
texture = ExtResource("4_ob8kj")
|
||||
|
||||
|
||||
@ -35,9 +35,6 @@ viewport_path = NodePath("IconViewPort")
|
||||
font = ExtResource("4_ux0j5")
|
||||
font_size = 30
|
||||
|
||||
[sub_resource type="Animation" id="Animation_65b0j"]
|
||||
resource_name = "empty"
|
||||
|
||||
[sub_resource type="Animation" id="Animation_8nmxn"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
@ -69,6 +66,9 @@ tracks/0/keys = {
|
||||
"values": [Vector2(1, 1), Vector2(1.195, 0.915), Vector2(0.81, 1.195), Vector2(1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_65b0j"]
|
||||
resource_name = "empty"
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_8nmxn"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_8nmxn"),
|
||||
@ -78,6 +78,9 @@ _data = {
|
||||
|
||||
[node name="Compost" type="Area2D"]
|
||||
script = ExtResource("1_ux0j5")
|
||||
default_interact_text = "Place Seed"
|
||||
default_info_title = "Compost"
|
||||
default_info_desc = "This research station can provide some bonus if filled with seeds."
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, -3)
|
||||
|
||||
@ -3,6 +3,7 @@ class_name Compost
|
||||
|
||||
const FILLED_ICON = preload("res://common/icons/bucket.svg")
|
||||
|
||||
signal filled(c : Compost)
|
||||
signal rewarded(c : Compost)
|
||||
|
||||
var reward : Reward = null :
|
||||
@ -17,46 +18,19 @@ var containing_seed : int = 0 :
|
||||
func _ready():
|
||||
update_info()
|
||||
|
||||
func pointer_text() -> String:
|
||||
return "Compost"
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
var info = Inspector.Info.new(
|
||||
pointer_text(),
|
||||
"Fill this machine with seeds to get an reward",
|
||||
%Sprite.texture,
|
||||
)
|
||||
|
||||
if reward != null:
|
||||
info.framed_infos.append(
|
||||
Inspector.FramedInfo.new(
|
||||
"On filled",
|
||||
reward.desc(),
|
||||
FILLED_ICON,
|
||||
)
|
||||
)
|
||||
|
||||
return info
|
||||
|
||||
func update_info():
|
||||
%Count.text = "" if reward == null else "%d/%d" % [containing_seed, reward.get_seed_needed()]
|
||||
%Icon.texture = null if reward == null else reward.icon()
|
||||
|
||||
func interact_text():
|
||||
if reward:
|
||||
return "Put a seed (%d left)" % (reward.get_seed_needed() - containing_seed)
|
||||
else:
|
||||
return ""
|
||||
|
||||
func can_interact(p : Player) -> bool:
|
||||
return reward and p.inventory.get_item() and p.inventory.get_item() is Seed
|
||||
return reward and p.data.inventory.get_item() and p.data.inventory.get_item() is Seed
|
||||
|
||||
func interact(p : Player) -> bool:
|
||||
if not can_interact(p):
|
||||
return false
|
||||
|
||||
p.play_sfx("harvest")
|
||||
p.inventory.remove_current_item()
|
||||
p.data.inventory.remove_current_item()
|
||||
containing_seed += 1
|
||||
if containing_seed >= reward.get_seed_needed():
|
||||
containing_seed = 0
|
||||
@ -64,66 +38,34 @@ func interact(p : Player) -> bool:
|
||||
rewarded.emit(self)
|
||||
%AnimationPlayer.play("bump")
|
||||
|
||||
filled.emit(self)
|
||||
|
||||
return true
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
pointer_text()
|
||||
)
|
||||
|
||||
if default_info_desc != "":
|
||||
var desc_section = CardSectionInfo.new(
|
||||
"Description",
|
||||
default_info_desc
|
||||
)
|
||||
desc_section.title_icon = DESC_ICON
|
||||
info.sections.append(
|
||||
desc_section
|
||||
)
|
||||
|
||||
var reward_section = CardSectionInfo.new(
|
||||
"When filled",
|
||||
reward.desc()
|
||||
)
|
||||
reward_section.title_icon = FILLED_ICON
|
||||
|
||||
info.sections.append(reward_section)
|
||||
|
||||
return info
|
||||
|
||||
func product(_player : Player):
|
||||
pass
|
||||
|
||||
class Reward:
|
||||
|
||||
var seed_needed : int = 1
|
||||
|
||||
func _init(_seed_needed : int):
|
||||
seed_needed = _seed_needed
|
||||
|
||||
func reward(_p: Player):
|
||||
pass
|
||||
|
||||
func get_seed_needed() -> int:
|
||||
return seed_needed
|
||||
|
||||
func desc() -> String:
|
||||
return ""
|
||||
|
||||
func icon() -> Texture:
|
||||
return null
|
||||
|
||||
class UpgradeMaxEnergyReward extends Reward:
|
||||
func reward(p: Player):
|
||||
p.upgrade_max_energy(1)
|
||||
|
||||
func desc() -> String:
|
||||
return "Upgrade max energy"
|
||||
|
||||
func icon() -> Texture:
|
||||
return preload("res://common/icons/bolt.svg")
|
||||
|
||||
class UpgradeMaxInventoryReward extends Reward:
|
||||
func reward(p: Player):
|
||||
p.upgrade_inventory_size()
|
||||
|
||||
func desc() -> String:
|
||||
return "Upgrade max inventory size"
|
||||
|
||||
func icon() -> Texture:
|
||||
return preload("res://common/icons/backpack.svg")
|
||||
|
||||
class GiveItemReward extends Reward:
|
||||
|
||||
var item : Item
|
||||
|
||||
func _init(_seed_needed : int, _item : Item):
|
||||
item = _item
|
||||
seed_needed = _seed_needed
|
||||
|
||||
func reward(p: Player):
|
||||
if p.inventory.is_full():
|
||||
p.terrain.drop_item(item, p.global_position, 10)
|
||||
else:
|
||||
p.pick_item(item)
|
||||
|
||||
func desc() -> String:
|
||||
return "Give the item %s" % item.get_item_name()
|
||||
|
||||
func icon() -> Texture:
|
||||
return item.icon
|
||||
|
||||
19
entities/interactables/truck/compost/scripts/reward.gd
Normal file
19
entities/interactables/truck/compost/scripts/reward.gd
Normal file
@ -0,0 +1,19 @@
|
||||
extends Resource
|
||||
class_name Reward
|
||||
|
||||
var seed_needed : int = 1
|
||||
|
||||
func _init(_seed_needed : int):
|
||||
seed_needed = _seed_needed
|
||||
|
||||
func reward(_p: Player):
|
||||
pass
|
||||
|
||||
func get_seed_needed() -> int:
|
||||
return seed_needed
|
||||
|
||||
func desc() -> String:
|
||||
return ""
|
||||
|
||||
func icon() -> Texture:
|
||||
return null
|
||||
@ -0,0 +1 @@
|
||||
uid://djtiywfr031nr
|
||||
@ -0,0 +1,20 @@
|
||||
extends Reward
|
||||
class_name GiveItemReward
|
||||
|
||||
var item : Item
|
||||
|
||||
func _init(_seed_needed : int, _item : Item):
|
||||
item = _item
|
||||
seed_needed = _seed_needed
|
||||
|
||||
func reward(p: Player):
|
||||
if p.data.inventory.is_full():
|
||||
p.terrain.drop_item(item, p.global_position, 10)
|
||||
else:
|
||||
p.pick_item(item)
|
||||
|
||||
func desc() -> String:
|
||||
return "Give the following item : [b]%s[/b]. %s" % [item.name, item.description]
|
||||
|
||||
func icon() -> Texture:
|
||||
return item.icon
|
||||
@ -0,0 +1 @@
|
||||
uid://cqr2dpxwn6oa8
|
||||
@ -0,0 +1,10 @@
|
||||
extends Reward
|
||||
class_name UpgradeMaxEnergyReward
|
||||
func reward(p: Player):
|
||||
p.upgrade_max_energy(1)
|
||||
|
||||
func desc() -> String:
|
||||
return "Upgrade max energy"
|
||||
|
||||
func icon() -> Texture:
|
||||
return preload("res://common/icons/bolt.svg")
|
||||
@ -0,0 +1 @@
|
||||
uid://ck28pmq7jv66m
|
||||
@ -0,0 +1,11 @@
|
||||
extends Reward
|
||||
class_name UpgradeMaxInventoryReward
|
||||
|
||||
func reward(p: Player):
|
||||
p.upgrade_inventory_size()
|
||||
|
||||
func desc() -> String:
|
||||
return "Upgrade max inventory size"
|
||||
|
||||
func icon() -> Texture:
|
||||
return preload("res://common/icons/backpack.svg")
|
||||
@ -0,0 +1 @@
|
||||
uid://dnl5erwyrn44g
|
||||
@ -1,22 +1,9 @@
|
||||
extends Interactable
|
||||
class_name TruckLadder
|
||||
|
||||
@export var truck_interior : TruckInterior
|
||||
@export var planet_camera : Camera
|
||||
|
||||
func _ready():
|
||||
truck_interior.player_exited.connect(_on_truck_interior_player_exited)
|
||||
const TRUCK_SCENE_PATH = "res://stages/terrain/truck/truck.tscn"
|
||||
|
||||
func interact(p : Player):
|
||||
truck_interior.add_entity(p)
|
||||
p.global_position = truck_interior.spawn_position.global_position
|
||||
truck_interior.camera.make_current()
|
||||
planet_camera.following = null
|
||||
p.planet.save()
|
||||
get_tree().change_scene_to_file(TRUCK_SCENE_PATH)
|
||||
return true
|
||||
|
||||
|
||||
func _on_truck_interior_player_exited(p):
|
||||
planet.add_entity(p)
|
||||
p.global_position = global_position
|
||||
planet_camera.make_current()
|
||||
planet_camera.following = p
|
||||
|
||||
@ -9,15 +9,3 @@ func interact(_p: Player) -> bool:
|
||||
planet.pass_day()
|
||||
|
||||
return true
|
||||
|
||||
func interact_text():
|
||||
return "Recharge"
|
||||
|
||||
func pointer_text() -> String:
|
||||
return "Recharge Station"
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
pointer_text(),
|
||||
"You can recharge your robot here. When recharging, time will pass and plants may grow."
|
||||
)
|
||||
|
||||
@ -14,6 +14,9 @@ region = Rect2(64, 161, 101, 205)
|
||||
|
||||
[node name="TruckRecharge" type="Area2D"]
|
||||
script = ExtResource("1_ipgcv")
|
||||
default_interact_text = "Recharge"
|
||||
default_info_title = "Recharge Station"
|
||||
default_info_desc = "[b]You can recharge your robot here.[/b] When recharging, time will pass and plants may grow."
|
||||
metadata/_custom_type_script = "uid://dyprcd68fjstf"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
||||
@ -10,25 +10,9 @@ var completed : bool = false
|
||||
func pointer_text() -> String:
|
||||
return "Contamination Objective"
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
var info : Inspector.Info = Inspector.Info.new(
|
||||
pointer_text(),
|
||||
"This dead branch can hide a treasure of life."
|
||||
)
|
||||
|
||||
info.framed_infos.append(
|
||||
Inspector.FramedInfo.new(
|
||||
"When decontamined",
|
||||
reward.get_description(),
|
||||
DECONTAMINATION_ICON
|
||||
)
|
||||
)
|
||||
|
||||
return info
|
||||
|
||||
func _end_pass_day():
|
||||
if planet and not completed:
|
||||
if not planet.is_there_contamination(global_position):
|
||||
if not planet.garden.is_there_contamination(global_position):
|
||||
reward.reward(self)
|
||||
%AnimationPlayer.play("activate")
|
||||
completed = true
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
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):
|
||||
if objective.planet:
|
||||
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) + "."
|
||||
@ -1 +0,0 @@
|
||||
uid://df6i1hivw4ymn
|
||||
@ -15,7 +15,7 @@ func get_text() -> String:
|
||||
return ""
|
||||
|
||||
func get_description() -> String:
|
||||
return "Loot the following item: " + item.name + "."
|
||||
return "Loot the following item: [b]%s[/b]. %s" % [item.name, item.description]
|
||||
|
||||
func reward(objective : Objective):
|
||||
objective.terrain.drop_item(
|
||||
|
||||
@ -121,6 +121,7 @@ scale = Vector2(0.426047, 0.430108)
|
||||
texture = ExtResource("4_j6jm5")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_8eofq")
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
[sub_resource type="Resource" id="Resource_cf34j"]
|
||||
script = ExtResource("1_cf34j")
|
||||
level = 1
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_my6by"]
|
||||
|
||||
@ -1,28 +1,36 @@
|
||||
extends InspectableEntity
|
||||
class_name Plant
|
||||
|
||||
signal harvested(p: Plant)
|
||||
signal state_changed(p: Plant)
|
||||
|
||||
const PLANT_AREA_RADIUS = 20
|
||||
const PLANT_INFLUENCE_RADIUS = 100
|
||||
const HARVESTED_SEED_DISPLACEMENT_FACTOR = 100
|
||||
|
||||
const RANDOM_MAX_GROW_INTERVAL = Planet.PASS_DAY_ANIMATION_TIME/2. - 0.1
|
||||
const PLANT_TYPE_ICON = preload("res://common/icons/seedling.svg")
|
||||
const PLANT_POINT_ICON = preload("res://common/icons/growth.svg")
|
||||
const LIFETIME_ICON = preload("res://common/icons/calendar-week.svg")
|
||||
const SHOVEL_ICON = preload("res://common/icons/shovel.svg")
|
||||
const GROWING_ICON = preload("res://common/icons/chevrons-up.svg")
|
||||
|
||||
const HARVEST_EFFECT_ICON = preload("res://common/icons/shovel.svg")
|
||||
const MATURE_EFFECT_ICON = preload("res://common/icons/chevrons-up.svg")
|
||||
const CYCLIC_EFFECT_ICON = preload("res://common/icons/rotate-rectangle.svg")
|
||||
|
||||
const SPRITE_SCENE : PackedScene = preload("res://entities/plants/plant_sprite.tscn")
|
||||
|
||||
enum State {PLANTED, GROWING, MATURE}
|
||||
|
||||
@export var plant_type: PlantType
|
||||
|
||||
var state: State = State.PLANTED: set = change_state
|
||||
@export var day: int = 0 : set = set_day
|
||||
var state: State = State.PLANTED
|
||||
@export var day: int
|
||||
|
||||
@onready var plant_sprite: PlantSprite = generate_sprite()
|
||||
@onready var collision_shape: CollisionShape2D = generate_collision_shape()
|
||||
@onready var influence_zone : PlantInfluenceZone = generate_influence_zone()
|
||||
@onready var plant_sprite: PlantSprite
|
||||
@onready var collision_shape: CollisionShape2D
|
||||
@onready var influence_zone : PlantInfluenceZone
|
||||
|
||||
var harvest_effects = []
|
||||
var mature_effects = []
|
||||
@ -32,83 +40,37 @@ var plant_mutations : Array[PlantMutation] = []
|
||||
|
||||
func _init(
|
||||
_plant_type : PlantType,
|
||||
_planet : Planet,
|
||||
_plant_mutations : Array[PlantMutation] = []
|
||||
_plant_mutations : Array[PlantMutation] = [],
|
||||
_day = 0,
|
||||
):
|
||||
plant_type = _plant_type
|
||||
harvest_effects = plant_type.default_harvest_effects.duplicate_deep()
|
||||
mature_effects = plant_type.default_mature_effects.duplicate_deep()
|
||||
cyclic_effects = plant_type.default_cyclic_effects.duplicate_deep()
|
||||
|
||||
planet = _planet
|
||||
day = _day
|
||||
|
||||
plant_mutations = _plant_mutations
|
||||
|
||||
func _ready():
|
||||
plant_sprite = generate_sprite()
|
||||
collision_shape = generate_collision_shape()
|
||||
influence_zone = generate_influence_zone()
|
||||
|
||||
update_plant(false)
|
||||
plant_sprite.update_plant_sprite(self, false)
|
||||
|
||||
func pointer_text() -> String:
|
||||
var state_text = "Growing"
|
||||
if state == State.MATURE: state_text = "Mature"
|
||||
return state_text + " " + plant_type.name
|
||||
return plant_type.name
|
||||
|
||||
func inspect(is_inspected : bool = true):
|
||||
modulate = MODULATE_INSPECTED_COLOR if is_inspected else default_modulate
|
||||
influence_zone.show_influence = is_inspected
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
var info = Inspector.Info.new(
|
||||
pointer_text(),
|
||||
"",
|
||||
plant_type.mature_texture
|
||||
)
|
||||
|
||||
for m in plant_mutations:
|
||||
info.framed_infos.append(
|
||||
PlantMutation.get_framed_info_from_mutation(m)
|
||||
)
|
||||
|
||||
info.framed_infos.append_array(
|
||||
PlantEffect.get_framed_info_from_all_trigger_effects(
|
||||
mature_effects, harvest_effects, cyclic_effects
|
||||
)
|
||||
)
|
||||
|
||||
info.stat_infos.append(
|
||||
Inspector.StatInfo.new(
|
||||
"Day [b]%d[/b]" % day,
|
||||
LIFETIME_ICON
|
||||
)
|
||||
)
|
||||
|
||||
if state != State.MATURE:
|
||||
info.stat_infos.append_array([
|
||||
Inspector.StatInfo.new(
|
||||
"Mature on day [b]%d[/b]" % calculate_grow_time(),
|
||||
GROWING_ICON,
|
||||
),
|
||||
Inspector.StatInfo.new(
|
||||
"[b]%d[/b]" % [
|
||||
calculate_plant_score()
|
||||
],
|
||||
PLANT_POINT_ICON
|
||||
),
|
||||
])
|
||||
else:
|
||||
info.stat_infos.append(
|
||||
Inspector.StatInfo.new(
|
||||
"[b]%d[/b] point%s" % [
|
||||
calculate_plant_score(),
|
||||
"s" if calculate_plant_score() > 0 else ""
|
||||
],
|
||||
PLANT_POINT_ICON
|
||||
),
|
||||
)
|
||||
|
||||
return info
|
||||
|
||||
func generate_sprite() -> PlantSprite:
|
||||
var sprite_object : PlantSprite = SPRITE_SCENE.instantiate()
|
||||
|
||||
add_child(sprite_object)
|
||||
sprite_object.update_plant_sprite(self)
|
||||
sprite_object.generate_mutation_effects(self)
|
||||
|
||||
return sprite_object
|
||||
@ -138,24 +100,34 @@ func _pass_day():
|
||||
for effect in cyclic_effects:
|
||||
effect.effect(self)
|
||||
|
||||
day += 1
|
||||
var old_state = state
|
||||
|
||||
func set_day(d):
|
||||
day = d
|
||||
day += 1
|
||||
update_plant()
|
||||
|
||||
if old_state != state and state == State.MATURE:
|
||||
for effect in mature_effects:
|
||||
if effect : effect.effect(self)
|
||||
for effect in cyclic_effects:
|
||||
if effect : effect.effect(self)
|
||||
|
||||
func update_plant(with_animation : bool = true):
|
||||
if day + 1 > calculate_grow_time():
|
||||
if state != State.MATURE:
|
||||
change_state(State.MATURE)
|
||||
change_state(State.MATURE, with_animation)
|
||||
elif day == 0:
|
||||
change_state(State.PLANTED)
|
||||
change_state(State.PLANTED, with_animation)
|
||||
else:
|
||||
if state != State.GROWING:
|
||||
change_state(State.GROWING)
|
||||
change_state(State.GROWING, with_animation)
|
||||
|
||||
func calculate_plant_score() -> int:
|
||||
var mutated_plant_score = plant_type.default_plant_score if state == State.MATURE else 0
|
||||
func calculate_plant_score(
|
||||
overwite_state : State = state
|
||||
) -> int:
|
||||
var mutated_plant_score = plant_type.default_plant_score if overwite_state == State.MATURE else 0
|
||||
|
||||
for m in plant_mutations:
|
||||
mutated_plant_score = m.mutate_score(self, mutated_plant_score)
|
||||
mutated_plant_score = m.mutate_score(overwite_state, self, mutated_plant_score)
|
||||
|
||||
return mutated_plant_score
|
||||
|
||||
@ -167,16 +139,12 @@ func calculate_grow_time() -> int:
|
||||
|
||||
return mutated_grow_time
|
||||
|
||||
func change_state(_state: State):
|
||||
state = _state
|
||||
|
||||
if state == State.MATURE and len(mature_effects):
|
||||
for effect in mature_effects:
|
||||
if effect : effect.effect(self)
|
||||
for effect in cyclic_effects:
|
||||
if effect : effect.effect(self)
|
||||
|
||||
plant_sprite.update_plant_sprite(self, true)
|
||||
func change_state(_state: State, with_animation : bool = true):
|
||||
if state != _state:
|
||||
state = _state
|
||||
|
||||
plant_sprite.update_plant_sprite(self, with_animation)
|
||||
state_changed.emit(self)
|
||||
|
||||
func harvest():
|
||||
if state == State.MATURE:
|
||||
@ -185,4 +153,89 @@ func harvest():
|
||||
|
||||
plant_sprite.start_harvest_animation()
|
||||
await plant_sprite.harvest_animation_finished
|
||||
harvested.emit(self)
|
||||
queue_free()
|
||||
|
||||
func save() -> EntityData:
|
||||
return PlantData.new(self)
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
pointer_text()
|
||||
)
|
||||
|
||||
info.important_stat_icon = PLANT_POINT_ICON
|
||||
info.important_stat_text = "%d" % calculate_plant_score()
|
||||
info.texture = plant_type.mature_texture
|
||||
info.type_icon = PLANT_TYPE_ICON
|
||||
|
||||
var state_text = "Mature"
|
||||
if state != State.MATURE:
|
||||
state_text = "Growing"
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
"Day [b]%d[/b]" % day,
|
||||
LIFETIME_ICON
|
||||
))
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
state_text,
|
||||
PLANT_TYPE_ICON
|
||||
))
|
||||
|
||||
if state != State.MATURE:
|
||||
info.stats.append(CardStatInfo.new(
|
||||
"Mature on day [b]%d[/b]" % calculate_grow_time(),
|
||||
GROWING_ICON
|
||||
))
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
"[b]%d[/b] score when mature" % calculate_plant_score(State.MATURE),
|
||||
PLANT_POINT_ICON
|
||||
))
|
||||
|
||||
|
||||
if len(plant_mutations) != 0:
|
||||
var rarest : int = plant_mutations.map(
|
||||
func(m : PlantMutation) : return m.get_rarity()
|
||||
).max()
|
||||
info.bg_color = PlantMutation.get_rarity_color(rarest)
|
||||
for m in plant_mutations:
|
||||
info.sections.append(m.card_section())
|
||||
|
||||
info.sections.append_array(card_effect_sections())
|
||||
|
||||
return info
|
||||
|
||||
func card_effect_sections() -> Array[CardSectionInfo]:
|
||||
var sections : Array[CardSectionInfo] = []
|
||||
var effects_category = [
|
||||
mature_effects,
|
||||
harvest_effects,
|
||||
cyclic_effects
|
||||
]
|
||||
var effects_category_labels : Array[String] = [
|
||||
"On mature",
|
||||
"When harvested",
|
||||
"Each day when mature",
|
||||
]
|
||||
var effects_category_icon : Array[Texture] = [
|
||||
MATURE_EFFECT_ICON,
|
||||
HARVEST_EFFECT_ICON,
|
||||
CYCLIC_EFFECT_ICON,
|
||||
]
|
||||
|
||||
for i in range(len(effects_category)):
|
||||
var effects = effects_category[i]
|
||||
if len(effects):
|
||||
var section = CardSectionInfo.new(
|
||||
effects_category_labels[i]
|
||||
)
|
||||
section.title_icon = effects_category_icon[i]
|
||||
var effects_text : Array = effects.map(
|
||||
func (e : PlantEffect): return "[b]%s[/b] %s" % [e.get_styled_effect_name() , e.get_effect_description()]
|
||||
)
|
||||
section.text = "\n".join(effects_text)
|
||||
sections.append(section)
|
||||
|
||||
return sections
|
||||
|
||||
20
entities/plants/scripts/plant_data.gd
Normal file
20
entities/plants/scripts/plant_data.gd
Normal file
@ -0,0 +1,20 @@
|
||||
extends EntityData
|
||||
class_name PlantData
|
||||
|
||||
var plant_type : PlantType
|
||||
var plant_mutations : Array[PlantMutation]
|
||||
var day : int
|
||||
|
||||
func _init(plant : Plant):
|
||||
position = plant.global_position
|
||||
plant_type = plant.plant_type
|
||||
plant_mutations = plant.plant_mutations
|
||||
day = plant.day
|
||||
|
||||
func load() -> Entity:
|
||||
var plant = Plant.new(
|
||||
plant_type,
|
||||
plant_mutations,
|
||||
day
|
||||
)
|
||||
return plant
|
||||
1
entities/plants/scripts/plant_data.gd.uid
Normal file
1
entities/plants/scripts/plant_data.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://da6j333qs7wse
|
||||
@ -2,10 +2,6 @@
|
||||
extends Resource
|
||||
class_name PlantEffect
|
||||
|
||||
const HARVEST_EFFECT_ICON = preload("res://common/icons/shovel.svg")
|
||||
const MATURE_EFFECT_ICON = preload("res://common/icons/chevrons-up.svg")
|
||||
const CYCLIC_EFFECT_ICON = preload("res://common/icons/rotate-rectangle.svg")
|
||||
|
||||
@export var level : int
|
||||
|
||||
func _init(_level : int = 1):
|
||||
@ -22,67 +18,17 @@ func get_effect_description() -> String:
|
||||
func effect(plant):
|
||||
printerr("Classe abstraite PlantEffect appelée")
|
||||
|
||||
static func get_framed_info_from_effects(
|
||||
effects : Array[PlantEffect],
|
||||
trigger_text = "",
|
||||
trigger_icon: Texture = null
|
||||
) -> Array[Inspector.FramedInfo]:
|
||||
if len(effects) == 0 : return []
|
||||
|
||||
var desc = "%s %s" % [PlantEffect.get_framed_info_effect_name(effects[0]), effects[0].get_effect_description()]
|
||||
|
||||
for i in range(1, len(effects)):
|
||||
if effects[i]:
|
||||
desc += "\n%s %s" % [PlantEffect.get_framed_info_effect_name(effects[i]), effects[i].get_effect_description()]
|
||||
|
||||
return [Inspector.FramedInfo.new(
|
||||
trigger_text,
|
||||
desc,
|
||||
trigger_icon
|
||||
)]
|
||||
|
||||
static func get_framed_info_effect_name(e : PlantEffect):
|
||||
func get_styled_effect_name():
|
||||
var levels_bbcode = [
|
||||
"[color=#ffffff][b]%s[/b][/color]",
|
||||
"[color=#FFBE0B][b]%s %d[/b][/color]",
|
||||
"[color=#FB5607][b]%s %d[/b][/color]",
|
||||
"[color=#3A86FF][b]%s %d[/b][/color]",
|
||||
"[color=#8338EC][b]%s %d[/b][/color]",
|
||||
"[color=#FF006E][b]%s %d[/b][/color]",
|
||||
"[rainbow][b]%s %d[/b][/rainbow]"
|
||||
"[color=#2364AA]%s[/color]",
|
||||
"[color=#25C147]%s %d[/color]",
|
||||
"[color=#8B2DFF]%s %d[/color]",
|
||||
"[color=#FF006E]%s %d[/color]",
|
||||
"[color=#FFA617]%s %d[/color]",
|
||||
"[rainbow]%s %d[/rainbow]"
|
||||
]
|
||||
|
||||
if e.level == 1:
|
||||
return levels_bbcode[0] % e.get_effect_name()
|
||||
if level == 1:
|
||||
return levels_bbcode[0] % get_effect_name()
|
||||
else :
|
||||
return levels_bbcode[min(e.level - 1, len(levels_bbcode) - 1)] % [e.get_effect_name(), e.level]
|
||||
|
||||
static func get_framed_info_from_all_trigger_effects(
|
||||
mature_effects : Array[PlantEffect],
|
||||
harvest_effects : Array[PlantEffect],
|
||||
cyclic_effects : Array[PlantEffect],
|
||||
) -> Array[Inspector.FramedInfo] :
|
||||
var framed_infos : Array[Inspector.FramedInfo] = []
|
||||
framed_infos.append_array(
|
||||
PlantEffect.get_framed_info_from_effects(
|
||||
mature_effects,
|
||||
"On maturation",
|
||||
MATURE_EFFECT_ICON
|
||||
)
|
||||
)
|
||||
framed_infos.append_array(
|
||||
PlantEffect.get_framed_info_from_effects(
|
||||
harvest_effects,
|
||||
"When harvested",
|
||||
HARVEST_EFFECT_ICON
|
||||
)
|
||||
)
|
||||
framed_infos.append_array(
|
||||
PlantEffect.get_framed_info_from_effects(
|
||||
cyclic_effects,
|
||||
"Each days",
|
||||
CYCLIC_EFFECT_ICON
|
||||
)
|
||||
)
|
||||
|
||||
return framed_infos
|
||||
return levels_bbcode[min(level - 1, len(levels_bbcode) - 1)] % [get_effect_name(), level]
|
||||
@ -14,7 +14,7 @@ func get_effect_description() -> String:
|
||||
func effect(plant):
|
||||
var radius = get_decontamination_radius()
|
||||
|
||||
plant.planet.impact_contamination(
|
||||
plant.planet.garden.impact_contamination(
|
||||
plant.global_position,
|
||||
radius
|
||||
)
|
||||
@ -2,11 +2,10 @@ extends Resource
|
||||
class_name PlantMutation
|
||||
|
||||
const BASE_RARITY_CHANCE : Array[float] = [
|
||||
0.6,
|
||||
0.8,
|
||||
0.75,
|
||||
0.9,
|
||||
0.95,
|
||||
1
|
||||
1,
|
||||
1,
|
||||
]
|
||||
|
||||
@export var level : int = 1
|
||||
@ -28,7 +27,7 @@ func get_mutation_description() -> String:
|
||||
printerr("Classe abstraite PlantMutation appelée")
|
||||
return ""
|
||||
|
||||
func mutate_score(_plant : Plant, score) -> int:
|
||||
func mutate_score(_plant_state : Plant.State, _plant : Plant, score,) -> int:
|
||||
return score
|
||||
|
||||
func mutate_grow_time(_plant : Plant, grow_time : int) -> int:
|
||||
@ -40,56 +39,44 @@ func mutate_plant(_plant : Plant):
|
||||
func get_level_for_rarity(rarity : int) -> int :
|
||||
return rarity - get_base_rarity() + 1
|
||||
|
||||
static func get_rarity(mutation : PlantMutation) -> int:
|
||||
return mutation.get_base_rarity() + mutation.level - 1
|
||||
func get_rarity() -> int:
|
||||
return get_base_rarity() + level - 1
|
||||
|
||||
static func get_rarity_text(mutation : PlantMutation) -> String:
|
||||
func card_section() -> CardSectionInfo:
|
||||
var section = CardSectionInfo.new(
|
||||
get_mutation_name() + (" %d" % level if level > 1 else ""),
|
||||
"[b]%s[/b] %s" % [PlantMutation.get_rarity_text(get_rarity()), get_mutation_description()]
|
||||
)
|
||||
|
||||
section.title_color = PlantMutation.get_rarity_color(get_rarity())
|
||||
section.title_colored = true
|
||||
section.title_icon = get_icon()
|
||||
|
||||
return section
|
||||
|
||||
static func get_rarity_text(rarity) -> String:
|
||||
var rarity_text : Array[String] = [
|
||||
"Common",
|
||||
"Rare",
|
||||
"Very rare",
|
||||
"Impossible",
|
||||
"Absurd",
|
||||
"[rainbow]Absurd[/rainbow]",
|
||||
]
|
||||
|
||||
var rarity = PlantMutation.get_rarity(mutation)
|
||||
|
||||
if rarity < len(rarity_text):
|
||||
return rarity_text[rarity]
|
||||
else :
|
||||
return rarity_text[len(rarity_text) - 1] + " " + str(rarity - len(rarity_text) + 2)
|
||||
|
||||
static func get_rarity_bg_color(mutation : PlantMutation) -> Color:
|
||||
static func get_rarity_color(rarity : int) -> Color:
|
||||
var rarity_colors : Array[Color] = [
|
||||
Color("4b3700"),
|
||||
Color("6d2300"),
|
||||
Color("001f50"),
|
||||
Color("311558"),
|
||||
Color("780235"),
|
||||
]
|
||||
|
||||
return rarity_colors[min(PlantMutation.get_rarity(mutation), len(rarity_colors) - 1)]
|
||||
|
||||
static func get_rarity_color(mutation : PlantMutation) -> Color:
|
||||
var rarity_colors : Array[Color] = [
|
||||
Color("FFBE0B"),
|
||||
Color("FB5607"),
|
||||
Color("3A86FF"),
|
||||
Color("8338EC"),
|
||||
Color("25C147"),
|
||||
Color("8B2DFF"),
|
||||
Color("FF006E"),
|
||||
Color("FFA617"),
|
||||
]
|
||||
|
||||
return rarity_colors[min(PlantMutation.get_rarity(mutation), len(rarity_colors) - 1)]
|
||||
|
||||
static func get_framed_info_from_mutation(
|
||||
mutation : PlantMutation
|
||||
) -> Inspector.FramedInfo:
|
||||
return Inspector.FramedInfo.new(
|
||||
mutation.get_mutation_name() + (" %d" % mutation.level if mutation.level > 1 else ""),
|
||||
"[b]%s[/b] %s" % [PlantMutation.get_rarity_text(mutation), mutation.get_mutation_description()],
|
||||
mutation.get_icon(),
|
||||
PlantMutation.get_rarity_bg_color(mutation)
|
||||
)
|
||||
return rarity_colors[min(rarity, len(rarity_colors) - 1)]
|
||||
|
||||
static func random_rarity() -> int:
|
||||
var random_float = randf()
|
||||
|
||||
@ -18,7 +18,7 @@ func get_mutation_description() -> String:
|
||||
func get_day_factor():
|
||||
return max(1, DEFAULT_DAY_FACTOR - level + 1)
|
||||
|
||||
func mutate_score(plant : Plant, score) -> int:
|
||||
if plant.state != Plant.State.MATURE:
|
||||
func mutate_score(plant_state : Plant.State, plant : Plant, score) -> int:
|
||||
if plant_state != Plant.State.MATURE:
|
||||
return score
|
||||
return score + floori(plant.day / get_day_factor())
|
||||
@ -13,8 +13,10 @@ func get_mutation_name() -> String:
|
||||
func get_mutation_description() -> String:
|
||||
return "When mature, add [b]%d[/b] to the score for each plant of the same species around, but score become 0 if none is around." % level
|
||||
|
||||
func mutate_score(plant : Plant, score) -> int:
|
||||
if plant.state != Plant.State.MATURE:
|
||||
func mutate_score(plant_state : Plant.State, plant : Plant, score) -> int:
|
||||
if plant.influence_zone == null:
|
||||
return score
|
||||
if plant_state != Plant.State.MATURE:
|
||||
return score
|
||||
var plant_count = 0
|
||||
|
||||
|
||||
@ -2,23 +2,25 @@ extends PlantMutation
|
||||
class_name ErmitMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/seedling-off.svg")
|
||||
return preload("res://common/icons/seedling-off.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
return 0
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return "Ermit"
|
||||
return "Ermit"
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return "Multiply the score by [b]%d[/b] if no plant is near, but set it to 0 otherwise." % get_score_multiplier()
|
||||
return "Multiply the score by [b]%d[/b] if no plant is near, but set it to 0 otherwise." % get_score_multiplier()
|
||||
|
||||
func get_score_multiplier():
|
||||
return level + 1
|
||||
return level + 1
|
||||
|
||||
func mutate_score(plant : Plant, score) -> int:
|
||||
for area in plant.influence_zone.get_overlapping_areas():
|
||||
if area is Plant and area != plant:
|
||||
return 0
|
||||
func mutate_score(_plant_state : Plant.State, plant : Plant, score) -> int:
|
||||
if plant.influence_zone == null:
|
||||
return score
|
||||
for area in plant.influence_zone.get_overlapping_areas():
|
||||
if area is Plant and area != plant:
|
||||
return 0
|
||||
|
||||
return score * get_score_multiplier()
|
||||
return score * get_score_multiplier()
|
||||
|
||||
@ -13,5 +13,5 @@ func get_mutation_name() -> String:
|
||||
func get_mutation_description() -> String:
|
||||
return "Add [b]%d[/b] to the score while the plant is growing" % level
|
||||
|
||||
func mutate_score(plant : Plant, score) -> int:
|
||||
return score + (0 if plant.state == Plant.State.MATURE else level)
|
||||
func mutate_score(plant_state : Plant.State, _plant : Plant, score) -> int:
|
||||
return score + (0 if plant_state == Plant.State.MATURE else level)
|
||||
@ -13,5 +13,5 @@ func get_mutation_name() -> String:
|
||||
func get_mutation_description() -> String:
|
||||
return "Add [b]%d[/b] to the score if the plant is mature." % level
|
||||
|
||||
func mutate_score(plant : Plant, score : int) -> int:
|
||||
return score + (level if plant.state == Plant.State.MATURE else 0)
|
||||
func mutate_score(plant_state : Plant.State, _plant : Plant, score : int) -> int:
|
||||
return score + (level if plant_state == Plant.State.MATURE else 0)
|
||||
@ -18,8 +18,10 @@ func get_mutation_description() -> String:
|
||||
func get_score_bonus():
|
||||
return (level + 2)
|
||||
|
||||
func mutate_score(plant : Plant, score) -> int:
|
||||
if plant.state != Plant.State.MATURE:
|
||||
func mutate_score(plant_state : Plant.State, plant : Plant, score) -> int:
|
||||
if plant.influence_zone == null:
|
||||
return score
|
||||
if plant_state != Plant.State.MATURE:
|
||||
return score
|
||||
var plant_count = 0
|
||||
|
||||
|
||||
@ -16,5 +16,5 @@ func get_mutation_description() -> String:
|
||||
func get_score_multiplier():
|
||||
return float(level)/2.
|
||||
|
||||
func mutate_score(_plant : Plant, score: int) -> int:
|
||||
func mutate_score(_plant_state : Plant.State, _plant : Plant, score: int) -> int:
|
||||
return score + roundi(score * get_score_multiplier())
|
||||
@ -10,8 +10,8 @@ signal harvest_animation_finished
|
||||
|
||||
func update_plant_sprite(plant : Plant, with_animation = false):
|
||||
if with_animation:
|
||||
$AnimationPlayer.play("bump")
|
||||
await $AnimationPlayer.animation_finished
|
||||
%AnimationPlayer.play("bump")
|
||||
await %AnimationPlayer.animation_finished
|
||||
|
||||
%Sprite.flip_h = true if randi()%2 == 0 else false
|
||||
|
||||
@ -43,7 +43,7 @@ func generate_mutation_effects(plant : Plant):
|
||||
particles_emitter.setup_particles(
|
||||
Particles.Parameters.new(
|
||||
m.get_icon(),
|
||||
PlantMutation.get_rarity_color(m)
|
||||
PlantMutation.get_rarity_color(m.get_rarity())
|
||||
)
|
||||
)
|
||||
add_child(particles_emitter)
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
extends Resource
|
||||
class_name Inventory
|
||||
|
||||
signal inventory_changed(inventory: Inventory)
|
||||
signal updated(inventory: Inventory)
|
||||
|
||||
@export var items: Array[Item] = []
|
||||
|
||||
var current_item_ind: int = 0
|
||||
@export var current_item_ind: int = 0
|
||||
|
||||
func _init(inventory_size: int = 1):
|
||||
items.resize(inventory_size)
|
||||
@ -24,7 +23,7 @@ func set_current_item(new_ind: int):
|
||||
|
||||
if new_ind != current_item_ind:
|
||||
current_item_ind = new_ind
|
||||
emit_signal("inventory_changed", self)
|
||||
updated.emit(self)
|
||||
|
||||
func change_current_item(ind_mod: int):
|
||||
if items.size() == 0:
|
||||
@ -40,6 +39,7 @@ func add_item(item: Item):
|
||||
var best_ind = get_best_available_slot_ind()
|
||||
if best_ind != current_item_ind:
|
||||
set_item(item, best_ind)
|
||||
updated.emit(self)
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
@ -50,7 +50,7 @@ func set_item(item: Item, ind: int = 0) -> bool:
|
||||
while len(items) <= ind:
|
||||
items.append(null)
|
||||
items[ind] = item
|
||||
emit_signal("inventory_changed", self)
|
||||
updated.emit(self)
|
||||
return true
|
||||
|
||||
func get_item(ind: int = current_item_ind) -> Item:
|
||||
@ -65,14 +65,14 @@ func remove_item(item: Item):
|
||||
var ind = items.find(item)
|
||||
if ind >= 0:
|
||||
items[ind] = null
|
||||
emit_signal("inventory_changed", self)
|
||||
updated.emit(self)
|
||||
|
||||
func remove_item_at(ind: int = current_item_ind):
|
||||
if items.size() <= ind:
|
||||
return
|
||||
|
||||
items[ind] = null
|
||||
emit_signal("inventory_changed", self)
|
||||
updated.emit(self)
|
||||
|
||||
func remove_current_item():
|
||||
remove_item_at()
|
||||
@ -83,7 +83,7 @@ func pop_item(ind: int = current_item_ind) -> Item:
|
||||
|
||||
var item_removed: Item = items[ind]
|
||||
items[ind] = null
|
||||
emit_signal("inventory_changed", self)
|
||||
updated.emit(self)
|
||||
return item_removed
|
||||
|
||||
func is_full():
|
||||
81
entities/player/inventory/scripts/item.gd
Normal file
81
entities/player/inventory/scripts/item.gd
Normal file
@ -0,0 +1,81 @@
|
||||
extends Resource
|
||||
class_name Item
|
||||
|
||||
const TYPE_ICON = preload("res://common/icons/backpack.svg")
|
||||
const ACTION_ICON = preload("res://common/icons/swipe-down.svg")
|
||||
const ENERGY_ICON = preload("res://common/icons/bolt.svg")
|
||||
const ONE_TIME_ICON = preload("res://common/icons/circle-number-1.svg")
|
||||
|
||||
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 get_usage_object_affected(_i : InspectableEntity) -> bool:
|
||||
return false
|
||||
|
||||
func is_one_time_use():
|
||||
return false
|
||||
|
||||
func can_use(_player : Player, zone: Player.ActionZone) -> bool:
|
||||
return false
|
||||
|
||||
func use_text() -> String:
|
||||
return ""
|
||||
|
||||
func use(_player : Player, zone: Player.ActionZone):
|
||||
return false
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
get_item_name()
|
||||
)
|
||||
info.texture = icon
|
||||
info.type_icon = TYPE_ICON
|
||||
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
"Cost %d energy" % energy_usage,
|
||||
ENERGY_ICON
|
||||
)
|
||||
)
|
||||
|
||||
if is_one_time_use():
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
"One time use",
|
||||
ONE_TIME_ICON
|
||||
)
|
||||
)
|
||||
|
||||
var effect_section = CardSectionInfo.new(
|
||||
"Effect",
|
||||
get_description()
|
||||
)
|
||||
effect_section.title_icon = ACTION_ICON
|
||||
|
||||
if energy_usage > 0:
|
||||
effect_section.title_icon = ENERGY_ICON
|
||||
|
||||
info.sections.append(effect_section)
|
||||
|
||||
return info
|
||||
|
||||
func get_particles() -> Array[Particles.Parameters]:
|
||||
return []
|
||||
@ -30,10 +30,13 @@ func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
return player.planet && player.planet.is_in_base(zone.get_global_position())
|
||||
return player.terrain is Planet
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
if machine_type and machine_level and player.planet:
|
||||
player.planet.instantiate_machine(machine_type, machine_level, zone.get_global_position())
|
||||
player.planet.add_entity(
|
||||
Machine.instantiate_machine(machine_type, machine_level),
|
||||
zone.get_global_position()
|
||||
)
|
||||
return true
|
||||
return false
|
||||
@ -42,5 +42,3 @@ func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
func harvest(p : Plant, player: Player):
|
||||
player.play_sfx("harvest")
|
||||
p.harvest()
|
||||
if player.planet:
|
||||
player.planet.update_garden_score()
|
||||
@ -11,10 +11,10 @@ const SCORE_ICON = preload("res://common/icons/growth.svg")
|
||||
@export var plant_mutations: Array[PlantMutation]
|
||||
|
||||
func get_item_name() -> String:
|
||||
return plant_type.name
|
||||
return "%s Seed" % plant_type.name
|
||||
|
||||
func get_description() -> String:
|
||||
return ""
|
||||
return "Plant [b]%s[/b]. Must be used in decontamined zone." % plant_type.name
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return plant_type.seed_texture
|
||||
@ -42,7 +42,10 @@ func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
if player.planet == null:
|
||||
if (
|
||||
player.planet == null
|
||||
or not player.planet.garden.is_in_garden(zone.get_global_position())
|
||||
):
|
||||
return false
|
||||
|
||||
var is_there_a_plant_here = false
|
||||
@ -52,7 +55,7 @@ func can_use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
|
||||
var is_there_contamination_in_zone = false
|
||||
for point in zone.get_points_in_zone():
|
||||
if player.planet.is_there_contamination(point):
|
||||
if player.planet.garden.is_there_contamination(point):
|
||||
is_there_contamination_in_zone = true
|
||||
|
||||
return not is_there_a_plant_here and not is_there_contamination_in_zone
|
||||
@ -68,39 +71,50 @@ func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
plant_mutations
|
||||
)
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
var info = Inspector.Info.new(
|
||||
get_item_name(),
|
||||
get_description(),
|
||||
get_icon()
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
get_item_name()
|
||||
)
|
||||
info.texture = icon
|
||||
info.type_icon = TYPE_ICON
|
||||
|
||||
for m in plant_mutations:
|
||||
info.framed_infos.append(
|
||||
PlantMutation.get_framed_info_from_mutation(m)
|
||||
)
|
||||
|
||||
info.framed_infos.append_array(
|
||||
PlantEffect.get_framed_info_from_all_trigger_effects(
|
||||
plant_type.default_mature_effects,
|
||||
plant_type.default_harvest_effects,
|
||||
plant_type.default_cyclic_effects
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
"Cost %d energy" % energy_usage,
|
||||
ENERGY_ICON
|
||||
)
|
||||
)
|
||||
|
||||
info.stat_infos = [
|
||||
Inspector.StatInfo.new(
|
||||
"[b]%d[/b] points when mature" % plant_type.default_plant_score,
|
||||
SCORE_ICON
|
||||
),
|
||||
Inspector.StatInfo.new(
|
||||
"Grow in [b]%d[/b] days" % plant_type.default_growing_time,
|
||||
GROWING_ICON
|
||||
if is_one_time_use():
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
"One time use",
|
||||
ONE_TIME_ICON
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
var effect_section = CardSectionInfo.new(
|
||||
"Effect",
|
||||
get_description()
|
||||
)
|
||||
effect_section.title_icon = ACTION_ICON
|
||||
|
||||
if energy_usage > 0:
|
||||
effect_section.title_icon = ENERGY_ICON
|
||||
|
||||
info.sections.append(effect_section)
|
||||
|
||||
if len(plant_mutations) != 0:
|
||||
var rarest : int = plant_mutations.map(
|
||||
func(m : PlantMutation) : return m.get_rarity()
|
||||
).max()
|
||||
info.bg_color = PlantMutation.get_rarity_color(rarest)
|
||||
for m in plant_mutations:
|
||||
info.sections.append(m.card_section())
|
||||
|
||||
return info
|
||||
|
||||
|
||||
func get_particles() -> Array[Particles.Parameters]:
|
||||
var param : Array[Particles.Parameters] = []
|
||||
|
||||
@ -108,7 +122,7 @@ func get_particles() -> Array[Particles.Parameters]:
|
||||
param.append(
|
||||
Particles.Parameters.new(
|
||||
m.get_icon(),
|
||||
PlantMutation.get_rarity_color(m)
|
||||
PlantMutation.get_rarity_color(m.get_rarity())
|
||||
)
|
||||
)
|
||||
|
||||
@ -41,4 +41,4 @@ func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
|
||||
func dig(u: UndergroundLoot, player: Player):
|
||||
player.play_sfx("dig")
|
||||
u.dig()
|
||||
u.dig()
|
||||
@ -3,8 +3,6 @@ class_name Player
|
||||
|
||||
const MAX_REACH = 100
|
||||
const HOLDING_ITEM_SPRITE_SIZE = 20.
|
||||
const DEFAULT_INVENTORY_SIZE = 2
|
||||
const DEFAULT_MAX_ENERGY = 2
|
||||
|
||||
signal player_updated(player: Player)
|
||||
signal upgraded
|
||||
@ -14,9 +12,10 @@ var planet : Planet :
|
||||
get(): return terrain if terrain is Planet else null
|
||||
@export var speed = 350
|
||||
|
||||
var max_energy : int = DEFAULT_MAX_ENERGY
|
||||
var has_just_received_instruction : bool = false # pour récupérer les zones dans les action_area, une frame doit être passée depuis la création de la zone
|
||||
|
||||
var data : PlayerData
|
||||
|
||||
var controlling_player : bool = true :
|
||||
set(v):
|
||||
controlling_player = v
|
||||
@ -24,28 +23,23 @@ var controlling_player : bool = true :
|
||||
|
||||
var instruction : Instruction = null
|
||||
|
||||
var energy : int = max_energy :
|
||||
set(v):
|
||||
energy = v
|
||||
player_updated.emit(self)
|
||||
|
||||
@onready var inventory : Inventory = Inventory.new(DEFAULT_INVENTORY_SIZE)
|
||||
@onready var preview_zone : ActionZone = null
|
||||
@onready var action_zone : ActionZone = null
|
||||
@onready var preview_zone : ActionZone = setup_action_zone(Vector2.ZERO, null)
|
||||
@onready var action_zone : ActionZone = setup_action_zone(Vector2.ZERO, null)
|
||||
|
||||
func _ready():
|
||||
data = GameInfo.game_data.player_data
|
||||
data.inventory.updated.connect(_on_inventory_updated)
|
||||
player_updated.emit(self)
|
||||
inventory.inventory_changed.connect(_on_inventory_updated)
|
||||
Pointer.player = self
|
||||
|
||||
func _input(_event) -> void:
|
||||
if Input.is_action_pressed("change_item_left"):
|
||||
inventory.change_current_item(1)
|
||||
data.inventory.change_current_item(1)
|
||||
if Input.is_action_pressed("change_item_right"):
|
||||
inventory.change_current_item(-1)
|
||||
data.inventory.change_current_item(-1)
|
||||
for i in range(1, 10):
|
||||
if Input.is_action_pressed("item_" + str(i)):
|
||||
inventory.set_current_item(i - 1)
|
||||
data.inventory.set_current_item(i - 1)
|
||||
|
||||
# Méthode déclenchée par la classe planet
|
||||
func _start_pass_day():
|
||||
@ -80,8 +74,8 @@ func _process(_delta):
|
||||
move_and_slide()
|
||||
|
||||
func _on_inventory_updated(_inventory: Inventory):
|
||||
var item : Item = inventory.get_item()
|
||||
setup_preview_zone(item)
|
||||
setup_preview_zone(data.inventory.get_item())
|
||||
var item : Item = data.inventory.get_item()
|
||||
if item:
|
||||
var item_texture = item.icon
|
||||
%ItemSprite.texture = item_texture
|
||||
@ -128,27 +122,30 @@ func try_move(move_to : Vector2):
|
||||
|
||||
func pick_item(item : Item) -> Item:
|
||||
play_sfx("pick")
|
||||
if inventory.is_full():
|
||||
if data.inventory.is_full():
|
||||
drop_item()
|
||||
|
||||
var available_slot_ind = inventory.get_best_available_slot_ind()
|
||||
if available_slot_ind == inventory.current_item_ind && inventory.items[available_slot_ind] != null:
|
||||
var current_item : Item = inventory.get_item()
|
||||
inventory.set_item(item, available_slot_ind)
|
||||
var available_slot_ind = data.inventory.get_best_available_slot_ind()
|
||||
if (
|
||||
available_slot_ind == data.inventory.current_item_ind
|
||||
&& data.inventory.items[available_slot_ind] != null
|
||||
):
|
||||
var current_item : Item = data.inventory.get_item()
|
||||
data.inventory.set_item(item, available_slot_ind)
|
||||
return current_item
|
||||
else :
|
||||
if inventory.set_item(item, available_slot_ind):
|
||||
inventory.set_current_item(available_slot_ind);
|
||||
if data.inventory.set_item(item, available_slot_ind):
|
||||
data.inventory.set_current_item(available_slot_ind);
|
||||
return null
|
||||
|
||||
func drop_item():
|
||||
var item_to_drop = inventory.pop_item()
|
||||
var item_to_drop = data.inventory.pop_item()
|
||||
if item_to_drop:
|
||||
terrain.drop_item(item_to_drop, global_position)
|
||||
play_sfx("drop")
|
||||
|
||||
func delete_item(item: Item):
|
||||
inventory.remove_item(item)
|
||||
data.inventory.remove_item(item)
|
||||
|
||||
func try_use_item(item : Item, use_position : Vector2):
|
||||
has_just_received_instruction = true
|
||||
@ -163,7 +160,7 @@ func preview_could_use_item(item : Item) -> bool:
|
||||
|
||||
func could_use_item_on_zone(item : Item, zone: ActionZone) -> bool:
|
||||
return (
|
||||
inventory.has_item(item)
|
||||
data.inventory.has_item(item)
|
||||
and item.can_use(self, zone)
|
||||
)
|
||||
|
||||
@ -174,32 +171,32 @@ func can_use_item_on_zone(item : Item, zone: ActionZone) -> bool:
|
||||
)
|
||||
|
||||
func has_energy_to_use_item(item : Item):
|
||||
return (energy - item.energy_usage) >= 0
|
||||
return (data.energy - item.energy_usage) >= 0
|
||||
|
||||
func use_item(item : Item):
|
||||
if can_use_item_on_zone(item, action_zone):
|
||||
var is_item_used = await item.use(self, action_zone)
|
||||
if is_item_used:
|
||||
energy -= item.energy_usage
|
||||
data.energy -= item.energy_usage
|
||||
if item.is_one_time_use():
|
||||
inventory.remove_item(item)
|
||||
data.inventory.remove_item(item)
|
||||
|
||||
func upgrade_max_energy(amount = 1):
|
||||
max_energy += amount
|
||||
data.max_energy += amount
|
||||
upgraded.emit()
|
||||
player_updated.emit(self)
|
||||
|
||||
func upgrade_inventory_size(amount = 1):
|
||||
inventory.items.resize(inventory.items.size() + amount)
|
||||
data.inventory.items.resize(data.inventory.items.size() + amount)
|
||||
upgraded.emit()
|
||||
player_updated.emit(self)
|
||||
|
||||
func recharge(amount : int = max_energy):
|
||||
energy = energy + amount
|
||||
func recharge(amount : int = data.max_energy):
|
||||
data.energy += + amount
|
||||
upgraded.emit()
|
||||
|
||||
func full_recharge():
|
||||
energy = max(energy, max_energy)
|
||||
data.energy = max(data.energy, data.max_energy)
|
||||
|
||||
func generate_action_zone(item : Item) -> ActionZone:
|
||||
var zone = ActionZone.new(item)
|
||||
@ -226,7 +223,7 @@ func setup_action_zone(zone_position : Vector2, item: Item) -> ActionZone:
|
||||
if action_zone:
|
||||
action_zone.destroy()
|
||||
action_zone = generate_action_zone(item)
|
||||
action_zone.area.global_position = zone_position
|
||||
action_zone.move_to_position(zone_position)
|
||||
return action_zone
|
||||
|
||||
func move_preview_zone(zone_position : Vector2):
|
||||
@ -320,11 +317,13 @@ class ActionZone:
|
||||
affected_areas = new_affected_areas
|
||||
|
||||
func get_affected_areas() -> Array[Area2D]:
|
||||
return [] if area == null else area.get_overlapping_areas()
|
||||
var empty_array : Array[Area2D] = []
|
||||
return empty_array if area == null else area.get_overlapping_areas()
|
||||
|
||||
func destroy():
|
||||
clear_preview_on_affected_area()
|
||||
area.queue_free()
|
||||
if area:
|
||||
area.queue_free()
|
||||
|
||||
func get_global_position() -> Vector2:
|
||||
return Vector2.ZERO if area == null else area.global_position
|
||||
|
||||
17
entities/player/scripts/player_data.gd
Normal file
17
entities/player/scripts/player_data.gd
Normal file
@ -0,0 +1,17 @@
|
||||
extends Resource
|
||||
class_name PlayerData
|
||||
|
||||
signal updated(player_data : PlayerData)
|
||||
|
||||
const DEFAULT_MAX_ENERGY = 2
|
||||
const DEFAULT_INVENTORY_SIZE = 3
|
||||
|
||||
@export var max_energy : int = DEFAULT_MAX_ENERGY :
|
||||
set(v):
|
||||
max_energy = v
|
||||
updated.emit(self)
|
||||
@export var energy : int = DEFAULT_MAX_ENERGY :
|
||||
set(v):
|
||||
energy = v
|
||||
updated.emit(self)
|
||||
@export var inventory = Inventory.new(DEFAULT_INVENTORY_SIZE)
|
||||
1
entities/player/scripts/player_data.gd.uid
Normal file
1
entities/player/scripts/player_data.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://d4kdfrdv83xve
|
||||
9
entities/scripts/entity.gd
Normal file
9
entities/scripts/entity.gd
Normal file
@ -0,0 +1,9 @@
|
||||
extends Area2D
|
||||
class_name Entity
|
||||
|
||||
var terrain : Terrain
|
||||
var planet : Planet :
|
||||
get(): return terrain if terrain is Planet else null
|
||||
|
||||
func save() -> EntityData:
|
||||
return null
|
||||
1
entities/scripts/entity.gd.uid
Normal file
1
entities/scripts/entity.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dxb383bmy4kdx
|
||||
13
entities/scripts/entity_data.gd
Normal file
13
entities/scripts/entity_data.gd
Normal file
@ -0,0 +1,13 @@
|
||||
extends Resource
|
||||
class_name EntityData
|
||||
|
||||
@export var position : Vector2
|
||||
|
||||
func _init(e : Entity):
|
||||
position = e.global_position
|
||||
|
||||
func get_position() -> Vector2:
|
||||
return position
|
||||
|
||||
func load() -> Entity:
|
||||
return null
|
||||
1
entities/scripts/entity_data.gd.uid
Normal file
1
entities/scripts/entity_data.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bgbbce45hjv3d
|
||||
@ -1,15 +1,12 @@
|
||||
extends Area2D
|
||||
extends Entity
|
||||
class_name InspectableEntity
|
||||
|
||||
const MODULATE_INSPECTED_COLOR = Color.GRAY
|
||||
const MODULATE_AFFECTED_COLOR = Color.RED
|
||||
|
||||
var terrain : Terrain
|
||||
var planet : Planet :
|
||||
get(): return terrain if terrain is Planet else null
|
||||
const DESC_ICON = preload("res://common/icons/align-right.svg")
|
||||
|
||||
@export var default_info_title = ""
|
||||
@export var default_info_desc = ""
|
||||
@export_multiline var default_info_desc = ""
|
||||
|
||||
@onready var default_modulate : Color = modulate
|
||||
@onready var inspectable_signals_setuped : bool = setup_inspectable_signals()
|
||||
@ -26,7 +23,7 @@ func setup_inspectable_signals() -> bool:
|
||||
return true
|
||||
|
||||
func _on_mouse_entered():
|
||||
Pointer.inspect(self, inspector_info())
|
||||
Pointer.inspect(self)
|
||||
|
||||
func _on_mouse_excited():
|
||||
Pointer.stop_inspect(self)
|
||||
@ -34,12 +31,23 @@ func _on_mouse_excited():
|
||||
func pointer_text() -> String:
|
||||
return default_info_title
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
pointer_text(),
|
||||
default_info_desc
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
pointer_text()
|
||||
)
|
||||
|
||||
if default_info_desc != "":
|
||||
var desc_section = CardSectionInfo.new(
|
||||
"Description",
|
||||
default_info_desc
|
||||
)
|
||||
desc_section.title_icon = DESC_ICON
|
||||
info.sections.append(
|
||||
desc_section
|
||||
)
|
||||
|
||||
return info
|
||||
|
||||
func _notification(what):
|
||||
if (what == NOTIFICATION_PREDELETE):
|
||||
Pointer.stop_inspect(self)
|
||||
|
||||
@ -12,15 +12,13 @@ const SPRITE_SCENE : PackedScene = preload("res://entities/underground_loot/unde
|
||||
@onready var collision_shape: CollisionShape2D = generate_collision_shape()
|
||||
|
||||
|
||||
func _init(_loot : Array[Item] = []):
|
||||
loot = _loot
|
||||
default_info_desc = "Contain some random seeds. [b]Dig it with a shovel.[/b]"
|
||||
|
||||
func pointer_text() -> String:
|
||||
return "Buried Loot"
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
"Buried Loot",
|
||||
"Can contain some seeds from the past... Dig it with a shovel."
|
||||
)
|
||||
|
||||
func generate_sprite() -> Node2D:
|
||||
var object = SPRITE_SCENE.instantiate()
|
||||
|
||||
@ -42,3 +40,6 @@ func dig():
|
||||
for item in loot:
|
||||
planet.drop_item(item, global_position, LOOTED_ITEM_RANDOM_RANGE)
|
||||
queue_free()
|
||||
|
||||
func save() -> UndergroundLootData:
|
||||
return UndergroundLootData.new(self)
|
||||
11
entities/underground_loot/scripts/underground_loot_data.gd
Normal file
11
entities/underground_loot/scripts/underground_loot_data.gd
Normal file
@ -0,0 +1,11 @@
|
||||
extends EntityData
|
||||
class_name UndergroundLootData
|
||||
|
||||
@export var loot : Array[Item]
|
||||
|
||||
func _init(e : UndergroundLoot):
|
||||
position = e.global_position
|
||||
loot = e.loot
|
||||
|
||||
func load() -> Entity:
|
||||
return UndergroundLoot.new(loot)
|
||||
@ -0,0 +1 @@
|
||||
uid://68plwch6h4f7
|
||||
@ -62,7 +62,7 @@ tracks/2/keys = {
|
||||
|
||||
[sub_resource type="Animation" id="Animation_871vo"]
|
||||
resource_name = "pass"
|
||||
length = 3.0
|
||||
length = 4.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
@ -70,7 +70,7 @@ tracks/0/path = NodePath(".:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.0333333, 2.93334, 2.96667),
|
||||
"times": PackedFloat32Array(0, 0.0333333, 3.96667, 4),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [false, true, true, false]
|
||||
@ -82,7 +82,7 @@ tracks/1/path = NodePath("VBoxContainer/AnnounceTexture:custom_minimum_size")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0.0666667, 0.433333, 2.42651, 2.93334),
|
||||
"times": PackedFloat32Array(0.0666667, 0.433333, 3.5, 3.96667),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0), Vector2(0, 65), Vector2(0, 65), Vector2(0, 0)]
|
||||
@ -94,7 +94,7 @@ tracks/2/path = NodePath("VBoxContainer:modulate")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0.0666667, 0.133333, 2.83334, 2.93334),
|
||||
"times": PackedFloat32Array(0.0666667, 0.133333, 3.86667, 3.96667),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
|
||||
BIN
gui/game/card/assets/texture/reflect.png
Normal file
BIN
gui/game/card/assets/texture/reflect.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
@ -2,22 +2,24 @@
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bnrjnvceprxfn"
|
||||
path="res://.godot/imported/sol_gamejam_normal.png-a8a63b9f57f727b96585445cbd74ba15.ctex"
|
||||
uid="uid://cxoi7fd2em002"
|
||||
path="res://.godot/imported/reflect.png-bcb8dad250fa32818817143cee617537.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/assets/textures/sol_gamejam_normal.png"
|
||||
dest_files=["res://.godot/imported/sol_gamejam_normal.png-a8a63b9f57f727b96585445cbd74ba15.ctex"]
|
||||
source_file="res://gui/game/card/assets/texture/reflect.png"
|
||||
dest_files=["res://.godot/imported/reflect.png-bcb8dad250fa32818817143cee617537.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
@ -25,6 +27,10 @@ mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
203
gui/game/card/card.tscn
Normal file
203
gui/game/card/card.tscn
Normal file
@ -0,0 +1,203 @@
|
||||
[gd_scene load_steps=20 format=3 uid="uid://753270jjxmfg"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_m317d"]
|
||||
[ext_resource type="Script" uid="uid://b7f10wuounfan" path="res://gui/game/card/scripts/card.gd" id="2_kpm7h"]
|
||||
[ext_resource type="FontFile" uid="uid://qt80w6o01q5s" path="res://gui/ressources/fonts/TitanOne-Regular.ttf" id="2_plgbn"]
|
||||
[ext_resource type="Script" uid="uid://dj2pv1hiwjfv0" path="res://gui/game/card/scripts/card_info.gd" id="3_7wc8v"]
|
||||
[ext_resource type="Texture2D" uid="uid://bt3g5bmar0icf" path="res://common/icons/growth.svg" id="3_kpm7h"]
|
||||
[ext_resource type="Script" uid="uid://dgbh38j13g5kn" path="res://gui/game/card/scripts/card_section_info.gd" id="5_7wc8v"]
|
||||
[ext_resource type="Texture2D" uid="uid://0hbdgalf04e" path="res://common/icons/wood.svg" id="6_7wc8v"]
|
||||
[ext_resource type="Script" uid="uid://b4tkium34c831" path="res://gui/game/card/scripts/card_stat_info.gd" id="6_pmldi"]
|
||||
[ext_resource type="Texture2D" uid="uid://baaujfw8piywi" path="res://common/icons/dna.svg" id="7_mwhj8"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="7_pmldi"]
|
||||
[ext_resource type="Texture2D" uid="uid://deywxmh76nu5w" path="res://common/icons/caret-down.svg" id="11_kpm7h"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gibok"]
|
||||
bg_color = Color(1, 1, 1, 1)
|
||||
corner_radius_top_left = 20
|
||||
corner_radius_top_right = 20
|
||||
corner_radius_bottom_right = 20
|
||||
corner_radius_bottom_left = 20
|
||||
|
||||
[sub_resource type="Resource" id="Resource_mwhj8"]
|
||||
script = ExtResource("5_7wc8v")
|
||||
title_text = "Title"
|
||||
title_icon = ExtResource("6_7wc8v")
|
||||
text = "Text"
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_plgbn"]
|
||||
script = ExtResource("3_7wc8v")
|
||||
title = "Hello"
|
||||
type_icon = ExtResource("6_7wc8v")
|
||||
texture = ExtResource("7_mwhj8")
|
||||
important_stat_text = "10"
|
||||
important_stat_icon = ExtResource("3_kpm7h")
|
||||
sections = Array[ExtResource("5_7wc8v")]([SubResource("Resource_mwhj8")])
|
||||
metadata/_custom_type_script = "uid://dj2pv1hiwjfv0"
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vnqhg"]
|
||||
bg_color = Color(1, 1, 1, 1)
|
||||
corner_radius_top_left = 20
|
||||
corner_radius_top_right = 20
|
||||
corner_radius_bottom_right = 20
|
||||
corner_radius_bottom_left = 20
|
||||
|
||||
[sub_resource type="Theme" id="Theme_on5kv"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_sx78e"]
|
||||
font = ExtResource("2_plgbn")
|
||||
font_size = 20
|
||||
|
||||
[sub_resource type="Animation" id="Animation_7wc8v"]
|
||||
resource_name = "expand"
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_pmldi"]
|
||||
_data = {
|
||||
&"expand": SubResource("Animation_7wc8v")
|
||||
}
|
||||
|
||||
[node name="Card" type="PanelContainer"]
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
offset_right = 140.0
|
||||
offset_bottom = 60.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
theme = ExtResource("1_m317d")
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_gibok")
|
||||
script = ExtResource("2_kpm7h")
|
||||
info = SubResource("Resource_plgbn")
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("1_m317d")
|
||||
theme_override_constants/h_separation = 0
|
||||
theme_override_constants/v_separation = 0
|
||||
|
||||
[node name="CardUpperPart" type="PanelContainer" parent="GridContainer"]
|
||||
unique_name_in_owner = true
|
||||
self_modulate = Color(0.13725491, 0.39215687, 0.6666667, 1)
|
||||
clip_contents = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme = ExtResource("1_m317d")
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_vnqhg")
|
||||
|
||||
[node name="EntityTexture" type="TextureRect" parent="GridContainer/CardUpperPart"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 1, 1, 0.23137255)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("7_mwhj8")
|
||||
expand_mode = 1
|
||||
stretch_mode = 6
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/CardUpperPart"]
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_on5kv")
|
||||
theme_override_constants/margin_left = 25
|
||||
|
||||
[node name="ContentContainer" type="VBoxContainer" parent="GridContainer/CardUpperPart/MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("1_m317d")
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="TitleContainer" type="HBoxContainer" parent="GridContainer/CardUpperPart/MarginContainer/ContentContainer"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("1_m317d")
|
||||
|
||||
[node name="CardTitle" type="Label" parent="GridContainer/CardUpperPart/MarginContainer/ContentContainer/TitleContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Hello"
|
||||
label_settings = SubResource("LabelSettings_sx78e")
|
||||
|
||||
[node name="CardTypeIcon" type="TextureRect" parent="GridContainer/CardUpperPart/MarginContainer/ContentContainer/TitleContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(30, 30)
|
||||
layout_mode = 2
|
||||
theme = ExtResource("1_m317d")
|
||||
texture = ExtResource("6_7wc8v")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="CardStats" type="MarginContainer" parent="GridContainer/CardUpperPart/MarginContainer/ContentContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme = ExtResource("1_m317d")
|
||||
theme_override_constants/margin_left = 0
|
||||
theme_override_constants/margin_top = 0
|
||||
theme_override_constants/margin_right = 40
|
||||
theme_override_constants/margin_bottom = 0
|
||||
|
||||
[node name="CardStatsContainer" type="VBoxContainer" parent="GridContainer/CardUpperPart/MarginContainer/ContentContainer/CardStats"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme = ExtResource("1_m317d")
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="CardSections" type="MarginContainer" parent="GridContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CardSectionsContainer" type="VBoxContainer" parent="GridContainer/CardSections"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ImportantStat" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 0
|
||||
theme_override_constants/margin_top = 30
|
||||
theme_override_constants/margin_right = 0
|
||||
theme_override_constants/margin_bottom = 0
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="ImportantStat"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
use_top_left = true
|
||||
|
||||
[node name="ImportantStatIcon" type="TextureRect" parent="ImportantStat/CenterContainer"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 0.6509804, 0.09019608, 1)
|
||||
custom_minimum_size = Vector2(60, 60)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("3_kpm7h")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="ImportantStatText" type="Label" parent="ImportantStat/CenterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "10"
|
||||
label_settings = ExtResource("7_pmldi")
|
||||
|
||||
[node name="ArrowDown" type="Control" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="ArrowDown"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -24.0
|
||||
offset_top = -24.0
|
||||
offset_right = 24.0
|
||||
offset_bottom = 24.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
texture = ExtResource("11_kpm7h")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_pmldi")
|
||||
}
|
||||
71
gui/game/card/card_section.tscn
Normal file
71
gui/game/card/card_section.tscn
Normal file
@ -0,0 +1,71 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://bghefrgaujjt6"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dcmee2jvohudl" path="res://gui/game/card/scripts/card_section.gd" id="1_41hkv"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_t7m3x"]
|
||||
[ext_resource type="Script" uid="uid://dgbh38j13g5kn" path="res://gui/game/card/scripts/card_section_info.gd" id="2_3ktqg"]
|
||||
[ext_resource type="Texture2D" uid="uid://baaujfw8piywi" path="res://common/icons/dna.svg" id="2_41hkv"]
|
||||
[ext_resource type="FontFile" uid="uid://qt80w6o01q5s" path="res://gui/ressources/fonts/TitanOne-Regular.ttf" id="3_3ktqg"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_vlpjv"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ycbno"]
|
||||
script = ExtResource("2_3ktqg")
|
||||
title_colored = true
|
||||
title_text = "Hello"
|
||||
title_icon = ExtResource("2_41hkv")
|
||||
text = "Hello"
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_ycbno"]
|
||||
font = ExtResource("3_3ktqg")
|
||||
font_size = 15
|
||||
|
||||
[node name="CardSection" type="VBoxContainer"]
|
||||
offset_right = 176.0
|
||||
offset_bottom = 71.0
|
||||
theme = SubResource("Theme_vlpjv")
|
||||
theme_override_constants/separation = 6
|
||||
script = ExtResource("1_41hkv")
|
||||
info = SubResource("Resource_ycbno")
|
||||
|
||||
[node name="CardSectionTitle" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
theme = ExtResource("1_t7m3x")
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="TitleIcon" type="TextureRect" parent="CardSectionTitle"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.14509805, 0.75686276, 0.2784314, 1)
|
||||
custom_minimum_size = Vector2(20, 20)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("2_41hkv")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="TitleText" type="Label" parent="CardSectionTitle"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.14509805, 0.75686276, 0.2784314, 1)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme = ExtResource("1_t7m3x")
|
||||
text = "Hello"
|
||||
label_settings = SubResource("LabelSettings_ycbno")
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="CardSectionTextContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("1_t7m3x")
|
||||
theme_override_constants/margin_left = 25
|
||||
theme_override_constants/margin_top = 0
|
||||
theme_override_constants/margin_right = 0
|
||||
theme_override_constants/margin_bottom = 0
|
||||
|
||||
[node name="Text" type="RichTextLabel" parent="CardSectionTextContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme = ExtResource("1_t7m3x")
|
||||
theme_override_colors/default_color = Color(0.0627451, 0.05882353, 0.16862746, 1)
|
||||
bbcode_enabled = true
|
||||
text = "Hello"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
37
gui/game/card/card_stat.tscn
Normal file
37
gui/game/card/card_stat.tscn
Normal file
@ -0,0 +1,37 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://cpen6hj0rbw8x"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_6abif"]
|
||||
[ext_resource type="Script" uid="uid://c8xxhu28xm4hy" path="res://gui/game/card/scripts/card_stat.gd" id="2_30iht"]
|
||||
[ext_resource type="Texture2D" uid="uid://baaujfw8piywi" path="res://common/icons/dna.svg" id="3_30iht"]
|
||||
[ext_resource type="Script" uid="uid://b4tkium34c831" path="res://gui/game/card/scripts/card_stat_info.gd" id="3_c3wpw"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_n0n76"]
|
||||
script = ExtResource("3_c3wpw")
|
||||
|
||||
[node name="CardStat" type="HBoxContainer"]
|
||||
offset_right = 222.0
|
||||
offset_bottom = 30.0
|
||||
theme = ExtResource("1_6abif")
|
||||
theme_override_constants/separation = 6
|
||||
script = ExtResource("2_30iht")
|
||||
info = SubResource("Resource_n0n76")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(20, 20)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("3_30iht")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
theme = ExtResource("1_6abif")
|
||||
bbcode_enabled = true
|
||||
text = "[b]10[/b] A very long text that will eventually break"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
autowrap_mode = 2
|
||||
85
gui/game/card/card_visualiser.tscn
Normal file
85
gui/game/card/card_visualiser.tscn
Normal file
@ -0,0 +1,85 @@
|
||||
[gd_scene load_steps=15 format=3 uid="uid://3ss8pvhsackj"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://753270jjxmfg" path="res://gui/game/card/card.tscn" id="1_we78f"]
|
||||
[ext_resource type="Shader" uid="uid://bqjwmomh851lc" path="res://common/vfx/materials/shaders/skew.gdshader" id="1_x54se"]
|
||||
[ext_resource type="Script" uid="uid://dj5pld5ragrjp" path="res://gui/game/card/scripts/card_visualiser.gd" id="2_ntbk8"]
|
||||
[ext_resource type="Script" uid="uid://dj2pv1hiwjfv0" path="res://gui/game/card/scripts/card_info.gd" id="3_5yk1o"]
|
||||
[ext_resource type="Script" uid="uid://dgbh38j13g5kn" path="res://gui/game/card/scripts/card_section_info.gd" id="4_7xkgc"]
|
||||
[ext_resource type="Script" uid="uid://b4tkium34c831" path="res://gui/game/card/scripts/card_stat_info.gd" id="5_1et8x"]
|
||||
[ext_resource type="Texture2D" uid="uid://bt3g5bmar0icf" path="res://common/icons/growth.svg" id="6_7xkgc"]
|
||||
[ext_resource type="Texture2D" uid="uid://bsvxhafoxwmw0" path="res://common/icons/cube-3d-sphere.svg" id="7_1et8x"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_r0jrf"]
|
||||
shader = ExtResource("1_x54se")
|
||||
shader_parameter/fov = 90.0
|
||||
shader_parameter/cull_back = true
|
||||
shader_parameter/y_rot = -6e-45
|
||||
shader_parameter/x_rot = -6e-45
|
||||
shader_parameter/inset = 0.0
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_5yk1o"]
|
||||
viewport_path = NodePath("SubViewport")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_r0jrf"]
|
||||
script = ExtResource("3_5yk1o")
|
||||
title = "Hello"
|
||||
texture = ExtResource("6_7xkgc")
|
||||
metadata/_custom_type_script = "uid://dj2pv1hiwjfv0"
|
||||
|
||||
[sub_resource type="Animation" id="Animation_1et8x"]
|
||||
length = 0.3
|
||||
|
||||
[sub_resource type="Animation" id="Animation_7xkgc"]
|
||||
resource_name = "appear"
|
||||
length = 0.2
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_r0jrf"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_1et8x"),
|
||||
&"appear": SubResource("Animation_7xkgc")
|
||||
}
|
||||
|
||||
[node name="CardVisualiser" type="TextureRect"]
|
||||
material = SubResource("ShaderMaterial_r0jrf")
|
||||
offset_left = -24.0
|
||||
offset_right = 276.0
|
||||
offset_bottom = 110.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 4
|
||||
mouse_filter = 2
|
||||
texture = SubResource("ViewportTexture_5yk1o")
|
||||
stretch_mode = 4
|
||||
script = ExtResource("2_ntbk8")
|
||||
small_mode = true
|
||||
card_info = SubResource("Resource_r0jrf")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="."]
|
||||
unique_name_in_owner = true
|
||||
transparent_bg = true
|
||||
size = Vector2i(300, 110)
|
||||
|
||||
[node name="CardContainer" type="MarginContainer" parent="SubViewport"]
|
||||
unique_name_in_owner = true
|
||||
clip_contents = true
|
||||
offset_right = 350.0
|
||||
offset_bottom = 110.0
|
||||
size_flags_horizontal = 0
|
||||
theme_override_constants/margin_left = 25
|
||||
theme_override_constants/margin_top = 25
|
||||
theme_override_constants/margin_right = 25
|
||||
theme_override_constants/margin_bottom = 25
|
||||
|
||||
[node name="Card" parent="SubViewport/CardContainer" instance=ExtResource("1_we78f")]
|
||||
unique_name_in_owner = true
|
||||
self_modulate = Color(1, 1, 1, 0)
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
||||
small_mode = true
|
||||
down_arrow = true
|
||||
info = SubResource("Resource_r0jrf")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_r0jrf")
|
||||
}
|
||||
57
gui/game/card/scripts/card.gd
Normal file
57
gui/game/card/scripts/card.gd
Normal file
@ -0,0 +1,57 @@
|
||||
@tool
|
||||
extends PanelContainer
|
||||
class_name Card
|
||||
|
||||
const CARD_STAT_SCENE : PackedScene = preload("res://gui/game/card/card_stat.tscn")
|
||||
const CARD_SECTION_SCENE : PackedScene = preload("res://gui/game/card/card_section.tscn")
|
||||
|
||||
@export var small_mode : bool = false
|
||||
@export var down_arrow : bool = false
|
||||
|
||||
@export var info : CardInfo = CardInfo.new("Default Card Name")
|
||||
|
||||
@export_tool_button("Update", "Callable") var update_action = update
|
||||
|
||||
func _ready():
|
||||
update()
|
||||
|
||||
func update():
|
||||
%CardTitle.text = info.title
|
||||
%CardUpperPart.self_modulate = info.bg_color
|
||||
%CardTypeIcon.texture = info.type_icon
|
||||
%EntityTexture.texture = info.texture
|
||||
|
||||
%ImportantStatIcon.texture = info.important_stat_icon
|
||||
%ImportantStatText.text = info.important_stat_text
|
||||
|
||||
%ArrowDown.visible = down_arrow
|
||||
|
||||
self_modulate = Color.TRANSPARENT if small_mode else Color.WHITE
|
||||
%CardUpperPart.self_modulate.a = 0.7 if small_mode else 1.0
|
||||
|
||||
update_card_stats()
|
||||
update_card_sections()
|
||||
|
||||
func update_card_stats():
|
||||
for stat in %CardStatsContainer.get_children():
|
||||
stat.queue_free()
|
||||
|
||||
for stat_info in info.stats:
|
||||
if stat_info:
|
||||
var new_stat : CardStat = CARD_STAT_SCENE.instantiate() as CardStat
|
||||
new_stat.info = stat_info
|
||||
%CardStatsContainer.add_child(new_stat)
|
||||
|
||||
%CardStats.visible = len(info.stats) != 0 && small_mode == false
|
||||
|
||||
func update_card_sections():
|
||||
for stat in %CardSectionsContainer.get_children():
|
||||
stat.queue_free()
|
||||
|
||||
for sections_info in info.sections:
|
||||
if sections_info:
|
||||
var new_section : CardSection = CARD_SECTION_SCENE.instantiate() as CardSection
|
||||
new_section.info = sections_info
|
||||
%CardSectionsContainer.add_child(new_section)
|
||||
|
||||
%CardSections.visible = len(%CardSectionsContainer.get_children()) != 0 && small_mode == false
|
||||
1
gui/game/card/scripts/card.gd.uid
Normal file
1
gui/game/card/scripts/card.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://b7f10wuounfan
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user