Compare commits
No commits in common. "2e30a20389b590fb43c8042a8d8143ad90b6900a" and "a0d3ded1853a0a1bf50645d62b4d62711155f73b" have entirely different histories.
2e30a20389
...
a0d3ded185
|
|
@ -25,4 +25,3 @@ script = ExtResource( 1 )
|
||||||
name = "mushroom"
|
name = "mushroom"
|
||||||
inventory_icon = ExtResource( 3 )
|
inventory_icon = ExtResource( 3 )
|
||||||
in_game_sprite = SubResource( 3 )
|
in_game_sprite = SubResource( 3 )
|
||||||
consumable = true
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 153 B |
|
|
@ -1,35 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="StreamTexture"
|
|
||||||
path="res://.import/fist.png-706e5fdb4c3a8f903a9552e9097a3a72.stex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/items/fist.png"
|
|
||||||
dest_files=[ "res://.import/fist.png-706e5fdb4c3a8f903a9552e9097a3a72.stex" ]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_mode=0
|
|
||||||
compress/bptc_ldr=0
|
|
||||||
compress/normal_map=0
|
|
||||||
flags/repeat=0
|
|
||||||
flags/filter=false
|
|
||||||
flags/mipmaps=false
|
|
||||||
flags/anisotropic=false
|
|
||||||
flags/srgb=2
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/HDR_as_SRGB=false
|
|
||||||
process/invert_color=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
stream=false
|
|
||||||
size_limit=0
|
|
||||||
detect_3d=true
|
|
||||||
svg/scale=1.0
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
[gd_resource type="Resource" load_steps=3 format=2]
|
|
||||||
|
|
||||||
[ext_resource path="res://src/classes/item.gd" type="Script" id=1]
|
|
||||||
[ext_resource path="res://assets/items/fist.png" type="Texture" id=2]
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
name = "punch"
|
|
||||||
inventory_icon = ExtResource( 2 )
|
|
||||||
consumable = false
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 179 B |
|
|
@ -1,35 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="StreamTexture"
|
|
||||||
path="res://.import/sword.png-847a038487b8fb3480b77e98fb70eb52.stex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/items/sword.png"
|
|
||||||
dest_files=[ "res://.import/sword.png-847a038487b8fb3480b77e98fb70eb52.stex" ]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_mode=0
|
|
||||||
compress/bptc_ldr=0
|
|
||||||
compress/normal_map=0
|
|
||||||
flags/repeat=0
|
|
||||||
flags/filter=false
|
|
||||||
flags/mipmaps=false
|
|
||||||
flags/anisotropic=false
|
|
||||||
flags/srgb=2
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/HDR_as_SRGB=false
|
|
||||||
process/invert_color=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
stream=false
|
|
||||||
size_limit=0
|
|
||||||
detect_3d=true
|
|
||||||
svg/scale=1.0
|
|
||||||
|
|
@ -10,7 +10,6 @@ export var debug_state_machine: bool = false
|
||||||
signal state_changed(old_state_name, new_state)
|
signal state_changed(old_state_name, new_state)
|
||||||
signal modifiers_updated(modifier_type, modifier_eventid)
|
signal modifiers_updated(modifier_type, modifier_eventid)
|
||||||
|
|
||||||
|
|
||||||
var current_state: State
|
var current_state: State
|
||||||
var state_modifiers: Array
|
var state_modifiers: Array
|
||||||
onready var merged_animation_state_modifiers :StateModifierAnimatedActor = StateModifierAnimatedActor.new()
|
onready var merged_animation_state_modifiers :StateModifierAnimatedActor = StateModifierAnimatedActor.new()
|
||||||
|
|
@ -97,15 +96,6 @@ func change_to_known_state(new_state_name: String) -> void:
|
||||||
push_warning(get_parent().name + ": Attempt to switch state to unknown: " + new_state_name)
|
push_warning(get_parent().name + ": Attempt to switch state to unknown: " + new_state_name)
|
||||||
change_state(states_index["default"])
|
change_state(states_index["default"])
|
||||||
|
|
||||||
func check_parent_before_state_change(new_state_name: String) -> bool:
|
|
||||||
##TODO: Make this a verifiable funcref or something
|
|
||||||
if get_parent().has_method("check_state_change"):
|
|
||||||
var _check_result = get_parent().check_state_change(new_state_name)
|
|
||||||
if _check_result:
|
|
||||||
change_to_known_state(new_state_name)
|
|
||||||
return true
|
|
||||||
return false
|
|
||||||
|
|
||||||
func get_state_reference(state_name: String) -> State:
|
func get_state_reference(state_name: String) -> State:
|
||||||
print ("what you want? ", state_name)
|
print ("what you want? ", state_name)
|
||||||
if states_index.has(state_name):
|
if states_index.has(state_name):
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
extends Movement_StateReceiver
|
extends Movement_StateReceiver
|
||||||
|
|
||||||
var parent_request_state_change :FuncRef
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var state_ref :State
|
var state_ref :State
|
||||||
var state_name :String
|
var state_name :String
|
||||||
|
|
@ -9,7 +7,7 @@ func _ready():
|
||||||
state_ref = get_node(callable_state_machine).get_state_reference(state_name)
|
state_ref = get_node(callable_state_machine).get_state_reference(state_name)
|
||||||
#TODO Should probably assert here or something.
|
#TODO Should probably assert here or something.
|
||||||
state_ref.connect("state_entered", self, "_on_state_entered_" + state_name)
|
state_ref.connect("state_entered", self, "_on_state_entered_" + state_name)
|
||||||
parent_request_state_change = funcref(get_node(callable_state_machine), 'check_parent_before_state_change')
|
|
||||||
# Lets see if this nutty thing works
|
# Lets see if this nutty thing works
|
||||||
# var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
|
# var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
|
||||||
# state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
# state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
||||||
|
|
@ -43,13 +41,13 @@ func wants_crouch() -> bool:
|
||||||
_wants_crouch = false
|
_wants_crouch = false
|
||||||
return false
|
return false
|
||||||
|
|
||||||
var _wants_attack_primary :bool
|
var _wants_shoot :bool
|
||||||
func wants_attack_primary() -> bool:
|
func wants_shoot() -> bool:
|
||||||
if Input.is_action_just_pressed("attack_" + str(player_number)):
|
if Input.is_action_just_pressed("attack_" + str(player_number)):
|
||||||
_wants_attack_primary = true
|
_wants_shoot = true
|
||||||
return true
|
return true
|
||||||
else:
|
else:
|
||||||
_wants_attack_primary = false
|
_wants_shoot = false
|
||||||
return false
|
return false
|
||||||
|
|
||||||
var _wants_attack_secondary :bool
|
var _wants_attack_secondary :bool
|
||||||
|
|
@ -107,7 +105,7 @@ func process_physics_input(delta):
|
||||||
get_movement_direction()
|
get_movement_direction()
|
||||||
wants_jump()
|
wants_jump()
|
||||||
wants_crouch()
|
wants_crouch()
|
||||||
wants_attack_primary()
|
wants_shoot()
|
||||||
wants_attack_secondary()
|
wants_attack_secondary()
|
||||||
wants_dash()
|
wants_dash()
|
||||||
wants_roll()
|
wants_roll()
|
||||||
|
|
@ -134,32 +132,15 @@ func _state_process_physics_idle():
|
||||||
if _wants_roll == true:
|
if _wants_roll == true:
|
||||||
request_state_change.call_func('roll')
|
request_state_change.call_func('roll')
|
||||||
|
|
||||||
if _wants_attack_primary == true:
|
if _wants_shoot == true:
|
||||||
#request_state_change.call_func('attack_shoot')
|
request_state_change.call_func('attack_shoot')
|
||||||
attack_primary()
|
|
||||||
|
|
||||||
if _wants_attack_secondary == true:
|
if _wants_attack_secondary == true:
|
||||||
#parent_request_state_change.call_func('attack_sword')
|
request_state_change.call_func('attack_sword')
|
||||||
attack_secondary()
|
|
||||||
|
|
||||||
if $"../LadderDetector".is_colliding() and _wants_climb == true:
|
if $"../LadderDetector".is_colliding() and _wants_climb == true:
|
||||||
request_state_change.call_func('climb')
|
request_state_change.call_func('climb')
|
||||||
|
|
||||||
func attack_primary():
|
|
||||||
##Another thing I wish I could avoid the funcref or string call
|
|
||||||
if get_parent().has_method("primary_item"):
|
|
||||||
var _item_state_name :String = get_parent().primary_item()
|
|
||||||
if _item_state_name != '':
|
|
||||||
request_state_change.call_func(_item_state_name)
|
|
||||||
|
|
||||||
|
|
||||||
func attack_secondary():
|
|
||||||
if get_parent().has_method("secondary_item"):
|
|
||||||
var _item_state_name :String = get_parent().secondary_item()
|
|
||||||
if _item_state_name != '':
|
|
||||||
request_state_change.call_func(_item_state_name)
|
|
||||||
|
|
||||||
|
|
||||||
func _state_process_physics_attack_shoot():
|
func _state_process_physics_attack_shoot():
|
||||||
if current_state.animation_finished == true:
|
if current_state.animation_finished == true:
|
||||||
request_state_change.call_func('idle')
|
request_state_change.call_func('idle')
|
||||||
|
|
@ -168,13 +149,6 @@ func _state_process_physics_attack_shoot():
|
||||||
#return fall_state
|
#return fall_state
|
||||||
request_state_change.call_func('fall')
|
request_state_change.call_func('fall')
|
||||||
|
|
||||||
func _state_process_physics_attack_punch():
|
|
||||||
if current_state.animation_finished == true:
|
|
||||||
request_state_change.call_func('idle')
|
|
||||||
|
|
||||||
if !parent.is_on_floor():
|
|
||||||
#return fall_state
|
|
||||||
request_state_change.call_func('fall')
|
|
||||||
|
|
||||||
func _state_process_physics_attack_sword():
|
func _state_process_physics_attack_sword():
|
||||||
if current_state.animation_finished == true:
|
if current_state.animation_finished == true:
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export var player_number: int = 1
|
||||||
|
|
||||||
onready var player_inventory :InventoryManager = InventoryManager.new()
|
onready var player_inventory :InventoryManager = InventoryManager.new()
|
||||||
|
|
||||||
var punch_item :Item = preload("res://assets/items/punch.tres")
|
#var mushroom :Item = preload("res://assets/items/doodad.tres")
|
||||||
|
|
||||||
# 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():
|
func _ready():
|
||||||
|
|
@ -17,8 +17,8 @@ func _ready():
|
||||||
# Set initial player position in world.
|
# Set initial player position in world.
|
||||||
global_position = LevelInfo.player_start_position
|
global_position = LevelInfo.player_start_position
|
||||||
|
|
||||||
player_inventory.add_to_inventory(punch_item)
|
# player_inventory.add_to_inventory(mushroom)
|
||||||
player_inventory.select_primary(punch_item)
|
# player_inventory.select_primary(mushroom)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -56,41 +56,6 @@ func touch_the_thing(the_thing: Interactable) -> bool:
|
||||||
the_thing.trigger_interaction()
|
the_thing.trigger_interaction()
|
||||||
if the_thing is ItemPickup:
|
if the_thing is ItemPickup:
|
||||||
player_inventory.add_to_inventory(the_thing.item)
|
player_inventory.add_to_inventory(the_thing.item)
|
||||||
player_inventory.select_secondary(the_thing.item)
|
player_inventory.select_primary(the_thing.item)
|
||||||
the_thing.trigger_interaction()
|
the_thing.trigger_interaction()
|
||||||
return true
|
return true
|
||||||
|
|
||||||
var state_to_item_map :Dictionary = {
|
|
||||||
"sword": "attack_sword" ,
|
|
||||||
"gun": "attack_shoot",
|
|
||||||
"punch" : "attack_punch",
|
|
||||||
"mushroom" : "attack_shoot"
|
|
||||||
}
|
|
||||||
|
|
||||||
##TODO: We need to find a way to 'use' the item.
|
|
||||||
func primary_item() -> String:
|
|
||||||
if player_inventory.primary_selection.consumable == false:
|
|
||||||
if state_to_item_map.has(player_inventory.primary_selection.name):
|
|
||||||
player_inventory.remove_from_inventory(player_inventory.primary_selection)
|
|
||||||
return state_to_item_map[player_inventory.primary_selection.name]
|
|
||||||
return ''
|
|
||||||
|
|
||||||
func secondary_item() -> String:
|
|
||||||
if player_inventory.secondary_selection != null: # Have to make sure we even have a second
|
|
||||||
var _item_name :String = player_inventory.secondary_selection.name
|
|
||||||
if state_to_item_map.has(_item_name):
|
|
||||||
player_inventory.remove_from_inventory(player_inventory.secondary_selection)
|
|
||||||
return state_to_item_map[_item_name]
|
|
||||||
|
|
||||||
return ''
|
|
||||||
|
|
||||||
func check_state_change(_new_state_name: String) -> bool:
|
|
||||||
match _new_state_name:
|
|
||||||
"attack_sword":
|
|
||||||
print("nope.")
|
|
||||||
return false
|
|
||||||
"attack_shoot":
|
|
||||||
return true
|
|
||||||
_: # None
|
|
||||||
return true
|
|
||||||
return true
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=34 format=2]
|
[gd_scene load_steps=33 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
|
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
[ext_resource path="res://lib/classes/sound_effect_state_frame.gd" type="Script" id=24]
|
[ext_resource path="res://lib/classes/sound_effect_state_frame.gd" type="Script" id=24]
|
||||||
[ext_resource path="res://assets_tmp/SE/tap.wav" type="AudioStream" id=25]
|
[ext_resource path="res://assets_tmp/SE/tap.wav" type="AudioStream" id=25]
|
||||||
[ext_resource path="res://assets_tmp/SE/land.wav" type="AudioStream" id=26]
|
[ext_resource path="res://assets_tmp/SE/land.wav" type="AudioStream" id=26]
|
||||||
[ext_resource path="res://src/actors/players/playerE/states/attack_punch.tres" type="Resource" id=27]
|
|
||||||
|
|
||||||
[sub_resource type="Resource" id=3]
|
[sub_resource type="Resource" id=3]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
|
|
@ -79,7 +78,7 @@ player_number = 1
|
||||||
|
|
||||||
[node name="Movement_StateMachine" parent="." index="0"]
|
[node name="Movement_StateMachine" parent="." index="0"]
|
||||||
starting_state_name = "idle"
|
starting_state_name = "idle"
|
||||||
states = [ ExtResource( 4 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 10 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ), SubResource( 3 ), ExtResource( 19 ), ExtResource( 20 ), ExtResource( 22 ), ExtResource( 23 ), ExtResource( 27 ) ]
|
states = [ ExtResource( 4 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 10 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ), SubResource( 3 ), ExtResource( 19 ), ExtResource( 20 ), ExtResource( 22 ), ExtResource( 23 ) ]
|
||||||
|
|
||||||
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
||||||
frames = ExtResource( 2 )
|
frames = ExtResource( 2 )
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
[gd_resource type="Resource" load_steps=2 format=2]
|
|
||||||
|
|
||||||
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
resource_local_to_scene = true
|
|
||||||
resource_name = "attack_punch"
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
debug_state = false
|
|
||||||
timeout_seconds = 0.0
|
|
||||||
name = "attack_punch"
|
|
||||||
horizontal_speed = 1.36422e-12
|
|
||||||
horizontal_acceleration = 0.0
|
|
||||||
horizontal_speed_offset = 0.0
|
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
|
||||||
jerk_factor = 0.0
|
|
||||||
animation_sequence = [ "attack-punch" ]
|
|
||||||
|
|
@ -39,21 +39,12 @@ func add_to_inventory(_item :Item) -> int:
|
||||||
|
|
||||||
func remove_from_inventory (_item :Item) -> int:
|
func remove_from_inventory (_item :Item) -> int:
|
||||||
if _items.has(_item):
|
if _items.has(_item):
|
||||||
if _item.consumable:
|
_items[_item] -= 1
|
||||||
## Reduce inventory for item
|
if _items[_item] == 0:
|
||||||
_items[_item] -= 1
|
_items.erase(_item)
|
||||||
if _items[_item] == 0: ## Item count 0, no inentory
|
return 0
|
||||||
if primary_selection == _item:
|
|
||||||
primary_selection = null
|
|
||||||
if secondary_selection == _item:
|
|
||||||
secondary_selection = null
|
|
||||||
_items.erase(_item) ## Remove it
|
|
||||||
return 0
|
|
||||||
else:
|
|
||||||
return _items[_item] ## Return item count
|
|
||||||
else:
|
else:
|
||||||
## Non consumables don't get cleared out.
|
return _items[_item]
|
||||||
return 1
|
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ extends Resource
|
||||||
export var name :String
|
export var name :String
|
||||||
export var inventory_icon :Texture
|
export var inventory_icon :Texture
|
||||||
export var in_game_sprite :SpriteFrames
|
export var in_game_sprite :SpriteFrames
|
||||||
export var consumable :bool = true
|
|
||||||
|
|
||||||
# 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():
|
func _ready():
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,4 @@ func _ready():
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if (PlayerInfo.player_inventory.primary_selection):
|
if (PlayerInfo.player_inventory.primary_selection):
|
||||||
primary_item.texture = PlayerInfo.player_inventory.primary_selection.inventory_icon
|
primary_item.texture = PlayerInfo.player_inventory.primary_selection.inventory_icon
|
||||||
else:
|
|
||||||
primary_item.texture = null
|
|
||||||
|
|
||||||
if (PlayerInfo.player_inventory.secondary_selection):
|
|
||||||
secondary_item.texture = PlayerInfo.player_inventory.secondary_selection.inventory_icon
|
|
||||||
else:
|
|
||||||
secondary_item.texture = null
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user