updated npc instances to new Enemy class, added initial damage and death signal emission
This commit is contained in:
parent
7d79eab28a
commit
fab3fe56c1
14
scenes/ability_ph.tscn
Normal file
14
scenes/ability_ph.tscn
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[gd_scene load_steps=3 format=3 uid="uid://dvwo26vsk46tl"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/AbilityPH.gd" id="1_6jbus"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b10c1776j6j60" path="res://assets/icon.svg" id="1_eoss7"]
|
||||||
|
|
||||||
|
[node name="AbilityPH" type="TextureRect"]
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
texture = ExtResource("1_eoss7")
|
||||||
|
script = ExtResource("1_6jbus")
|
||||||
|
|
||||||
|
[node name="IdleCooldown" type="Timer" parent="."]
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[connection signal="timeout" from="IdleCooldown" to="." method="_on_idle_cooldown_timeout"]
|
@ -1,13 +1,13 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://dkmnvye1y33d7"]
|
[gd_scene load_steps=4 format=3 uid="uid://dkmnvye1y33d7"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/Character.gd" id="1_teyfy"]
|
||||||
[ext_resource type="Texture2D" uid="uid://b10c1776j6j60" path="res://assets/icon.svg" id="2_6hwax"]
|
[ext_resource type="Texture2D" uid="uid://b10c1776j6j60" path="res://assets/icon.svg" id="2_6hwax"]
|
||||||
[ext_resource type="Script" path="res://scripts/character.gd" id="2_bft53"]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_tv6kf"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_tv6kf"]
|
||||||
size = Vector2(196, 175)
|
size = Vector2(196, 175)
|
||||||
|
|
||||||
[node name="Character" type="Node2D"]
|
[node name="Character" type="Node2D"]
|
||||||
script = ExtResource("2_bft53")
|
script = ExtResource("1_teyfy")
|
||||||
|
|
||||||
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
|
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
|
||||||
|
|
||||||
|
59
scenes/enemy.tscn
Normal file
59
scenes/enemy.tscn
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://55qfhbliodhn"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/Enemy.gd" id="1_4u60d"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b10c1776j6j60" path="res://assets/icon.svg" id="2_twdr5"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_tv6kf"]
|
||||||
|
size = Vector2(196, 175)
|
||||||
|
|
||||||
|
[node name="NPC" type="Node2D"]
|
||||||
|
script = ExtResource("1_4u60d")
|
||||||
|
|
||||||
|
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
|
||||||
|
position = Vector2(0, -11.5)
|
||||||
|
shape = SubResource("RectangleShape2D_tv6kf")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"]
|
||||||
|
texture = ExtResource("2_twdr5")
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="CharacterBody2D/Sprite2D"]
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = -91.0
|
||||||
|
offset_top = -94.0
|
||||||
|
offset_right = -36.0
|
||||||
|
offset_bottom = -57.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="Nameplate" type="VBoxContainer" parent="CharacterBody2D/Sprite2D/MarginContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Healthbar" type="ProgressBar" parent="CharacterBody2D/Sprite2D/MarginContainer/Nameplate"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(0, 16)
|
||||||
|
layout_mode = 2
|
||||||
|
max_value = 10.0
|
||||||
|
step = 1.0
|
||||||
|
value = 10.0
|
||||||
|
show_percentage = false
|
||||||
|
|
||||||
|
[node name="TitleBox" type="HBoxContainer" parent="CharacterBody2D/Sprite2D/MarginContainer/Nameplate"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="TierLabel" type="Label" parent="CharacterBody2D/Sprite2D/MarginContainer/Nameplate/TitleBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 0
|
||||||
|
text = "Tier
|
||||||
|
"
|
||||||
|
|
||||||
|
[node name="NPCNameLabel" type="Label" parent="CharacterBody2D/Sprite2D/MarginContainer/Nameplate/TitleBox"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 0
|
||||||
|
text = "Name"
|
@ -33,6 +33,7 @@ grow_vertical = 2
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="Healthbar" type="ProgressBar" parent="CharacterBody2D/Sprite2D/MarginContainer/Nameplate"]
|
[node name="Healthbar" type="ProgressBar" parent="CharacterBody2D/Sprite2D/MarginContainer/Nameplate"]
|
||||||
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(0, 16)
|
custom_minimum_size = Vector2(0, 16)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
max_value = 10.0
|
max_value = 10.0
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://0h3dpe6fuhe8"]
|
[gd_scene load_steps=3 format=3 uid="uid://0h3dpe6fuhe8"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/test_scroll_scene.gd" id="1_gc1kb"]
|
[ext_resource type="Script" path="res://scripts/test_scroll_scene.gd" id="1_gc1kb"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dvwo26vsk46tl" path="res://scenes/ability_ph.tscn" id="2_heria"]
|
||||||
|
|
||||||
[node name="TestInstanceScene" type="Control"]
|
[node name="TestInstanceScene" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
@ -11,6 +12,7 @@ grow_horizontal = 2
|
|||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1_gc1kb")
|
script = ExtResource("1_gc1kb")
|
||||||
debug = true
|
debug = true
|
||||||
|
spawnTimerValue = 20.0
|
||||||
|
|
||||||
[node name="SpawnTimer" type="Timer" parent="."]
|
[node name="SpawnTimer" type="Timer" parent="."]
|
||||||
|
|
||||||
@ -33,61 +35,69 @@ theme_override_constants/margin_top = 10
|
|||||||
theme_override_constants/margin_right = 10
|
theme_override_constants/margin_right = 10
|
||||||
theme_override_constants/margin_bottom = 10
|
theme_override_constants/margin_bottom = 10
|
||||||
|
|
||||||
[node name="Menus" type="VBoxContainer" parent="MarginContainer"]
|
[node name="BottomUI" type="VBoxContainer" parent="MarginContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 8
|
size_flags_vertical = 8
|
||||||
|
|
||||||
[node name="MenuButtons" type="HBoxContainer" parent="MarginContainer/Menus"]
|
[node name="AbilityBar" type="HBoxContainer" parent="MarginContainer/BottomUI"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 8
|
size_flags_vertical = 8
|
||||||
|
|
||||||
[node name="MainMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"]
|
[node name="AbilityPH" parent="MarginContainer/BottomUI/AbilityBar" instance=ExtResource("2_heria")]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="MenuButtons" type="HBoxContainer" parent="MarginContainer/BottomUI"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 8
|
||||||
|
|
||||||
|
[node name="MainMenuButton" type="Button" parent="MarginContainer/BottomUI/MenuButtons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Menu"
|
text = "Menu"
|
||||||
|
|
||||||
[node name="MapMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"]
|
[node name="MapMenuButton" type="Button" parent="MarginContainer/BottomUI/MenuButtons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Map"
|
text = "Map"
|
||||||
|
|
||||||
[node name="SkillsMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"]
|
[node name="SkillsMenuButton" type="Button" parent="MarginContainer/BottomUI/MenuButtons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Skills"
|
text = "Skills"
|
||||||
|
|
||||||
[node name="InvMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"]
|
[node name="InvMenuButton" type="Button" parent="MarginContainer/BottomUI/MenuButtons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Inventory"
|
text = "Inventory"
|
||||||
|
|
||||||
[node name="LogMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"]
|
[node name="LogMenuButton" type="Button" parent="MarginContainer/BottomUI/MenuButtons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Log"
|
text = "Log"
|
||||||
|
|
||||||
[node name="CraftMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"]
|
[node name="CraftMenuButton" type="Button" parent="MarginContainer/BottomUI/MenuButtons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Crafting"
|
text = "Crafting"
|
||||||
|
|
||||||
[node name="DebugMenu" type="HBoxContainer" parent="MarginContainer/Menus/MenuButtons"]
|
[node name="DebugMenu" type="HBoxContainer" parent="MarginContainer/BottomUI/MenuButtons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 8
|
size_flags_vertical = 8
|
||||||
|
|
||||||
[node name="ButtonTest" type="Button" parent="MarginContainer/Menus/MenuButtons/DebugMenu"]
|
[node name="ButtonTest" type="Button" parent="MarginContainer/BottomUI/MenuButtons/DebugMenu"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 8
|
size_flags_vertical = 8
|
||||||
text = "Complete Quest"
|
text = "Complete Quest"
|
||||||
|
|
||||||
[node name="TouchScreenButton" type="TouchScreenButton" parent="MarginContainer/Menus/MenuButtons/DebugMenu/ButtonTest"]
|
[node name="TouchScreenButton" type="TouchScreenButton" parent="MarginContainer/BottomUI/MenuButtons/DebugMenu/ButtonTest"]
|
||||||
|
|
||||||
[node name="ButtonExit" type="Button" parent="MarginContainer/Menus/MenuButtons/DebugMenu"]
|
[node name="ButtonExit" type="Button" parent="MarginContainer/BottomUI/MenuButtons/DebugMenu"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 8
|
size_flags_vertical = 8
|
||||||
text = "Exit"
|
text = "Exit"
|
||||||
|
|
||||||
[node name="TouchScreenButton" type="TouchScreenButton" parent="MarginContainer/Menus/MenuButtons/DebugMenu/ButtonExit"]
|
[node name="TouchScreenButton" type="TouchScreenButton" parent="MarginContainer/BottomUI/MenuButtons/DebugMenu/ButtonExit"]
|
||||||
|
|
||||||
[connection signal="timeout" from="SpawnTimer" to="." method="_on_spawn_timer_timeout"]
|
[connection signal="timeout" from="SpawnTimer" to="." method="_on_spawn_timer_timeout"]
|
||||||
[connection signal="pressed" from="MarginContainer/Menus/MenuButtons/DebugMenu/ButtonTest" to="." method="_on_button_test_pressed"]
|
[connection signal="pressed" from="MarginContainer/BottomUI/MenuButtons/DebugMenu/ButtonTest" to="." method="_on_button_test_pressed"]
|
||||||
[connection signal="pressed" from="MarginContainer/Menus/MenuButtons/DebugMenu/ButtonExit" to="." method="_on_button_exit_pressed"]
|
[connection signal="pressed" from="MarginContainer/BottomUI/MenuButtons/DebugMenu/ButtonExit" to="." method="_on_button_exit_pressed"]
|
||||||
|
@ -1,5 +1,54 @@
|
|||||||
|
# placerholder test ability
|
||||||
class_name Ability
|
class_name Ability
|
||||||
extends Sprite2D
|
extends TextureRect
|
||||||
|
|
||||||
|
|
||||||
# basis for the 6 abilities
|
var middleX
|
||||||
|
var playerPos
|
||||||
|
|
||||||
|
@export var attack_range := 0
|
||||||
|
@export var attack_type := "single_target"
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
middleX = get_viewport_rect().size.x/2
|
||||||
|
playerPos = Vector2(middleX, get_viewport_rect().size.y*(0.75))
|
||||||
|
|
||||||
|
|
||||||
|
func _get_enemies() -> Array:
|
||||||
|
var enemies := get_tree().get_nodes_in_group("enemies")
|
||||||
|
return enemies
|
||||||
|
|
||||||
|
|
||||||
|
func _get_num_enemies() -> int:
|
||||||
|
var enemies := get_tree().get_nodes_in_group("enemies")
|
||||||
|
return enemies.size()
|
||||||
|
|
||||||
|
|
||||||
|
func _get_distance_to_player(enemy: Node) -> float:
|
||||||
|
return enemy.position.distance_squared_to(playerPos)
|
||||||
|
|
||||||
|
|
||||||
|
func _get_target(enemies) -> Node:
|
||||||
|
# var numEnemies := _get_num_enemies()
|
||||||
|
var enemyDists
|
||||||
|
var closestEnemy
|
||||||
|
# get array of difficulties using map
|
||||||
|
# get list of distances by mapping distance to each node in enemies
|
||||||
|
enemyDists = enemies.map(_get_distance_to_player)
|
||||||
|
# get closest enemy by finding index with min dist
|
||||||
|
closestEnemy = enemies[enemyDists.find(enemyDists.min())]
|
||||||
|
|
||||||
|
return closestEnemy
|
||||||
|
|
||||||
|
|
||||||
|
func _deal_idle_damage(enemiesList) -> void:
|
||||||
|
var damage = 200
|
||||||
|
var target = _get_target(enemiesList)
|
||||||
|
target.damageTaken += damage
|
||||||
|
|
||||||
|
|
||||||
|
func _on_idle_cooldown_timeout() -> void:
|
||||||
|
var enemiesList = _get_enemies()
|
||||||
|
if not enemiesList.is_empty():
|
||||||
|
_deal_idle_damage(enemiesList)
|
||||||
|
@ -2,33 +2,11 @@ class_name Enemy
|
|||||||
extends NPC
|
extends NPC
|
||||||
|
|
||||||
|
|
||||||
enum npcDifficulties { MINION, NORMAL, ELITE, BOSS, ELITEBOSS, BBEG }
|
enum questTypes { NONE, FEW_KILL, MANY_KILL, ONE_KILL }
|
||||||
enum npcTiers { I, II, III, IV, V, VI, VII, VIII, IX, X }
|
|
||||||
|
|
||||||
@export var npcDifficulty: npcDifficulties
|
signal enemy_died(npcDifficulty: npcDifficulties, questType: questTypes)
|
||||||
@export var npcTier: npcTiers
|
|
||||||
|
|
||||||
func _random_mod_health() -> void:
|
@export var questType: questTypes = questTypes.NONE
|
||||||
randomize()
|
|
||||||
# noise factor
|
|
||||||
var noise_factor = randf_range(7, 10)
|
|
||||||
self.maxHealth *= noise_factor
|
|
||||||
# difficulty factor
|
|
||||||
match self.npcDifficulty:
|
|
||||||
npcDifficulties.MINION:
|
|
||||||
self.maxHealth /= 2
|
|
||||||
npcDifficulties.ELITE:
|
|
||||||
self.maxHealth *= 2
|
|
||||||
npcDifficulties.BOSS:
|
|
||||||
self.maxHealth *= 4
|
|
||||||
npcDifficulties.ELITEBOSS:
|
|
||||||
self.maxHealth *= 8
|
|
||||||
npcDifficulties.BBEG:
|
|
||||||
self.maxHealth *= 16
|
|
||||||
# npcTier factor
|
|
||||||
self.maxHealth *= exp(self.npcTier)
|
|
||||||
# fun factor (just additional factor to tweak)
|
|
||||||
self.maxHealth *= 10
|
|
||||||
|
|
||||||
|
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
@ -40,11 +18,17 @@ func _ready() -> void:
|
|||||||
# add to enemies
|
# add to enemies
|
||||||
add_to_group("enemies")
|
add_to_group("enemies")
|
||||||
|
|
||||||
# modify max health value based on the various factors
|
# set health
|
||||||
_random_mod_health()
|
_random_mod_health()
|
||||||
|
|
||||||
|
# set health bar
|
||||||
|
%Healthbar.max_value = maxHealth
|
||||||
|
%Healthbar.value = maxHealth
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
# if damageTaken > maxHealth:
|
%Healthbar.value = maxHealth - damageTaken
|
||||||
# self.free()?
|
if damageTaken >= maxHealth:
|
||||||
# send signal that I died to be counted, etc.
|
# send signal that I died to be counted, etc.
|
||||||
pass
|
enemy_died.emit(self.npcDifficulty, self.questType)
|
||||||
|
# delete node
|
||||||
|
self.queue_free()
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
class_name NPC
|
class_name NPC
|
||||||
extends Character
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
enum npcDifficulties { MINION, NORMAL, ELITE, BOSS, ELITEBOSS, BBEG }
|
enum npcDifficulties { MINION, NORMAL, ELITE, BOSS, ELITEBOSS, BBEG }
|
||||||
enum npcTiers { I, II, III, IV, V, VI, VII, VIII, IX, X }
|
enum npcTiers { I, II, III, IV, V, VI, VII, VIII, IX, X }
|
||||||
|
|
||||||
|
signal npc_died(npcTier: npcTiers)
|
||||||
|
|
||||||
|
@export var charName := "Character"
|
||||||
|
@export var maxHealth := 10
|
||||||
|
@export var damageTaken := 0
|
||||||
@export var npcDifficulty: npcDifficulties
|
@export var npcDifficulty: npcDifficulties
|
||||||
@export var npcTier: npcTiers
|
@export var npcTier: npcTiers
|
||||||
|
|
||||||
@ -37,14 +42,17 @@ func _init() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
# add to enemies
|
|
||||||
add_to_group("enemies")
|
|
||||||
|
|
||||||
# modify max health value based on the various factors
|
# modify max health value based on the various factors
|
||||||
_random_mod_health()
|
_random_mod_health()
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
# set health bar
|
||||||
# if damageTaken > maxHealth:
|
%Healthbar.max_value = maxHealth
|
||||||
# self.free()?
|
%Healthbar.value = maxHealth
|
||||||
# send signal that I died to be counted, etc.
|
|
||||||
pass
|
func _process(_delta: float) -> void:
|
||||||
|
%Healthbar.value = maxHealth - damageTaken
|
||||||
|
if damageTaken >= maxHealth:
|
||||||
|
# send signal that I died to be counted, gen loot, etc.
|
||||||
|
npc_died.emit(self.npcTier)
|
||||||
|
# delete node
|
||||||
|
self.free()
|
||||||
|
@ -18,9 +18,10 @@ func _ready() -> void:
|
|||||||
if not debug:
|
if not debug:
|
||||||
$MarginContainer/Menus/MenuButtons/DebugMenu.hide()
|
$MarginContainer/Menus/MenuButtons/DebugMenu.hide()
|
||||||
$SpawnTimer.start(spawnTimerValue)
|
$SpawnTimer.start(spawnTimerValue)
|
||||||
|
_spawn_enemies(5)
|
||||||
|
|
||||||
func _create_enemy():
|
func _create_enemy():
|
||||||
var enemy = load("res://scenes/npc.tscn").instantiate()
|
var enemy = load("res://scenes/enemy.tscn").instantiate()
|
||||||
enemy.scale = Vector2.ONE*0.5
|
enemy.scale = Vector2.ONE*0.5
|
||||||
enemy.position = Vector2(randi_range(0, get_viewport_rect().size.x), -50)
|
enemy.position = Vector2(randi_range(0, get_viewport_rect().size.x), -50)
|
||||||
#enemy.get_node("%NPCNameLabel").text = "Test"
|
#enemy.get_node("%NPCNameLabel").text = "Test"
|
||||||
@ -37,37 +38,6 @@ func _get_num_enemies() -> int:
|
|||||||
return len(enemies)
|
return len(enemies)
|
||||||
|
|
||||||
|
|
||||||
func _get_distance_to_player(enemy: Node) -> float:
|
|
||||||
return enemy.position.distance_squared_to(playerPos)
|
|
||||||
|
|
||||||
|
|
||||||
func _get_target() -> Node:
|
|
||||||
# arrays of enemies by difficulty
|
|
||||||
var enemies := _get_enemies()
|
|
||||||
var numEnemies := _get_num_enemies()
|
|
||||||
#var highestDifficulty
|
|
||||||
var enemyDists
|
|
||||||
var closestEnemy
|
|
||||||
# get array of difficulties using map
|
|
||||||
if not enemies.is_empty():
|
|
||||||
# get index of largest non-zero val in numEnemies array, ignoring minions
|
|
||||||
#highestDifficulty = numEnemies.find(0, 1) - 1
|
|
||||||
enemyDists = enemies.map(_get_distance_to_player)
|
|
||||||
closestEnemy = enemies[enemyDists.find(enemyDists.min())]
|
|
||||||
#var closestDist = INF
|
|
||||||
#for enemy in enemies:
|
|
||||||
#var enemyPos = enemy.position
|
|
||||||
#var enemyDist = playerPos.distance_squared_to(enemyPos)
|
|
||||||
#if enemyDist < closestDist:
|
|
||||||
#closestEnemy = enemy
|
|
||||||
print(enemies)
|
|
||||||
#print(highestDifficulty)
|
|
||||||
print(enemyDists)
|
|
||||||
print(closestEnemy)
|
|
||||||
|
|
||||||
return closestEnemy
|
|
||||||
|
|
||||||
|
|
||||||
func _spawn_enemies(maxEnemies: int) -> void:
|
func _spawn_enemies(maxEnemies: int) -> void:
|
||||||
#await get_tree().create_timer(time).timeout
|
#await get_tree().create_timer(time).timeout
|
||||||
var numEnemies = randi_range(1, maxEnemies)
|
var numEnemies = randi_range(1, maxEnemies)
|
||||||
@ -78,7 +48,7 @@ func _spawn_enemies(maxEnemies: int) -> void:
|
|||||||
create_tween().tween_property(enemy, "position", playerPos, randEnemyMoveSpeed)
|
create_tween().tween_property(enemy, "position", playerPos, randEnemyMoveSpeed)
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
#var closestEnemy = _get_closest_enemy()
|
#var closestEnemy = _get_closest_enemy()
|
||||||
deltaCount += 1
|
deltaCount += 1
|
||||||
#if numEnemies != 0:
|
#if numEnemies != 0:
|
||||||
@ -87,9 +57,6 @@ func _process(delta: float) -> void:
|
|||||||
#create_tween().tween_property(enemies[randi_range(0, numEnemies-1)], "position", Vector2(100, 100), 1.0)
|
#create_tween().tween_property(enemies[randi_range(0, numEnemies-1)], "position", Vector2(100, 100), 1.0)
|
||||||
#if deltaCount % 200 == 0:
|
#if deltaCount % 200 == 0:
|
||||||
#%SpawnArea.remove_child(closestEnemy)
|
#%SpawnArea.remove_child(closestEnemy)
|
||||||
if not _get_enemies().is_empty() and deltaCount % 100 == 0:
|
|
||||||
var targetEnemy = _get_target()
|
|
||||||
$SpawnArea.remove_child(targetEnemy)
|
|
||||||
# change to signal
|
# change to signal
|
||||||
if questsComplete:
|
if questsComplete:
|
||||||
$SpawnTimer.stop()
|
$SpawnTimer.stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user