From 220ca2886f25ff4ab15d9a4ca33ce8b1f081c519 Mon Sep 17 00:00:00 2001 From: Clevertop Date: Sat, 10 Aug 2024 22:24:26 +1000 Subject: [PATCH] pedestals light up --- Commands/command_pedestal.gd | 2 ++ Commands/command_pedestal.tscn | 3 ++- Levels/StartingRoom.tscn | 9 ++++++--- Scripts/ChronoManager.gd | 30 +++++++++++++++++++++++++++++- project.godot | 5 +++++ 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/Commands/command_pedestal.gd b/Commands/command_pedestal.gd index 12d34c2..07842ee 100644 --- a/Commands/command_pedestal.gd +++ b/Commands/command_pedestal.gd @@ -4,10 +4,12 @@ class_name Pedestal @export var placed_command : Node3D @export var has_command : bool = false @export var slot : Node3D +@export var mesh :MeshInstance3D # Called when the node enters the scene tree for the first time. func _ready(): + pass # Replace with function body. diff --git a/Commands/command_pedestal.tscn b/Commands/command_pedestal.tscn index 384a525..fe0cb6c 100644 --- a/Commands/command_pedestal.tscn +++ b/Commands/command_pedestal.tscn @@ -10,10 +10,11 @@ size = Vector3(0.8, 1, 0.8) [sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_8evcs"] data = PackedVector3Array(-0.4, 0.5, 0.4, 0.4, 0.5, 0.4, -0.4, -0.5, 0.4, 0.4, 0.5, 0.4, 0.4, -0.5, 0.4, -0.4, -0.5, 0.4, 0.4, 0.5, -0.4, -0.4, 0.5, -0.4, 0.4, -0.5, -0.4, -0.4, 0.5, -0.4, -0.4, -0.5, -0.4, 0.4, -0.5, -0.4, 0.4, 0.5, 0.4, 0.4, 0.5, -0.4, 0.4, -0.5, 0.4, 0.4, 0.5, -0.4, 0.4, -0.5, -0.4, 0.4, -0.5, 0.4, -0.4, 0.5, -0.4, -0.4, 0.5, 0.4, -0.4, -0.5, -0.4, -0.4, 0.5, 0.4, -0.4, -0.5, 0.4, -0.4, -0.5, -0.4, 0.4, 0.5, 0.4, -0.4, 0.5, 0.4, 0.4, 0.5, -0.4, -0.4, 0.5, 0.4, -0.4, 0.5, -0.4, 0.4, 0.5, -0.4, -0.4, -0.5, 0.4, 0.4, -0.5, 0.4, -0.4, -0.5, -0.4, 0.4, -0.5, 0.4, 0.4, -0.5, -0.4, -0.4, -0.5, -0.4) -[node name="CommandPedestal" type="StaticBody3D" node_paths=PackedStringArray("slot")] +[node name="CommandPedestal" type="StaticBody3D" node_paths=PackedStringArray("slot", "mesh")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0) script = ExtResource("1_02nqv") slot = NodePath("slot") +mesh = NodePath("MeshInstance3D") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] mesh = SubResource("BoxMesh_hrk6g") diff --git a/Levels/StartingRoom.tscn b/Levels/StartingRoom.tscn index 8a7f54b..55936c2 100644 --- a/Levels/StartingRoom.tscn +++ b/Levels/StartingRoom.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=27 format=3 uid="uid://bojbawyoy11i4"] +[gd_scene load_steps=28 format=3 uid="uid://bojbawyoy11i4"] [ext_resource type="Script" path="res://Scripts/ChronoManager.gd" id="1_5b2rd"] [ext_resource type="Material" uid="uid://cr4ra7ijk1uec" path="res://Assets/Materials/floor.tres" id="2_0aj3l"] [ext_resource type="PackedScene" uid="uid://d34smep2ukq7w" path="res://player.tscn" id="2_hsi55"] [ext_resource type="PackedScene" uid="uid://bnlexkofp68gv" path="res://gui.tscn" id="3_60lfp"] +[ext_resource type="Material" uid="uid://didvwdmm46bmq" path="res://Assets/Materials/green_floor.tres" id="3_mnhg8"] [ext_resource type="Texture2D" uid="uid://c1fesrqdpjloa" path="res://Assets/Textures/ice_0_old.png" id="4_v03h0"] [ext_resource type="PackedScene" uid="uid://dqvq4ybcpws87" path="res://Commands/command_block.tscn" id="5_81jk1"] [ext_resource type="Texture2D" uid="uid://dc23iehev1s8w" path="res://Assets/Textures/crystal_wall_2.png" id="6_g3qnb"] @@ -107,6 +108,8 @@ material = SubResource("StandardMaterial3D_itc1d") [node name="ChronoManager" type="Node3D" node_paths=PackedStringArray("gui", "pedestals")] script = ExtResource("1_5b2rd") +pedestal_off_mat = ExtResource("2_0aj3l") +pedestal_on_mat = ExtResource("3_mnhg8") gui = NodePath("Gui") pedestals = [NodePath("Pedestals/CommandPedestal"), NodePath("Pedestals/CommandPedestal2"), NodePath("Pedestals/CommandPedestal3"), NodePath("Pedestals/CommandPedestal4"), NodePath("Pedestals/CommandPedestal5"), NodePath("Pedestals/CommandPedestal6"), NodePath("Pedestals/CommandPedestal7"), NodePath("Pedestals/CommandPedestal8"), NodePath("Pedestals/CommandPedestal9"), NodePath("Pedestals/CommandPedestal10")] @@ -148,10 +151,10 @@ command_sprite = ExtResource("7_qjeey") [node name="Pedestals" type="Node3D" parent="."] [node name="CommandPedestal" parent="Pedestals" instance=ExtResource("10_sghta")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.5, 1, 2.5) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.5, 1, 1.5) [node name="CommandPedestal2" parent="Pedestals" instance=ExtResource("10_sghta")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.5, 1, 1.5) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.5, 1, 2.5) [node name="CommandPedestal3" parent="Pedestals" instance=ExtResource("10_sghta")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.5, 1, 3.5) diff --git a/Scripts/ChronoManager.gd b/Scripts/ChronoManager.gd index e29f63a..b12ab3a 100644 --- a/Scripts/ChronoManager.gd +++ b/Scripts/ChronoManager.gd @@ -6,7 +6,11 @@ signal broadcast(command : String) @export_group("Variables") @export var level_tick : float = 1 # how often to run a command @export var level_time : float = 10 # the amoutn of time allowed for the level - +var tick_timer : float = 0 +var room_started : bool = false +var current_tick = 0 +@export var pedestal_off_mat : Material +@export var pedestal_on_mat : Material @export_group("Node References") @export var gui : Control @@ -14,16 +18,37 @@ signal broadcast(command : String) # Called when the node enters the scene tree for the first time. func _ready(): + for i in pedestals.size(): + pedestals[i].mesh.mesh = pedestals[i].mesh.mesh.duplicate() pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): + if Input.is_action_just_pressed("debug_start"): + start_room() + + if room_started and current_tick < level_time: + tick_timer += delta + + if tick_timer > level_tick: + tick_timer = 0 + current_tick += 1 + print("Tick: " + str(current_tick)) + for i in pedestals.size(): + if i+1 == current_tick: + pedestals[i].mesh.mesh.material = pedestal_on_mat + else: + pass + #pedestals[i].mesh.material pass func start_room(): + print("START") + room_started = true + # open door # start timers # start running commands @@ -32,6 +57,9 @@ func start_room(): func reset_room(): # run if timer expires, resets puzzle + # replace door + # put player back in start room + # reset timers pass func finish_room(): diff --git a/project.godot b/project.godot index 087eaaa..71d3208 100644 --- a/project.godot +++ b/project.godot @@ -58,6 +58,11 @@ drop={ , Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"canceled":false,"pressed":false,"double_click":false,"script":null) ] } +debug_start={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":49,"key_label":0,"unicode":49,"echo":false,"script":null) +] +} [rendering]