-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ranged enemy
- Loading branch information
Showing
19 changed files
with
458 additions
and
16 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.import/goblin_idle_spritesheet.png-aef10c686a5967a1767056ccd7ee312d.md5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
source_md5="8c97e935786b994c3cff4008212381b9" | ||
dest_md5="95f9f4dfdc6535bb78f265d86373e65e" | ||
dest_md5="2ae8fab63415433bb13b0ee2b9c689cb" | ||
|
Binary file modified
BIN
+0 Bytes
(100%)
.import/goblin_idle_spritesheet.png-aef10c686a5967a1767056ccd7ee312d.stex
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
source_md5="ee2cf371bf7f1107007e67b62680a86b" | ||
dest_md5="501ca82ac953257960b45b55f8a3b4ae" | ||
dest_md5="23f4c0e52d0d2dd5cfcce1b99d33fc36" | ||
|
Binary file modified
BIN
+0 Bytes
(100%)
.import/goblin_knife.png-4461242fc35ba4832657ab1a22ed648e.stex
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
.import/goblin_run_spritesheet.png-120d6a6e3b00bd38e486d50facff5ae9.md5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
source_md5="565c2f9a0bb01a9c56975664f8cd375c" | ||
dest_md5="b1dabbd61e5fab5ecb683741906255c8" | ||
dest_md5="1396d62ebda6149cad7dd800805a6f69" | ||
|
Binary file modified
BIN
+0 Bytes
(100%)
.import/goblin_run_spritesheet.png-120d6a6e3b00bd38e486d50facff5ae9.stex
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
extends Enemy | ||
|
||
const THROWABLE_KNIFE_SCENE: PackedScene = preload("res://Characters/Enemies/Goblin/ThrowableKnike.tscn") | ||
|
||
const MAX_DISTANCE_TO_PLAYER: int = 80 | ||
const MIN_DISTANCE_TO_PLAYER: int = 40 | ||
|
||
export(int) var projectile_speed: int = 150 | ||
|
||
var can_attack: bool = true | ||
|
||
var distance_to_player: float | ||
|
||
onready var attack_timer: Timer = get_node("AttackTimer") | ||
|
||
|
||
func _on_PathTimer_timeout() -> void: | ||
if is_instance_valid(player): | ||
distance_to_player = (player.position - global_position).length() | ||
if distance_to_player > MAX_DISTANCE_TO_PLAYER: | ||
_get_path_to_player() | ||
elif distance_to_player < MIN_DISTANCE_TO_PLAYER: | ||
_get_path_to_move_away_from_player() | ||
else: | ||
if can_attack: | ||
can_attack = false | ||
_throw_knife() | ||
attack_timer.start() | ||
else: | ||
path_timer.stop() | ||
path = [] | ||
mov_direction = Vector2.ZERO | ||
|
||
|
||
func _get_path_to_move_away_from_player() -> void: | ||
var dir: Vector2 = (global_position - player.position).normalized() | ||
path = navigation.get_simple_path(global_position, global_position + dir * 100) | ||
|
||
|
||
func _throw_knife() -> void: | ||
var projectile: Area2D = THROWABLE_KNIFE_SCENE.instance() | ||
projectile.launch(global_position, (player.position - global_position).normalized(), projectile_speed) | ||
get_tree().current_scene.add_child(projectile) | ||
|
||
|
||
|
||
func _on_AttackTimer_timeout() -> void: | ||
can_attack = true |
Oops, something went wrong.