Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f4dfccbc6 | |||
| 3c370e30a0 | |||
| 073a74bb22 |
@@ -6,3 +6,4 @@
|
|||||||
script = ExtResource("1_5dt1r")
|
script = ExtResource("1_5dt1r")
|
||||||
_fightRoomScenePath = "res://scenes/Babushka_scene_fight_world_room.tscn"
|
_fightRoomScenePath = "res://scenes/Babushka_scene_fight_world_room.tscn"
|
||||||
_fightHappeningScene = "res://scenes/Babushka_scene_fight_happening.tscn"
|
_fightHappeningScene = "res://scenes/Babushka_scene_fight_happening.tscn"
|
||||||
|
_nightEndScene = "res://scenes/Babushka_scene_indoor_vesnas_room.tscn"
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ Signal_Debugger="*res://addons/SignalVisualizer/Debugger/SignalDebugger.gd"
|
|||||||
FightWorldAutoload="*res://prefabs/fight/fight_world_autoload.tscn"
|
FightWorldAutoload="*res://prefabs/fight/fight_world_autoload.tscn"
|
||||||
FieldService="*res://scripts/CSharp/Common/Farming/FieldService.cs"
|
FieldService="*res://scripts/CSharp/Common/Farming/FieldService.cs"
|
||||||
SaveGameManager="*res://scripts/CSharp/Common/Savegame/SaveGameManager.cs"
|
SaveGameManager="*res://scripts/CSharp/Common/Savegame/SaveGameManager.cs"
|
||||||
SettingsSaveController="*res://scripts/CSharp/Common/Savegame/SettingsSaveController.cs"
|
|
||||||
|
|
||||||
[dialogic]
|
[dialogic]
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://bopv10dqm1knc"]
|
[gd_scene load_steps=2 format=3 uid="uid://bopv10dqm1knc"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://c6wnoif01ltld" path="res://scenes/Babushka_scene_startMenu.tscn" id="1_15ton"]
|
[ext_resource type="PackedScene" uid="uid://c6wnoif01ltld" path="res://scenes/Babushka_scene_startMenu.tscn" id="1_15ton"]
|
||||||
[ext_resource type="Script" uid="uid://bbp0dyddwdbl8" path="res://scripts/CSharp/Common/Savegame/WindowSettingsSync.cs" id="2_d3jfo"]
|
|
||||||
|
|
||||||
[node name="BabushkaSceneBootstrap" type="Node2D"]
|
[node name="BabushkaSceneBootstrap" type="Node2D"]
|
||||||
|
|
||||||
[node name="BabushkaSceneStartMenu" parent="." instance=ExtResource("1_15ton")]
|
[node name="BabushkaSceneStartMenu" parent="." instance=ExtResource("1_15ton")]
|
||||||
|
_sceneNamesToLoad = PackedStringArray("res://scenes/Babushka_scene_farm_outside_2d.tscn")
|
||||||
|
|
||||||
[node name="SceneParent" type="Node" parent="."]
|
[node name="SceneParent" type="Node" parent="."]
|
||||||
|
|
||||||
[node name="WindowSettings" type="Node" parent="."]
|
|
||||||
script = ExtResource("2_d3jfo")
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=117 format=3 uid="uid://gigb28qk8t12"]
|
[gd_scene load_steps=116 format=3 uid="uid://gigb28qk8t12"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/characters/Player2D.tscn" id="1_7wfwe"]
|
[ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/characters/Player2D.tscn" id="1_7wfwe"]
|
||||||
[ext_resource type="Texture2D" uid="uid://8sr11ex30n0m" path="res://art/mockups/Kenney_Backgrounds/Samples/uncolored_hills.png" id="2_7b2ri"]
|
[ext_resource type="Texture2D" uid="uid://8sr11ex30n0m" path="res://art/mockups/Kenney_Backgrounds/Samples/uncolored_hills.png" id="2_7b2ri"]
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
[ext_resource type="Resource" uid="uid://d1uuxp1lp4aro" path="res://resources/items/tomato_seed.tres" id="35_64mdn"]
|
[ext_resource type="Resource" uid="uid://d1uuxp1lp4aro" path="res://resources/items/tomato_seed.tres" id="35_64mdn"]
|
||||||
[ext_resource type="Texture2D" uid="uid://65e44yde224q" path="res://art/farm/Babushka_house_01.png" id="36_e5b7x"]
|
[ext_resource type="Texture2D" uid="uid://65e44yde224q" path="res://art/farm/Babushka_house_01.png" id="36_e5b7x"]
|
||||||
[ext_resource type="Resource" uid="uid://duq7tshxv6uhp" path="res://resources/items/beet_seed.tres" id="36_fv1t2"]
|
[ext_resource type="Resource" uid="uid://duq7tshxv6uhp" path="res://resources/items/beet_seed.tres" id="36_fv1t2"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cyyxqmphcrjj" path="res://art/farm/farming/farmobjekte/tomaten/tomaten_template.png" id="36_l7ekk"]
|
||||||
[ext_resource type="AudioStream" uid="uid://cfqg50am0swb7" path="res://audio/Music/Farming_90BPM_69Bars_Loop.wav" id="37_8ey8m"]
|
[ext_resource type="AudioStream" uid="uid://cfqg50am0swb7" path="res://audio/Music/Farming_90BPM_69Bars_Loop.wav" id="37_8ey8m"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dku1rq5cocisg" path="res://audio/Music/Farming_90BPM_69Bars.wav" id="37_di1ed"]
|
[ext_resource type="AudioStream" uid="uid://dku1rq5cocisg" path="res://audio/Music/Farming_90BPM_69Bars.wav" id="37_di1ed"]
|
||||||
[ext_resource type="Shader" uid="uid://braevmqauoek7" path="res://shader/swaying_plant.gdshader" id="37_taxvr"]
|
[ext_resource type="Shader" uid="uid://braevmqauoek7" path="res://shader/swaying_plant.gdshader" id="37_taxvr"]
|
||||||
@@ -78,7 +79,6 @@
|
|||||||
[ext_resource type="Script" uid="uid://dih1b0opgc3f7" path="res://scripts/GdScript/dialogic_start_specific.gd" id="77_l7ekk"]
|
[ext_resource type="Script" uid="uid://dih1b0opgc3f7" path="res://scripts/GdScript/dialogic_start_specific.gd" id="77_l7ekk"]
|
||||||
[ext_resource type="Resource" uid="uid://tt3d166mntmi" path="res://resources/low code/farming/var_sceneNameProvider.tres" id="77_xcwle"]
|
[ext_resource type="Resource" uid="uid://tt3d166mntmi" path="res://resources/low code/farming/var_sceneNameProvider.tres" id="77_xcwle"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b1d2e7ely6hyw" path="res://prefabs/farm/base_field.tscn" id="78_xcwle"]
|
[ext_resource type="PackedScene" uid="uid://b1d2e7ely6hyw" path="res://prefabs/farm/base_field.tscn" id="78_xcwle"]
|
||||||
[ext_resource type="Script" uid="uid://iquhbkr7pqeg" path="res://scripts/CSharp/Common/Savegame/SaveCheats.cs" id="79_065st"]
|
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_wtdui"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_wtdui"]
|
||||||
shader = ExtResource("13_7p0hq")
|
shader = ExtResource("13_7p0hq")
|
||||||
@@ -2509,9 +2509,6 @@ script = ExtResource("76_l7ekk")
|
|||||||
_variableResource = ExtResource("77_xcwle")
|
_variableResource = ExtResource("77_xcwle")
|
||||||
_payloadToSet = "farmOutside"
|
_payloadToSet = "farmOutside"
|
||||||
|
|
||||||
[node name="SaveGameCheat" type="Node" parent="."]
|
|
||||||
script = ExtResource("79_065st")
|
|
||||||
|
|
||||||
[connection signal="FilledWateringCan" from="YSorted/Vesna" to="Audio/SFX/FillWater SFX2" method="PlayOneShot"]
|
[connection signal="FilledWateringCan" from="YSorted/Vesna" to="Audio/SFX/FillWater SFX2" method="PlayOneShot"]
|
||||||
[connection signal="InteractedTool" from="YSorted/Well/InteractionArea" to="YSorted/Vesna" method="TryFillWateringCan"]
|
[connection signal="InteractedTool" from="YSorted/Well/InteractionArea" to="YSorted/Vesna" method="TryFillWateringCan"]
|
||||||
[connection signal="SuccessfulPickUp" from="YSorted/CanGenericPickup" to="YSorted/Vesna" method="HandlePickUp"]
|
[connection signal="SuccessfulPickUp" from="YSorted/CanGenericPickup" to="YSorted/Vesna" method="HandlePickUp"]
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
[gd_scene load_steps=14 format=3 uid="uid://ceaa2qj2bmw43"]
|
[gd_scene load_steps=15 format=3 uid="uid://ceaa2qj2bmw43"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cssdu8viimwm6" path="res://scripts/CSharp/Common/SceneTransition.cs" id="1_c6eln"]
|
[ext_resource type="Script" uid="uid://cssdu8viimwm6" path="res://scripts/CSharp/Common/SceneTransition.cs" id="1_c6eln"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cugtxcfuds31r" path="res://art/indoor/Babushka_bg_01.png" id="2_j25a2"]
|
[ext_resource type="Texture2D" uid="uid://cugtxcfuds31r" path="res://art/indoor/Babushka_bg_01.png" id="2_j25a2"]
|
||||||
[ext_resource type="Script" uid="uid://cldtt4atgymm5" path="res://scripts/CSharp/Common/Quest/QuestTrigger.cs" id="8_j25a2"]
|
[ext_resource type="Script" uid="uid://cldtt4atgymm5" path="res://scripts/CSharp/Common/Quest/QuestTrigger.cs" id="8_j25a2"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interactions/interaction_area_2d.tscn" id="8_phqdf"]
|
[ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interactions/interaction_area_2d.tscn" id="8_phqdf"]
|
||||||
[ext_resource type="Resource" uid="uid://csj15gnlx1jmx" path="res://resources/quests/demo/8_goto_bed.tres" id="9_heyef"]
|
[ext_resource type="Resource" uid="uid://csj15gnlx1jmx" path="res://resources/quests/demo/8_goto_bed.tres" id="9_heyef"]
|
||||||
|
[ext_resource type="Script" uid="uid://puw74w6lmcvl" path="res://scripts/CSharp/Common/Fight/NightStarter.cs" id="10_j25a2"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cop1vjvhwlsec" path="res://art/indoor/room export/Room_01_shelf.png" id="13_11fdt"]
|
[ext_resource type="Texture2D" uid="uid://cop1vjvhwlsec" path="res://art/indoor/room export/Room_01_shelf.png" id="13_11fdt"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/characters/Player2D.tscn" id="18_3gevq"]
|
[ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/characters/Player2D.tscn" id="18_3gevq"]
|
||||||
[ext_resource type="Script" uid="uid://bqomwxclsbhd3" path="res://scripts/CSharp/Common/Camera/CameraController.cs" id="23_408bg"]
|
[ext_resource type="Script" uid="uid://bqomwxclsbhd3" path="res://scripts/CSharp/Common/Camera/CameraController.cs" id="23_408bg"]
|
||||||
@@ -120,9 +121,14 @@ _id = 0
|
|||||||
[node name="CollisionShape3D" parent="DoorInteraction/Area2D" index="0"]
|
[node name="CollisionShape3D" parent="DoorInteraction/Area2D" index="0"]
|
||||||
shape = SubResource("CircleShape2D_2spkc")
|
shape = SubResource("CircleShape2D_2spkc")
|
||||||
|
|
||||||
|
[node name="NightStarter" type="Node" parent="."]
|
||||||
|
script = ExtResource("10_j25a2")
|
||||||
|
_sceneIndexToLoad = 1
|
||||||
|
|
||||||
[connection signal="Interacted" from="BedInteraction" to="BedInteraction/QuestCompleter" method="Trigger"]
|
[connection signal="Interacted" from="BedInteraction" to="BedInteraction/QuestCompleter" method="Trigger"]
|
||||||
[connection signal="InteractedTool" from="BedInteraction" to="." method="LoadSceneAtIndex"]
|
[connection signal="Interacted" from="BedInteraction" to="NightStarter" method="StartNight"]
|
||||||
[connection signal="Interacted" from="DoorInteraction" to="." method="LoadScene"]
|
[connection signal="Interacted" from="DoorInteraction" to="." method="LoadScene"]
|
||||||
|
[connection signal="LoadScene" from="NightStarter" to="." method="LoadSceneAtIndex"]
|
||||||
|
|
||||||
[editable path="Vesna"]
|
[editable path="Vesna"]
|
||||||
[editable path="BedInteraction"]
|
[editable path="BedInteraction"]
|
||||||
|
|||||||
@@ -216,9 +216,6 @@ public partial class FieldBehaviour2D : Sprite2D
|
|||||||
var sceneName = _sceneKeyProvider.Payload.AsString();
|
var sceneName = _sceneKeyProvider.Payload.AsString();
|
||||||
var id = SaveId + _fieldIndex.Payload.AsString();
|
var id = SaveId + _fieldIndex.Payload.AsString();
|
||||||
string jsonPayload = SavegameService.GetSaveData(sceneName, id);
|
string jsonPayload = SavegameService.GetSaveData(sceneName, id);
|
||||||
if (string.IsNullOrEmpty(jsonPayload))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Dictionary<string, Variant> save = Json.ParseString(jsonPayload).AsGodotDictionary<string, Variant>();
|
Dictionary<string, Variant> save = Json.ParseString(jsonPayload).AsGodotDictionary<string, Variant>();
|
||||||
|
|
||||||
if (save.Count > 0)
|
if (save.Count > 0)
|
||||||
|
|||||||
@@ -4,11 +4,8 @@ using Babushka.scripts.CSharp.Common.Util;
|
|||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Fight.Actions;
|
namespace Babushka.scripts.CSharp.Common.Fight.Actions;
|
||||||
|
|
||||||
public class BlobAttackAction : FighterAction
|
public class BlobAttackAction(int damage = 3) : FighterAction
|
||||||
{
|
{
|
||||||
// settings
|
|
||||||
private const int Damage = 3;
|
|
||||||
|
|
||||||
public override Variant<float, Func<bool>> GetAnimationEnd()
|
public override Variant<float, Func<bool>> GetAnimationEnd()
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
@@ -21,7 +18,7 @@ public class BlobAttackAction : FighterAction
|
|||||||
|
|
||||||
public override void ExecuteAction()
|
public override void ExecuteAction()
|
||||||
{
|
{
|
||||||
FightWorld.Instance.allyFighters.vesnaFighter.AddHealth(-Damage);
|
FightWorld.Instance.allyFighters.vesnaFighter.AddHealth(-damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task AnimateAction(AllFightersVisual allFightersVisual)
|
public override async Task AnimateAction(AllFightersVisual allFightersVisual)
|
||||||
@@ -34,7 +31,7 @@ public class BlobAttackAction : FighterAction
|
|||||||
|
|
||||||
await currentFighterVisual.AnimatePosToTarget(targetFighterVisual);
|
await currentFighterVisual.AnimatePosToTarget(targetFighterVisual);
|
||||||
_ = targetFighterVisual.AnimateHit();
|
_ = targetFighterVisual.AnimateHit();
|
||||||
targetFighterVisual.SpawnDamageIndicatorNumber(Damage);
|
targetFighterVisual.SpawnDamageIndicatorNumber(damage);
|
||||||
await currentFighterVisual.AnimatePosToBase();
|
await currentFighterVisual.AnimatePosToBase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ public class AllyFighters
|
|||||||
public FightWorld.Fighter vesnaFighter = new()
|
public FightWorld.Fighter vesnaFighter = new()
|
||||||
{
|
{
|
||||||
type = FightWorld.Fighter.Type.Vesna,
|
type = FightWorld.Fighter.Type.Vesna,
|
||||||
maxHealth = 20,
|
maxHealth = 60,
|
||||||
availableActions =
|
availableActions =
|
||||||
[
|
[
|
||||||
new AllyAttackAction()
|
new AllyAttackAction()
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public partial class FightSceneSwitcher : Node
|
|||||||
[Export] private Node _sceneRoot = null!;
|
[Export] private Node _sceneRoot = null!;
|
||||||
[Export] private string _fightRoomScenePath = null!;
|
[Export] private string _fightRoomScenePath = null!;
|
||||||
[Export] private string _fightHappeningScene = null!;
|
[Export] private string _fightHappeningScene = null!;
|
||||||
|
[Export] private string _nightEndScene = null!;
|
||||||
|
|
||||||
private void LoadNext()
|
private void LoadNext()
|
||||||
{
|
{
|
||||||
@@ -36,6 +37,12 @@ public partial class FightSceneSwitcher : Node
|
|||||||
if (!FightWorld.Instance.currentRoom.paths.TryGetValue(pathIndex, out var nextRoom))
|
if (!FightWorld.Instance.currentRoom.paths.TryGetValue(pathIndex, out var nextRoom))
|
||||||
throw new Exception("Trying to go down a non-existent path");
|
throw new Exception("Trying to go down a non-existent path");
|
||||||
|
|
||||||
|
if (nextRoom.specialRoom == FightWorld.Room.Special.EndOfNight)
|
||||||
|
{
|
||||||
|
ExitFightWorld();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FightWorld.Instance.currentRoom = nextRoom;
|
FightWorld.Instance.currentRoom = nextRoom;
|
||||||
LoadNext();
|
LoadNext();
|
||||||
}
|
}
|
||||||
@@ -60,4 +67,10 @@ public partial class FightSceneSwitcher : Node
|
|||||||
FightWorld.Instance.fightHappeningData = null;
|
FightWorld.Instance.fightHappeningData = null;
|
||||||
LoadNext();
|
LoadNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ExitFightWorld()
|
||||||
|
{
|
||||||
|
SceneTransitionThreaded.Instance.ChangeSceneToFile(_nightEndScene);
|
||||||
|
_ = UnloadAfterDelay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -14,8 +14,14 @@ public partial class FightWorld : Node
|
|||||||
|
|
||||||
public class Room
|
public class Room
|
||||||
{
|
{
|
||||||
|
public enum Special
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
EndOfNight
|
||||||
|
}
|
||||||
public required Dictionary<int, Room> paths;
|
public required Dictionary<int, Room> paths;
|
||||||
public required List<FighterGroup> enemyGroups;
|
public required List<FighterGroup> enemyGroups;
|
||||||
|
public Special specialRoom = Special.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FighterGroup
|
public class FighterGroup
|
||||||
@@ -66,7 +72,6 @@ public partial class FightWorld : Node
|
|||||||
public override void _EnterTree()
|
public override void _EnterTree()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
MyEnterTree();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -76,7 +81,7 @@ public partial class FightWorld : Node
|
|||||||
public FightHappeningData? fightHappeningData = null;
|
public FightHappeningData? fightHappeningData = null;
|
||||||
public AllyFighters allyFighters = new();
|
public AllyFighters allyFighters = new();
|
||||||
|
|
||||||
public void MyEnterTree()
|
public void ResetFightWorld()
|
||||||
{
|
{
|
||||||
Generate();
|
Generate();
|
||||||
currentRoom = world!.rooms[0];
|
currentRoom = world!.rooms[0];
|
||||||
@@ -108,6 +113,13 @@ public partial class FightWorld : Node
|
|||||||
{
|
{
|
||||||
rooms.Add(GenerateDisconnectedRoom());
|
rooms.Add(GenerateDisconnectedRoom());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rooms.Add(new Room
|
||||||
|
{
|
||||||
|
paths = [],
|
||||||
|
enemyGroups = [],
|
||||||
|
specialRoom = Room.Special.EndOfNight
|
||||||
|
});
|
||||||
|
|
||||||
// Connect rooms linearly
|
// Connect rooms linearly
|
||||||
for (var i = 0; i < rooms.Count - 1; i++)
|
for (var i = 0; i < rooms.Count - 1; i++)
|
||||||
@@ -133,7 +145,7 @@ public partial class FightWorld : Node
|
|||||||
{
|
{
|
||||||
var enemyGroups = new List<FighterGroup>();
|
var enemyGroups = new List<FighterGroup>();
|
||||||
|
|
||||||
var enemyGroupCount = GD.RandRange(1, 3);
|
var enemyGroupCount = GD.RandRange(1, 2);
|
||||||
|
|
||||||
for (var i = 0; i < enemyGroupCount; i++)
|
for (var i = 0; i < enemyGroupCount; i++)
|
||||||
{
|
{
|
||||||
@@ -150,7 +162,7 @@ public partial class FightWorld : Node
|
|||||||
fighters = []
|
fighters = []
|
||||||
};
|
};
|
||||||
|
|
||||||
var enemyCount = GD.RandRange(1, 3);
|
var enemyCount = GD.RandRange(2, 3);
|
||||||
|
|
||||||
for (var i = 0; i < enemyCount; i++)
|
for (var i = 0; i < enemyCount; i++)
|
||||||
{
|
{
|
||||||
@@ -178,10 +190,10 @@ public partial class FightWorld : Node
|
|||||||
{
|
{
|
||||||
type = type,
|
type = type,
|
||||||
health = null,
|
health = null,
|
||||||
maxHealth = 12,
|
maxHealth = GD.RandRange(8, 20),
|
||||||
availableActions =
|
availableActions =
|
||||||
[
|
[
|
||||||
new BlobAttackAction()
|
new BlobAttackAction(GD.RandRange(2, 5))
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
using Babushka.scripts.CSharp.Common.Fight;
|
||||||
|
|
||||||
|
public partial class NightStarter : Node
|
||||||
|
{
|
||||||
|
[Export] private int _sceneIndexToLoad;
|
||||||
|
|
||||||
|
[Signal] public delegate void LoadSceneEventHandler(int index);
|
||||||
|
|
||||||
|
public void StartNight()
|
||||||
|
{
|
||||||
|
FightWorld.Instance.ResetFightWorld();
|
||||||
|
EmitSignalLoadScene(_sceneIndexToLoad);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://puw74w6lmcvl
|
||||||
@@ -3,7 +3,6 @@ using System;
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Babushka.scripts.CSharp.Common.Savegame;
|
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Inventory;
|
namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||||
|
|
||||||
@@ -18,9 +17,6 @@ public partial class InventoryInstance : Node
|
|||||||
[Signal]
|
[Signal]
|
||||||
public delegate void InventoryContentsChangedEventHandler();
|
public delegate void InventoryContentsChangedEventHandler();
|
||||||
|
|
||||||
private const string SCENE_NAME = "inventory";
|
|
||||||
private const string ID = "instace";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The total amount of Inventoryslots in the inventory (empty and occupied).
|
/// The total amount of Inventoryslots in the inventory (empty and occupied).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -46,19 +42,6 @@ public partial class InventoryInstance : Node
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _EnterTree()
|
|
||||||
{
|
|
||||||
LoadFromSaveData();
|
|
||||||
InventoryContentsChanged += UpdateSaveData;
|
|
||||||
SlotAmountChanged += UpdateSaveData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _ExitTree()
|
|
||||||
{
|
|
||||||
InventoryContentsChanged -= UpdateSaveData;
|
|
||||||
SlotAmountChanged -= UpdateSaveData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InventoryActionResult AddItem(ItemInstance newItem)
|
public InventoryActionResult AddItem(ItemInstance newItem)
|
||||||
{
|
{
|
||||||
var result = AddItemAndStackRecursive(newItem, 0);
|
var result = AddItemAndStackRecursive(newItem, 0);
|
||||||
@@ -173,59 +156,4 @@ public partial class InventoryInstance : Node
|
|||||||
{
|
{
|
||||||
return items.All(HasItems);
|
return items.All(HasItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region SAVE AND LOAD
|
|
||||||
|
|
||||||
public void UpdateSaveData()
|
|
||||||
{
|
|
||||||
var saveData = new SaveData();
|
|
||||||
|
|
||||||
saveData.SceneName = SCENE_NAME;
|
|
||||||
saveData.Id = ID;
|
|
||||||
var payloadData = new Godot.Collections.Dictionary<string, Variant>();
|
|
||||||
|
|
||||||
for (int i = 0; i < _slots.Count; i++)
|
|
||||||
{
|
|
||||||
if (!_slots[i].IsEmpty())
|
|
||||||
{
|
|
||||||
string key = i.ToString();
|
|
||||||
string[] value = new string[2];
|
|
||||||
value[0] = _slots[i].itemInstance.blueprint.ResourcePath;
|
|
||||||
value[1] = _slots[i].itemInstance.amount.ToString();
|
|
||||||
payloadData.Add(key,value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
saveData.JsonPayload = Json.Stringify(payloadData, indent: "\t");
|
|
||||||
|
|
||||||
SavegameService.AppendSave(saveData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadFromSaveData()
|
|
||||||
{
|
|
||||||
var sceneName = SCENE_NAME;
|
|
||||||
var id = ID;
|
|
||||||
string jsonPayload = SavegameService.GetSaveData(sceneName, id);
|
|
||||||
if (string.IsNullOrEmpty(jsonPayload))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Godot.Collections.Dictionary<string, Variant> save = Json.ParseString(jsonPayload).AsGodotDictionary<string, Variant>();
|
|
||||||
|
|
||||||
if (save.Count > 0)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _slots.Count; i++)
|
|
||||||
{
|
|
||||||
if (save.TryGetValue(i.ToString(), out Variant inventoryItemData))
|
|
||||||
{
|
|
||||||
string[] savePayload = inventoryItemData.AsStringArray();
|
|
||||||
ItemResource resource = ResourceLoader.Load<ItemResource>(savePayload[0]);
|
|
||||||
int _amount = int.Parse(savePayload[1]);
|
|
||||||
|
|
||||||
ItemInstance instance = new ItemInstance { blueprint = resource, amount = _amount };
|
|
||||||
AddItem(instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public partial class InventoryManager : Node
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryInstance? playerInventory;
|
public InventoryInstance playerInventory = new InventoryInstance();
|
||||||
|
|
||||||
private int _currentSelectedSlotIndex = 0;
|
private int _currentSelectedSlotIndex = 0;
|
||||||
|
|
||||||
@@ -34,9 +34,7 @@ public partial class InventoryManager : Node
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
playerInventory = new InventoryInstance();
|
|
||||||
playerInventory.SlotAmount = 37;
|
playerInventory.SlotAmount = 37;
|
||||||
AddChild(playerInventory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryActionResult CreateItem(
|
public InventoryActionResult CreateItem(
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Savegame;
|
|
||||||
|
|
||||||
[Tool]
|
|
||||||
public partial class SaveCheats : Node
|
|
||||||
{
|
|
||||||
[ExportToolButton("ResetSave")] Callable _raiseAction => Callable.From(Reset);
|
|
||||||
|
|
||||||
public void Reset()
|
|
||||||
{
|
|
||||||
SavegameService.Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
uid://iquhbkr7pqeg
|
|
||||||
@@ -9,15 +9,6 @@ namespace Babushka.scripts.CSharp.Common.Savegame;
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
public class SaveData
|
public class SaveData
|
||||||
{
|
{
|
||||||
// for future use in case the structure changes.
|
|
||||||
public const int VERSION = 1;
|
|
||||||
public int version { get; set; } = VERSION;
|
|
||||||
|
|
||||||
public bool IsVersionValid()
|
|
||||||
{
|
|
||||||
return VERSION == version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SceneName;
|
public string SceneName;
|
||||||
public string Id;
|
public string Id;
|
||||||
public string JsonPayload;
|
public string JsonPayload;
|
||||||
|
|||||||
@@ -7,15 +7,12 @@ namespace Babushka.scripts.CSharp.Common.Savegame;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SaveGameManager : Node
|
public partial class SaveGameManager : Node
|
||||||
{
|
{
|
||||||
public static string USER_DATA_FILE_PATH = "user://save_data/userData.json";
|
|
||||||
|
|
||||||
public static SaveGameManager? Instance { get; private set; } = null!;
|
public static SaveGameManager? Instance { get; private set; } = null!;
|
||||||
|
|
||||||
public override void _EnterTree()
|
public override void _EnterTree()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
USER_DATA_FILE_PATH = ProjectSettings.GlobalizePath(USER_DATA_FILE_PATH);
|
|
||||||
SavegameService.SavePath = USER_DATA_FILE_PATH;
|
|
||||||
SavegameService.Load();
|
SavegameService.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,10 @@ namespace Babushka.scripts.CSharp.Common.Savegame;
|
|||||||
/// Handles the saving and loading of game states.
|
/// Handles the saving and loading of game states.
|
||||||
/// Holds the central SaveData object that serves as a temporary SaveFile.
|
/// Holds the central SaveData object that serves as a temporary SaveFile.
|
||||||
/// Automatically writes to disk on every scene change.
|
/// Automatically writes to disk on every scene change.
|
||||||
/// Uses the Godot Json Serializer, which may implicitly convert integers to floats, so be careful when extending!
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class SavegameService
|
public static class SavegameService
|
||||||
{
|
{
|
||||||
public static string SavePath = "";
|
public static readonly string SavePath = "user://babushka_savegame.json";
|
||||||
|
|
||||||
public static Dictionary<string, string> SaveDatas = new ();
|
public static Dictionary<string, string> SaveDatas = new ();
|
||||||
|
|
||||||
@@ -73,20 +72,8 @@ public static class SavegameService
|
|||||||
public static void Save()
|
public static void Save()
|
||||||
{
|
{
|
||||||
string json = Json.Stringify(SaveDatas, indent: "\t");
|
string json = Json.Stringify(SaveDatas, indent: "\t");
|
||||||
|
using var file = FileAccess.Open(SavePath, FileAccess.ModeFlags.Write);
|
||||||
GD.Print(SavePath);
|
file.StoreString(json);
|
||||||
// create cloud directory
|
|
||||||
System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(SavePath) ?? "");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var file = FileAccess.Open(SavePath, FileAccess.ModeFlags.Write);
|
|
||||||
file.StoreString(json);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
GD.Print(e.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -96,15 +83,8 @@ public static class SavegameService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!System.IO.File.Exists(SavePath))
|
|
||||||
{
|
|
||||||
SaveDatas = new();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string saveDataJson = FileAccess.GetFileAsString(SavePath);
|
string saveDataJson = FileAccess.GetFileAsString(SavePath);
|
||||||
SaveDatas = Json.ParseString(saveDataJson).AsGodotDictionary<string, string>();
|
SaveDatas = Json.ParseString(saveDataJson).AsGodotDictionary<string, string>();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
@@ -114,10 +94,4 @@ public static class SavegameService
|
|||||||
|
|
||||||
_loaded = true;
|
_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Reset()
|
|
||||||
{
|
|
||||||
SaveDatas = new ();
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Savegame;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Data structure for device-specific settings that should be saved / loaded to disk.
|
|
||||||
/// Will not be synced across devices.
|
|
||||||
/// </summary>
|
|
||||||
public class SettingsData
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// To be incremented (and migrated) on modification.
|
|
||||||
/// </summary>
|
|
||||||
public const int VERSION = 1;
|
|
||||||
public int version { get; set; } = VERSION;
|
|
||||||
|
|
||||||
public bool IsVersionValid()
|
|
||||||
{
|
|
||||||
return VERSION == version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double runtimeSeconds { get; set; }
|
|
||||||
public int windowSizeX { get; set; } = 800;
|
|
||||||
public int windowSizeY { get; set; } = 600;
|
|
||||||
public int windowPositionX { get; set; } = 100;
|
|
||||||
public int windowPositionY { get; set; } = 100;
|
|
||||||
public bool windowBorderless { get; set; }
|
|
||||||
public float volumeMaster { get; set; } = 1.0f;
|
|
||||||
public float volumeFx { get; set; } = 1.0f;
|
|
||||||
public float volumeMusic { get; set; } = 1.0f;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
uid://ol8xw1ekx0c2
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Text.Json;
|
|
||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Savegame;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Handles the saving and loading of local settings data.
|
|
||||||
/// </summary>
|
|
||||||
[GlobalClass]
|
|
||||||
public partial class SettingsSaveController : Node
|
|
||||||
{
|
|
||||||
public static string SETTINGS_FILE_PATH = "user://userSettings.json";
|
|
||||||
public static SettingsSaveController Instance;
|
|
||||||
|
|
||||||
public SettingsData? settings = new SettingsData();
|
|
||||||
public SettingsData settingsDefault = new SettingsData();
|
|
||||||
|
|
||||||
public event Action OnSettingsReloaded;
|
|
||||||
|
|
||||||
private bool _loadedData;
|
|
||||||
private DateTime _readyTime;
|
|
||||||
|
|
||||||
public bool LoadedData => _loadedData;
|
|
||||||
|
|
||||||
public override void _EnterTree()
|
|
||||||
{
|
|
||||||
SETTINGS_FILE_PATH = ProjectSettings.GlobalizePath(SETTINGS_FILE_PATH);
|
|
||||||
_readyTime = DateTime.Now;
|
|
||||||
Instance = this;
|
|
||||||
LoadSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _ExitTree()
|
|
||||||
{
|
|
||||||
if (settings != null)
|
|
||||||
settings.runtimeSeconds += (DateTime.Now - _readyTime).TotalSeconds;
|
|
||||||
SaveSettings();
|
|
||||||
Instance = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Saves Settings Data onto disk.
|
|
||||||
/// </summary>
|
|
||||||
public void SaveSettings()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string jsonString = JsonSerializer.Serialize(
|
|
||||||
settings,
|
|
||||||
new JsonSerializerOptions() { WriteIndented = true}
|
|
||||||
);
|
|
||||||
|
|
||||||
System.IO.File.WriteAllText(SETTINGS_FILE_PATH, jsonString);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
GD.PrintErr("Error Saving Settings:", e);
|
|
||||||
Console.WriteLine(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Loads Settings data from disk.
|
|
||||||
/// </summary>
|
|
||||||
public void LoadSettings()
|
|
||||||
{
|
|
||||||
_loadedData = false;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!System.IO.File.Exists(SETTINGS_FILE_PATH))
|
|
||||||
{
|
|
||||||
settings = new SettingsData();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string jsonString = System.IO.File.ReadAllText(SETTINGS_FILE_PATH);
|
|
||||||
SettingsData? loadedSettings = JsonSerializer.Deserialize<SettingsData>(jsonString);
|
|
||||||
if (loadedSettings != null && !loadedSettings.IsVersionValid())
|
|
||||||
{
|
|
||||||
_loadedData = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
settings = loadedSettings;
|
|
||||||
_loadedData = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
GD.PrintErr("Loading Error:", e);
|
|
||||||
Console.WriteLine(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Resets Settings to default.
|
|
||||||
/// </summary>
|
|
||||||
public void ResetSettings()
|
|
||||||
{
|
|
||||||
settings = JsonSerializer.Deserialize<SettingsData>(JsonSerializer.Serialize<SettingsData>(settingsDefault));
|
|
||||||
OnSettingsReloaded?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
uid://cc7gnydmbcft7
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Savegame;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Tracks important window settings and communicates with the <see cref="SettingsSaveController"/> to save/load them.
|
|
||||||
/// </summary>
|
|
||||||
public partial class WindowSettingsSync : Node
|
|
||||||
{
|
|
||||||
private Window window;
|
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
window = GetWindow();
|
|
||||||
window.SizeChanged += SaveWindowSize;
|
|
||||||
|
|
||||||
SyncSettings();
|
|
||||||
SettingsSaveController.Instance.OnSettingsReloaded += SyncSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void _ExitTree()
|
|
||||||
{
|
|
||||||
SaveWindowPosition();
|
|
||||||
SaveWindowBorderless();
|
|
||||||
SaveWindowSize();
|
|
||||||
SettingsSaveController.Instance.SaveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Tries to get previous settings from settings-savefile, if available.
|
|
||||||
/// </summary>
|
|
||||||
public void SyncSettings()
|
|
||||||
{
|
|
||||||
if (!SettingsSaveController.Instance.LoadedData)
|
|
||||||
{
|
|
||||||
SaveWindowPosition();
|
|
||||||
SaveWindowSize();
|
|
||||||
SaveWindowBorderless();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsData? settingsData = SettingsSaveController.Instance.settings;
|
|
||||||
if (settingsData != null)
|
|
||||||
{
|
|
||||||
window.Position = new Vector2I(settingsData.windowPositionX, settingsData.windowPositionY);
|
|
||||||
ValidateWindowPosition();
|
|
||||||
|
|
||||||
window.Size = new Vector2I(settingsData.windowSizeX, settingsData.windowSizeY);
|
|
||||||
window.Borderless = settingsData.windowBorderless;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ValidateWindowPosition()
|
|
||||||
{
|
|
||||||
bool validWindowPosition = false;
|
|
||||||
foreach (Rect2I displayRect in DisplayServer.GetDisplayCutouts())
|
|
||||||
{
|
|
||||||
if (displayRect.HasPoint(window.Position))
|
|
||||||
{
|
|
||||||
validWindowPosition = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!validWindowPosition)
|
|
||||||
{
|
|
||||||
window.MoveToCenter();
|
|
||||||
SaveWindowPosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveWindowPosition()
|
|
||||||
{
|
|
||||||
SettingsData? settingsData = SettingsSaveController.Instance.settings;
|
|
||||||
|
|
||||||
if (settingsData != null)
|
|
||||||
{
|
|
||||||
settingsData.windowPositionX = window.Position.X;
|
|
||||||
settingsData.windowPositionY = window.Position.Y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveWindowSize()
|
|
||||||
{
|
|
||||||
SettingsData? settingsData = SettingsSaveController.Instance.settings;
|
|
||||||
if (settingsData != null)
|
|
||||||
{
|
|
||||||
settingsData.windowSizeX = window.Size.X;
|
|
||||||
settingsData.windowSizeY = window.Size.Y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveWindowBorderless()
|
|
||||||
{
|
|
||||||
SettingsData? settingsData = SettingsSaveController.Instance.settings;
|
|
||||||
if (settingsData != null)
|
|
||||||
settingsData.windowBorderless = window.Borderless;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
uid://bbp0dyddwdbl8
|
|
||||||
@@ -34,7 +34,6 @@ public partial class SceneTransition : Node
|
|||||||
|
|
||||||
public void Quit()
|
public void Quit()
|
||||||
{
|
{
|
||||||
SettingsSaveController.Instance.SaveSettings();
|
|
||||||
GetTree().Quit();
|
GetTree().Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user