Get Map Gernation in #17
5 changed files with 24 additions and 9 deletions
|
@ -6,7 +6,6 @@
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_sedmr"]
|
||||
|
||||
[node name="Bunny" type="CharacterBody2D"]
|
||||
scale = Vector2(0.5, 0.5)
|
||||
collision_layer = 4
|
||||
collision_mask = 11
|
||||
script = ExtResource("1_1kj2b")
|
||||
|
|
|
@ -8,7 +8,6 @@ radius = 8.57143
|
|||
height = 22.8571
|
||||
|
||||
[node name="Projectile" type="Area2D"]
|
||||
scale = Vector2(0.5, 0.5)
|
||||
collision_layer = 8
|
||||
collision_mask = 5
|
||||
script = ExtResource("1_os652")
|
||||
|
|
|
@ -128,9 +128,10 @@ format = 2
|
|||
script = ExtResource("2_yhpwh")
|
||||
start_area_corner_size = 3
|
||||
|
||||
[node name="Bunny Generator" type="Node" parent="."]
|
||||
[node name="Bunny Generator" type="Node" parent="." node_paths=PackedStringArray("player")]
|
||||
script = ExtResource("3_dvklj")
|
||||
bunny_prefab = ExtResource("4_0fyd5")
|
||||
player = NodePath("../Player")
|
||||
|
||||
[node name="Player" type="CharacterBody2D" parent="." node_paths=PackedStringArray("animation_player")]
|
||||
position = Vector2(1440, 810)
|
||||
|
|
|
@ -1,17 +1,32 @@
|
|||
extends Node
|
||||
|
||||
@export var bunny_prefab : Resource
|
||||
@export var player : CharacterBody2D
|
||||
@export var player_save_distance : float = 32.0
|
||||
@onready var BunnyPrefab : PackedScene = load(bunny_prefab.resource_path)
|
||||
|
||||
func spawn_bunny(x : float, y : float, team : int, health : int) -> Bunny:
|
||||
func spawn_bunny(pos : Vector2, team : int, health : int) -> Bunny:
|
||||
var bunny = BunnyPrefab.instantiate()
|
||||
self.add_child(bunny)
|
||||
bunny.global_position = Vector2(x,y)
|
||||
bunny.global_position = pos
|
||||
bunny.health = health
|
||||
bunny.team = team
|
||||
return bunny
|
||||
|
||||
func _ready():
|
||||
var bunny = spawn_bunny(960, 512, TEAM.EVIL, 3)
|
||||
bunny.sub_on_death(func(bunny): bunny.queue_free())
|
||||
func spawn_wave(free_tiles : Array, amount : int, health : int):
|
||||
|
||||
# Make Sure that no possitions to near to the player are insdie of the list
|
||||
for tile in free_tiles:
|
||||
if tile.distance_to(player.global_position) <= player_save_distance:
|
||||
free_tiles.erase(tile)
|
||||
|
||||
# Make sure amount isnt bigger then available positions
|
||||
if free_tiles.size() < amount: amount = free_tiles.size()
|
||||
|
||||
# Spawn at random psoitions of the list
|
||||
for i in amount:
|
||||
var pos = free_tiles.pick_random()
|
||||
free_tiles.erase(pos)
|
||||
var bunny = spawn_bunny(pos, TEAM.EVIL, 3)
|
||||
bunny.sub_on_death(func(bunny): bunny.queue_free())
|
||||
pass
|
||||
|
|
|
@ -18,7 +18,6 @@ var tile_array : Array
|
|||
func _ready():
|
||||
var time = generate()
|
||||
print("time for generation: " + str(time))
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
@ -39,6 +38,8 @@ func generate() -> float:
|
|||
set_borders_solid()
|
||||
|
||||
tile_array_to_terrain()
|
||||
|
||||
|
||||
return Time.get_unix_time_from_system() - start_time
|
||||
|
||||
func setup_tile_data_array():
|
||||
|
|
Reference in a new issue