fix spawning
This commit is contained in:
parent
dbfff61052
commit
94e51d3009
@ -1,5 +1,8 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
onready var rootnode = get_node("/root/World")
|
||||
onready var tilesmap = $"/root/World/tilemap"
|
||||
|
||||
const MOVEMENT_VECTORS = [
|
||||
Vector2.UP,
|
||||
Vector2.RIGHT,
|
||||
@ -8,6 +11,9 @@ const MOVEMENT_VECTORS = [
|
||||
]
|
||||
|
||||
func _physics_process(_delta):
|
||||
if position != null:
|
||||
if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0:
|
||||
queue_free()
|
||||
var movement = MOVEMENT_VECTORS[randi() % 4]
|
||||
move_and_collide(movement * 2)
|
||||
|
||||
@ -20,8 +26,8 @@ func _on_death_finished():
|
||||
var instance2 = ooze.instance()
|
||||
instance1.position = position
|
||||
instance2.position = find_free_position(position)
|
||||
get_parent().add_child(instance1)
|
||||
get_parent().add_child(instance2)
|
||||
rootnode.add_child(instance1)
|
||||
rootnode.add_child(instance2)
|
||||
queue_free()
|
||||
|
||||
func _on_Hitbox_area_entered(_area):
|
||||
@ -34,8 +40,6 @@ func _on_Hitbox_area_entered(_area):
|
||||
pass
|
||||
|
||||
func find_free_position(start, skip = 0):
|
||||
var tilesmap = $"../TileMap"
|
||||
|
||||
var direction = randi() % 4
|
||||
var pos = start + MOVEMENT_VECTORS[direction]*11
|
||||
for _i in range(0, skip + 1):
|
||||
|
@ -1,6 +1,10 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
onready var pregnancy = 0
|
||||
onready var age = 0
|
||||
|
||||
onready var tilesmap = $"/root/World/tilemap"
|
||||
onready var rootnode = get_node("/root/World")
|
||||
|
||||
const MOVEMENT_VECTORS = [
|
||||
Vector2.UP,
|
||||
@ -10,18 +14,27 @@ const MOVEMENT_VECTORS = [
|
||||
]
|
||||
|
||||
func _physics_process(_delta):
|
||||
if pregnancy == 20:
|
||||
if position != null:
|
||||
if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0:
|
||||
queue_free()
|
||||
|
||||
if age > 5000:
|
||||
queue_free()
|
||||
else:
|
||||
age = age + 1
|
||||
|
||||
if pregnancy == 100:
|
||||
pregnancy = 0
|
||||
var female = load("res://NPCs/femalegoblin.tscn")
|
||||
var male = load("res://NPCs/malegoblin.tscn")
|
||||
var femalechild = female.instance()
|
||||
var malechild = male.instance()
|
||||
femalechild.position = find_free_position(position)
|
||||
femalechild.pregnancy = 200
|
||||
malechild.position = find_free_position(position, 1)
|
||||
get_parent().add_child(femalechild)
|
||||
get_parent().add_child(malechild)
|
||||
rootnode.add_child(femalechild)
|
||||
rootnode.add_child(malechild)
|
||||
if pregnancy > 0:
|
||||
pregnancy = pregnancy - 1
|
||||
pregnancy = pregnancy + 1
|
||||
var movement = MOVEMENT_VECTORS[randi() % 4]
|
||||
move_and_collide(movement * 2)
|
||||
|
||||
@ -32,12 +45,10 @@ func _on_death_finished():
|
||||
queue_free()
|
||||
|
||||
func _on_Romance_area_entered(area):
|
||||
if area.is_in_group("malegoblin") and pregnancy == 0:
|
||||
pregnancy = 100
|
||||
if area.is_in_group("malegoblin") and pregnancy == 0 and age > 2500:
|
||||
pregnancy = 1
|
||||
|
||||
func find_free_position(start, skip = 0):
|
||||
var tilesmap = $"../TileMap"
|
||||
|
||||
var direction = randi() % 4
|
||||
var pos = start + MOVEMENT_VECTORS[direction]*11
|
||||
for _i in range(0, skip):
|
||||
|
@ -1,5 +1,9 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
onready var age = 0
|
||||
|
||||
onready var tilesmap = $"/root/World/tilemap"
|
||||
|
||||
const MOVEMENT_VECTORS = [
|
||||
Vector2.UP,
|
||||
Vector2.RIGHT,
|
||||
@ -8,6 +12,16 @@ const MOVEMENT_VECTORS = [
|
||||
]
|
||||
|
||||
func _physics_process(_delta):
|
||||
if position != null:
|
||||
if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0:
|
||||
queue_free()
|
||||
if age > 2500:
|
||||
$"Romance".add_to_group("malegoblin")
|
||||
if age > 5000:
|
||||
queue_free()
|
||||
else:
|
||||
age = age + 1
|
||||
|
||||
var movement = MOVEMENT_VECTORS[randi() % 4]
|
||||
move_and_collide(movement * 2)
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
onready var immunity = 500
|
||||
onready var immunity = 50
|
||||
onready var tilesmap = $"/root/World/tilemap"
|
||||
onready var rootnode = get_node("/root/World")
|
||||
|
||||
const MOVEMENT_VECTORS = [
|
||||
Vector2.UP,
|
||||
@ -10,6 +12,9 @@ const MOVEMENT_VECTORS = [
|
||||
]
|
||||
|
||||
func _physics_process(_delta):
|
||||
if position != null:
|
||||
if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0:
|
||||
queue_free()
|
||||
if immunity > 0:
|
||||
immunity = immunity - 1
|
||||
var movement = MOVEMENT_VECTORS[randi() % 4]
|
||||
@ -25,8 +30,8 @@ func _on_death_finished():
|
||||
var instance2 = smallooze.instance()
|
||||
instance1.position = position
|
||||
instance2.position = find_free_position(position)
|
||||
get_parent().add_child(instance1)
|
||||
get_parent().add_child(instance2)
|
||||
rootnode.add_child(instance1)
|
||||
rootnode.add_child(instance2)
|
||||
queue_free()
|
||||
|
||||
func _on_Hitbox_area_entered(_area):
|
||||
@ -34,12 +39,10 @@ func _on_Hitbox_area_entered(_area):
|
||||
var bigooze = load("res://NPCs/big_ooze.tscn")
|
||||
var instance = bigooze.instance()
|
||||
instance.position = position
|
||||
get_parent().add_child(instance)
|
||||
rootnode.add_child(instance)
|
||||
queue_free()
|
||||
|
||||
func find_free_position(start, skip = 0):
|
||||
var tilesmap = $"../TileMap"
|
||||
|
||||
var direction = randi() % 4
|
||||
var pos = start + MOVEMENT_VECTORS[direction]*11
|
||||
for _i in range(0, skip):
|
||||
|
@ -1,6 +1,8 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
onready var immunity = 5
|
||||
onready var immunity = 50
|
||||
onready var tilesmap = $"/root/World/tilemap"
|
||||
onready var rootnode = get_node("/root/World")
|
||||
|
||||
const MOVEMENT_VECTORS = [
|
||||
Vector2.UP,
|
||||
@ -10,6 +12,9 @@ const MOVEMENT_VECTORS = [
|
||||
]
|
||||
|
||||
func _physics_process(_delta):
|
||||
if position != null:
|
||||
if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0:
|
||||
queue_free()
|
||||
if immunity > 0:
|
||||
immunity = immunity - 1
|
||||
var movement = MOVEMENT_VECTORS[randi() % 4]
|
||||
@ -27,6 +32,6 @@ func _on_Hitbox_area_entered(_area):
|
||||
var ooze = load("res://NPCs/ooze.tscn")
|
||||
var instance = ooze.instance()
|
||||
instance.position = position
|
||||
get_parent().add_child(instance)
|
||||
rootnode.add_child(instance)
|
||||
queue_free()
|
||||
|
||||
|
@ -51,7 +51,6 @@ stream = ExtResource( 3 )
|
||||
]]
|
||||
position = Vector2( -0.0787458, 0.0787449 )
|
||||
shape = SubResource( 3 )
|
||||
script = ExtResource( 2 )
|
||||
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
|
||||
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
|
||||
[connection signal="finished" from="Hurtbox/death" to="." method="_on_death_finished"]
|
||||
|
@ -226,7 +226,7 @@ max_zoom = 8.0
|
||||
|
||||
[node name="Tween" type="Tween" parent="Camera2D"]
|
||||
|
||||
[node name="TileMap" type="TileMap" parent="."]
|
||||
[node name="tilemap" type="TileMap" parent="."]
|
||||
tile_set = SubResource( 16 )
|
||||
cell_size = Vector2( 8, 8 )
|
||||
cell_quadrant_size = 8
|
||||
|
17
src/spawn.gd
17
src/spawn.gd
@ -1,6 +1,8 @@
|
||||
extends Timer
|
||||
|
||||
onready var tilesmap = $"../TileMap"
|
||||
onready var tilesmap = $"/root/World/tilemap"
|
||||
onready var rootnode = get_node("/root/World")
|
||||
|
||||
onready var dirttiles = tilesmap.get_used_cells_by_id(0)
|
||||
onready var tilesize = tilesmap.tile_set.autotile_get_size(0)
|
||||
|
||||
@ -27,28 +29,29 @@ func _on_Timer_timeout():
|
||||
var mossscene = load("res://NPCs/moss.tscn")
|
||||
var mossinstance = mossscene.instance()
|
||||
mossinstance.position = mossspawner * tilesize + (tilesize / 2)
|
||||
get_parent().add_child(mossinstance)
|
||||
rootnode.add_child(mossinstance)
|
||||
|
||||
if random in range(0, 25):
|
||||
var femalegoblinscene = load("res://NPCs/femalegoblin.tscn")
|
||||
var femalegoblininstance = femalegoblinscene.instance()
|
||||
femalegoblininstance.position = spawner * tilesize + (tilesize / 2)
|
||||
get_parent().add_child(femalegoblininstance)
|
||||
rootnode.add_child(femalegoblininstance)
|
||||
if random in range(25, 50):
|
||||
var malegoblinscene = load("res://NPCs/malegoblin.tscn")
|
||||
var malegoblininstance = malegoblinscene.instance()
|
||||
malegoblininstance.position = spawner * tilesize + (tilesize / 2)
|
||||
get_parent().add_child(malegoblininstance)
|
||||
rootnode.add_child(malegoblininstance)
|
||||
if random in range(50,75):
|
||||
var oozescene = load("res://NPCs/ooze.tscn")
|
||||
var oozeinstance = oozescene.instance()
|
||||
oozeinstance.position = spawner * tilesize + (tilesize / 2)
|
||||
rootnode.add_child(oozeinstance)
|
||||
|
||||
func find_coast():
|
||||
var coast = []
|
||||
var coastline = []
|
||||
for dirt in dirttiles:
|
||||
for direction in MOVEMENT_VECTORS:
|
||||
if dirt + direction in watertiles:
|
||||
coast.append(dirt)
|
||||
coastline.append(dirt)
|
||||
break
|
||||
return coast
|
||||
return coastline
|
||||
|
Loading…
Reference in New Issue
Block a user