From 59cadd2279e77d770e90c4031097a726a11f16a7 Mon Sep 17 00:00:00 2001 From: Hugo Pezziardi Date: Thu, 2 Nov 2023 17:59:02 +0100 Subject: [PATCH] :recycle: (GameEngineKit): Add overlay on wrong DnD answers --- .../Views/DragAndDrop/DragAndDropBaseScene.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Modules/GameEngineKit/Sources/_NewSystem/Views/DragAndDrop/DragAndDropBaseScene.swift b/Modules/GameEngineKit/Sources/_NewSystem/Views/DragAndDrop/DragAndDropBaseScene.swift index 9d9f43b571..ce04d3fdd2 100644 --- a/Modules/GameEngineKit/Sources/_NewSystem/Views/DragAndDrop/DragAndDropBaseScene.swift +++ b/Modules/GameEngineKit/Sources/_NewSystem/Views/DragAndDrop/DragAndDropBaseScene.swift @@ -175,6 +175,7 @@ class DragAndDropBaseScene: SKScene { group.notify(queue: .main) { self.onDropAction(node) } + disableWrongAnswer(node) } func onDragAnimation(_ node: SKSpriteNode) { @@ -193,6 +194,14 @@ class DragAndDropBaseScene: SKScene { selectedNodes = [:] } + private func disableWrongAnswer(_ node: DraggableImageAnswerNode) { + let gameplayChoiceModel = viewModel.choices.first(where: { $0.choice.value == node.name })! + if gameplayChoiceModel.choice.dropZone == nil { + node.colorBlendFactor = 0.4 + node.isDraggable = false + } + } + override func didMove(to view: SKView) { self.reset() }