Made quest usable
This commit is contained in:
@@ -11,12 +11,9 @@
|
|||||||
|
|
||||||
[node name="CanvasLayer" type="CanvasLayer"]
|
[node name="CanvasLayer" type="CanvasLayer"]
|
||||||
layer = 90
|
layer = 90
|
||||||
follow_viewport_enabled = true
|
|
||||||
|
|
||||||
[node name="DialogicToggle" type="Node2D" parent="." node_paths=PackedStringArray("itemToToggle")]
|
[node name="DialogicToggle" type="Node2D" parent="."]
|
||||||
scale = Vector2(0.7, 0.7)
|
scale = Vector2(0.7, 0.7)
|
||||||
script = ExtResource("6_n5apg")
|
|
||||||
itemToToggle = NodePath("../Inventory")
|
|
||||||
|
|
||||||
[node name="Inventory" type="Control" parent="." node_paths=PackedStringArray("_slotsParent", "_slotsMover", "_headerSlots", "_slotSelect")]
|
[node name="Inventory" type="Control" parent="." node_paths=PackedStringArray("_slotsParent", "_slotsMover", "_headerSlots", "_slotSelect")]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
@@ -36,7 +33,6 @@ _headerSlots = [NodePath("SlotsContainer/SlotsMover/Slots/Slot"), NodePath("Slot
|
|||||||
_slotSelect = NodePath("SlotsContainer/SlotsMover/SlotSelectContainer/Selector")
|
_slotSelect = NodePath("SlotsContainer/SlotsMover/SlotSelectContainer/Selector")
|
||||||
|
|
||||||
[node name="SlotsContainer" type="Control" parent="Inventory"]
|
[node name="SlotsContainer" type="Control" parent="Inventory"]
|
||||||
custom_minimum_size = Vector2(500, 0)
|
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 8
|
anchors_preset = 8
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
@@ -46,7 +42,8 @@ anchor_bottom = 0.5
|
|||||||
offset_left = -250.0
|
offset_left = -250.0
|
||||||
offset_right = 250.0
|
offset_right = 250.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 0
|
||||||
|
scale = Vector2(0.7, 0.7)
|
||||||
|
|
||||||
[node name="SlotsMover" type="Control" parent="Inventory/SlotsContainer"]
|
[node name="SlotsMover" type="Control" parent="Inventory/SlotsContainer"]
|
||||||
custom_minimum_size = Vector2(900, 610)
|
custom_minimum_size = Vector2(900, 610)
|
||||||
|
|||||||
@@ -19,5 +19,6 @@ anchor_right = 1.0
|
|||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
text = "Hello world"
|
||||||
|
|
||||||
[connection signal="pressed" from="TitleButton" to="." method="ClickedTitleButton"]
|
[connection signal="pressed" from="TitleButton" to="." method="ClickedTitleButton"]
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ script = ExtResource("1_vc33n")
|
|||||||
|
|
||||||
[node name="LeftPage" type="Control" parent="."]
|
[node name="LeftPage" type="Control" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
anchors_preset = 9
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
offset_right = 350.0
|
offset_right = 350.0
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
@@ -35,6 +36,7 @@ _questListItemPrefab = ExtResource("2_fswdj")
|
|||||||
|
|
||||||
[node name="RightPage" type="Control" parent="."]
|
[node name="RightPage" type="Control" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
anchors_preset = 11
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
|||||||
@@ -0,0 +1,202 @@
|
|||||||
|
[gd_scene load_steps=7 format=3 uid="uid://c4ns2ixo8k2ih"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cgjc4wurbgimy" path="res://prefabs/UI/Inventory/Inventory.tscn" id="1_opxcj"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://2q1n6g2kj5er" path="res://prefabs/UI/Quest/QuestLog.tscn" id="2_lj712"]
|
||||||
|
[ext_resource type="Script" uid="uid://cldtt4atgymm5" path="res://scripts/CSharp/Common/Quest/QuestTrigger.cs" id="3_sx4ix"]
|
||||||
|
[ext_resource type="Resource" uid="uid://0aruj4lm74n6" path="res://resources/quests/test_01.tres" id="4_qyyck"]
|
||||||
|
[ext_resource type="Resource" uid="uid://be1dmc6d2mxl5" path="res://resources/quests/test_02.tres" id="5_sokiv"]
|
||||||
|
[ext_resource type="Resource" uid="uid://tmmnsg1bge2" path="res://resources/quests/test_03.tres" id="6_ajsa7"]
|
||||||
|
|
||||||
|
[node name="BabushkaTestsQuests" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="CanvasLayer" parent="." instance=ExtResource("1_opxcj")]
|
||||||
|
|
||||||
|
[node name="CanvasLayer2" type="CanvasLayer" parent="."]
|
||||||
|
layer = 128
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer2"]
|
||||||
|
offset_left = 71.0
|
||||||
|
offset_top = 53.0
|
||||||
|
offset_right = 571.0
|
||||||
|
offset_bottom = 353.0
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer2/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="CanvasLayer2/VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 1
|
||||||
|
text = "Quest 1"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Active" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Active"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer/Active"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("4_qyyck")
|
||||||
|
toStatus = 1
|
||||||
|
makeCurrent = true
|
||||||
|
|
||||||
|
[node name="Done" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Done"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer/Done"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("4_qyyck")
|
||||||
|
toStatus = 2
|
||||||
|
|
||||||
|
[node name="Cancle" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Cancle"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer/Cancle"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("4_qyyck")
|
||||||
|
toStatus = 3
|
||||||
|
|
||||||
|
[node name="Hide" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Hide
|
||||||
|
"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer/Hide"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("4_qyyck")
|
||||||
|
|
||||||
|
[node name="HBoxContainer2" type="HBoxContainer" parent="CanvasLayer2/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="CanvasLayer2/VBoxContainer/HBoxContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 1
|
||||||
|
text = "Quest 2"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Active" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Active"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer2/Active"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("5_sokiv")
|
||||||
|
toStatus = 1
|
||||||
|
|
||||||
|
[node name="Done" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Done"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer2/Done"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("5_sokiv")
|
||||||
|
toStatus = 2
|
||||||
|
|
||||||
|
[node name="Cancle" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Cancle"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer2/Cancle"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("5_sokiv")
|
||||||
|
toStatus = 3
|
||||||
|
|
||||||
|
[node name="Hide" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Hide
|
||||||
|
"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer2/Hide"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("5_sokiv")
|
||||||
|
|
||||||
|
[node name="HBoxContainer3" type="HBoxContainer" parent="CanvasLayer2/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="CanvasLayer2/VBoxContainer/HBoxContainer3"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 1
|
||||||
|
text = "Quest 3"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Active" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer3"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Active"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer3/Active"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("6_ajsa7")
|
||||||
|
toStatus = 1
|
||||||
|
|
||||||
|
[node name="Done" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer3"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Done"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer3/Done"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("6_ajsa7")
|
||||||
|
toStatus = 2
|
||||||
|
|
||||||
|
[node name="Cancle" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer3"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Cancle"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer3/Cancle"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("6_ajsa7")
|
||||||
|
toStatus = 3
|
||||||
|
|
||||||
|
[node name="Hide" type="Button" parent="CanvasLayer2/VBoxContainer/HBoxContainer3"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Hide
|
||||||
|
"
|
||||||
|
|
||||||
|
[node name="QuestSetter" type="Node" parent="CanvasLayer2/VBoxContainer/HBoxContainer3/Hide"]
|
||||||
|
script = ExtResource("3_sx4ix")
|
||||||
|
questResource = ExtResource("6_ajsa7")
|
||||||
|
|
||||||
|
[node name="QuestLog" parent="CanvasLayer2" instance=ExtResource("2_lj712")]
|
||||||
|
offset_left = 625.0
|
||||||
|
offset_top = 294.0
|
||||||
|
offset_right = -595.0
|
||||||
|
offset_bottom = -286.0
|
||||||
|
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer/Active" to="CanvasLayer2/VBoxContainer/HBoxContainer/Active/QuestSetter" method="Trigger"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer/Done" to="CanvasLayer2/VBoxContainer/HBoxContainer/Done/QuestSetter" method="Trigger"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer/Cancle" to="CanvasLayer2/VBoxContainer/HBoxContainer/Cancle/QuestSetter" method="Trigger"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer/Hide" to="CanvasLayer2/VBoxContainer/HBoxContainer/Hide/QuestSetter" method="Trigger"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer2/Active" to="CanvasLayer2/VBoxContainer/HBoxContainer2/Active/QuestSetter" method="Trigger"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer2/Done" to="CanvasLayer2/VBoxContainer/HBoxContainer2/Done/QuestSetter" method="Trigger"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer2/Cancle" to="CanvasLayer2/VBoxContainer/HBoxContainer2/Cancle/QuestSetter" method="Trigger"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer2/Hide" to="CanvasLayer2/VBoxContainer/HBoxContainer2/Hide/QuestSetter" method="Trigger"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer3/Active" to="CanvasLayer2/VBoxContainer/HBoxContainer3/Active/QuestSetter" method="Trigger"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer3/Done" to="CanvasLayer2/VBoxContainer/HBoxContainer3/Done/QuestSetter" method="Trigger"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer3/Cancle" to="CanvasLayer2/VBoxContainer/HBoxContainer3/Cancle/QuestSetter" method="Trigger"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer2/VBoxContainer/HBoxContainer3/Hide" to="CanvasLayer2/VBoxContainer/HBoxContainer3/Hide/QuestSetter" method="Trigger"]
|
||||||
|
|
||||||
|
[editable path="CanvasLayer"]
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
using Babushka.scripts.CSharp.Common.Quest;
|
||||||
|
|
||||||
|
public partial class PopUpPostIt : Control
|
||||||
|
{
|
||||||
|
private Label Text => GetNode<Label>("Text");
|
||||||
|
|
||||||
|
private AnimationPlayer Animation => GetNode<AnimationPlayer>("AnimationPlayer");
|
||||||
|
|
||||||
|
QuestManager QM => QuestManager.Instance!;
|
||||||
|
public override void _EnterTree()
|
||||||
|
{
|
||||||
|
QM.QuestBecomesActive += NewQuestPostIt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NewQuestPostIt(QuestResource questResource)
|
||||||
|
{
|
||||||
|
Text.Text = questResource.title;
|
||||||
|
Animation.Play("NewPostit");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://byar6yqrlph6k
|
||||||
@@ -12,7 +12,17 @@ public partial class QuestListItemUi : Control
|
|||||||
public void UpdateButton(QuestResource questResource)
|
public void UpdateButton(QuestResource questResource)
|
||||||
{
|
{
|
||||||
_questResource = questResource;
|
_questResource = questResource;
|
||||||
ShowName(questResource.title);
|
var questStatus = QuestManager.Instance!.GetQuestStatus(_questResource);
|
||||||
|
var name = questResource.title;
|
||||||
|
|
||||||
|
name += questStatus.status switch
|
||||||
|
{
|
||||||
|
QuestStatus.Status.Done => " \u2713", // Check
|
||||||
|
QuestStatus.Status.Canceled => " \u2715", // X
|
||||||
|
_ => ""
|
||||||
|
};
|
||||||
|
|
||||||
|
ShowName(name);
|
||||||
TitleButton.Pressed += ClickedTitleButton;
|
TitleButton.Pressed += ClickedTitleButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ public partial class QuestListUi : VBoxContainer
|
|||||||
public override void _EnterTree()
|
public override void _EnterTree()
|
||||||
{
|
{
|
||||||
UpdateList();
|
UpdateList();
|
||||||
|
QuestManager.Instance!.QuestsChanged += UpdateList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _ExitTree()
|
||||||
|
{
|
||||||
|
QuestManager.Instance!.QuestsChanged -= UpdateList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
@@ -27,8 +33,8 @@ public partial class QuestListUi : VBoxContainer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// recreate children
|
// recreate children
|
||||||
var activeQuests = QuestManager.Instance.GetActiveQuests();
|
var activeQuests = QuestManager.Instance.GetVisibleQuests();
|
||||||
|
|
||||||
foreach (var questPair in activeQuests)
|
foreach (var questPair in activeQuests)
|
||||||
{
|
{
|
||||||
var questResource = questPair.Key;
|
var questResource = questPair.Key;
|
||||||
|
|||||||
@@ -7,15 +7,21 @@ public partial class QuestLog : Control
|
|||||||
{
|
{
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void DetailQuestChangedEventHandler(QuestLog questLog);
|
public delegate void DetailQuestChangedEventHandler(QuestLog questLog);
|
||||||
|
|
||||||
public QuestResource? currentDetailQuest
|
public QuestResource? currentDetailQuest
|
||||||
{
|
{
|
||||||
get => _currentDetailQuestBacking;
|
get => QuestManager.Instance!.GetFollowQuest();
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_currentDetailQuestBacking = value;
|
QuestManager.Instance!.SetFollowQuest(value); // TODO: fix setup
|
||||||
EmitSignalDetailQuestChanged(this);
|
EmitSignalDetailQuestChanged(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private QuestResource? _currentDetailQuestBacking;
|
|
||||||
|
public override void _EnterTree()
|
||||||
|
{
|
||||||
|
QuestManager.Instance!.QuestsChanged += () => EmitSignalDetailQuestChanged(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//private QuestResource? _currentDetailQuestBacking;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,13 @@ namespace Babushka.scripts.CSharp.Common.Quest;
|
|||||||
using QuestPair = KeyValuePair<QuestResource, QuestStatus>;
|
using QuestPair = KeyValuePair<QuestResource, QuestStatus>;
|
||||||
public partial class QuestManager : Node
|
public partial class QuestManager : Node
|
||||||
{
|
{
|
||||||
public static QuestManager Instance { get; private set; }
|
public static QuestManager? Instance { get; private set; }
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void QuestBecomesActiveEventHandler(QuestResource questResource);
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void QuestsChangedEventHandler();
|
||||||
|
|
||||||
public override void _EnterTree()
|
public override void _EnterTree()
|
||||||
{
|
{
|
||||||
@@ -16,6 +22,8 @@ public partial class QuestManager : Node
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Godot.Collections.Dictionary<QuestResource, QuestStatus> _questStatus = new();
|
private Godot.Collections.Dictionary<QuestResource, QuestStatus> _questStatus = new();
|
||||||
|
|
||||||
|
private QuestResource? _followQuest;
|
||||||
|
|
||||||
|
|
||||||
public void ChangeQuestStatus(QuestResource questResource, QuestStatus.Status newStatus)
|
public void ChangeQuestStatus(QuestResource questResource, QuestStatus.Status newStatus)
|
||||||
@@ -27,6 +35,13 @@ public partial class QuestManager : Node
|
|||||||
}
|
}
|
||||||
|
|
||||||
value.status = newStatus;
|
value.status = newStatus;
|
||||||
|
|
||||||
|
EmitSignalQuestsChanged();
|
||||||
|
|
||||||
|
if (newStatus == QuestStatus.Status.Active)
|
||||||
|
{
|
||||||
|
EmitSignalQuestBecomesActive(questResource);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<QuestPair> GetVisibleQuests()
|
public IEnumerable<QuestPair> GetVisibleQuests()
|
||||||
@@ -38,4 +53,24 @@ public partial class QuestManager : Node
|
|||||||
{
|
{
|
||||||
return _questStatus.Where(qs => qs.Value.status == QuestStatus.Status.Active);
|
return _questStatus.Where(qs => qs.Value.status == QuestStatus.Status.Active);
|
||||||
}
|
}
|
||||||
|
public QuestStatus GetQuestStatus(QuestResource questResource)
|
||||||
|
{
|
||||||
|
if (_questStatus.TryGetValue(questResource, out var status))
|
||||||
|
return status;
|
||||||
|
|
||||||
|
status = new QuestStatus();
|
||||||
|
_questStatus.Add(questResource, status);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QuestResource? GetFollowQuest()
|
||||||
|
{
|
||||||
|
return _followQuest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFollowQuest(QuestResource? questResource)
|
||||||
|
{
|
||||||
|
_followQuest = questResource;
|
||||||
|
EmitSignalQuestsChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
using System.Net.Mime;
|
||||||
|
using Babushka.scripts.CSharp.Common.Quest;
|
||||||
|
|
||||||
|
public partial class QuestMessagePopup : Control
|
||||||
|
{
|
||||||
|
|
||||||
|
private Label Text => GetNode<Label>("Text");
|
||||||
|
|
||||||
|
private QuestResource? _currentlyShown;
|
||||||
|
|
||||||
|
private Tween? _activeTween = null;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private Vector2 _showPosition;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private Vector2 _hidePosition;
|
||||||
|
|
||||||
|
public override void _EnterTree()
|
||||||
|
{
|
||||||
|
QuestManager.Instance!.QuestsChanged += NewActiveQuest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _ExitTree()
|
||||||
|
{
|
||||||
|
QuestManager.Instance!.QuestsChanged -= NewActiveQuest;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NewActiveQuest()
|
||||||
|
{
|
||||||
|
GD.Print("NewActiveQuest");
|
||||||
|
|
||||||
|
var shownQuest = QuestManager.Instance!.GetFollowQuest();
|
||||||
|
if (_currentlyShown == shownQuest)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_activeTween != null)
|
||||||
|
{
|
||||||
|
_activeTween.Kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shownQuest == null)
|
||||||
|
{
|
||||||
|
HideAnimate();
|
||||||
|
_currentlyShown = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_currentlyShown == null)
|
||||||
|
{
|
||||||
|
Text.Text = shownQuest.title;
|
||||||
|
ShowAnimate();
|
||||||
|
_currentlyShown = shownQuest;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// else (_currentlyShown != null)
|
||||||
|
|
||||||
|
_currentlyShown = shownQuest;
|
||||||
|
HideAnimate(() =>
|
||||||
|
{
|
||||||
|
Text.Text = shownQuest.title;
|
||||||
|
ShowAnimate();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HideAnimate(Action? then = null)
|
||||||
|
{
|
||||||
|
_activeTween = GetTree().CreateTween();
|
||||||
|
_activeTween.TweenProperty(this, "position", _hidePosition, 0.4)
|
||||||
|
.SetTrans(Tween.TransitionType.Cubic)
|
||||||
|
.SetEase(Tween.EaseType.Out);
|
||||||
|
if (then != null)
|
||||||
|
_activeTween.Finished += then;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowAnimate(Action? then = null)
|
||||||
|
{
|
||||||
|
_activeTween = GetTree().CreateTween();
|
||||||
|
_activeTween.TweenProperty(this, "position", _showPosition, 0.4)
|
||||||
|
.SetTrans(Tween.TransitionType.Cubic)
|
||||||
|
.SetEase(Tween.EaseType.Out);
|
||||||
|
if (then != null)
|
||||||
|
_activeTween.Finished += then;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://7wwid23tc8as
|
||||||
@@ -5,13 +5,29 @@ using Babushka.scripts.CSharp.Common.Quest;
|
|||||||
public partial class QuestTrigger : Node
|
public partial class QuestTrigger : Node
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
public QuestResource questResource;
|
public QuestResource? questResource;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public QuestStatus.Status toStatus;
|
public QuestStatus.Status toStatus;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private bool makeCurrent = false;
|
||||||
|
|
||||||
public void Trigger()
|
public void Trigger()
|
||||||
{
|
{
|
||||||
|
GD.Print("trigger");
|
||||||
|
|
||||||
|
if(questResource== null)
|
||||||
|
throw new Exception("QuestResource is not set on QuestTrigger node.");
|
||||||
|
|
||||||
|
if(QuestManager.Instance == null)
|
||||||
|
throw new Exception("QuestManager instance is not available. Make sure it is initialized before calling Trigger.");
|
||||||
|
|
||||||
QuestManager.Instance.ChangeQuestStatus(questResource, toStatus);
|
QuestManager.Instance.ChangeQuestStatus(questResource, toStatus);
|
||||||
|
|
||||||
|
if (makeCurrent)
|
||||||
|
{
|
||||||
|
QuestManager.Instance.SetFollowQuest(questResource);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user