Compare commits

...

4 Commits

26 changed files with 195 additions and 1475 deletions

View File

@ -0,0 +1,19 @@
class_name PlayerData
extends Resource
# Declare member variables here. Examples:
var player_position: Vector2
var player_health: int
var player_stamina: int
var player_inventory: InventoryManager
# Called when the node enters the scene tree for the first time.
#func _ready():
# pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@ -9,10 +9,23 @@ var player_health: int
var player_stamina: int
var player_inventory: InventoryManager
## An array of player data objects
var _player_data :Array = []
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func register_player() -> int:
_player_data.append(PlayerData.new())
## Return the index of the player data
return (_player_data.size() - 1 )
func get_player_data(index :int) -> PlayerData:
if _player_data.size() > index:
return _player_data[index]
else:
return null
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):

View File

@ -94,6 +94,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://lib/classes/movement_state_receiver.gd"
}, {
"base": "Resource",
"class": "PlayerData",
"language": "GDScript",
"path": "res://lib/classes/player_data.gd"
}, {
"base": "Area2D",
"class": "Projectile",
"language": "GDScript",
@ -162,6 +167,7 @@ _global_script_class_icons={
"Modifier_Receiver": "",
"MovementComponent": "",
"Movement_StateReceiver": "",
"PlayerData": "",
"Projectile": "",
"SE_StateFrame": "",
"StaminaComponent": "",
@ -330,18 +336,20 @@ crouch_2={
}
jump_2={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":74,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":70,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
attack_2={
"deadzone": 0.5,
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
attack_secondary_2={
"deadzone": 0.5,
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":84,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
switch_primary_item_1={
@ -359,13 +367,19 @@ switch_secondary_item_1={
switch_primary_item_2={
"deadzone": 0.5,
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":4,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":86,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
switch_secondary_item_2={
"deadzone": 0.5,
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":5,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":66,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
dash_2={
"deadzone": 0.5,
"events": [ ]
}
[layer_names]

View File

@ -4,6 +4,7 @@ extends Camera2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
export var debug_component :bool = false
var game_size := Vector2(320,180)
onready var window_scale :float = (OS.window_size / game_size).x
@ -66,12 +67,12 @@ func _process(delta):
#global_position = actual_cam_pos.round()
UiManager.debug_text = ("SP: " + str(cam_subpixel_pos.snapped(Vector2(0.01,0.01))) +
"\nCP: " + str (global_position.snapped(Vector2(0.1,0.1))) +
"\nTP: " + str(tracking_pos) +
"\nDT: " + str(distance_to)
)
if debug_component:
UiManager.debug_text = ("SP: " + str(cam_subpixel_pos.snapped(Vector2(0.01,0.01))) +
"\nCP: " + str (global_position.snapped(Vector2(0.1,0.1))) +
"\nTP: " + str(tracking_pos) +
"\nDT: " + str(distance_to)
)
## The original Algo

View File

@ -5,6 +5,7 @@ extends Node2D
# var a = 2
# var b = "text"
export var starting_level: PackedScene
export var debug_singletons :bool = false
# Called when the node enters the scene tree for the first time.

View File

@ -1,75 +0,0 @@
extends Actor
export var player_number: int = 1
onready var player_hurtbox = $Hurtbox_Component/CollisionShape2D
# Removing gun for now
#onready var gun = $Gun
func _ready() -> void:
PlayerInfo.player_health = $Health_Component.health
# Disabled for testing
#global_position = LevelInfo.player_start_position.transform.origin
movement_component.player_number = player_number
var portrait = preload("res://assets/MManPortrait.png")
func hit_Receiver(damage):
$Hurtbox_Component.set_hurtbox(false)
$Health_Component.take_damage(damage)
if $Health_Component.health > 0:
movement_state_machine.change_state($movement_state_machine/hurt)
PlayerInfo.player_health = $Health_Component.health
if PlayerInfo.player_health <= 0:
return
yield( get_tree().create_timer(2 + $movement_state_machine/hurt.timeout_seconds), "timeout")
$Hurtbox_Component.set_hurtbox(true)
func receive_modifier(incomming_modifier :StateModifier, is_adding_modifier_operation: bool):
#var mod :StateModifier
if is_adding_modifier_operation:
print("Player Received modifier:", incomming_modifier.name)
if movement_state_machine.current_state is StateAnimatedActor:
movement_state_machine.current_state.physics_modifier = incomming_modifier
else:
print("Player Removed modifier:", incomming_modifier.name)
if movement_state_machine.current_state is StateAnimatedActor:
movement_state_machine.current_state.physics_modifier = null
func touch_the_thing(the_thing: Interactable) -> bool:
print("You see! a THING...", the_thing.name)
if the_thing is HealthPickup:
# Do some healthy stuff.
the_thing.trigger_interaction()
return false
return true
func _on_attack_do_attack():
var is_shooting = false
print("Direction: ", transform.x.x)
# Gun removed for now
#is_shooting = gun.shoot(int(transform.x.x))
func _on_Health_Component_health_depleted():
$Hurtbox_Component.set_hurtbox(false)
movement_state_machine.change_state($movement_state_machine/die)
yield( get_tree().create_timer(10), "timeout")
#queue_free()
func _on_roll_frame_reached(state_name, animation_name, frame_number):
print("I'm invincible!!!")
$Hurtbox_Component.set_hurtbox(false)
func _on_roll_state_exited():
print("Nevermind. I'm vulnerable.")
$Hurtbox_Component.set_hurtbox(true)
func _on_die_state_entered():
pass # Replace with function body.

View File

@ -1,597 +0,0 @@
[gd_scene load_steps=116 format=2]
[ext_resource path="res://lib/parent_scenes/actor.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/actors/players/playerD/movement_component.gd" type="Script" id=2]
[ext_resource path="res://src/actors/players/playerD/Player.gd" type="Script" id=3]
[ext_resource path="res://lib/components/Health_Component.tscn" type="PackedScene" id=7]
[ext_resource path="res://lib/components/Modifier_Receiver.tscn" type="PackedScene" id=9]
[ext_resource path="res://lib/templates/Interactable/Interactable_Receiver.gd" type="Script" id=16]
[sub_resource type="RectangleShape2D" id=197]
extents = Vector2( 13, 18.5 )
[sub_resource type="StreamTexture" id=90]
load_path = "res://.import/Mega.png-398a010e8e27ac84fe3335706e03da1e.stex"
[sub_resource type="AtlasTexture" id=91]
atlas = SubResource( 90 )
region = Rect2( 1680, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=92]
atlas = SubResource( 90 )
region = Rect2( 1920, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=93]
atlas = SubResource( 90 )
region = Rect2( 2160, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=94]
atlas = SubResource( 90 )
region = Rect2( 2400, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=95]
atlas = SubResource( 90 )
region = Rect2( 0, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=96]
atlas = SubResource( 90 )
region = Rect2( 240, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=97]
atlas = SubResource( 90 )
region = Rect2( 1440, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=98]
atlas = SubResource( 90 )
region = Rect2( 480, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=99]
atlas = SubResource( 90 )
region = Rect2( 480, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=100]
atlas = SubResource( 90 )
region = Rect2( 720, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=101]
atlas = SubResource( 90 )
region = Rect2( 960, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=102]
atlas = SubResource( 90 )
region = Rect2( 1200, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=103]
atlas = SubResource( 90 )
region = Rect2( 1440, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=104]
atlas = SubResource( 90 )
region = Rect2( 240, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=105]
atlas = SubResource( 90 )
region = Rect2( 480, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=106]
atlas = SubResource( 90 )
region = Rect2( 720, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=107]
atlas = SubResource( 90 )
region = Rect2( 960, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=108]
atlas = SubResource( 90 )
region = Rect2( 1200, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=109]
atlas = SubResource( 90 )
region = Rect2( 1440, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=110]
atlas = SubResource( 90 )
region = Rect2( 1680, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=111]
atlas = SubResource( 90 )
region = Rect2( 1920, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=112]
atlas = SubResource( 90 )
region = Rect2( 2160, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=113]
atlas = SubResource( 90 )
region = Rect2( 2400, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=114]
atlas = SubResource( 90 )
region = Rect2( 0, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=115]
atlas = SubResource( 90 )
region = Rect2( 960, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=116]
atlas = SubResource( 90 )
region = Rect2( 1200, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=117]
atlas = SubResource( 90 )
region = Rect2( 1200, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=118]
atlas = SubResource( 90 )
region = Rect2( 0, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=119]
atlas = SubResource( 90 )
region = Rect2( 1440, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=120]
atlas = SubResource( 90 )
region = Rect2( 1680, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=121]
atlas = SubResource( 90 )
region = Rect2( 1920, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=122]
atlas = SubResource( 90 )
region = Rect2( 2160, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=123]
atlas = SubResource( 90 )
region = Rect2( 240, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=124]
atlas = SubResource( 90 )
region = Rect2( 480, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=125]
atlas = SubResource( 90 )
region = Rect2( 720, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=126]
atlas = SubResource( 90 )
region = Rect2( 240, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=127]
atlas = SubResource( 90 )
region = Rect2( 1680, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=128]
atlas = SubResource( 90 )
region = Rect2( 1920, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=129]
atlas = SubResource( 90 )
region = Rect2( 2160, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=130]
atlas = SubResource( 90 )
region = Rect2( 2400, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=131]
atlas = SubResource( 90 )
region = Rect2( 0, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=132]
atlas = SubResource( 90 )
region = Rect2( 240, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=133]
atlas = SubResource( 90 )
region = Rect2( 480, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=134]
atlas = SubResource( 90 )
region = Rect2( 720, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=135]
atlas = SubResource( 90 )
region = Rect2( 960, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=136]
atlas = SubResource( 90 )
region = Rect2( 1200, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=137]
atlas = SubResource( 90 )
region = Rect2( 1680, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=138]
atlas = SubResource( 90 )
region = Rect2( 1920, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=139]
atlas = SubResource( 90 )
region = Rect2( 2160, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=140]
atlas = SubResource( 90 )
region = Rect2( 2400, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=141]
atlas = SubResource( 90 )
region = Rect2( 0, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=142]
atlas = SubResource( 90 )
region = Rect2( 240, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=143]
atlas = SubResource( 90 )
region = Rect2( 480, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=144]
atlas = SubResource( 90 )
region = Rect2( 720, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=145]
atlas = SubResource( 90 )
region = Rect2( 960, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=146]
atlas = SubResource( 90 )
region = Rect2( 1200, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=147]
atlas = SubResource( 90 )
region = Rect2( 1440, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=148]
atlas = SubResource( 90 )
region = Rect2( 1920, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=149]
atlas = SubResource( 90 )
region = Rect2( 2160, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=150]
atlas = SubResource( 90 )
region = Rect2( 2400, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=151]
atlas = SubResource( 90 )
region = Rect2( 0, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=152]
atlas = SubResource( 90 )
region = Rect2( 240, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=153]
atlas = SubResource( 90 )
region = Rect2( 480, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=154]
atlas = SubResource( 90 )
region = Rect2( 720, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=155]
atlas = SubResource( 90 )
region = Rect2( 960, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=156]
atlas = SubResource( 90 )
region = Rect2( 1200, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=157]
atlas = SubResource( 90 )
region = Rect2( 1440, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=158]
atlas = SubResource( 90 )
region = Rect2( 1920, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=159]
atlas = SubResource( 90 )
region = Rect2( 2160, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=160]
atlas = SubResource( 90 )
region = Rect2( 2400, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=161]
atlas = SubResource( 90 )
region = Rect2( 0, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=162]
atlas = SubResource( 90 )
region = Rect2( 240, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=163]
atlas = SubResource( 90 )
region = Rect2( 480, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=164]
atlas = SubResource( 90 )
region = Rect2( 720, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=165]
atlas = SubResource( 90 )
region = Rect2( 960, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=166]
atlas = SubResource( 90 )
region = Rect2( 1200, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=167]
atlas = SubResource( 90 )
region = Rect2( 1440, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=168]
atlas = SubResource( 90 )
region = Rect2( 2400, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=169]
atlas = SubResource( 90 )
region = Rect2( 0, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=170]
atlas = SubResource( 90 )
region = Rect2( 720, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=171]
atlas = SubResource( 90 )
region = Rect2( 960, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=172]
atlas = SubResource( 90 )
region = Rect2( 1200, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=173]
atlas = SubResource( 90 )
region = Rect2( 1440, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=174]
atlas = SubResource( 90 )
region = Rect2( 1680, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=175]
atlas = SubResource( 90 )
region = Rect2( 1920, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=176]
atlas = SubResource( 90 )
region = Rect2( 2160, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=177]
atlas = SubResource( 90 )
region = Rect2( 2400, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=178]
atlas = SubResource( 90 )
region = Rect2( 0, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=179]
atlas = SubResource( 90 )
region = Rect2( 240, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=180]
atlas = SubResource( 90 )
region = Rect2( 480, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=181]
atlas = SubResource( 90 )
region = Rect2( 720, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=182]
atlas = SubResource( 90 )
region = Rect2( 960, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=183]
atlas = SubResource( 90 )
region = Rect2( 1200, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=184]
atlas = SubResource( 90 )
region = Rect2( 1440, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=185]
atlas = SubResource( 90 )
region = Rect2( 1680, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=186]
atlas = SubResource( 90 )
region = Rect2( 1920, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=187]
atlas = SubResource( 90 )
region = Rect2( 2160, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=188]
atlas = SubResource( 90 )
region = Rect2( 2400, 1280, 240, 160 )
[sub_resource type="AtlasTexture" id=189]
atlas = SubResource( 90 )
region = Rect2( 0, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=190]
atlas = SubResource( 90 )
region = Rect2( 240, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=191]
atlas = SubResource( 90 )
region = Rect2( 480, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=192]
atlas = SubResource( 90 )
region = Rect2( 720, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=193]
atlas = SubResource( 90 )
region = Rect2( 960, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=194]
atlas = SubResource( 90 )
region = Rect2( 1680, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=195]
atlas = SubResource( 90 )
region = Rect2( 1680, 480, 240, 160 )
[sub_resource type="SpriteFrames" id=196]
animations = [ {
"frames": [ SubResource( 91 ), SubResource( 92 ), SubResource( 93 ), SubResource( 94 ), SubResource( 95 ), SubResource( 96 ) ],
"loop": true,
"name": "climb",
"speed": 10.0
}, {
"frames": [ SubResource( 97 ) ],
"loop": false,
"name": "climb_step",
"speed": 10.0
}, {
"frames": [ SubResource( 98 ) ],
"loop": false,
"name": "climb_upstep",
"speed": 10.0
}, {
"frames": [ SubResource( 99 ), SubResource( 99 ), SubResource( 99 ), SubResource( 100 ), SubResource( 101 ), SubResource( 102 ), SubResource( 103 ), SubResource( 103 ), SubResource( 103 ) ],
"loop": false,
"name": "dash",
"speed": 10.0
}, {
"frames": [ SubResource( 104 ), SubResource( 105 ), SubResource( 106 ), SubResource( 107 ), SubResource( 108 ), SubResource( 109 ), SubResource( 110 ), SubResource( 111 ), SubResource( 112 ), SubResource( 113 ), SubResource( 112 ), SubResource( 114 ) ],
"loop": false,
"name": "die",
"speed": 10.0
}, {
"frames": [ SubResource( 115 ), SubResource( 116 ) ],
"loop": true,
"name": "hurt",
"speed": 4.0
}, {
"frames": [ SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 118 ), SubResource( 119 ), SubResource( 120 ), SubResource( 121 ), SubResource( 122 ) ],
"loop": true,
"name": "idle",
"speed": 10.0
}, {
"frames": [ SubResource( 123 ), SubResource( 124 ), SubResource( 125 ) ],
"loop": true,
"name": "idle_shield",
"speed": 10.0
}, {
"frames": [ SubResource( 126 ) ],
"loop": true,
"name": "idle_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 127 ), SubResource( 128 ), SubResource( 129 ), SubResource( 130 ), SubResource( 128 ), SubResource( 131 ), SubResource( 132 ), SubResource( 133 ) ],
"loop": false,
"name": "jump",
"speed": 10.0
}, {
"frames": [ SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 135 ), SubResource( 136 ) ],
"loop": false,
"name": "jump_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 137 ), SubResource( 138 ), SubResource( 139 ), SubResource( 140 ), SubResource( 141 ), SubResource( 142 ), SubResource( 143 ), SubResource( 144 ), SubResource( 145 ), SubResource( 146 ), SubResource( 147 ) ],
"loop": false,
"name": "roll",
"speed": 10.0
}, {
"frames": [ SubResource( 148 ), SubResource( 149 ), SubResource( 150 ), SubResource( 151 ), SubResource( 152 ), SubResource( 153 ), SubResource( 154 ), SubResource( 155 ), SubResource( 156 ), SubResource( 157 ) ],
"loop": true,
"name": "run",
"speed": 10.0
}, {
"frames": [ SubResource( 158 ), SubResource( 159 ), SubResource( 160 ), SubResource( 161 ), SubResource( 162 ), SubResource( 163 ), SubResource( 164 ), SubResource( 165 ), SubResource( 166 ), SubResource( 167 ) ],
"loop": true,
"name": "run_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 168 ), SubResource( 169 ), SubResource( 126 ) ],
"loop": false,
"name": "shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 170 ), SubResource( 171 ), SubResource( 172 ), SubResource( 172 ), SubResource( 173 ), SubResource( 174 ), SubResource( 175 ), SubResource( 176 ), SubResource( 176 ), SubResource( 177 ), SubResource( 178 ), SubResource( 179 ), SubResource( 180 ), SubResource( 181 ), SubResource( 182 ), SubResource( 183 ), SubResource( 184 ), SubResource( 185 ), SubResource( 186 ), SubResource( 187 ), SubResource( 188 ), SubResource( 189 ) ],
"loop": true,
"name": "slash",
"speed": 10.0
}, {
"frames": [ SubResource( 118 ), SubResource( 190 ), SubResource( 191 ), SubResource( 192 ), SubResource( 193 ) ],
"loop": false,
"name": "stand",
"speed": 10.0
}, {
"frames": [ SubResource( 194 ) ],
"loop": false,
"name": "step",
"speed": 10.0
}, {
"frames": [ SubResource( 195 ) ],
"loop": false,
"name": "step_shoot",
"speed": 10.0
} ]
[sub_resource type="RectangleShape2D" id=89]
extents = Vector2( 12, 16 )
[node name="Player" instance=ExtResource( 1 )]
script = ExtResource( 3 )
actor_type = "Player"
player_number = 1
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="0"]
position = Vector2( 0, -3.5 )
shape = SubResource( 197 )
[node name="AnimatedSprite" parent="." index="1"]
position = Vector2( -1, -51 )
frames = SubResource( 196 )
animation = "idle_shoot"
__meta__ = {
"_aseprite_wizard_config_": {
"layer": "",
"o_ex_p": "_+",
"o_folder": "res://assets",
"o_name": "",
"only_visible": true,
"op_exp": false,
"slice": "",
"source": "D:/Sync/Assets/Library/Mega.ase"
}
}
[node name="movement_component" parent="." index="2"]
script = ExtResource( 2 )
player_number = 1
interactable_node = NodePath("../Interactable_Receiver")
[node name="Hurtbox_Component" parent="." index="4"]
collision_layer = 16
collision_mask = 128
hurtbox_entered_function = "hit_Receiver"
[node name="CollisionShape2D" parent="Hurtbox_Component" index="0"]
position = Vector2( 0, -2 )
shape = SubResource( 89 )
[node name="Health_Component" parent="." index="6" instance=ExtResource( 7 )]
max_health = 100
[node name="Interactable_Receiver" type="Node2D" parent="." index="7"]
script = ExtResource( 16 )
interactable_parent_callback = "touch_the_thing"
[node name="Modifier_Receiver" parent="." index="8" instance=ExtResource( 9 )]
modifier_parent_callback = "receive_modifier"
debug_receiver = true
[node name="Ladder_Detection" type="RayCast2D" parent="." index="9"]
modulate = Color( 0.247059, 0.92549, 0.0313726, 1 )
position = Vector2( 0, 5 )
enabled = true
cast_to = Vector2( 0, 15 )
collision_mask = 1024
collide_with_areas = true
collide_with_bodies = false
[connection signal="health_depleted" from="Health_Component" to="." method="_on_Health_Component_health_depleted"]

View File

@ -1,140 +0,0 @@
extends MovementComponent
## Constants available to you
# UP = -1.0
# DOWN = 1.0
# LEFT = -1.0
# RIGHT = 1.0
# Avalable functions to call
# A Series of helper functions
# go_up():
# go_down():
# go_left():
# go_right():
# stop():
export var player_number: int = 1
export (NodePath) var interactable_node
onready var interactable_receiver_node: Interactable_Receiver = get_node(interactable_node)
onready var ladder_detection:RayCast2D = $"../Ladder_Detection"
var ladder_collision: RayCast2D
func _ready():
ladder_collision = ladder_detection
# Guess there isn't a hit from inside in 3.5
# Remember to make raycast as tall as needed for the player
#ladder_collision.hit_from_inside = true
func process_physics(delta):
PlayerInfo.player_position = owner.global_position
func process_input(event: InputEvent):
var interactables = interactable_receiver_node.interactable_function_callables
for interactable in interactables: # Iterate through the interactable collection
if interactable is Interactable: # Make sure we didn't push something dumb in there.
if (Input.is_action_pressed("ui_up")): # We pressed up?
interactable.trigger_interaction()
get_movement_direction()
# Return the desired direction of movement for the character
# in the range [-1, 1], where positive values indicate a desire
# to move to the right and negative values to the left.
func get_movement_direction() -> float:
#return Input.get_axis('move_left', 'move_right')
desired_movement_vector.x = Input.get_axis("move_left_" + str(player_number), "move_right_" + str(player_number))
return Input.get_axis("move_left_" + str(player_number), "move_right_" + str(player_number))
# Return a boolean indicating if the character wants to jump
func wants_jump() -> bool:
if Input.is_action_just_pressed("jump_" + str(player_number)):
desired_movement_vector.y = 1
return true
else:
return false
# Return a boolean indicating if the character wants to jump
func wants_shoot() -> bool:
if Input.is_action_just_pressed("shoot_" + str(player_number)):
return true
else:
return false
func wants_dash() -> bool:
if Input.is_action_just_pressed("dash_" + str(player_number)):
return true
else:
return false
func wants_roll() -> bool:
if Input.is_action_just_pressed("dash_" + str(player_number)) and Input.is_action_pressed("ui_up"):
return true
else:
return false
func wants_climb() -> bool:
if ladder_detection.is_colliding() and Input.is_action_pressed("ui_up"):
#print("betcha wanna climb though!")
return true
else:
return false
func get_climb_shape_location() -> Vector2:
if ladder_detection.is_colliding():
var point: Vector2 = ladder_collision.get_collision_point()
var shape_id = ladder_collision.get_collider_shape()
var object = ladder_collision.get_collider()
# This works but doesn't get the shapes location.
# if object is Area2D:
# print("You got an area bro!" , object.global_position)
# This appears to get the shapes location!
var area = Physics2DServer.area_get_transform(object)
var areashape = Physics2DServer.area_get_shape_transform(object, shape_id)
var y_dir = Input.get_axis("ui_up" , "ui_down")
#var target = get_collider() # A CollisionObject2D.
#var shape_id = get_collider_shape() # The shape index in the collider.
#var owner_id = target.shape_find_owner(shape_id) # The owner ID in the collider.
#var shape = target.shape_owner_get_owner(owner_id)
#UiManager.debug_text = str(round(point.x)) + ' ' + str(round(point.y)) #( "Mod(" + str(sign(_move_speed_modifier)) + ") Dir(" + str(move_direction) + ") Vel(" + str(sign(current_x_velocity)) + ") Mov(" + str(sign(move_component.desired_movement_vector.x)) +
return Vector2(areashape.origin.x, y_dir)
else:
return Vector2(-1,-1)
## Other needed variables
# desired_movement_vector: Vector2 - Used to store desired movement depending on the state
# current_movement_state:String - The name of the current State
# Since animactor state machine can actually view properties from this type
# I'm thinking about moving the velocity tracker in here instead of player.
# velocity: Vector2 - Current velocity, you can change this at will but state may modify it
# Declare any other member variables here. Examples:
# var a = 2
# var b = "text"
# Called every frame. 'delta' is the elapsed time since the previous frame.
# you do not normally need to define this for Actor
#func process(delta):
# pass
# For Enemy and NPC Actors:
# should be called on the frame process.
# For Player Actors:
# Should be called on the input process

View File

@ -1,140 +0,0 @@
extends StateAnimatedActor
export (NodePath) var jump_node
export (NodePath) var idle_node
export (NodePath) var fall_node
export (NodePath) var move_node
export (NodePath) var draw_weapon_node
onready var jump_state: StateAnimatedActor = get_node(jump_node)
onready var idle_state: StateAnimatedActor = get_node(idle_node)
onready var fall_state: StateAnimatedActor = get_node(fall_node)
onready var move_state: StateAnimatedActor = get_node(move_node)
#onready var weapon_state_modifier: StateModifier = get_node(draw_weapon_node)
var can_fire = true
signal do_attack()
var draw_weapon_modifier: StateModifier
func _ready():
state_timeout.connect("timeout", self, "disable_cooldown")
draw_weapon_modifier = StateModifier.new()
var mod_timer :Timer = draw_weapon_modifier.ready( "draw_weapon", "_shoot" , draw_weapon_modifier.TYPE.ANIMATION_SUFFIX, 2.0)
add_child(mod_timer)
func disable_cooldown():
if debug_state:
print("Attack state cooldown timeout. Can attack again.")
state_ready = true
func enter() -> void:
if modifier:
if modifier.get_instance_id() == draw_weapon_modifier.get_instance_id():
#print ("They the same cannot apply modifier: ", draw_weapon_modifier.get_instance_id())
modifier = null
.enter()
##TODO: Turn this to clear only the animation modifiers.
# modifier_stack_ref.clear()
# mod_animation_sequence.clear()
# #mod_animation_sequence = animation_sequence.duplicate(true)
# mod_animation_sequence.append_array(animation_sequence)
# # Reset animation suffix in case there isn't one
# animation_suffix = '_shoot'
# animation_index = 0
# current_animation_sequence = 0
# #var enter_animation = ''
# var enter_frame = 0
#
# if debug_state:
# print(parent.name, " entering State: ", self.name)
# move_component.current_movement_state = self.name
# emit_signal("state_entered")
can_fire = true
# if modifier_stack_ref.has($"../draw_weapon") == false:
# $"../draw_weapon".enter()
# modifier_stack_ref.push_front($"../draw_weapon")
if debug_state:
print("Previous State Info: ", previous_animation_name, " ",
previous_state_frame_number, " ", previous_state_name)
match previous_animation_name:
"idle":
#animations.play("idle_shoot")
if debug_state:
print("no need to change idle animation")
"run":
animations.play("run_shoot")
animations.frame = previous_state_frame_number
"jump":
animations.play("jump_shoot")
animations.frame = previous_state_frame_number
if debug_state:
print("Starting Animation: jump_shoot at frame ", animations.animation , animations.frame)
_:
print("Warning!: Attack state encountered unhandled prev animation: ", previous_animation_name)
# An example where the modifier is left to alert on a timeout
#mod_timer.connect("timeout", draw_weapon_modifier, "_on_Timer_timeout")
# An example where the current node subscribes
#mod_timer.connect("timeout", self, "_on_Timer_timeout")
state_timeout.start()
draw_weapon_modifier.state_timeout.start()
state_ready = false
animation_finished = false
func _on_Timer_timeout():
print("Modifier Timeout from attack! Forcing animation recall")
#animations.stop()
func process_frame(delta: float) -> State:
if animation_finished:
draw_weapon_modifier.state_timeout.start()
modifier = draw_weapon_modifier
return idle_state
# if animations.frame == 2:
# animations.stop()
# if state_timeout.time_left == 0 and animations.animation == "shoot":
# return idle_state
return null
func process_physics(delta: float) -> State:
if can_fire: # trying to do this in the physics because irrecular behavior
emit_signal("do_attack")
can_fire = false
if move_component.wants_jump() and parent.is_on_floor():
draw_weapon_modifier.state_timeout.start()
jump_state.modifier = draw_weapon_modifier
return jump_state
move_actor_as_desired(delta)
# if previous_state_name == "move" and move_component.velocity.x == 0.0:
# return idle_state
if move_component.velocity.x != 0.0:
draw_weapon_modifier.state_timeout.start()
move_state.modifier = draw_weapon_modifier
#draw_weapon_modifier.transfer_owner(move_state)
return move_state
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
# if move_component.velocity.x != 0.0:
# return move_state
if !parent.is_on_floor():
draw_weapon_modifier.state_timeout.start()
fall_state.modifier = draw_weapon_modifier
return fall_state
return null

View File

@ -1,51 +0,0 @@
extends StateAnimatedActor
export (NodePath) var idle_node
onready var idle_state: StateAnimatedActor = get_node(idle_node)
#onready var landing_mod: StateModifier = get_node(landing_node)
var climbing_modifier: StateModifier
func _ready():
climbing_modifier= StateModifier.new()
#add_child(modifier)
#modifier.init_ref()
# climbing_modifier.ready( "landing", "jump" , climbing_modifier.TYPE.EXIT_ANIMATION)
# climbing_modifier.starting_frame = 6
#print("ready! MOD")
func enter() -> void:
.enter()
animations.frame = 5
func process_physics(delta: float) -> State:
# First allow horizontal movement.
#move_actor_as_desired(delta)
# Make wure we still want to climb
var ladder_location = move_component.get_climb_shape_location()
if ladder_location != Vector2(-1,-1):
UiManager.debug_text = str(ladder_location) + '\n' + str(ladder_location - parent.global_position) #+ '\n' + str(parent.global_position.distance_to(ladder_location))
# An attempt to snap to the ladder location
if parent.global_position.x != round(ladder_location.x):
parent.global_translate(Vector2(round((ladder_location.x - parent.global_position.x)),(ladder_location.y * move_speed) * delta))
if ladder_location.y != 0:
animations.play()
else:
# Make sure we hopped the step index
if animation_index > 0:
animations.stop()
else:
return idle_state
#parent.move_local_x()
#Flip the character before tha actual move maybe.
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
# if parent.is_on_floor():
# #modifier.reference()
# idle_state.modifier = climbing_modifier
# return idle_state
return null

View File

@ -1,78 +0,0 @@
extends StateAnimatedActor
export (NodePath) var fall_node
export (NodePath) var idle_node
export (NodePath) var attack_node
export (NodePath) var jump_node
onready var jump_state: State = get_node(jump_node)
onready var fall_state: State = get_node(fall_node)
onready var idle_state: State = get_node(idle_node)
onready var attack_state: State = get_node(attack_node)
#var speed_decay_rate := 1.0
func process_physics(delta: float) -> State:
# if move_component.wants_shoot():
# return attack_state
if move_component.wants_jump():
return jump_state
# Move the last direction we were facing.
move_actor_as_desired(delta, parent.transform.x.x)
# # Assuming adjusted_move_speed is set to the mood speed modifier on state entry
# # Move speed is the base speed plus the modifier minus the decay adjusted for time
# jerk += jerk_factor * delta
# adjusted_move_speed += move_modifier_move_acceleration * delta
# var new_move_speed = move_speed + (move_acceleration * delta) + adjusted_move_speed + jerk
#
# # A really crappy normalization to prevent modifying past the base move speed.
# if move_speed_modifier > 0 and new_move_speed < move_speed: # positive modifier
# #print("nope1")
# new_move_speed = move_speed
# elif move_speed_modifier < 0 and new_move_speed > move_speed: # negative modifier
# #print("nope2")
# new_move_speed = move_speed
# else:
# UiManager.debug_text = str(round(adjusted_move_speed)) + "," + str(round(new_move_speed)) + "," + str(round(jerk))
# #print(adjusted_move_speed, ",", new_move_speed, ",", jerk)
#
# #print(new_move_speed, " ", adjusted_move_speed)
#
# move_component.velocity.y += gravity * delta
# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
# #print(speed_multiplier)
# move_component.velocity.x = parent.transform.x.x * new_move_speed
# move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
## Trying a whole new model
# var new_move_speed = move_speed * speed_multiplier
# if speed_multiplier > 1.0:
# print("PPS: ", new_move_speed * delta)
# speed_multiplier -= delta * (speed_decay_rate * speed_multiplier)
# #speed_decay_rate += delta * speed_decay_rate
#
# elif speed_multiplier < 1.0:
# speed_multiplier += delta * (speed_decay_rate * speed_multiplier)
# #speed_decay_rate += delta * speed_decay_rate
#
# # Deadzone
# if speed_multiplier < 1.1 and speed_multiplier > 0.9:
# speed_multiplier = 1.0
#
# move_component.velocity.y += gravity * delta
# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
# #print(speed_multiplier)
# move_component.velocity.x = parent.transform.x.x * new_move_speed
# move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
if move_component.velocity.x == 0.0 or animations.playing == false:
if !parent.is_on_floor():
return fall_state
else:
return idle_state
return null

View File

@ -1,12 +0,0 @@
extends StateAnimatedActor
func enter() -> void:
# modifier_stack_ref.clear()
.enter()
move_component.velocity.x = 0
func process_physics(_delta: float) -> State:
#Dead Dead dead.
#move_actor_as_desired(_delta)
return null

View File

@ -1,50 +0,0 @@
extends StateAnimatedActor
export (NodePath) var idle_node
export (NodePath) var landing_node
onready var idle_state: StateAnimatedActor = get_node(idle_node)
#onready var landing_mod: StateModifier = get_node(landing_node)
var landing_modifier: StateModifier
func _ready():
landing_modifier= StateModifier.new()
#add_child(modifier)
#modifier.init_ref()
landing_modifier.ready( "landing", "jump" , landing_modifier.TYPE.EXIT_ANIMATION)
landing_modifier.starting_frame = 6
#print("ready! MOD")
func enter() -> void:
# var landing_mod_index = modifier_stack_ref.rfind(landing_mod)
# if landing_mod_index != -1:
# #print("You're Supposed to be dead!?: ", landing_mod_index)
# modifier_stack_ref.remove(landing_mod_index)
.enter()
# Jump to fall frame
animations.frame = 5
animations.stop()
func process_physics(delta: float) -> State:
# First allow horizontal movement.
move_actor_as_desired(delta)
#Flip the character before tha actual move maybe.
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
if parent.is_on_floor():
#modifier.reference()
idle_state.modifier = landing_modifier
return idle_state
return null
#func exit() -> void:
# .exit()
## push_animation_state_modifier(landing_mod)
## $"../landing".enter()
## modifier_stack_ref.push_front($"../landing")
# return

View File

@ -1,57 +0,0 @@
extends StateAnimatedActor
export (NodePath) var idle_node
onready var idle_state: State = get_node(idle_node)
var flash_color = Color.yellow
var store_modifier: StateModifier
func enter() -> void:
if modifier:
if debug_state:
print(name, " skipping modifier and holding for next state.")
store_modifier = modifier
modifier = null
# modifier_stack_ref.clear()
.enter()
move_component.velocity.x = 0
#parent.set_hurtbox(false)
#TODO: Error check if timer was actually instanced
state_timeout.start()
func exit() -> void:
modifier = store_modifier
.exit()
animations.modulate = Color.white
func process_input(_event: InputEvent) -> State:
# move_component.wants_jump()
move_component.get_movement_direction()
return null
func process_frame(delta: float) -> State:
# Apply a little effect when damage taken.
#UiManager.debug_text = str(abs(sin((ceil(state_timeout.time_left) - state_timeout.time_left)/.5)))
animations.modulate = flash_color.linear_interpolate(Color.white, abs(sin((ceil(state_timeout.time_left) - state_timeout.time_left)/.5)))
if state_timeout.time_left == 0:
return idle_state
return null
func process_physics(delta: float) -> State:
move_component.velocity.y += gravity * delta
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
move_component.velocity.x = parent.transform.x.x * move_speed
# if (parent.direction.x > 0):
# parent.velocity.x = 1 * move_speed
# else:
# parent.velocity.x = -1 * move_speed
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
return null

View File

@ -1,52 +0,0 @@
extends StateAnimatedActor
export (NodePath) var fall_node
export (NodePath) var move_node
export (NodePath) var jump_node
export (NodePath) var attack_node
export (NodePath) var dash_node
export (NodePath) var roll_node
export (NodePath) var climb_node
onready var fall_state: State = get_node(fall_node)
onready var move_state: State = get_node(move_node)
onready var jump_state: State = get_node(jump_node)
onready var attack_state: State = get_node(attack_node)
onready var dash_state: State = get_node(dash_node)
onready var roll_state: State = get_node(roll_node)
onready var climb_state: State = get_node(climb_node)
func enter() -> void:
.enter()
# parent.set_hurtbox(true)
#move_component.velocity.x = 0
#move_component.momentum.x *= -1
if debug_state:
print(owner.name, " Move Component: ", move_component.desired_movement_vector.x)
func process_physics(delta: float) -> State:
if move_component.wants_jump() and parent.is_on_floor():
return jump_state
# We need to offer roll before dash because the inputs are the same
if move_component.wants_roll() and parent.is_on_floor():
return roll_state
if move_component.wants_dash() and parent.is_on_floor():
return dash_state
if move_component.wants_climb():
return climb_state
if move_component.wants_shoot():
return attack_state
move_actor_as_desired(delta)
if move_component.desired_movement_vector.x != 0 and move_component.velocity.x != 0:
return move_state
if !parent.is_on_floor():
return fall_state
return null

View File

@ -1,45 +0,0 @@
extends StateAnimatedActor
export (NodePath) var idle_node
export (NodePath) var fall_node
export (NodePath) var attack_node
export (NodePath) var landing_node
onready var idle_state: State = get_node(idle_node)
onready var fall_state: State = get_node(fall_node)
onready var attack_state: State = get_node(attack_node)
#onready var landing_mod: StateModifier = get_node(landing_node)
export var jump_force: float = 200.0
func enter() -> void:
# var landing_mod_index = modifier_stack_ref.rfind(landing_mod)
# if landing_mod_index != -1:
# #print("You're Supposed to be dead!?: ", landing_mod_index)
# modifier_stack_ref.remove(landing_mod_index)
# if modifier_stack_ref.has(landing_mod):
# print("Jump from Landing Mod at: ", modifier_stack_ref.rfind(landing_mod))
.enter()
# Apply initial jump velocity on state enter
move_component.velocity.y = -jump_force
func process_physics(delta: float) -> State:
if move_component.velocity.y > 0:
return fall_state
if move_component.wants_shoot():
return attack_state
# First allow horizontal movement.
move_actor_as_desired(delta)
#Flip the character before tha actual move maybe.
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
if parent.is_on_floor():
return idle_state
return null

View File

@ -1,34 +0,0 @@
extends StateAnimatedActor
export (NodePath) var fall_node
export (NodePath) var idle_node
export (NodePath) var jump_node
export (NodePath) var attack_node
onready var fall_state: State = get_node(fall_node)
onready var idle_state: State = get_node(idle_node)
onready var jump_state: State = get_node(jump_node)
onready var attack_state: State = get_node(attack_node)
func process_physics(delta: float) -> State:
if move_component.wants_jump() and parent.is_on_floor():
return jump_state
if move_component.wants_shoot():
return attack_state
move_actor_as_desired(delta)
# if move_component.velocity.x == 0.0:
# return idle_state
#Flip the character before tha actual move maybe.
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
if move_component.desired_movement_vector.x == 0:
return idle_state
if !parent.is_on_floor():
return fall_state
return null

View File

@ -1,46 +0,0 @@
extends StateAnimatedActor
export (NodePath) var fall_node
export (NodePath) var idle_node
onready var fall_state: State = get_node(fall_node)
onready var idle_state: State = get_node(idle_node)
var speed_decay_rate := 1.0
func enter():
#remove_animation_state_modifiers()
.enter()
func process_physics(delta: float) -> State:
# if move_component.wants_shoot():
# return attack_state
if speed_multiplier > 1.0:
#print(speed_multiplier,", ", delta)
speed_multiplier -= delta * speed_decay_rate
speed_decay_rate += delta
elif speed_multiplier < 1.0:
speed_multiplier += delta * speed_decay_rate
speed_decay_rate += delta
# Deadzone
if speed_multiplier < 1.1 and speed_multiplier > 0.9:
speed_multiplier = 1.0
move_component.velocity.y += gravity * delta
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
#print(speed_multiplier)
move_component.velocity.x = parent.transform.x.x * move_speed * speed_multiplier
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
if animations.frame >= 10:
#print("WTF - ", animations.frame, " ,", move_component.velocity.x)
if !parent.is_on_floor():
return fall_state
else:
return idle_state
return null

View File

@ -275,7 +275,8 @@ func _state_process_physics_fall():
if $"../LedgeDetector".is_colliding() and !$"../WallDetector".is_colliding():
#print("it touched me!")
UiManager.debug_text = (str($"../LedgeDetector".get_collision_point()))
if debug_component:
UiManager.debug_text = (str($"../LedgeDetector".get_collision_point()))
request_state_change.call_func('ledge_grab')
if parent.is_on_floor():
@ -286,7 +287,6 @@ func _state_process_physics_fall():
move_actor_as_desired()
func _state_process_physics_jump():
#UiManager.debug_text = (str(velocity))
flip_sprite_to_movement_direction()
@ -356,7 +356,8 @@ func _state_process_physics_climb():
request_state_change.call_func('fall')
func _state_process_physics_ledge_grab():
UiManager.debug_text = (str(velocity))
if debug_component:
UiManager.debug_text = (str(velocity))
$"../LedgeDetector".set_enabled(false)
if _wants_jump:
@ -366,11 +367,11 @@ func _state_process_physics_ledge_grab():
request_state_change.call_func('fall')
func _state_process_physics_ledge_climb():
# UiManager.debug_text = (str(velocity))
# $"../LedgeDetector".set_enabled(false)
UiManager.debug_text = (str(parent.is_on_floor()) +
str(parent.is_on_wall()) + ")\nV:" + str(velocity))
if debug_component:
UiManager.debug_text = (str(parent.is_on_floor()) +
str(parent.is_on_wall()) + ")\nV:" + str(velocity))
if current_state.animation_finished == true:
request_state_change.call_func('land')

View File

@ -20,11 +20,23 @@ const state_stamina_cost :Dictionary = {
"ledge_climb":10
}
var player_info_index :int
var player_data :PlayerData
# Called when the node enters the scene tree for the first time.
func _ready():
PlayerInfo.player_health = health_component.health
# PlayerInfo.player_health = health_component.health
PlayerInfo.player_inventory = player_inventory
PlayerInfo.player_stamina = stamina_component.stamina
# PlayerInfo.player_stamina = stamina_component.stamina
player_info_index = PlayerInfo.register_player()
print ("Registered as player: ", player_info_index)
player_data = PlayerInfo.get_player_data(player_info_index)
PlayerInfo.get_player_data(player_info_index).player_health = health_component.health
print ("My health is: ", player_data.player_health)
player_data.player_inventory = player_inventory
player_data.player_stamina = stamina_component.stamina
# Set initial player position in world.
global_position = LevelInfo.player_start_position
@ -34,18 +46,21 @@ func _ready():
movement_component.state_stamina_cost = state_stamina_cost
#var stamina_recovery :float = 0.0
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
PlayerInfo.player_position = global_position.round()
#PlayerInfo.player_position = global_position.round()
player_data.player_position = global_position.round()
# stamina_recovery += delta
# if stamina_recovery > 1.0:
# stamina_component.recover(1)
# stamina_recovery = 0.0
# #print("recover ", stamina_component.stamina)
PlayerInfo.player_stamina = stamina_component.stamina
#PlayerInfo.player_stamina = stamina_component.stamina
player_data.player_stamina = stamina_component.stamina
match movement_state_machine.current_state.name:
@ -64,8 +79,10 @@ func hit_Receiver(damage):
health_component.take_damage(damage)
if $Health_Component.health > 0:
movement_state_machine.change_to_known_state('hurt')
PlayerInfo.player_health = health_component.health
if PlayerInfo.player_health <= 0:
#PlayerInfo.player_health = health_component.health
player_data.player_health = health_component.health
print ("Got Hurt, What happend: " , PlayerInfo.get_player_data(player_info_index).player_health, " vs ", player_data.player_health)
if health_component.health <= 0:
return
yield( get_tree().create_timer(2 + movement_state_machine.get_state_reference('hurt').timeout_seconds), "timeout")
$Hurtbox_Component.set_hurtbox(true)

View File

@ -14,12 +14,12 @@ onready var DialogContainerText = $PanelContainer/HSplitContainer/Label
onready var DialogIndicator = $PanelContainer/Polygon2D
onready var health_bar = $HealthBar
onready var health_bar = $PlayerHUD/HealthBar
onready var stamina_bar = $StaminaBar
onready var stamina_bar = $PlayerHUD/StaminaBar
## Cool I can bring this in with a ctrl drag
onready var selected_inventory_items = $"%SelectedInventoryItems"
#onready var selected_inventory_items = $"%SelectedInventoryItems"
var current_pane

View File

@ -1,14 +1,9 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://icon.png" type="Texture" id=1]
[ext_resource path="res://assets/Fonts/QuinqueFive.tres" type="DynamicFont" id=2]
[ext_resource path="res://src/ui/HUD.gd" type="Script" id=3]
[ext_resource path="res://assets/UI/Healthbar.png" type="Texture" id=4]
[ext_resource path="res://src/ui/HealthBar.gd" type="Script" id=5]
[ext_resource path="res://assets/UI/Healthbar-Indicator.png" type="Texture" id=6]
[ext_resource path="res://assets/UI/Staminabar-Indicator.png" type="Texture" id=7]
[ext_resource path="res://src/ui/SelectedInventoryItems.gd" type="Script" id=8]
[ext_resource path="res://src/ui/StaminaBar.gd" type="Script" id=9]
[ext_resource path="res://src/ui/PlayerHUD.tscn" type="PackedScene" id=4]
[node name="HUD" type="CanvasLayer"]
pause_mode = 2
@ -52,28 +47,6 @@ scale = Vector2( 0.769547, 0.833333 )
color = Color( 0.533333, 0.533333, 0.533333, 1 )
polygon = PoolVector2Array( 294, 63, 300.177, 63, 307, 63, 300.503, 69 )
[node name="HealthBar" type="TextureProgress" parent="."]
margin_left = 2.0
margin_top = 2.0
margin_right = 104.0
margin_bottom = 14.0
value = 50.0
texture_under = ExtResource( 4 )
texture_progress = ExtResource( 6 )
texture_progress_offset = Vector2( 1, 1 )
script = ExtResource( 5 )
[node name="StaminaBar" type="TextureProgress" parent="."]
margin_left = 2.0
margin_top = 14.0
margin_right = 104.0
margin_bottom = 14.0
value = 50.0
texture_under = ExtResource( 4 )
texture_progress = ExtResource( 7 )
texture_progress_offset = Vector2( 1, 1 )
script = ExtResource( 9 )
[node name="Debug" type="Label" parent="."]
anchor_left = 1.0
anchor_right = 1.0
@ -85,49 +58,4 @@ custom_fonts/font = ExtResource( 2 )
text = "Foo"
align = 2
[node name="InventoryContainer" type="HSplitContainer" parent="."]
margin_right = 40.0
margin_bottom = 40.0
split_offset = 1
[node name="Primary" type="TextureRect" parent="InventoryContainer"]
margin_right = 1.0
margin_bottom = 40.0
[node name="Secondary" type="TextureRect" parent="InventoryContainer"]
margin_left = 13.0
margin_right = 40.0
margin_bottom = 40.0
[node name="SelectedInventoryItems" type="HBoxContainer" parent="."]
unique_name_in_owner = true
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 2.0
margin_top = -18.0
margin_right = 48.0
margin_bottom = -2.0
rect_clip_content = true
script = ExtResource( 8 )
[node name="PrimaryItem" type="TextureRect" parent="SelectedInventoryItems"]
margin_bottom = 16.0
[node name="Label" type="Label" parent="SelectedInventoryItems/PrimaryItem"]
margin_right = 20.0
margin_bottom = 10.0
custom_fonts/font = ExtResource( 2 )
align = 2
valign = 2
[node name="SecondaryItem" type="TextureRect" parent="SelectedInventoryItems"]
margin_left = 4.0
margin_right = 4.0
margin_bottom = 16.0
[node name="Label" type="Label" parent="SelectedInventoryItems/SecondaryItem"]
margin_right = 20.0
margin_bottom = 10.0
custom_fonts/font = ExtResource( 2 )
align = 2
valign = 2
[node name="PlayerHUD" parent="." instance=ExtResource( 4 )]

View File

@ -5,12 +5,19 @@ extends TextureProgress
# var a = 2
# var b = "text"
var _player_number :int
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func set_player_number(_player_num: int) -> void:
_player_number = _player_num
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
value = PlayerInfo.player_health
if _player_number:
#value = PlayerInfo.player_health
var pd :PlayerData = PlayerInfo.get_player_data(_player_number - 1)
if pd:
value = pd.player_health

22
src/ui/PlayerHUD.gd Normal file
View File

@ -0,0 +1,22 @@
extends Control
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
export var player_number :int = 1
onready var health_bar = $"%HealthBar"
onready var stamina_bar = $"%StaminaBar"
onready var selected_inventory_items = $"%SelectedInventoryItems"
# Called when the node enters the scene tree for the first time.
func _ready():
health_bar.set_player_number(1)
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

70
src/ui/PlayerHUD.tscn Normal file
View File

@ -0,0 +1,70 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://assets/Fonts/QuinqueFive.tres" type="DynamicFont" id=1]
[ext_resource path="res://assets/UI/Staminabar-Indicator.png" type="Texture" id=2]
[ext_resource path="res://assets/UI/Healthbar.png" type="Texture" id=3]
[ext_resource path="res://assets/UI/Healthbar-Indicator.png" type="Texture" id=4]
[ext_resource path="res://src/ui/HealthBar.gd" type="Script" id=5]
[ext_resource path="res://src/ui/SelectedInventoryItems.gd" type="Script" id=6]
[ext_resource path="res://src/ui/StaminaBar.gd" type="Script" id=7]
[ext_resource path="res://src/ui/PlayerHUD.gd" type="Script" id=8]
[node name="PlayerHUD" type="Control"]
margin_right = 320.0
margin_bottom = 180.0
script = ExtResource( 8 )
[node name="HealthBar" type="TextureProgress" parent="."]
unique_name_in_owner = true
margin_left = 2.0
margin_top = 2.0
margin_right = 104.0
margin_bottom = 14.0
value = 50.0
texture_under = ExtResource( 3 )
texture_progress = ExtResource( 4 )
texture_progress_offset = Vector2( 1, 1 )
script = ExtResource( 5 )
[node name="StaminaBar" type="TextureProgress" parent="."]
unique_name_in_owner = true
margin_left = 2.0
margin_top = 14.0
margin_right = 104.0
margin_bottom = 26.0
value = 50.0
texture_under = ExtResource( 3 )
texture_progress = ExtResource( 2 )
texture_progress_offset = Vector2( 1, 1 )
script = ExtResource( 7 )
[node name="SelectedInventoryItems" type="HBoxContainer" parent="."]
unique_name_in_owner = true
anchor_top = 1.0
anchor_bottom = 1.0
margin_top = -16.0
margin_right = 46.0
rect_clip_content = true
script = ExtResource( 6 )
[node name="PrimaryItem" type="TextureRect" parent="SelectedInventoryItems"]
margin_bottom = 16.0
[node name="Label" type="Label" parent="SelectedInventoryItems/PrimaryItem"]
margin_right = 20.0
margin_bottom = 10.0
custom_fonts/font = ExtResource( 1 )
align = 2
valign = 2
[node name="SecondaryItem" type="TextureRect" parent="SelectedInventoryItems"]
margin_left = 4.0
margin_right = 4.0
margin_bottom = 16.0
[node name="Label" type="Label" parent="SelectedInventoryItems/SecondaryItem"]
margin_right = 20.0
margin_bottom = 10.0
custom_fonts/font = ExtResource( 1 )
align = 2
valign = 2

View File

@ -12,6 +12,10 @@ onready var _secondary_item_count = $SecondaryItem/Label
# Called when the node enters the scene tree for the first time.
func _ready():
if primary_item == null:
print("--------WTF is going oN")
else:
print("----------thats find. ")
pass
#secondary_item.texture = PlayerInfo.player_inventory.secondary_selection.inventory_icon