Added ColorSwitchingPlatform
This commit is contained in:
@@ -39,19 +39,20 @@ const SHADER_INTENSITY = "shader_parameter/intensity"
|
|||||||
|
|
||||||
@export var object : CollisionObject2D
|
@export var object : CollisionObject2D
|
||||||
|
|
||||||
@export_range(0.0, 60.0, 0.1) var switch_time := 0.0
|
|
||||||
@export var initial_state := State.White
|
@export var initial_state := State.White
|
||||||
|
|
||||||
|
|
||||||
var material : Material:
|
var material : Material:
|
||||||
set(value):
|
set(value):
|
||||||
material = value
|
material = value
|
||||||
_apply_color()
|
if is_node_ready():
|
||||||
|
_apply_color()
|
||||||
|
|
||||||
var _state : State:
|
var _state : State:
|
||||||
set(value):
|
set(value):
|
||||||
_state = value
|
_state = value
|
||||||
_apply_color()
|
if is_node_ready():
|
||||||
|
_apply_color()
|
||||||
|
|
||||||
var _intensity_tween : Tween
|
var _intensity_tween : Tween
|
||||||
|
|
||||||
@@ -71,8 +72,10 @@ func _ready() -> void:
|
|||||||
|
|
||||||
_state = initial_state
|
_state = initial_state
|
||||||
|
|
||||||
|
_apply_color()
|
||||||
|
|
||||||
func switch_color() -> void:
|
|
||||||
|
func switch_color(switch_time := 0.0) -> void:
|
||||||
if _intensity_tween != null and _intensity_tween.is_running(): return #TODO
|
if _intensity_tween != null and _intensity_tween.is_running(): return #TODO
|
||||||
|
|
||||||
if is_zero_approx(switch_time):
|
if is_zero_approx(switch_time):
|
||||||
|
|||||||
@@ -3,5 +3,8 @@ extends AbstractLevel
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
super._ready()
|
super._ready()
|
||||||
$Objects/Lever.switching.connect($Doors/LeverDoor.toggle)
|
$Objects/LeverDoor.switching.connect($Doors/LeverDoor.toggle)
|
||||||
$Objects/Lever.switching.connect($ConnectionCables/ConnectionCable.toggle)
|
$Objects/LeverDoor.switching.connect($ConnectionCables/ConnectionCableDoor.toggle)
|
||||||
|
|
||||||
|
$Objects/LeverPlatform.switching.connect($Platforms/ColorSwitchingPlatform.toggle)
|
||||||
|
$Objects/LeverPlatform.switching.connect($ConnectionCables/ConnectionCablePlatform.toggle)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://jab32eoyc523" path="res://game/platform/moving_platform.tscn" id="4_h1708"]
|
[ext_resource type="PackedScene" uid="uid://jab32eoyc523" path="res://game/platform/moving_platform.tscn" id="4_h1708"]
|
||||||
[ext_resource type="PackedScene" uid="uid://g0n5npbt3hb2" path="res://game/doors/circle_door.tscn" id="4_yrqjd"]
|
[ext_resource type="PackedScene" uid="uid://g0n5npbt3hb2" path="res://game/doors/circle_door.tscn" id="4_yrqjd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cojxqx5al7kyv" path="res://game/doors/locked_door.tscn" id="5_1skah"]
|
[ext_resource type="PackedScene" uid="uid://cojxqx5al7kyv" path="res://game/doors/locked_door.tscn" id="5_1skah"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bwmd8w677p7k3" path="res://game/platform/color_switching_platform.tscn" id="5_a50fq"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dwvv5dj8lqif2" path="res://game/doors/triangle_door.tscn" id="6_75eok"]
|
[ext_resource type="PackedScene" uid="uid://dwvv5dj8lqif2" path="res://game/doors/triangle_door.tscn" id="6_75eok"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b7imlh4sl036i" path="res://game/doors/square_door.tscn" id="7_1skah"]
|
[ext_resource type="PackedScene" uid="uid://b7imlh4sl036i" path="res://game/doors/square_door.tscn" id="7_1skah"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cudbspmpx6sik" path="res://game/pickups/book_pickup.tscn" id="7_fq0h3"]
|
[ext_resource type="PackedScene" uid="uid://cudbspmpx6sik" path="res://game/pickups/book_pickup.tscn" id="7_fq0h3"]
|
||||||
@@ -24,7 +25,6 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://cb0w6mt8g4mer" path="res://game/characters/enemies/gray_cultist.tscn" id="18_blgb8"]
|
[ext_resource type="PackedScene" uid="uid://cb0w6mt8g4mer" path="res://game/characters/enemies/gray_cultist.tscn" id="18_blgb8"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cutjutvd8dqqc" path="res://game/characters/enemies/black_cultist.tscn" id="19_ohfy3"]
|
[ext_resource type="PackedScene" uid="uid://cutjutvd8dqqc" path="res://game/characters/enemies/black_cultist.tscn" id="19_ohfy3"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bv2gahb4wxgb1" path="res://game/characters/enemies/white_cultist.tscn" id="20_rt0xo"]
|
[ext_resource type="PackedScene" uid="uid://bv2gahb4wxgb1" path="res://game/characters/enemies/white_cultist.tscn" id="20_rt0xo"]
|
||||||
[ext_resource type="PackedScene" uid="uid://wpkj48bqyuy2" path="res://game/platform/abstract_color_platform.tscn" id="24_h1708"]
|
|
||||||
|
|
||||||
[sub_resource type="Curve2D" id="Curve2D_h1708"]
|
[sub_resource type="Curve2D" id="Curve2D_h1708"]
|
||||||
_data = {
|
_data = {
|
||||||
@@ -35,23 +35,22 @@ point_count = 2
|
|||||||
[node name="TestLevel" unique_id=600627332 instance=ExtResource("1_15okj")]
|
[node name="TestLevel" unique_id=600627332 instance=ExtResource("1_15okj")]
|
||||||
script = ExtResource("2_a2sw7")
|
script = ExtResource("2_a2sw7")
|
||||||
|
|
||||||
[node name="ConnectionCable" parent="ConnectionCables" parent_id_path=PackedInt32Array(279521385) index="0" unique_id=1234500644 instance=ExtResource("3_a50fq")]
|
[node name="ConnectionCableDoor" parent="ConnectionCables" parent_id_path=PackedInt32Array(279521385) index="0" unique_id=1234500644 instance=ExtResource("3_a50fq")]
|
||||||
position = Vector2(208, 13)
|
position = Vector2(208, 13)
|
||||||
points = PackedVector2Array(0, 0, 92, 0, 92, -49, 199, -49)
|
points = PackedVector2Array(0, 0, 92, 0, 92, -49, 199, -49)
|
||||||
width = 1.0
|
|
||||||
|
|
||||||
[node name="AbstractColoredPlatform" parent="Platforms" parent_id_path=PackedInt32Array(1140671629) index="0" unique_id=137546339 instance=ExtResource("24_h1708")]
|
[node name="ConnectionCablePlatform" parent="ConnectionCables" parent_id_path=PackedInt32Array(279521385) index="1" unique_id=561577961 instance=ExtResource("3_a50fq")]
|
||||||
position = Vector2(274, -81)
|
position = Vector2(520, -35)
|
||||||
platform_width = 48
|
points = PackedVector2Array(0, 0, 0, -76, -454, -76, -454, 3)
|
||||||
|
|
||||||
[node name="SelfMovingPlatform" parent="Platforms" parent_id_path=PackedInt32Array(1140671629) index="1" unique_id=349378100 node_paths=PackedStringArray("path", "path_follow") instance=ExtResource("4_h1708")]
|
[node name="SelfMovingPlatform" parent="Platforms" parent_id_path=PackedInt32Array(1140671629) index="0" unique_id=349378100 node_paths=PackedStringArray("path", "path_follow") instance=ExtResource("4_h1708")]
|
||||||
position = Vector2(201.03143, -75)
|
position = Vector2(201.03143, -75)
|
||||||
rotation = -3.1415925
|
rotation = -3.1415925
|
||||||
path = NodePath("../Path2D")
|
path = NodePath("../Path2D")
|
||||||
path_follow = NodePath("../Path2D/PathFollow2D")
|
path_follow = NodePath("../Path2D/PathFollow2D")
|
||||||
platform_width = 104
|
platform_width = 104
|
||||||
|
|
||||||
[node name="Path2D" type="Path2D" parent="Platforms" parent_id_path=PackedInt32Array(1140671629) index="2" unique_id=1306055237]
|
[node name="Path2D" type="Path2D" parent="Platforms" parent_id_path=PackedInt32Array(1140671629) index="1" unique_id=1306055237]
|
||||||
curve = SubResource("Curve2D_h1708")
|
curve = SubResource("Curve2D_h1708")
|
||||||
|
|
||||||
[node name="PathFollow2D" type="PathFollow2D" parent="Platforms/Path2D" index="0" unique_id=1206016336]
|
[node name="PathFollow2D" type="PathFollow2D" parent="Platforms/Path2D" index="0" unique_id=1206016336]
|
||||||
@@ -63,6 +62,12 @@ rotates = false
|
|||||||
[node name="RemoteTransform2D" type="RemoteTransform2D" parent="Platforms/Path2D/PathFollow2D" index="0" unique_id=1642833722]
|
[node name="RemoteTransform2D" type="RemoteTransform2D" parent="Platforms/Path2D/PathFollow2D" index="0" unique_id=1642833722]
|
||||||
remote_path = NodePath("../../../SelfMovingPlatform")
|
remote_path = NodePath("../../../SelfMovingPlatform")
|
||||||
|
|
||||||
|
[node name="ColorSwitchingPlatform" parent="Platforms" parent_id_path=PackedInt32Array(1140671629) index="2" unique_id=137546339 instance=ExtResource("5_a50fq")]
|
||||||
|
position = Vector2(66, -32)
|
||||||
|
collision_layer = 2
|
||||||
|
initial_color = 1
|
||||||
|
platform_width = 104
|
||||||
|
|
||||||
[node name="LeverDoor" parent="Doors" parent_id_path=PackedInt32Array(1468144392) index="0" unique_id=1575363350 instance=ExtResource("2_r01v2")]
|
[node name="LeverDoor" parent="Doors" parent_id_path=PackedInt32Array(1468144392) index="0" unique_id=1575363350 instance=ExtResource("2_r01v2")]
|
||||||
position = Vector2(416, -56)
|
position = Vector2(416, -56)
|
||||||
|
|
||||||
@@ -102,9 +107,12 @@ position = Vector2(344, -78)
|
|||||||
[node name="SwitchActionTip" parent="Objects" parent_id_path=PackedInt32Array(1320033435) index="4" unique_id=1142055805 instance=ExtResource("12_r01v2")]
|
[node name="SwitchActionTip" parent="Objects" parent_id_path=PackedInt32Array(1320033435) index="4" unique_id=1142055805 instance=ExtResource("12_r01v2")]
|
||||||
position = Vector2(699, -90)
|
position = Vector2(699, -90)
|
||||||
|
|
||||||
[node name="Lever" parent="Objects" parent_id_path=PackedInt32Array(1320033435) index="5" unique_id=1479061220 instance=ExtResource("13_00l78")]
|
[node name="LeverDoor" parent="Objects" parent_id_path=PackedInt32Array(1320033435) index="5" unique_id=1479061220 instance=ExtResource("13_00l78")]
|
||||||
position = Vector2(208, 8)
|
position = Vector2(208, 8)
|
||||||
|
|
||||||
|
[node name="LeverPlatform" parent="Objects" parent_id_path=PackedInt32Array(1320033435) index="6" unique_id=705939742 instance=ExtResource("13_00l78")]
|
||||||
|
position = Vector2(520, -40)
|
||||||
|
|
||||||
[node name="BookPickup" parent="Pickups" parent_id_path=PackedInt32Array(1113969064) index="0" unique_id=261982174 instance=ExtResource("7_fq0h3")]
|
[node name="BookPickup" parent="Pickups" parent_id_path=PackedInt32Array(1113969064) index="0" unique_id=261982174 instance=ExtResource("7_fq0h3")]
|
||||||
position = Vector2(1216, 86)
|
position = Vector2(1216, 86)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
[ext_resource type="Shader" uid="uid://dbsrm43wcolg4" path="res://game/shaders/connection_cable.gdshader" id="1_i3upv"]
|
[ext_resource type="Shader" uid="uid://dbsrm43wcolg4" path="res://game/shaders/connection_cable.gdshader" id="1_i3upv"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
resource_local_to_scene = true
|
||||||
shader = ExtResource("1_i3upv")
|
shader = ExtResource("1_i3upv")
|
||||||
|
shader_parameter/glow_interval = 1.0
|
||||||
shader_parameter/glow_radius = 1.0
|
shader_parameter/glow_radius = 1.0
|
||||||
shader_parameter/travel_time = 5.0
|
shader_parameter/travel_time = 5.0
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
shader = ExtResource("1_p23e2")
|
shader = ExtResource("1_p23e2")
|
||||||
shader_parameter/black_color = Color(0, 0, 0, 1)
|
shader_parameter/black_color = Color(0, 0, 0, 1)
|
||||||
shader_parameter/white_color = Color(1, 1, 1, 1)
|
shader_parameter/white_color = Color(1, 1, 1, 1)
|
||||||
shader_parameter/switch_colors = false
|
shader_parameter/switch_colors = true
|
||||||
shader_parameter/threshold = 0.5
|
shader_parameter/threshold = 0.5
|
||||||
shader_parameter/speed = 1.0
|
shader_parameter/speed = 1.0
|
||||||
shader_parameter/intensity = 1.0
|
shader_parameter/intensity = 1.0
|
||||||
|
|||||||
@@ -5,6 +5,6 @@
|
|||||||
|
|
||||||
[node name="ConnectionCable" type="Line2D" unique_id=1234500644]
|
[node name="ConnectionCable" type="Line2D" unique_id=1234500644]
|
||||||
material = ExtResource("1_k2dc5")
|
material = ExtResource("1_k2dc5")
|
||||||
width = 2.0
|
width = 1.0
|
||||||
texture_mode = 2
|
texture_mode = 2
|
||||||
script = ExtResource("1_43n88")
|
script = ExtResource("1_43n88")
|
||||||
|
|||||||
@@ -3,9 +3,20 @@ class_name AbstractColorPlatform
|
|||||||
extends AbstractPlatform
|
extends AbstractPlatform
|
||||||
|
|
||||||
|
|
||||||
|
enum PlatformColor {
|
||||||
|
White,
|
||||||
|
Black,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@export var initial_color := PlatformColor.White
|
||||||
|
|
||||||
|
|
||||||
@onready var collision_switcher : CollisionSwitcher = $CollisionSwitcher
|
@onready var collision_switcher : CollisionSwitcher = $CollisionSwitcher
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
super._ready()
|
super._ready()
|
||||||
collision_switcher.material = platform_rect.material
|
collision_switcher.material = platform_sprite.material
|
||||||
|
if initial_color == PlatformColor.Black:
|
||||||
|
collision_switcher.switch_color()
|
||||||
|
|||||||
@@ -13,13 +13,6 @@ viewport_path = NodePath("SubViewport")
|
|||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_vbsvi"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_vbsvi"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
shader = ExtResource("4_cdhfe")
|
shader = ExtResource("4_cdhfe")
|
||||||
shader_parameter/black_color = Color(0, 0, 0, 1)
|
|
||||||
shader_parameter/white_color = Color(1, 1, 1, 1)
|
|
||||||
shader_parameter/switch_colors = false
|
|
||||||
shader_parameter/threshold = 0.5
|
|
||||||
shader_parameter/speed = 0.5
|
|
||||||
shader_parameter/intensity = 1.0
|
|
||||||
shader_parameter/scale = 20.0
|
|
||||||
shader_parameter/tile_size = 8.0
|
shader_parameter/tile_size = 8.0
|
||||||
shader_parameter/platform_width = 24.0
|
shader_parameter/platform_width = 24.0
|
||||||
shader_parameter/atlas = ExtResource("5_uk0x1")
|
shader_parameter/atlas = ExtResource("5_uk0x1")
|
||||||
@@ -32,6 +25,7 @@ size = Vector2(16, 7)
|
|||||||
[node name="AbstractColorPlatform" unique_id=137546339 instance=ExtResource("1_ovkrd")]
|
[node name="AbstractColorPlatform" unique_id=137546339 instance=ExtResource("1_ovkrd")]
|
||||||
collision_layer = 32
|
collision_layer = 32
|
||||||
script = ExtResource("2_vbsvi")
|
script = ExtResource("2_vbsvi")
|
||||||
|
initial_color = 0
|
||||||
|
|
||||||
[node name="Sprite2D" parent="." index="0" unique_id=264863796]
|
[node name="Sprite2D" parent="." index="0" unique_id=264863796]
|
||||||
material = ExtResource("3_pbfpg")
|
material = ExtResource("3_pbfpg")
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ const MAX_WIDTH = TILE_SIZE * 32
|
|||||||
|
|
||||||
@onready var collision: CollisionShape2D = $CollisionShape2D
|
@onready var collision: CollisionShape2D = $CollisionShape2D
|
||||||
@onready var sub_viewport: SubViewport = $SubViewport
|
@onready var sub_viewport: SubViewport = $SubViewport
|
||||||
|
@onready var platform_sprite: Sprite2D = $Sprite2D
|
||||||
@onready var platform_rect: ColorRect = $SubViewport/PlatformRect
|
@onready var platform_rect: ColorRect = $SubViewport/PlatformRect
|
||||||
@onready var icon_sprite: AnimatedSprite2D = $SubViewport/IconSprite
|
@onready var icon_sprite: AnimatedSprite2D = $SubViewport/IconSprite
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
@tool
|
||||||
|
class_name ColorSwitchingPlatform
|
||||||
|
extends AbstractColorPlatform
|
||||||
|
|
||||||
|
|
||||||
|
func toggle() -> void:
|
||||||
|
collision_switcher.switch_color()
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://b2bityno64bl4
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bwmd8w677p7k3"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://wpkj48bqyuy2" path="res://game/platform/abstract_color_platform.tscn" id="1_6jqdv"]
|
||||||
|
[ext_resource type="Script" uid="uid://b2bityno64bl4" path="res://game/platform/color_switching_platform.gd" id="2_sbqh7"]
|
||||||
|
[ext_resource type="Shader" uid="uid://d4hm3vjx1rhsf" path="res://game/shaders/platform.gdshader" id="2_svoke"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cpcuokqv8u2xa" path="res://images/level/platform.png" id="3_sbqh7"]
|
||||||
|
|
||||||
|
[sub_resource type="ViewportTexture" id="ViewportTexture_svoke"]
|
||||||
|
viewport_path = NodePath("SubViewport")
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_sbqh7"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
shader = ExtResource("2_svoke")
|
||||||
|
shader_parameter/tile_size = 8.0
|
||||||
|
shader_parameter/platform_width = 24.0
|
||||||
|
shader_parameter/atlas = ExtResource("3_sbqh7")
|
||||||
|
shader_parameter/seed = 0.12241629
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5slkc"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
size = Vector2(16, 7)
|
||||||
|
|
||||||
|
[node name="ColorSwitchingPlatform" unique_id=137546339 instance=ExtResource("1_6jqdv")]
|
||||||
|
script = ExtResource("2_sbqh7")
|
||||||
|
initial_color = 0
|
||||||
|
|
||||||
|
[node name="Sprite2D" parent="." index="0" unique_id=264863796]
|
||||||
|
texture = SubResource("ViewportTexture_svoke")
|
||||||
|
|
||||||
|
[node name="PlatformRect" parent="SubViewport" parent_id_path=PackedInt32Array(226200089) index="0" unique_id=794315918]
|
||||||
|
material = SubResource("ShaderMaterial_sbqh7")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" parent="." index="2" unique_id=175449124]
|
||||||
|
shape = SubResource("RectangleShape2D_5slkc")
|
||||||
Reference in New Issue
Block a user