Merge remote-tracking branch 'refs/remotes/origin/stage/molecular' into stage/molecular
This commit is contained in:
@@ -28,7 +28,7 @@ func _ready() -> void:
|
|||||||
var screen_size = get_viewport_rect().size
|
var screen_size = get_viewport_rect().size
|
||||||
GameManager.init_screen_size(screen_size.x, screen_size.y)
|
GameManager.init_screen_size(screen_size.x, screen_size.y)
|
||||||
|
|
||||||
attack_area.monitoring = false # no collision until attacking TODO: Thing about being attacked
|
attack_area.monitoring = false # no collision until attacking TODO: Think about being attacked
|
||||||
attack_timer.wait_time = attack_duration
|
attack_timer.wait_time = attack_duration
|
||||||
attack_cooldown_timer.wait_time = attack_cooldown_duration
|
attack_cooldown_timer.wait_time = attack_cooldown_duration
|
||||||
|
|
||||||
@@ -36,7 +36,6 @@ func _ready() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
# TODO: Connects this to some respawn screen
|
|
||||||
if isAlive:
|
if isAlive:
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
if Input.is_action_pressed("move_right"):
|
if Input.is_action_pressed("move_right"):
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ var can_attack: bool = true
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
health = maxHealth
|
health = maxHealth
|
||||||
sprite.play("Healthy") # TODO: sprite play logic (esp wrt state switching)
|
play_sprite(idle_sprite)
|
||||||
wrapper.play_sprite("Healthy")
|
|
||||||
if starting_pos:
|
if starting_pos:
|
||||||
collision.set_position(starting_pos)
|
collision.set_position(starting_pos)
|
||||||
|
|
||||||
@@ -61,8 +60,8 @@ func die() -> void:
|
|||||||
super.die()
|
super.die()
|
||||||
|
|
||||||
func become_injured() -> void:
|
func become_injured() -> void:
|
||||||
sprite.play("Hurt")
|
idle_sprite = "Hurt"
|
||||||
wrapper.play_sprite("Hurt")
|
play_sprite(idle_sprite)
|
||||||
|
|
||||||
func _on_sight_body_entered(body: Node2D) -> void:
|
func _on_sight_body_entered(body: Node2D) -> void:
|
||||||
if fsm.map(fsm.state) != fsm.States.HUNTING and body.is_in_group("prey") or (health < maxHealth and body.is_in_group("player")):
|
if fsm.map(fsm.state) != fsm.States.HUNTING and body.is_in_group("prey") or (health < maxHealth and body.is_in_group("player")):
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ var target: Node2D
|
|||||||
func enter(previous_state_path: String, data := {}) -> void:
|
func enter(previous_state_path: String, data := {}) -> void:
|
||||||
if data.has("target"):
|
if data.has("target"):
|
||||||
target = data["target"]
|
target = data["target"]
|
||||||
owner.sprite.play("Hunting")
|
owner.play_sprite("Hunting")
|
||||||
owner.wrapper.play_sprite("Hunting")
|
|
||||||
else:
|
else:
|
||||||
# default behaviour; do nothing
|
# default behaviour; do nothing
|
||||||
finished.emit(owner.fsm.States.IDLE, {})
|
finished.emit(owner.fsm.States.IDLE, {})
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ extends AbstractPrey
|
|||||||
|
|
||||||
@onready var wrapper: WrappingManager = $WrappingManager
|
@onready var wrapper: WrappingManager = $WrappingManager
|
||||||
@onready var collision: CharacterBody2D = $Collision
|
@onready var collision: CharacterBody2D = $Collision
|
||||||
@onready var sprite: AnimatedSprite2D = $"Collision/Sprite"
|
@onready var sprite: AnimatedSprite2D = $Collision/Sprite
|
||||||
@onready var fsm: StateMachine = $StateMachine
|
@onready var fsm: StateMachine = $StateMachine
|
||||||
var starting_pos
|
var starting_pos
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
health = maxHealth
|
health = maxHealth
|
||||||
sprite.play("Healthy")
|
play_sprite(idle_sprite)
|
||||||
wrapper.play_sprite("Healthy")
|
|
||||||
if starting_pos:
|
if starting_pos:
|
||||||
collision.set_position(starting_pos)
|
collision.set_position(starting_pos)
|
||||||
|
|
||||||
@@ -32,14 +31,13 @@ func handle_damage(dmg: int, src: Node) -> void:
|
|||||||
fsm.transition_to_next_state(fsm.States.FLEEING, {"threat": src})
|
fsm.transition_to_next_state(fsm.States.FLEEING, {"threat": src})
|
||||||
|
|
||||||
func die() -> void:
|
func die() -> void:
|
||||||
sprite.play("Dying")
|
play_sprite("Dying")
|
||||||
wrapper.play_sprite("Dying")
|
|
||||||
GameManager.foodManager._spawn_food(collision.position)
|
GameManager.foodManager._spawn_food(collision.position)
|
||||||
super.die()
|
super.die()
|
||||||
|
|
||||||
func become_injured() -> void:
|
func become_injured() -> void:
|
||||||
sprite.play("Injured")
|
idle_sprite = "Injured"
|
||||||
wrapper.play_sprite("Injured")
|
play_sprite(idle_sprite)
|
||||||
|
|
||||||
func _on_sight_body_entered(body: Node2D) -> void:
|
func _on_sight_body_entered(body: Node2D) -> void:
|
||||||
if body.is_in_group("predator") or (health < maxHealth and body.is_in_group("player")):
|
if body.is_in_group("predator") or (health < maxHealth and body.is_in_group("player")):
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var threshold: float = 100
|
|||||||
func enter(previous_state_path: String, data := {}) -> void:
|
func enter(previous_state_path: String, data := {}) -> void:
|
||||||
if data.has("threat"):
|
if data.has("threat"):
|
||||||
threat = data["threat"]
|
threat = data["threat"]
|
||||||
|
owner.play_sprite("Fleeing")
|
||||||
else:
|
else:
|
||||||
# default behaviour; do nothing
|
# default behaviour; do nothing
|
||||||
finished.emit(owner.fsm.States.IDLE, {})
|
finished.emit(owner.fsm.States.IDLE, {})
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ var dir = Vector3(1, 1, 0)
|
|||||||
|
|
||||||
func enter(previous_state_path: String, data := {}) -> void:
|
func enter(previous_state_path: String, data := {}) -> void:
|
||||||
timer.start((float)(randi() % 5)/5)
|
timer.start((float)(randi() % 5)/5)
|
||||||
|
owner.play_sprite(owner.idle_sprite)
|
||||||
|
|
||||||
func physics_update(_delta: float) -> void:
|
func physics_update(_delta: float) -> void:
|
||||||
owner.move(_delta * Vector3(randfn(0, 1), randfn(0, 1), 0), 1)
|
owner.move(_delta * Vector3(randfn(0, 1), randfn(0, 1), 0), 1)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var dir: Vector3 = Vector3(0,0,0);
|
|||||||
func enter(previous_state_path: String, data := {}) -> void:
|
func enter(previous_state_path: String, data := {}) -> void:
|
||||||
timer.start((float)(randi() % 10)/5)
|
timer.start((float)(randi() % 10)/5)
|
||||||
dir = calc_dir(randi() % 360)
|
dir = calc_dir(randi() % 360)
|
||||||
|
owner.play_sprite(owner.idle_sprite)
|
||||||
|
|
||||||
func physics_update(_delta: float) -> void:
|
func physics_update(_delta: float) -> void:
|
||||||
owner.move(dir)
|
owner.move(dir)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ GameManager="*res://game_manager.gd"
|
|||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/viewport_height=656
|
window/size/viewport_height=656
|
||||||
|
window/size/resizable=false
|
||||||
|
|
||||||
[editor_plugins]
|
[editor_plugins]
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ extends Node
|
|||||||
class_name NPC
|
class_name NPC
|
||||||
|
|
||||||
@export var maxHealth: int = 0
|
@export var maxHealth: int = 0
|
||||||
|
@export var idle_sprite: String = "Healthy"
|
||||||
var health: int = maxHealth
|
var health: int = maxHealth
|
||||||
|
|
||||||
signal died
|
signal died
|
||||||
@@ -30,3 +31,8 @@ func die() -> void:
|
|||||||
func move(destination: Vector3) -> void:
|
func move(destination: Vector3) -> void:
|
||||||
push_error("Function move() not implemented.")
|
push_error("Function move() not implemented.")
|
||||||
|
|
||||||
|
func play_sprite(anim: String) -> void:
|
||||||
|
if "sprite" in self:
|
||||||
|
self.sprite.play(anim)
|
||||||
|
if "wrapper" in self:
|
||||||
|
self.wrapper.play_sprite(anim)
|
||||||
|
|||||||
Reference in New Issue
Block a user