#18 ajout de la classe UndergroundLoot et aparition de loot par jour
This commit is contained in:
@@ -5,6 +5,13 @@ signal planet_updated(planet : Planet)
|
||||
|
||||
const PLANET_TEXTURE_SCALE : float = 5.0
|
||||
|
||||
@export_group("Loot")
|
||||
@export var first_loot_number : int = 3
|
||||
@export var loot_number : Array[int] = [0,1,2]
|
||||
@export var loot_item_number : Array[int] = [1,2]
|
||||
@export var loot_items : Array[Item] = []
|
||||
|
||||
@export_group("Textures")
|
||||
@export var background_texture : Texture2D
|
||||
@export var contamination_material : ShaderMaterial
|
||||
|
||||
@@ -23,6 +30,7 @@ var day : int = 0 :
|
||||
|
||||
func _ready():
|
||||
planet_updated.emit(self)
|
||||
generate_loot(first_loot_number)
|
||||
|
||||
#region ------------------ Generation ------------------
|
||||
|
||||
@@ -30,7 +38,7 @@ func add_entity(e : Node2D, container : Node2D = entityContainer):
|
||||
if e.get_parent():
|
||||
e.get_parent().remove_child(e)
|
||||
|
||||
if e is Player:
|
||||
if "planet" in e:
|
||||
e.planet = self
|
||||
|
||||
container.add_child(e)
|
||||
@@ -105,10 +113,25 @@ func is_there_contamination(point : Vector2) -> bool:
|
||||
return terrainData.get_contamination(point) < 0.5
|
||||
|
||||
func pass_day():
|
||||
|
||||
for e : Node2D in entityContainer.get_children():
|
||||
if e.has_method("pass_day"):
|
||||
e.pass_day()
|
||||
day += 1
|
||||
generate_loot()
|
||||
|
||||
func generate_loot(number : int = loot_number.pick_random()):
|
||||
for i in range(number):
|
||||
var loot = UndergroundLoot.new(self)
|
||||
for j in range(loot_item_number.pick_random()):
|
||||
loot.loot.append(loot_items.pick_random())
|
||||
|
||||
add_entity(loot)
|
||||
|
||||
loot.global_position = Vector2(
|
||||
randf_range(0, terrainData.terrainSize.x),
|
||||
randf_range(0, terrainData.terrainSize.y)
|
||||
)
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user