added models and changed spawnpoint
This commit is contained in:
parent
2cf0846597
commit
877ebafc74
1007 changed files with 120779 additions and 37 deletions
5
entities/healing_station/healing_station.gd
Normal file
5
entities/healing_station/healing_station.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
extends Node3D
|
||||
|
||||
func _on_area_3d_body_entered(body: Node3D) -> void:
|
||||
print("%s entered" % body.name)
|
||||
pass # Replace with function body.
|
||||
32
entities/healing_station/healing_station.tscn
Normal file
32
entities/healing_station/healing_station.tscn
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://dibg4wpthwdov"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/healing_station/healing_station.gd" id="1_7biqd"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_qkiex"]
|
||||
size = Vector3(3.6, 2.5, 2.6)
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_3nvn0"]
|
||||
height = 1.0
|
||||
radius = 1.1
|
||||
|
||||
[node name="HealingStation" type="Node3D"]
|
||||
script = ExtResource("1_7biqd")
|
||||
|
||||
[node name="Mesh" type="Node3D" parent="."]
|
||||
|
||||
[node name="Collision" type="StaticBody3D" parent="."]
|
||||
collision_layer = 2
|
||||
collision_mask = 5
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Collision"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.25, 0)
|
||||
shape = SubResource("BoxShape3D_qkiex")
|
||||
|
||||
[node name="InteractableArea" type="Area3D" parent="."]
|
||||
collision_layer = 8
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractableArea"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.6, 0.5, 0)
|
||||
shape = SubResource("CylinderShape3D_3nvn0")
|
||||
|
||||
[connection signal="body_entered" from="InteractableArea" to="." method="_on_area_3d_body_entered"]
|
||||
|
|
@ -3,7 +3,7 @@ extends CharacterBody3D
|
|||
|
||||
signal level_up
|
||||
|
||||
@export var stats: MonsterData = MonsterData.new()
|
||||
@export var data: MonsterData = MonsterData.new()
|
||||
|
||||
var spawn_point: Vector3 = Vector3(0, 0, 0)
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ var in_battle: bool = false
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
var model_instance = stats.model.instantiate()
|
||||
var model_instance = data.model.instantiate()
|
||||
frequency = randf_range(1.0, 4.0)
|
||||
amplitude = randf_range(1.0, 6.0)
|
||||
spawn_point = position
|
||||
|
|
|
|||
|
|
@ -6,23 +6,23 @@ extends Node3D
|
|||
# a spawnpoint that can spawn monsters
|
||||
# monsters are only spawned, if the player is not looking
|
||||
|
||||
# list that holds all spawnable monsters
|
||||
@export var spawnable_monsters: Array[MonsterData]
|
||||
## List that holds all spawnable monsters
|
||||
@export var spawnable_monsters: Array[MonsterSpawnpointProbability]
|
||||
|
||||
# ignore spawning only if visible
|
||||
## Ignore spawning only if visible
|
||||
@export var ignore_visibility: bool = false
|
||||
|
||||
# the maximum amount of spawned monsters
|
||||
# no monsters will spawn, when this number is reached
|
||||
## The maximum amount of spawned monsters.
|
||||
## No monsters will spawn, when this number is reached.
|
||||
@export var max_monsters: int = 5
|
||||
|
||||
# the maximum lifetime a monster can be in the world
|
||||
# a monster is then deleted if the following conditions are met:
|
||||
# the monster has exceeded its maximum lifetime and it is not on screen
|
||||
# TODO: figure out how to check for the exceeded lifetime and delete
|
||||
## The maximum lifetime a monster can be in the world
|
||||
@export var max_lifetime: float = 60.0 # seconds
|
||||
|
||||
# only spawn a monster every x seconds
|
||||
## A monster can only spawn every x seconds
|
||||
@export var spawn_cooldown: float = 3.0 # seconds
|
||||
|
||||
@onready var spawn_timer: Timer = Timer.new()
|
||||
|
|
@ -38,6 +38,9 @@ var active_monsters: Array[Monster] = []
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
if spawnable_monsters.is_empty():
|
||||
printerr("Spawnpoint (%s) does not have monsters to spawn." % self.name)
|
||||
|
||||
spawn_timer.wait_time = spawn_cooldown
|
||||
spawn_timer.autostart = true
|
||||
spawn_timer.timeout.connect(spawn)
|
||||
|
|
@ -45,21 +48,28 @@ func _ready() -> void:
|
|||
spawn_timer.start()
|
||||
|
||||
spawn_point = position
|
||||
|
||||
label.text = "%s / %s" % [len(active_monsters), max_monsters]
|
||||
|
||||
|
||||
func spawn() -> void:
|
||||
if len(active_monsters) >= max_monsters:
|
||||
print("Spawnpoint reached maximum amount of monsters")
|
||||
#print("Spawnpoint reached maximum amount of monsters")
|
||||
return
|
||||
|
||||
if ignore_visibility == false and $VisibleOnScreenNotifier3D.is_on_screen():
|
||||
print("Spawnpoint is visible on screen. Not spawning a monster.")
|
||||
#print("Spawnpoint is visible on screen. Not spawning a monster.")
|
||||
return
|
||||
|
||||
# TODO: Add a check to not spawn enemies X units near the player
|
||||
|
||||
# instantiate a monster .tscn scene
|
||||
var monster_to_spawn = monster_tscn.instantiate()
|
||||
monster_to_spawn.stats = spawnable_monsters[0]
|
||||
|
||||
# get a random monster data
|
||||
var random := randi() % spawnable_monsters.size()
|
||||
var data : MonsterData = spawnable_monsters[random].monster_data
|
||||
monster_to_spawn.data = data
|
||||
|
||||
# keep track of the current monster
|
||||
active_monsters.append(monster_to_spawn)
|
||||
|
|
@ -71,7 +81,7 @@ func spawn() -> void:
|
|||
|
||||
var debug_level_node = get_parent_node_3d()
|
||||
debug_level_node.add_child(monster_to_spawn)
|
||||
print("Spawning Mob \"%s\"" % monster_to_spawn.stats.display_name)
|
||||
#print("Spawning Mob \"%s\"" % monster_to_spawn.data.display_name)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
|
|
|
|||
|
|
@ -25,6 +25,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
|||
|
||||
[node name="Label3D" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 0)
|
||||
visible = false
|
||||
double_sided = false
|
||||
text = "0 / 5"
|
||||
font_size = 64
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
class_name MonsterSpawnpointProbability
|
||||
extends Resource
|
||||
|
||||
## Which monster to spawn
|
||||
@export var monster_data : MonsterData = null
|
||||
|
||||
## Chance that a monster can spawn
|
||||
@export var chance: float = 50.0
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
height = 1.7
|
||||
|
||||
[node name="Player" type="CharacterBody3D" groups=["save_nodes"]]
|
||||
collision_mask = 14
|
||||
axis_lock_angular_x = true
|
||||
axis_lock_angular_y = true
|
||||
axis_lock_angular_z = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue