Made the fight world completable #33
@@ -6,3 +6,4 @@
|
||||
script = ExtResource("1_5dt1r")
|
||||
_fightRoomScenePath = "res://scenes/Babushka_scene_fight_world_room.tscn"
|
||||
_fightHappeningScene = "res://scenes/Babushka_scene_fight_happening.tscn"
|
||||
_nightEndScene = "res://scenes/Babushka_scene_indoor_vesnas_room.tscn"
|
||||
|
||||
@@ -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="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="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="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="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"]
|
||||
@@ -120,9 +121,14 @@ _id = 0
|
||||
[node name="CollisionShape3D" parent="DoorInteraction/Area2D" index="0"]
|
||||
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="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="LoadScene" from="NightStarter" to="." method="LoadSceneAtIndex"]
|
||||
|
||||
[editable path="Vesna"]
|
||||
[editable path="BedInteraction"]
|
||||
|
||||
@@ -4,11 +4,8 @@ using Babushka.scripts.CSharp.Common.Util;
|
||||
|
||||
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()
|
||||
{
|
||||
return 1;
|
||||
@@ -21,7 +18,7 @@ public class BlobAttackAction : FighterAction
|
||||
|
||||
public override void ExecuteAction()
|
||||
{
|
||||
FightWorld.Instance.allyFighters.vesnaFighter.AddHealth(-Damage);
|
||||
FightWorld.Instance.allyFighters.vesnaFighter.AddHealth(-damage);
|
||||
}
|
||||
|
||||
public override async Task AnimateAction(AllFightersVisual allFightersVisual)
|
||||
@@ -34,7 +31,7 @@ public class BlobAttackAction : FighterAction
|
||||
|
||||
await currentFighterVisual.AnimatePosToTarget(targetFighterVisual);
|
||||
_ = targetFighterVisual.AnimateHit();
|
||||
targetFighterVisual.SpawnDamageIndicatorNumber(Damage);
|
||||
targetFighterVisual.SpawnDamageIndicatorNumber(damage);
|
||||
await currentFighterVisual.AnimatePosToBase();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ public class AllyFighters
|
||||
public FightWorld.Fighter vesnaFighter = new()
|
||||
{
|
||||
type = FightWorld.Fighter.Type.Vesna,
|
||||
maxHealth = 20,
|
||||
maxHealth = 60,
|
||||
availableActions =
|
||||
[
|
||||
new AllyAttackAction()
|
||||
|
||||
@@ -11,6 +11,7 @@ public partial class FightSceneSwitcher : Node
|
||||
[Export] private Node _sceneRoot = null!;
|
||||
[Export] private string _fightRoomScenePath = null!;
|
||||
[Export] private string _fightHappeningScene = null!;
|
||||
[Export] private string _nightEndScene = null!;
|
||||
|
||||
private void LoadNext()
|
||||
{
|
||||
@@ -36,6 +37,12 @@ public partial class FightSceneSwitcher : Node
|
||||
if (!FightWorld.Instance.currentRoom.paths.TryGetValue(pathIndex, out var nextRoom))
|
||||
throw new Exception("Trying to go down a non-existent path");
|
||||
|
||||
if (nextRoom.specialRoom == FightWorld.Room.Special.EndOfNight)
|
||||
{
|
||||
ExitFightWorld();
|
||||
return;
|
||||
}
|
||||
|
||||
FightWorld.Instance.currentRoom = nextRoom;
|
||||
LoadNext();
|
||||
}
|
||||
@@ -60,4 +67,10 @@ public partial class FightSceneSwitcher : Node
|
||||
FightWorld.Instance.fightHappeningData = null;
|
||||
LoadNext();
|
||||
}
|
||||
|
||||
public void ExitFightWorld()
|
||||
{
|
||||
SceneTransitionThreaded.Instance.ChangeSceneToFile(_nightEndScene);
|
||||
_ = UnloadAfterDelay();
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,14 @@ public partial class FightWorld : Node
|
||||
|
||||
public class Room
|
||||
{
|
||||
public enum Special
|
||||
{
|
||||
None,
|
||||
EndOfNight
|
||||
}
|
||||
public required Dictionary<int, Room> paths;
|
||||
public required List<FighterGroup> enemyGroups;
|
||||
public Special specialRoom = Special.None;
|
||||
}
|
||||
|
||||
public class FighterGroup
|
||||
@@ -66,7 +72,6 @@ public partial class FightWorld : Node
|
||||
public override void _EnterTree()
|
||||
{
|
||||
Instance = this;
|
||||
MyEnterTree();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -76,7 +81,7 @@ public partial class FightWorld : Node
|
||||
public FightHappeningData? fightHappeningData = null;
|
||||
public AllyFighters allyFighters = new();
|
||||
|
||||
public void MyEnterTree()
|
||||
public void ResetFightWorld()
|
||||
{
|
||||
Generate();
|
||||
currentRoom = world!.rooms[0];
|
||||
@@ -109,6 +114,13 @@ public partial class FightWorld : Node
|
||||
rooms.Add(GenerateDisconnectedRoom());
|
||||
}
|
||||
|
||||
rooms.Add(new Room
|
||||
{
|
||||
paths = [],
|
||||
enemyGroups = [],
|
||||
specialRoom = Room.Special.EndOfNight
|
||||
});
|
||||
|
||||
// Connect rooms linearly
|
||||
for (var i = 0; i < rooms.Count - 1; i++)
|
||||
{
|
||||
@@ -133,7 +145,7 @@ public partial class FightWorld : Node
|
||||
{
|
||||
var enemyGroups = new List<FighterGroup>();
|
||||
|
||||
var enemyGroupCount = GD.RandRange(1, 3);
|
||||
var enemyGroupCount = GD.RandRange(1, 2);
|
||||
|
||||
for (var i = 0; i < enemyGroupCount; i++)
|
||||
{
|
||||
@@ -150,7 +162,7 @@ public partial class FightWorld : Node
|
||||
fighters = []
|
||||
};
|
||||
|
||||
var enemyCount = GD.RandRange(1, 3);
|
||||
var enemyCount = GD.RandRange(2, 3);
|
||||
|
||||
for (var i = 0; i < enemyCount; i++)
|
||||
{
|
||||
@@ -178,10 +190,10 @@ public partial class FightWorld : Node
|
||||
{
|
||||
type = type,
|
||||
health = null,
|
||||
maxHealth = 12,
|
||||
maxHealth = GD.RandRange(8, 20),
|
||||
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
|
||||
Reference in New Issue
Block a user