Extensive work on the sideview and initial work on player profiles, inventory display, and renaming adventurerdata vs adventurer to adventurer vs adventurersprite
This commit is contained in:
@@ -1,74 +1,74 @@
|
||||
class_name Adventurer extends Npc
|
||||
class_name Adventurer extends Node
|
||||
|
||||
func _ready() -> void:
|
||||
nav_agent.navigation_finished.connect(_on_nav_agent_finished)
|
||||
pass
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if nav_agent.is_navigation_finished():
|
||||
if interaction_target:
|
||||
try_interact(interaction_target)
|
||||
#If they have an interaction target within range
|
||||
#clear the target
|
||||
#try_interact
|
||||
enum Gender{
|
||||
MASC,
|
||||
FEMME,
|
||||
NONBINARY
|
||||
}
|
||||
|
||||
var given_name : String = "Test"
|
||||
var surname : String = "Testing"
|
||||
var gender : Gender = Gender.MASC
|
||||
var life : int = 1
|
||||
var max_life : int = 1
|
||||
var energy : int = 1
|
||||
var max_energy : int = 1
|
||||
var level : int = 1
|
||||
var exp : int = 0
|
||||
var job : JobData
|
||||
var stats : StatBlock
|
||||
var gold : int = 0
|
||||
var quest : Quest
|
||||
var weapon : Weapon
|
||||
var armor : Armor
|
||||
var accessory : Accessory
|
||||
var inventory : Dictionary[Vector2, Item] = {}
|
||||
var inventory_size : Vector2i = Vector2i(6,1)
|
||||
|
||||
var quest_sprite : QuestSprite
|
||||
|
||||
func _init() -> void:
|
||||
stats = StatBlock.new()
|
||||
|
||||
func generate() -> void:
|
||||
if job == null:
|
||||
return
|
||||
var curr_pos: Vector2 = global_position
|
||||
var next_path_pos: Vector2 = nav_agent.get_next_path_position()
|
||||
stats.STR = randi_range(job.min_STR, job.max_STR)
|
||||
stats.DEX = randi_range(job.min_DEX, job.max_DEX)
|
||||
stats.INT = randi_range(job.min_INT, job.max_INT)
|
||||
stats.CHA = randi_range(job.min_CHA, job.max_CHA)
|
||||
stats.FAI = randi_range(job.min_FAI, job.max_FAI)
|
||||
stats.LUK = randi_range(job.min_LUK, job.max_LUK)
|
||||
|
||||
velocity = curr_pos.direction_to(next_path_pos) * movement_speed
|
||||
move_and_slide()
|
||||
#If they virtually didn't move
|
||||
if !stuck:
|
||||
if (global_position - last_position).length_squared() < 5:
|
||||
stuck = true
|
||||
stuck_time_remaining = 1
|
||||
max_life = stats.STR * 10 + stats.CHA * 10
|
||||
max_energy = stats.INT * 10 + stats.FAI * 10
|
||||
life = max_life
|
||||
energy = max_energy
|
||||
|
||||
func assign_quest(quest : Quest) -> void:
|
||||
self.quest = quest
|
||||
quest.initiate(self)
|
||||
|
||||
func full_name() -> String:
|
||||
return given_name + " " + surname
|
||||
|
||||
func gain_level() -> void:
|
||||
level += 1
|
||||
#TODO: Make stats improve based on job
|
||||
Game.notice("%s has reached level %d!" % [full_name(), level])
|
||||
|
||||
func gain_exp(amount : int) -> void:
|
||||
exp += amount
|
||||
while exp >= get_tnl():
|
||||
exp -= get_tnl()
|
||||
gain_level()
|
||||
|
||||
func gain_gold(amount :int) -> void:
|
||||
gold += amount
|
||||
|
||||
func get_tnl() -> int:
|
||||
if job:
|
||||
return job.get_tnl(level)
|
||||
else:
|
||||
if stuck_time_remaining > 0:
|
||||
stuck_time_remaining -= delta
|
||||
if stuck_time_remaining <= 0:
|
||||
nav_agent.target_position = global_position
|
||||
navigation_failed.emit()
|
||||
last_position = global_position
|
||||
|
||||
func approach(pos : Vector2) -> void:
|
||||
stuck = false
|
||||
var rid = get_world_2d().get_navigation_map()
|
||||
var point : Vector2 = NavigationServer2D.map_get_closest_point(rid, pos)
|
||||
set_movement_target(point)
|
||||
|
||||
func approach_and_interact(obj : Interactable) -> void:
|
||||
set_movement_target(obj.global_position)
|
||||
nav_agent.target_desired_distance = interaction_range - 5
|
||||
interaction_target = obj
|
||||
|
||||
func try_interact(obj : Interactable) -> void:
|
||||
var df = obj.global_position - global_position
|
||||
if df.length() > interaction_range:
|
||||
approach_and_interact(obj)
|
||||
else:
|
||||
interact(obj)
|
||||
interaction_target = null
|
||||
|
||||
func interact(obj : Interactable) -> void:
|
||||
obj.interact(self)
|
||||
|
||||
func set_movement_target(target : Vector2) -> void:
|
||||
nav_agent.target_position = target
|
||||
|
||||
func show_speech_bubble(bubble_type : String) -> void:
|
||||
bubble.try_show_speech(bubble_type)
|
||||
|
||||
|
||||
|
||||
func _on_nav_agent_finished() -> void:
|
||||
navigation_finished.emit()
|
||||
|
||||
|
||||
func _on_mouse_entered() -> void:
|
||||
profile_popup = popup_template.instantiate()
|
||||
add_child(profile_popup)
|
||||
profile_popup.setup(data.name, data.level, data.job.name, activity)
|
||||
|
||||
|
||||
func _on_mouse_exited() -> void:
|
||||
profile_popup.queue_free()
|
||||
return level * 10
|
||||
|
||||
Reference in New Issue
Block a user