first
This commit is contained in:
32
Minigames/Components/MouseInteractionComponent.gd
Normal file
32
Minigames/Components/MouseInteractionComponent.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
extends Area2D
|
||||
class_name MouseInteractionComponent
|
||||
|
||||
@export var stickyHold: bool = false #When this is true the action can be held even tho the mouse has allready left the area
|
||||
|
||||
var mouseInside: bool = false #When mouse is inside collision
|
||||
var mousePressedL: bool = false #When Left mouse button is pressed down
|
||||
|
||||
var actionHeld: bool = false
|
||||
signal actionPressed
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("MinigameClick"):
|
||||
mousePressedL = true
|
||||
if event.is_action_released("MinigameClick"):
|
||||
mousePressedL = false
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if mousePressedL and (mouseInside or (stickyHold and actionHeld)):
|
||||
if !actionHeld:
|
||||
actionPressed.emit()
|
||||
|
||||
actionHeld = true
|
||||
else:
|
||||
actionHeld = false
|
||||
|
||||
|
||||
func _mouse_enter() -> void:
|
||||
mouseInside = true
|
||||
|
||||
func _mouse_exit() -> void:
|
||||
mouseInside = false
|
||||
1
Minigames/Components/MouseInteractionComponent.gd.uid
Normal file
1
Minigames/Components/MouseInteractionComponent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dikeg0o7owamv
|
||||
88
Minigames/Components/dragComponent.gd
Normal file
88
Minigames/Components/dragComponent.gd
Normal file
@@ -0,0 +1,88 @@
|
||||
extends Node2D
|
||||
class_name DragComponent
|
||||
|
||||
@export var MouseIntComp: MouseInteractionComponent ##Where the player klicks to drag the component
|
||||
@export var intBox: InteractBoxMinigame ##Used to determine if this component interacts with another component
|
||||
|
||||
@export var canDrag: bool = true ##If true the component can be moved by dragging it
|
||||
@export var singleDrag: bool = true ##If true the component can only be moved when its the only dragged component
|
||||
@export var resetWhenLetGo: bool = false ##If the player stops dragging the component returns to its home pos
|
||||
@export var lockWhenatGoal: bool = false ##If the component reaches a goal, it cannot be dragged anymore
|
||||
@export var openLockOnClick: bool = false ##If the component is clicked (Impulse) it will stop being locked at its goal (THIS REQUIRES LOCK WHEN AT GOAL TO BE TRUE)
|
||||
@export var goalID: int = 0 ##What goals this component can interact with (All goals of the same ID)
|
||||
|
||||
@export var homePos: Vector2 = Vector2(0,0) ##If this is 0,0 it gets set to the current position on ready
|
||||
@export var goalPos: Vector2 = Vector2(0,0) ##Position of goal where to component can be dragged to stay there
|
||||
|
||||
var leftMouseClicked: bool = false
|
||||
var atGoal: bool = false
|
||||
var goalSocket: GoalBox
|
||||
|
||||
var mousePos: Vector2 = Vector2(0,0)
|
||||
|
||||
func _ready() -> void:
|
||||
if intBox:
|
||||
intBox.area_entered.connect(areaEntered)
|
||||
intBox.area_exited.connect(areaExited)
|
||||
|
||||
if MouseIntComp:
|
||||
MouseIntComp.stickyHold = true
|
||||
|
||||
MouseIntComp.actionPressed.connect(interactionClicked)
|
||||
|
||||
if !homePos:
|
||||
homePos = self.position
|
||||
else:
|
||||
self.position = homePos
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouse:
|
||||
mousePos = event.position
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if atGoal and lockWhenatGoal:
|
||||
self.position = goalPos
|
||||
canDrag = false
|
||||
MouseIntComp.monitorable = false
|
||||
|
||||
return
|
||||
else:
|
||||
MouseIntComp.monitorable = true
|
||||
if openLockOnClick and !atGoal:
|
||||
lockWhenatGoal = true
|
||||
|
||||
if !canDrag: return
|
||||
|
||||
if MouseIntComp.actionHeld:
|
||||
self.position = mousePos
|
||||
elif atGoal:
|
||||
self.position = goalPos
|
||||
elif resetWhenLetGo:
|
||||
self.position = homePos
|
||||
|
||||
func interactionClicked() -> void:
|
||||
if openLockOnClick and atGoal:
|
||||
lockWhenatGoal = false
|
||||
canDrag = true
|
||||
|
||||
func areaEntered(area: Area2D) -> void:
|
||||
if area is GoalBox:
|
||||
if area.goalID == goalID:
|
||||
goalPos = area.position
|
||||
atGoal = true
|
||||
goalSocket = area
|
||||
|
||||
if area is MouseInteractionComponent and singleDrag and canDrag:
|
||||
MouseIntComp.actionHeld = false
|
||||
self.position = homePos
|
||||
|
||||
func areaExited(area: Area2D) -> void:
|
||||
if area is GoalBox:
|
||||
if area.goalID == goalID:
|
||||
atGoal = false
|
||||
if area == goalSocket:
|
||||
goalSocket = null
|
||||
|
||||
func adaptCoordinateScale(input: Vector2) -> Vector2:
|
||||
return input / Vector2(1152,648) * Vector2(DisplayServer.window_get_size())
|
||||
1
Minigames/Components/dragComponent.gd.uid
Normal file
1
Minigames/Components/dragComponent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://djrwyn7u5y1eh
|
||||
8
Minigames/Components/goalBox.gd
Normal file
8
Minigames/Components/goalBox.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
extends Area2D
|
||||
class_name GoalBox
|
||||
|
||||
@export var goalID: int = 0
|
||||
|
||||
#func _ready() -> void:
|
||||
#collision_layer = 2
|
||||
#collision_mask = 2
|
||||
1
Minigames/Components/goalBox.gd.uid
Normal file
1
Minigames/Components/goalBox.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bt0fia4w2r4qv
|
||||
6
Minigames/Components/interactBox.gd
Normal file
6
Minigames/Components/interactBox.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
extends Area2D
|
||||
class_name InteractBoxMinigame
|
||||
|
||||
#func _ready() -> void:
|
||||
#collision_layer = 2
|
||||
#collision_mask = 2
|
||||
1
Minigames/Components/interactBox.gd.uid
Normal file
1
Minigames/Components/interactBox.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bxwi8drvl4kec
|
||||
17
Minigames/Components/minigameController.gd
Normal file
17
Minigames/Components/minigameController.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
extends Node2D
|
||||
class_name MinigameController
|
||||
|
||||
var winState: bool = false #Indicates if the minigame has been solved
|
||||
|
||||
signal minigameWon
|
||||
signal minigameLost
|
||||
|
||||
func win() -> void:
|
||||
minigameWon.emit()
|
||||
Minigames.endMinigame(true)
|
||||
winState = true
|
||||
|
||||
func loose() -> void:
|
||||
minigameLost.emit()
|
||||
Minigames.endMinigame(false)
|
||||
winState = false
|
||||
1
Minigames/Components/minigameController.gd.uid
Normal file
1
Minigames/Components/minigameController.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ckjr8awjg22gw
|
||||
8
Minigames/Components/wire_base.gd
Normal file
8
Minigames/Components/wire_base.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
extends Line2D
|
||||
|
||||
@export var point2pos: Node2D
|
||||
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
points[2] = point2pos.position - self.position
|
||||
1
Minigames/Components/wire_base.gd.uid
Normal file
1
Minigames/Components/wire_base.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bfrgkhri72myr
|
||||
38
Minigames/Initiators/MinigameFuseBox.tscn
Normal file
38
Minigames/Initiators/MinigameFuseBox.tscn
Normal file
@@ -0,0 +1,38 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://md1qkedi16r6"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://xe2cfvuij76h" path="res://Minigames/Initiators/minigame_fuse_box.gd" id="1_dv4be"]
|
||||
[ext_resource type="Script" uid="uid://ymaax1x5fos3" path="res://script/interactBox.gd" id="2_s6xia"]
|
||||
[ext_resource type="Script" uid="uid://cjiiw7cybj24b" path="res://script/ButtonLogicImpulse.gd" id="3_v532u"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_j2y4x"]
|
||||
size = Vector3(1, 0.75, 0.35)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_dv4be"]
|
||||
albedo_color = Color(1, 0.011764706, 0, 1)
|
||||
|
||||
[node name="MinigameFuseBox" type="Node3D"]
|
||||
script = ExtResource("1_dv4be")
|
||||
|
||||
[node name="InteractBox" type="Area3D" parent="." node_paths=PackedStringArray("object")]
|
||||
script = ExtResource("2_s6xia")
|
||||
object = NodePath("../ButtonLogicImpulse")
|
||||
type = "minigame"
|
||||
metadata/_custom_type_script = "uid://ymaax1x5fos3"
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractBox"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
||||
shape = SubResource("BoxShape3D_j2y4x")
|
||||
|
||||
[node name="ButtonLogicImpulse" type="Timer" parent="." node_paths=PackedStringArray("interactBox")]
|
||||
script = ExtResource("3_v532u")
|
||||
interactBox = NodePath("../InteractBox")
|
||||
metadata/_custom_type_script = "uid://cjiiw7cybj24b"
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
||||
size = Vector3(1, 0.75, 0.35)
|
||||
|
||||
[node name="CSGBox3D2" type="CSGBox3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.31196976, 1.6802979, 0.15137061)
|
||||
size = Vector3(0.3008423, 0.27441406, 0.1696289)
|
||||
material = SubResource("StandardMaterial3D_dv4be")
|
||||
11
Minigames/Initiators/MinigameInitiator.gd
Normal file
11
Minigames/Initiators/MinigameInitiator.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
extends Node3D
|
||||
class_name MinigameInitiator
|
||||
|
||||
var minigameCompleted: bool = false
|
||||
|
||||
var minigame: String = "wires"
|
||||
var minigameList: Array[String] = ["wires"]
|
||||
|
||||
func startMinigame() -> void:
|
||||
if minigameCompleted == false:
|
||||
Minigames.spawnMinigame(minigame,self)
|
||||
1
Minigames/Initiators/MinigameInitiator.gd.uid
Normal file
1
Minigames/Initiators/MinigameInitiator.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c2p5uwi4mhl2v
|
||||
16
Minigames/Initiators/minigame_fuse_box.gd
Normal file
16
Minigames/Initiators/minigame_fuse_box.gd
Normal file
@@ -0,0 +1,16 @@
|
||||
extends MinigameInitiator
|
||||
|
||||
@onready var interactLogic: ButtonLogicImpulse = $ButtonLogicImpulse
|
||||
|
||||
@onready var testIndicator: CSGBox3D = $CSGBox3D2
|
||||
|
||||
func _ready() -> void:
|
||||
interactLogic.onPressed.connect(startMinigame)
|
||||
Minigames.minigameCompleted.connect(disableInteractBox)
|
||||
|
||||
func disableInteractBox() -> void:
|
||||
if minigameCompleted:
|
||||
interactLogic.interactBox.collision_layer = 0
|
||||
var mat := StandardMaterial3D.new()
|
||||
mat.albedo_color = Color.GREEN
|
||||
testIndicator.material = mat
|
||||
1
Minigames/Initiators/minigame_fuse_box.gd.uid
Normal file
1
Minigames/Initiators/minigame_fuse_box.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://xe2cfvuij76h
|
||||
370
Minigames/Minigames/Wires.tscn
Normal file
370
Minigames/Minigames/Wires.tscn
Normal file
@@ -0,0 +1,370 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://dwrjtwtsp4jgy"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cpcjvqyv82sy" path="res://Minigames/Minigames/WiresMinigame.gd" id="1_5i1mj"]
|
||||
[ext_resource type="Script" uid="uid://bfrgkhri72myr" path="res://Minigames/Components/wire_base.gd" id="2_id6wv"]
|
||||
[ext_resource type="Script" uid="uid://djrwyn7u5y1eh" path="res://Minigames/Components/dragComponent.gd" id="3_o88if"]
|
||||
[ext_resource type="Script" uid="uid://dikeg0o7owamv" path="res://Minigames/Components/MouseInteractionComponent.gd" id="4_k4ik8"]
|
||||
[ext_resource type="Script" uid="uid://bxwi8drvl4kec" path="res://Minigames/Components/interactBox.gd" id="5_8do0e"]
|
||||
[ext_resource type="Script" uid="uid://bt0fia4w2r4qv" path="res://Minigames/Components/goalBox.gd" id="6_d8c52"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_h52mw"]
|
||||
size = Vector2(62, 36)
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_hubdl"]
|
||||
radius = 15.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_0ll5f"]
|
||||
radius = 19.0
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_1l75v"]
|
||||
font_size = 80
|
||||
|
||||
[node name="Wires" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="TestMinigame" type="Node2D" parent="."]
|
||||
script = ExtResource("1_5i1mj")
|
||||
metadata/_custom_type_script = "uid://cpcjvqyv82sy"
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="TestMinigame"]
|
||||
z_index = -2
|
||||
offset_left = 101.0
|
||||
offset_top = 98.0
|
||||
offset_right = 1077.0
|
||||
offset_bottom = 529.0
|
||||
size_flags_vertical = 4
|
||||
mouse_filter = 2
|
||||
color = Color(0.48178947, 0.48178947, 0.48178947, 1)
|
||||
|
||||
[node name="WireBases" type="Node2D" parent="TestMinigame"]
|
||||
|
||||
[node name="WireBase" type="Line2D" parent="TestMinigame/WireBases" node_paths=PackedStringArray("point2pos")]
|
||||
position = Vector2(205, 152)
|
||||
points = PackedVector2Array(-50, 0, -25, 0, 0, 0)
|
||||
width = 25.0
|
||||
default_color = Color(1, 0, 0, 1)
|
||||
script = ExtResource("2_id6wv")
|
||||
point2pos = NodePath("../../WireDraggers/Wire")
|
||||
|
||||
[node name="WireBase2" type="Line2D" parent="TestMinigame/WireBases" node_paths=PackedStringArray("point2pos")]
|
||||
position = Vector2(205, 262)
|
||||
points = PackedVector2Array(-50, 0, -25, 0, 0, 0)
|
||||
width = 25.0
|
||||
default_color = Color(0, 0, 1, 1)
|
||||
script = ExtResource("2_id6wv")
|
||||
point2pos = NodePath("../../WireDraggers/Wire2")
|
||||
|
||||
[node name="WireBase3" type="Line2D" parent="TestMinigame/WireBases" node_paths=PackedStringArray("point2pos")]
|
||||
position = Vector2(205, 362)
|
||||
points = PackedVector2Array(-50, 0, -25, 0, 0, 0)
|
||||
width = 25.0
|
||||
default_color = Color(1, 0, 1, 1)
|
||||
script = ExtResource("2_id6wv")
|
||||
point2pos = NodePath("../../WireDraggers/Wire3")
|
||||
|
||||
[node name="WireBase4" type="Line2D" parent="TestMinigame/WireBases" node_paths=PackedStringArray("point2pos")]
|
||||
position = Vector2(205, 464)
|
||||
points = PackedVector2Array(-50, 0, -25, 0, 0, 0)
|
||||
width = 25.0
|
||||
default_color = Color(1, 1, 0, 1)
|
||||
script = ExtResource("2_id6wv")
|
||||
point2pos = NodePath("../../WireDraggers/Wire4")
|
||||
|
||||
[node name="WireDraggers" type="Node2D" parent="TestMinigame"]
|
||||
|
||||
[node name="Wire" type="Node2D" parent="TestMinigame/WireDraggers" node_paths=PackedStringArray("MouseIntComp", "intBox")]
|
||||
position = Vector2(205, 152)
|
||||
script = ExtResource("3_o88if")
|
||||
MouseIntComp = NodePath("InteractionComponent")
|
||||
intBox = NodePath("InteractBox")
|
||||
singleDrag = false
|
||||
resetWhenLetGo = true
|
||||
lockWhenatGoal = true
|
||||
openLockOnClick = true
|
||||
metadata/_custom_type_script = "uid://djrwyn7u5y1eh"
|
||||
|
||||
[node name="InteractionComponent" type="Area2D" parent="TestMinigame/WireDraggers/Wire"]
|
||||
script = ExtResource("4_k4ik8")
|
||||
stickyHold = true
|
||||
metadata/_custom_type_script = "uid://dikeg0o7owamv"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/WireDraggers/Wire/InteractionComponent"]
|
||||
position = Vector2(1, -1.5)
|
||||
shape = SubResource("RectangleShape2D_h52mw")
|
||||
debug_color = Color(0.96168846, 1.540184e-06, 0.51167804, 0.41960785)
|
||||
|
||||
[node name="InteractBox" type="Area2D" parent="TestMinigame/WireDraggers/Wire"]
|
||||
script = ExtResource("5_8do0e")
|
||||
metadata/_custom_type_script = "uid://bxwi8drvl4kec"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/WireDraggers/Wire/InteractBox"]
|
||||
shape = SubResource("CircleShape2D_hubdl")
|
||||
|
||||
[node name="Wire2" type="Node2D" parent="TestMinigame/WireDraggers" node_paths=PackedStringArray("MouseIntComp", "intBox")]
|
||||
position = Vector2(205, 262)
|
||||
script = ExtResource("3_o88if")
|
||||
MouseIntComp = NodePath("InteractionComponent")
|
||||
intBox = NodePath("InteractBox")
|
||||
singleDrag = false
|
||||
resetWhenLetGo = true
|
||||
lockWhenatGoal = true
|
||||
openLockOnClick = true
|
||||
metadata/_custom_type_script = "uid://djrwyn7u5y1eh"
|
||||
|
||||
[node name="InteractionComponent" type="Area2D" parent="TestMinigame/WireDraggers/Wire2"]
|
||||
script = ExtResource("4_k4ik8")
|
||||
stickyHold = true
|
||||
metadata/_custom_type_script = "uid://dikeg0o7owamv"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/WireDraggers/Wire2/InteractionComponent"]
|
||||
position = Vector2(-1, -0.5)
|
||||
shape = SubResource("RectangleShape2D_h52mw")
|
||||
debug_color = Color(0.96168846, 1.540184e-06, 0.51167804, 0.41960785)
|
||||
|
||||
[node name="InteractBox" type="Area2D" parent="TestMinigame/WireDraggers/Wire2"]
|
||||
script = ExtResource("5_8do0e")
|
||||
metadata/_custom_type_script = "uid://bxwi8drvl4kec"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/WireDraggers/Wire2/InteractBox"]
|
||||
shape = SubResource("CircleShape2D_hubdl")
|
||||
|
||||
[node name="Wire3" type="Node2D" parent="TestMinigame/WireDraggers" node_paths=PackedStringArray("MouseIntComp", "intBox")]
|
||||
position = Vector2(205, 362)
|
||||
script = ExtResource("3_o88if")
|
||||
MouseIntComp = NodePath("InteractionComponent")
|
||||
intBox = NodePath("InteractBox")
|
||||
singleDrag = false
|
||||
resetWhenLetGo = true
|
||||
lockWhenatGoal = true
|
||||
openLockOnClick = true
|
||||
metadata/_custom_type_script = "uid://djrwyn7u5y1eh"
|
||||
|
||||
[node name="InteractionComponent" type="Area2D" parent="TestMinigame/WireDraggers/Wire3"]
|
||||
script = ExtResource("4_k4ik8")
|
||||
stickyHold = true
|
||||
metadata/_custom_type_script = "uid://dikeg0o7owamv"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/WireDraggers/Wire3/InteractionComponent"]
|
||||
position = Vector2(-1, -0.5)
|
||||
shape = SubResource("RectangleShape2D_h52mw")
|
||||
debug_color = Color(0.96168846, 1.540184e-06, 0.51167804, 0.41960785)
|
||||
|
||||
[node name="InteractBox" type="Area2D" parent="TestMinigame/WireDraggers/Wire3"]
|
||||
script = ExtResource("5_8do0e")
|
||||
metadata/_custom_type_script = "uid://bxwi8drvl4kec"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/WireDraggers/Wire3/InteractBox"]
|
||||
shape = SubResource("CircleShape2D_hubdl")
|
||||
|
||||
[node name="Wire4" type="Node2D" parent="TestMinigame/WireDraggers" node_paths=PackedStringArray("MouseIntComp", "intBox")]
|
||||
position = Vector2(205, 464)
|
||||
script = ExtResource("3_o88if")
|
||||
MouseIntComp = NodePath("InteractionComponent")
|
||||
intBox = NodePath("InteractBox")
|
||||
singleDrag = false
|
||||
resetWhenLetGo = true
|
||||
lockWhenatGoal = true
|
||||
openLockOnClick = true
|
||||
metadata/_custom_type_script = "uid://djrwyn7u5y1eh"
|
||||
|
||||
[node name="InteractionComponent" type="Area2D" parent="TestMinigame/WireDraggers/Wire4"]
|
||||
script = ExtResource("4_k4ik8")
|
||||
stickyHold = true
|
||||
metadata/_custom_type_script = "uid://dikeg0o7owamv"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/WireDraggers/Wire4/InteractionComponent"]
|
||||
position = Vector2(-1, 1)
|
||||
shape = SubResource("RectangleShape2D_h52mw")
|
||||
debug_color = Color(0.96168846, 1.540184e-06, 0.51167804, 0.41960785)
|
||||
|
||||
[node name="InteractBox" type="Area2D" parent="TestMinigame/WireDraggers/Wire4"]
|
||||
script = ExtResource("5_8do0e")
|
||||
metadata/_custom_type_script = "uid://bxwi8drvl4kec"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/WireDraggers/Wire4/InteractBox"]
|
||||
shape = SubResource("CircleShape2D_hubdl")
|
||||
|
||||
[node name="Sockets" type="Node2D" parent="TestMinigame"]
|
||||
|
||||
[node name="Socket" type="Area2D" parent="TestMinigame/Sockets"]
|
||||
position = Vector2(1032, 152)
|
||||
script = ExtResource("6_d8c52")
|
||||
metadata/_custom_type_script = "uid://bt0fia4w2r4qv"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/Sockets/Socket"]
|
||||
z_index = 1
|
||||
shape = SubResource("CircleShape2D_0ll5f")
|
||||
debug_color = Color(0, 0.5702603, 0.8470977, 0.41960785)
|
||||
|
||||
[node name="Panel" type="Panel" parent="TestMinigame/Sockets/Socket"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="TestMinigame/Sockets/Socket/Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="Socket2" type="Area2D" parent="TestMinigame/Sockets"]
|
||||
position = Vector2(1032, 262)
|
||||
script = ExtResource("6_d8c52")
|
||||
metadata/_custom_type_script = "uid://bt0fia4w2r4qv"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/Sockets/Socket2"]
|
||||
shape = SubResource("CircleShape2D_0ll5f")
|
||||
|
||||
[node name="Panel" type="Panel" parent="TestMinigame/Sockets/Socket2"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="TestMinigame/Sockets/Socket2/Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="Socket3" type="Area2D" parent="TestMinigame/Sockets"]
|
||||
position = Vector2(1032, 362)
|
||||
script = ExtResource("6_d8c52")
|
||||
metadata/_custom_type_script = "uid://bt0fia4w2r4qv"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/Sockets/Socket3"]
|
||||
shape = SubResource("CircleShape2D_0ll5f")
|
||||
|
||||
[node name="Panel" type="Panel" parent="TestMinigame/Sockets/Socket3"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="TestMinigame/Sockets/Socket3/Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="Socket4" type="Area2D" parent="TestMinigame/Sockets"]
|
||||
position = Vector2(1032, 464)
|
||||
script = ExtResource("6_d8c52")
|
||||
metadata/_custom_type_script = "uid://bt0fia4w2r4qv"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TestMinigame/Sockets/Socket4"]
|
||||
shape = SubResource("CircleShape2D_0ll5f")
|
||||
|
||||
[node name="Panel" type="Panel" parent="TestMinigame/Sockets/Socket4"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="TestMinigame/Sockets/Socket4/Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="Label" type="Label" parent="TestMinigame"]
|
||||
visible = false
|
||||
offset_left = 331.0
|
||||
offset_top = -5.0
|
||||
offset_right = 1593.0
|
||||
offset_bottom = 214.0
|
||||
text = "COMPLETED!"
|
||||
label_settings = SubResource("LabelSettings_1l75v")
|
||||
|
||||
[connection signal="actionPressed" from="TestMinigame/WireDraggers/Wire/InteractionComponent" to="TestMinigame/WireDraggers/Wire/InteractionComponent" method="_on_action_pressed"]
|
||||
[connection signal="area_entered" from="TestMinigame/WireDraggers/Wire/InteractBox" to="TestMinigame/WireDraggers/Wire/InteractBox" method="_on_area_entered"]
|
||||
[connection signal="actionPressed" from="TestMinigame/WireDraggers/Wire2/InteractionComponent" to="TestMinigame/WireDraggers/Wire2/InteractionComponent" method="_on_action_pressed"]
|
||||
[connection signal="area_entered" from="TestMinigame/WireDraggers/Wire2/InteractBox" to="TestMinigame/WireDraggers/Wire2/InteractBox" method="_on_area_entered"]
|
||||
[connection signal="actionPressed" from="TestMinigame/WireDraggers/Wire3/InteractionComponent" to="TestMinigame/WireDraggers/Wire3/InteractionComponent" method="_on_action_pressed"]
|
||||
[connection signal="area_entered" from="TestMinigame/WireDraggers/Wire3/InteractBox" to="TestMinigame/WireDraggers/Wire3/InteractBox" method="_on_area_entered"]
|
||||
[connection signal="actionPressed" from="TestMinigame/WireDraggers/Wire4/InteractionComponent" to="TestMinigame/WireDraggers/Wire4/InteractionComponent" method="_on_action_pressed"]
|
||||
[connection signal="area_entered" from="TestMinigame/WireDraggers/Wire4/InteractBox" to="TestMinigame/WireDraggers/Wire4/InteractBox" method="_on_area_entered"]
|
||||
63
Minigames/Minigames/WiresMinigame.gd
Normal file
63
Minigames/Minigames/WiresMinigame.gd
Normal file
@@ -0,0 +1,63 @@
|
||||
extends MinigameController
|
||||
class_name WiresMinigame
|
||||
|
||||
@onready var wireBase: Line2D = $WireBases/WireBase
|
||||
@onready var wireBase2: Line2D = $WireBases/WireBase2
|
||||
@onready var wireBase3: Line2D = $WireBases/WireBase3
|
||||
@onready var wireBase4: Line2D = $WireBases/WireBase4
|
||||
|
||||
@onready var dragComp: DragComponent = $WireDraggers/Wire
|
||||
@onready var dragComp2: DragComponent = $WireDraggers/Wire2
|
||||
@onready var dragComp3: DragComponent = $WireDraggers/Wire3
|
||||
@onready var dragComp4: DragComponent = $WireDraggers/Wire4
|
||||
|
||||
@onready var colorRect: ColorRect = $Sockets/Socket/Panel/ColorRect
|
||||
@onready var colorRect2: ColorRect = $Sockets/Socket2/Panel/ColorRect
|
||||
@onready var colorRect3: ColorRect = $Sockets/Socket3/Panel/ColorRect
|
||||
@onready var colorRect4: ColorRect = $Sockets/Socket4/Panel/ColorRect
|
||||
|
||||
@onready var socket: GoalBox = $Sockets/Socket
|
||||
@onready var socket2: GoalBox = $Sockets/Socket2
|
||||
@onready var socket3: GoalBox = $Sockets/Socket3
|
||||
@onready var socket4: GoalBox = $Sockets/Socket4
|
||||
|
||||
var colors: Array[Color] = [Color.RED,Color.BLUE,Color.YELLOW,Color.PURPLE]
|
||||
|
||||
func _ready() -> void:
|
||||
colors.shuffle()
|
||||
|
||||
#Setup Wires
|
||||
wireBase.default_color = colors[0]
|
||||
wireBase2.default_color = colors[1]
|
||||
wireBase3.default_color = colors[2]
|
||||
wireBase4.default_color = colors[3]
|
||||
|
||||
dragComp.name = str(colors[0].to_rgba32())
|
||||
dragComp2.name = str(colors[1].to_rgba32())
|
||||
dragComp3.name = str(colors[2].to_rgba32())
|
||||
dragComp4.name = str(colors[3].to_rgba32())
|
||||
|
||||
colors.shuffle()
|
||||
#Setup Sockets
|
||||
colorRect.color = colors[0]
|
||||
colorRect2.color = colors[1]
|
||||
colorRect3.color = colors[2]
|
||||
colorRect4.color = colors[3]
|
||||
|
||||
socket.name = str(colors[0].to_rgba32())
|
||||
socket2.name = str(colors[1].to_rgba32())
|
||||
socket3.name = str(colors[2].to_rgba32())
|
||||
socket4.name = str(colors[3].to_rgba32())
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if !dragComp.goalSocket or !dragComp2.goalSocket or !dragComp3.goalSocket or !dragComp4.goalSocket: return
|
||||
if (dragComp.name == dragComp.goalSocket.name) and (dragComp2.name == dragComp2.goalSocket.name) and (dragComp3.name == dragComp3.goalSocket.name) and (dragComp4.name == dragComp4.goalSocket.name):
|
||||
$Label.show()
|
||||
|
||||
win()
|
||||
dragComp.openLockOnClick = false
|
||||
dragComp2.openLockOnClick = false
|
||||
dragComp3.openLockOnClick = false
|
||||
dragComp4.openLockOnClick = false
|
||||
|
||||
1
Minigames/Minigames/WiresMinigame.gd.uid
Normal file
1
Minigames/Minigames/WiresMinigame.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cpcjvqyv82sy
|
||||
Reference in New Issue
Block a user