Skip to content

Commit

Permalink
Merge branch 'main' into 22-attach-sounds-to-objects-and-animations
Browse files Browse the repository at this point in the history
  • Loading branch information
Tombleron authored Apr 7, 2023
2 parents 5d02484 + 3481897 commit 876ddc6
Show file tree
Hide file tree
Showing 25 changed files with 3,852 additions and 231 deletions.
3 changes: 2 additions & 1 deletion enemies/shadow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ func attack() -> void:
return

var player = get_tree().get_first_node_in_group("Player")
player.receive_damage(damage)
if player != null and player.is_dead == false and World.current_plane == Globals.WorldPlane.COGNITIVE:
player.receive_damage(damage)
7 changes: 7 additions & 0 deletions enemies/shadow_master/shadow_master.gd
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ func reach_player(from: Vector3, sight_distance: int) -> Dictionary:
var local_shadow_position := _shadow_position_to_grid_coords(from)
var path := astar_grid.get_id_path(local_shadow_position, local_player_position)

if path.size() < 2:
return {
"next_step": Vector2i.ZERO,
"see_player": false,
"reached": false
}

var shadow_offset := Vector3(
path[1].x - local_shadow_position.x,
0.0,
Expand Down
21 changes: 21 additions & 0 deletions player/gui/death.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extends Node

var player: Player

signal inputed()

func _ready():
player = get_tree().get_first_node_in_group("Player")
player.died.connect(on_player_died)

func _input(event):
inputed.emit()

func _on_tree_exiting():
player.died.disconnect(on_player_died)

func on_player_died() -> void:
self.visible = true
Sfx.stop()
await get_tree().create_timer(5).timeout
get_tree().reload_current_scene()
7 changes: 7 additions & 0 deletions player/gui/gui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ func _input(event: InputEvent) -> void:

func toggle_book() -> void:
Sfx.play("book")

var inventory_item_types: Array = []
for i in Inventory.items.size():
inventory_item_types.push_back(Inventory.items[i].type)
if not inventory_item_types.has(InventoryItem.Type.BOOK):
return

if state == GuiState.BOOK:
book.visible = false
state = GuiState.DEFAULT
Expand Down
5 changes: 4 additions & 1 deletion player/gui/gui.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=13 format=3 uid="uid://bbtltjolwxc65"]
[gd_scene load_steps=14 format=3 uid="uid://bbtltjolwxc65"]

[ext_resource type="FontFile" uid="uid://b0y85cnal68dw" path="res://assets/gui/Davida.ttf" id="1_45prj"]
[ext_resource type="Script" path="res://player/gui/gui.gd" id="2_cnhhr"]
Expand All @@ -7,6 +7,7 @@
[ext_resource type="Texture2D" uid="uid://4ylf4r1nq21q" path="res://icon.svg" id="5_gsdnd"]
[ext_resource type="Script" path="res://player/gui/hud.gd" id="5_q0ini"]
[ext_resource type="PackedScene" uid="uid://bdj8vjtlfrh77" path="res://player/gui/health_point_icon.tscn" id="7_ykuim"]
[ext_resource type="Script" path="res://player/gui/death.gd" id="8_5qwr8"]
[ext_resource type="Script" path="res://player/gui/pause.gd" id="8_g38fo"]

[sub_resource type="Theme" id="Theme_ojf0e"]
Expand Down Expand Up @@ -160,6 +161,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("8_5qwr8")

[node name="Panel" type="Panel" parent="Death"]
layout_mode = 1
Expand Down Expand Up @@ -247,5 +249,6 @@ text = "Exit"
[connection signal="tree_exited" from="HUD" to="HUD" method="_on_tree_exited"]
[connection signal="pressed" from="Book/MarginContainer/VBoxContainer/HBoxContainer/PrevPageButton" to="Book" method="_on_prev_page_button_pressed"]
[connection signal="pressed" from="Book/MarginContainer/VBoxContainer/HBoxContainer/NextPageButton" to="Book" method="_on_next_page_button_pressed"]
[connection signal="tree_exiting" from="Pause" to="Pause" method="_on_tree_exiting"]
[connection signal="pressed" from="Pause/PauseController/CenterContainer/VBoxContainer/ResumeButton" to="Pause" method="_on_resume_button_pressed"]
[connection signal="pressed" from="Pause/PauseController/CenterContainer/VBoxContainer/ExitButton" to="Pause" method="_on_exit_button_pressed"]
15 changes: 15 additions & 0 deletions player/gui/pause.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
extends Control

var player: Player

func _ready():
player = get_tree().get_first_node_in_group("Player")
player.died.connect(on_player_died)

func _on_tree_exiting():
player.died.disconnect(on_player_died)


func _on_resume_button_pressed() -> void:
resume_game()
Expand All @@ -9,6 +18,10 @@ func _on_exit_button_pressed() -> void:
get_tree().quit()


func on_player_died() -> void:
queue_free()


func _input(event: InputEvent) -> void:
if event.is_action_pressed("pause"):
if get_tree().paused:
Expand All @@ -25,3 +38,5 @@ func resume_game() -> void:
func stop_game() -> void:
self.visible = true
get_tree().paused = true


2 changes: 1 addition & 1 deletion player/hand/hand_animation.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func on_spell_chooosed(spell_type: Globals.SpellType) -> void:
particles.process_material.color = Color.MEDIUM_PURPLE
Globals.SpellType.TIMESTOP:
particles.process_material.color = Color.BLACK
Globals.SpellType.WIND:
Globals.SpellType.LOCKPICK:
particles.process_material.color = Color.LIGHT_CYAN

state_machine.travel("OpenPalm")
Expand Down
5 changes: 2 additions & 3 deletions player/hand/hand_with_ring.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ states/Shaking/node = SubResource("AnimationNodeAnimation_02uwb")
states/Shaking/position = Vector2(549, 50)
states/Start/position = Vector2(216, 156)
transitions = ["Start", "Calm", SubResource("AnimationNodeStateMachineTransition_28s1e"), "Calm", "Focus", SubResource("AnimationNodeStateMachineTransition_1c2rv"), "Focus", "Shaking", SubResource("AnimationNodeStateMachineTransition_on0ju"), "Shaking", "Drop", SubResource("AnimationNodeStateMachineTransition_sdrhg"), "Drop", "Calm", SubResource("AnimationNodeStateMachineTransition_4ta65"), "Calm", "OpenPalm", SubResource("AnimationNodeStateMachineTransition_kg7ws"), "OpenPalm", "PalmShaking", SubResource("AnimationNodeStateMachineTransition_jk1tv"), "PalmShaking", "Cast", SubResource("AnimationNodeStateMachineTransition_ljk1q"), "PalmShaking", "Calm", SubResource("AnimationNodeStateMachineTransition_dm2w2"), "Cast", "PalmShaking", SubResource("AnimationNodeStateMachineTransition_elc36")]
graph_offset = Vector2(-65, 99.3348)
graph_offset = Vector2(-84, 11.3348)

[sub_resource type="AnimationNodeStateMachinePlayback" id="AnimationNodeStateMachinePlayback_gw4rh"]

Expand Down Expand Up @@ -1180,6 +1180,7 @@ tracks/22/keys = PackedFloat32Array(0, 1, 0.045988, 0.116805, -0.159748, 0.97914
[sub_resource type="Animation" id="Animation_medp8"]
resource_name = "Calm"
length = 4.0
loop_mode = 1
tracks/0/type = "rotation_3d"
tracks/0/imported = true
tracks/0/enabled = true
Expand Down Expand Up @@ -2768,5 +2769,3 @@ amount = 32
lifetime = 0.3
process_material = SubResource("ParticleProcessMaterial_x7m28")
draw_pass_1 = SubResource("QuadMesh_75nrd")

[connection signal="tree_exited" from="AnimationTree" to="AnimationTree" method="_on_tree_exited"]
2,577 changes: 2,577 additions & 0 deletions player/hand/hand_without_ring.tscn

Large diffs are not rendered by default.

35 changes: 28 additions & 7 deletions player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ const INTERACT_RAY_LENGTH: float = 3.0
@onready var shadesmar_env: Environment = load("res://player/shadesmar_env.tres")
@onready var gui: GUI = $GUI

@onready var hand_ring: Node3D = $Body/hand_with_ring
@onready var hand: Node3D = $Body/hand_without_ring

var can_input: bool = true:
get:
return (not is_jumping) and (transition_tween == null or not transition_tween.is_running()) and (not is_spell_delay)
return (not is_jumping) and (transition_tween == null or not transition_tween.is_running()) and (not is_spell_delay) and (not is_dead)

enum Movement {
ROTATE_LEFT,
Expand All @@ -44,11 +47,15 @@ var transition_tween: Tween

var last_transition: Movement = -1
var is_jumping: bool = false
var is_dead: bool = false
var is_spell_delay: bool = false
var spell_delay_time: float = 0.5

var transition_queue: Array = []

func _ready():
Globals.player_position = global_position

func _input(event: InputEvent) -> void:
if can_input == false:
return
Expand All @@ -67,7 +74,11 @@ func _input(event: InputEvent) -> void:
want_interact = true

if event.is_action_pressed("jump_to_plane"):
effects.play("hop")
var inventory_item_types: Array = []
for i in Inventory.items.size():
inventory_item_types.push_back(Inventory.items[i].type)
if inventory_item_types.has(InventoryItem.Type.RING):
effects.play("hop")

var transition = get_pressed_movement_transition()
if transition == -1:
Expand All @@ -79,6 +90,9 @@ func _input(event: InputEvent) -> void:
add_transition(transition)

func _process(delta: float) -> void:
if Input.is_key_pressed(KEY_1):
receive_damage(2)

if want_interact:
interact()

Expand Down Expand Up @@ -228,8 +242,12 @@ func receive_damage(amount: int) -> void:
print("Player damaged by " + str(amount))

func die():
died.emit() # todo respawn.
queue_free()
Inventory.items.clear()
World.current_plane = Globals.WorldPlane.MATERIAL
global_position.y += 1000000
died.emit()
is_dead = true
#queue_free()

# Interaction functions
# --------------------------------------------------------------------------------------------------
Expand All @@ -250,9 +268,12 @@ func interact() -> void:
intersection.collider.interacted.emit(null)
print("hit some shit")

if intersection.collider is InventoryItem and intersection.collider.type == InventoryItem.Type.BOOK:
gui.toggle_book()

if intersection.collider is InventoryItem:
if intersection.collider.type == InventoryItem.Type.BOOK:
gui.toggle_book()
elif intersection.collider.type == InventoryItem.Type.RING:
hand.visible = false
hand_ring.visible = true

want_interact = false

Expand Down
7 changes: 5 additions & 2 deletions player/player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[ext_resource type="PackedScene" uid="uid://cq2cbtc63fkp7" path="res://spells/fire_spell.tscn" id="6_7r8ka"]
[ext_resource type="Script" path="res://player/speech_recognition.gd" id="6_gxi0n"]
[ext_resource type="PackedScene" uid="uid://cynjrogfl7ks2" path="res://player/hand/hand_with_ring.tscn" id="7_j8jkj"]
[ext_resource type="PackedScene" uid="uid://bdptjf5n1xaqu" path="res://spells/wind_spell.tscn" id="8_f7els"]
[ext_resource type="PackedScene" uid="uid://dug0lui71my67" path="res://player/hand/hand_without_ring.tscn" id="10_ykexg"]
[ext_resource type="PackedScene" uid="uid://y8o54gbbmy7x" path="res://spells/repair_spell.tscn" id="11_mvv62"]
[ext_resource type="PackedScene" uid="uid://die2clnm3gt6u" path="res://spells/destruct_spell.tscn" id="13_mm8ql"]
[ext_resource type="PackedScene" uid="uid://dpe3c4jm65lo1" path="res://spells/timestop_spell.tscn" id="16_opg8d"]
Expand Down Expand Up @@ -342,8 +342,12 @@ target_position = Vector3(0, 0, -2)
collision_mask = 65
collide_with_areas = true

[node name="hand_without_ring" parent="Body" instance=ExtResource("10_ykexg")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0.2)

[node name="hand_with_ring" parent="Body" node_paths=PackedStringArray("spell_caster") instance=ExtResource("7_j8jkj")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0.2)
visible = false
spell_caster = NodePath("../../SpellCaster")

[node name="HitBox" type="Area3D" parent="Body"]
Expand All @@ -357,7 +361,6 @@ shape = SubResource("CapsuleShape3D_2q3p1")
script = ExtResource("5_jpbmn")
fire_spell_scene = ExtResource("6_7r8ka")
destruct_spell_scene = ExtResource("13_mm8ql")
wind_spell_scene = ExtResource("8_f7els")
repair_spell_scene = ExtResource("11_mvv62")
timestop_spell_scene = ExtResource("16_opg8d")
teleport_spell_scene = ExtResource("17_c6sm3")
Expand Down
2 changes: 1 addition & 1 deletion player/speech_recognition.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extends Node
@export var spells = {
"fire": Globals.SpellType.FIRE,
"destruction": Globals.SpellType.DESTRUCT,
"wind": Globals.SpellType.WIND,
"lockpick": Globals.SpellType.LOCKPICK,
"repair": Globals.SpellType.REPAIR,
"time": Globals.SpellType.TIMESTOP,
"teleport": Globals.SpellType.TELEPORT
Expand Down
6 changes: 3 additions & 3 deletions player/spell_caster.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ signal choose_canceled()

@export var fire_spell_scene: PackedScene
@export var destruct_spell_scene: PackedScene
@export var wind_spell_scene: PackedScene
@export var lockpick_spell_scene: PackedScene
@export var repair_spell_scene: PackedScene
@export var timestop_spell_scene: PackedScene
@export var teleport_spell_scene: PackedScene
Expand Down Expand Up @@ -63,8 +63,8 @@ func get_spell(spell_type: Globals.SpellType) -> Spell:
return fire_spell_scene.instantiate()
Globals.SpellType.DESTRUCT:
return destruct_spell_scene.instantiate()
Globals.SpellType.WIND:
return wind_spell_scene.instantiate()
Globals.SpellType.LOCKPICK:
return lockpick_spell_scene.instantiate()
Globals.SpellType.REPAIR:
return repair_spell_scene.instantiate()
Globals.SpellType.TIMESTOP:
Expand Down
2 changes: 1 addition & 1 deletion singletons/globals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum WorldPlane {
enum SpellType{
FIRE = 0,
DESTRUCT,
WIND,
LOCKPICK,
REPAIR,
TIMESTOP,
TELEPORT,
Expand Down
4 changes: 2 additions & 2 deletions singletons/inventory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ extends Node

func pick_item(inventory_item: InventoryItem):
var inventory_item_types: Array = []
for i in Inventory.items.size():
inventory_item_types.push_back(Inventory.items[i].type)
for i in items.size():
inventory_item_types.push_back(items[i].type)

if inventory_item.type != InventoryItem.Type.CRYSTAL:
if inventory_item_types.has(inventory_item.type) == false:
Expand Down
2 changes: 1 addition & 1 deletion speech_recognition/spells.dict
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fire K AA T UW N
destruction AH V AA D AH K EH D AA V R AH
wind K AH B AE B
lock K AH B AE B
repair HH OW K AH S P OW K AH S
time T AY M
teleport T EH L AH P AO R T
14 changes: 7 additions & 7 deletions spells/wind_spell.tscn → spells/lockpick_spell.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_scene load_steps=14 format=3 uid="uid://bdptjf5n1xaqu"]

[ext_resource type="Script" path="res://spells/spell.gd" id="1_nry0b"]
[ext_resource type="Texture2D" uid="uid://brsqvwcjo0v73" path="res://assets/textures/air.png" id="2_8dvd8"]
[ext_resource type="AudioStream" uid="uid://c0ihqvycfkon1" path="res://assets/sounds/sfx/air.wav" id="3_q0w07"]
[ext_resource type="Script" path="res://spells/spell.gd" id="1_eejm6"]
[ext_resource type="Texture2D" uid="uid://brsqvwcjo0v73" path="res://assets/textures/air.png" id="2_qrw2h"]
[ext_resource type="AudioStream" uid="uid://c0ihqvycfkon1" path="res://assets/sounds/sfx/air.wav" id="3_1o3qs"]

[sub_resource type="SphereShape3D" id="SphereShape3D_huiik"]
radius = 0.25
Expand Down Expand Up @@ -31,7 +31,7 @@ transparency = 1
blend_mode = 1
shading_mode = 0
albedo_color = Color(1, 1, 1, 0.254902)
albedo_texture = ExtResource("2_8dvd8")
albedo_texture = ExtResource("2_qrw2h")
billboard_mode = 3
particles_anim_h_frames = 1
particles_anim_v_frames = 1
Expand Down Expand Up @@ -80,7 +80,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0, 0.4, 0.6, 0.9),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Vector2(1, 1), Vector2(2, 2), Vector2(2, 5), Vector2(1, 1)]
"values": [Vector2(1, 1), Vector2(5, 5), Vector2(5, 5), Vector2(1, 1)]
}
tracks/1/type = "value"
tracks/1/imported = false
Expand Down Expand Up @@ -118,7 +118,7 @@ tracks/3/keys = {
"clips": [{
"end_offset": 0.0,
"start_offset": 0.0,
"stream": ExtResource("3_q0w07")
"stream": ExtResource("3_1o3qs")
}],
"times": PackedFloat32Array(0)
}
Expand Down Expand Up @@ -160,7 +160,7 @@ _data = {

[node name="WindSpell" type="Area3D"]
collision_layer = 0
script = ExtResource("1_nry0b")
script = ExtResource("1_eejm6")
type = 2

[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
Expand Down
Loading

0 comments on commit 876ddc6

Please sign in to comment.