2024-10-18 16:34:51 +02:00
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
var texture_new_sprite : Texture
|
|
|
|
|
2024-10-21 21:22:40 +02:00
|
|
|
var biom_n_w = preload("res://assets/Ground/transisions/n_w.png")
|
|
|
|
var biom_w_n = preload("res://assets/Ground/transisions/w_n.png")
|
|
|
|
var biom_n_s = preload("res://assets/Ground/transisions/n_s.png")
|
|
|
|
var biom_s_n = preload("res://assets/Ground/transisions/s_n.png")
|
|
|
|
|
2024-10-18 16:34:51 +02:00
|
|
|
var biom_n = preload("res://assets/Ground/n.png")
|
|
|
|
var biom_w = preload("res://assets/Ground/w.png")
|
2024-10-21 21:22:40 +02:00
|
|
|
var biom_s = preload("res://assets/Ground/s.png")
|
|
|
|
var biom_f = preload("res://assets/Ground/f.png")
|
2024-10-18 16:34:51 +02:00
|
|
|
|
|
|
|
var active_biom = "n"
|
2024-10-21 21:22:40 +02:00
|
|
|
var biom_type = "n"#normal,o=other,ui=übergangin,uo=übergangout
|
|
|
|
var change_in = 3
|
2024-10-18 16:34:51 +02:00
|
|
|
var passed
|
|
|
|
|
|
|
|
func probability(prozent):
|
2024-10-21 21:22:40 +02:00
|
|
|
return randf() > 1 - (0.01 * prozent)
|
|
|
|
|
|
|
|
func change_biom():
|
|
|
|
#if active_biom == "w_n":
|
|
|
|
# active_biom = "n"
|
|
|
|
#elif active_biom == "s_n":
|
|
|
|
# active_biom = "n"
|
|
|
|
#elif active_biom == "n_w":
|
|
|
|
# active_biom = "w"
|
|
|
|
#elif active_biom == "n_s":
|
|
|
|
# active_biom = "s"
|
|
|
|
|
|
|
|
if biom_type == "n":
|
|
|
|
change_in -= 1
|
|
|
|
if probability(60):
|
|
|
|
active_biom = "n"
|
|
|
|
else:
|
|
|
|
active_biom = "f"
|
|
|
|
elif biom_type == "o":
|
|
|
|
change_in -= 1
|
|
|
|
biom_type = "o"
|
|
|
|
elif biom_type == "ui":
|
|
|
|
if active_biom == "n_w":
|
|
|
|
active_biom = "w"
|
|
|
|
elif active_biom == "n_s":
|
|
|
|
active_biom = "s"
|
|
|
|
biom_type = "o"
|
|
|
|
elif biom_type == "uo":
|
|
|
|
if active_biom == "w":
|
|
|
|
active_biom = "w_n"
|
|
|
|
biom_type = "n"
|
|
|
|
elif active_biom == "s":
|
|
|
|
active_biom = "s_n"
|
|
|
|
biom_type = "n"
|
|
|
|
biom_type = "n"
|
|
|
|
|
|
|
|
if change_in <= 0: # bei übergängen
|
|
|
|
change_in = randi_range(3,7)
|
|
|
|
if biom_type == "n": #bei normalen biom auf neues biom oder wald
|
|
|
|
if probability(10): # 50% auf Biomwechsel
|
|
|
|
biom_type = "n"
|
|
|
|
else:
|
|
|
|
biom_type = "ui" #übergang in anderes biom
|
|
|
|
if probability(50):
|
|
|
|
active_biom = "n_w"
|
|
|
|
else:
|
|
|
|
active_biom = "n_s"
|
|
|
|
elif biom_type == "o": #bei anderen biomen auf normale Biome
|
|
|
|
biom_type = "uo"
|
|
|
|
|
|
|
|
#print("type : ", biom_type)
|
|
|
|
#print("active: ", active_biom)
|
|
|
|
#print("change: ", change_in)
|
|
|
|
#print(" ")
|
2024-10-18 16:34:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
func set_biom_texture():
|
|
|
|
if active_biom == "w":
|
|
|
|
texture_new_sprite = biom_w
|
|
|
|
elif active_biom == "n":
|
|
|
|
texture_new_sprite = biom_n
|
2024-10-21 21:22:40 +02:00
|
|
|
elif active_biom == "s":
|
|
|
|
texture_new_sprite = biom_s
|
|
|
|
elif active_biom == "f":
|
|
|
|
texture_new_sprite = biom_f
|
2024-10-18 16:34:51 +02:00
|
|
|
elif active_biom == "w_n":
|
|
|
|
texture_new_sprite = biom_w_n
|
|
|
|
elif active_biom == "n_w":
|
|
|
|
texture_new_sprite = biom_n_w
|
2024-10-21 21:22:40 +02:00
|
|
|
elif active_biom == "s_n":
|
|
|
|
texture_new_sprite = biom_s_n
|
|
|
|
elif active_biom == "n_s":
|
|
|
|
texture_new_sprite = biom_n_s
|
2024-10-18 16:34:51 +02:00
|
|
|
func _spawn(last_x_position) -> void:
|
|
|
|
var new_ground = preload("res://scenes/ground/ground.tscn").instantiate()
|
|
|
|
new_ground.texture = texture_new_sprite
|
2024-10-21 21:22:40 +02:00
|
|
|
new_ground.global_position.x = last_x_position + 400
|
2024-10-18 16:34:51 +02:00
|
|
|
add_child(new_ground)
|
2024-10-21 21:22:40 +02:00
|
|
|
new_ground.connect("screen_entered", _on_ground_sprite_screen_entered)
|
2024-10-18 16:34:51 +02:00
|
|
|
|
|
|
|
func _on_ground_sprite_screen_entered() -> void:
|
2024-10-21 21:22:40 +02:00
|
|
|
change_biom()
|
|
|
|
$"/root/Global".active_biom = active_biom
|
|
|
|
set_biom_texture()
|
2024-10-18 16:34:51 +02:00
|
|
|
_spawn(get_child(0).position.x)
|