- Fight World data structure - Generating basic fight world - Opening correct fight room - Block paths in fight rooms - Transition between roomspull/22/head
parent
759933c1cd
commit
fd0e631b1f
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://n5cj71bxxjkk"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dqe1i2qmpttwf" path="res://scripts/CSharp/Common/Fight/FightWorld.cs" id="1_tnyce"]
|
||||
|
||||
[node name="FightWorldAutoload" type="Node2D"]
|
||||
script = ExtResource("1_tnyce")
|
||||
@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://hk8ahyp6dgl6"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c76mhhqyk4lgh" path="res://scripts/CSharp/Common/Fight/FightInstance.cs" id="1_ygesl"]
|
||||
[ext_resource type="Script" uid="uid://oe1uypehqvr7" path="res://scripts/CSharp/Common/Fight/FightStateManager.cs" id="2_b0ivm"]
|
||||
[ext_resource type="Script" uid="uid://c76mhhqyk4lgh" path="res://scripts/CSharp/Common/FightOld/FightInstance.cs" id="1_ygesl"]
|
||||
[ext_resource type="Script" uid="uid://oe1uypehqvr7" path="res://scripts/CSharp/Common/FightOld/FightStateManager.cs" id="2_b0ivm"]
|
||||
|
||||
[node name="FightBaseScene" type="Node2D" node_paths=PackedStringArray("_friendlyFightSpots", "_enemyFightSpots", "camPositionNode", "_fightStateManager", "_fightEndText")]
|
||||
script = ExtResource("1_ygesl")
|
||||
@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cnjsepvaqdbyq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://j5ge24rk25wm" path="res://scripts/CSharp/Common/Fight/FightManager.cs" id="1_8p7ev"]
|
||||
[ext_resource type="PackedScene" uid="uid://cpanatqdjjpa3" path="res://prefabs/fight/fighters/vesna_fighter.tscn" id="2_ak1vo"]
|
||||
[ext_resource type="Script" uid="uid://j5ge24rk25wm" path="res://scripts/CSharp/Common/FightOld/FightManager.cs" id="1_8p7ev"]
|
||||
[ext_resource type="PackedScene" uid="uid://cpanatqdjjpa3" path="res://prefabs/fightOld/fighters/vesna_fighter.tscn" id="2_ak1vo"]
|
||||
|
||||
[node name="FightManagerAutoload" type="Node"]
|
||||
script = ExtResource("1_8p7ev")
|
||||
@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://bp64p6y72j71w"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://ccrnmx6bd842k" path="res://art/characters/farm fäulnis blobs.png" id="1_vem8k"]
|
||||
[ext_resource type="Script" uid="uid://by88f32fou7lh" path="res://scripts/CSharp/Common/Fight/Fighter.cs" id="2_4w1ab"]
|
||||
[ext_resource type="Script" uid="uid://by88f32fou7lh" path="res://scripts/CSharp/Common/FightOld/Fighter.cs" id="2_4w1ab"]
|
||||
[ext_resource type="Texture2D" uid="uid://qlfwuakhe57t" path="res://art/ui/UI/attack_select_wheel.png" id="3_v4f83"]
|
||||
[ext_resource type="AudioStream" uid="uid://x7cc5woop5ec" path="res://audio/sfx/Battle/Enemies/SFX_Slime_Hit_V2_03.wav" id="5_v4f83"]
|
||||
[ext_resource type="Texture2D" uid="uid://bn56p0ytuo060" path="res://art/ui/UI/AttackButton.png" id="5_vbkts"]
|
||||
@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://cr66tpdr5rma5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://by88f32fou7lh" path="res://scripts/CSharp/Common/Fight/Fighter.cs" id="1_t6th8"]
|
||||
[ext_resource type="Script" uid="uid://by88f32fou7lh" path="res://scripts/CSharp/Common/FightOld/Fighter.cs" id="1_t6th8"]
|
||||
[ext_resource type="Texture2D" uid="uid://bexymddkb6l0o" path="res://art/characters/Mavka/mavkha.png" id="2_shg7p"]
|
||||
[ext_resource type="Texture2D" uid="uid://qlfwuakhe57t" path="res://art/ui/UI/attack_select_wheel.png" id="3_nkuei"]
|
||||
[ext_resource type="Texture2D" uid="uid://bn56p0ytuo060" path="res://art/ui/UI/AttackButton.png" id="4_u3hw3"]
|
||||
@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://cpanatqdjjpa3"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://by88f32fou7lh" path="res://scripts/CSharp/Common/Fight/Fighter.cs" id="1_f3j2x"]
|
||||
[ext_resource type="Script" uid="uid://by88f32fou7lh" path="res://scripts/CSharp/Common/FightOld/Fighter.cs" id="1_f3j2x"]
|
||||
[ext_resource type="Texture2D" uid="uid://om2axn1vfa5o" path="res://art/animation/Vesna2D/Vesna Anims Sequences/S01-Idle/0001.png" id="2_2ud32"]
|
||||
[ext_resource type="Texture2D" uid="uid://qlfwuakhe57t" path="res://art/ui/UI/attack_select_wheel.png" id="3_80knd"]
|
||||
[ext_resource type="AudioStream" uid="uid://ch4c1wh4ghxyo" path="res://audio/sfx/Battle/Vesna/SFX_Battle_Vesna_Defense_08.wav" id="5_4r2vf"]
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class FightSceneSetup : Node
|
||||
{
|
||||
[Export] private Label debugLabel;
|
||||
public override void _Ready()
|
||||
{
|
||||
var room = FightWorld.Instance.currentRoom!;
|
||||
debugLabel.Text = $"Room Debug:\n{room.paths.Count} paths out of this room\n{room.enemyGroups.Count} enemy groups:\n";
|
||||
foreach (var enemyGroup in room.enemyGroups)
|
||||
{
|
||||
debugLabel.Text += $" {enemyGroup.enemies.Count} enemies:\n";
|
||||
foreach (var enemy in enemyGroup.enemies)
|
||||
{
|
||||
debugLabel.Text += $" {enemy.type}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
uid://dbu8afaiohpdh
|
||||
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Babushka.scripts.CSharp.Common.SceneManagement;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class FightSceneSwitcher : Node
|
||||
{
|
||||
[Export] private Node sceneRoot;
|
||||
[Export] private string fightRoomScenePath;
|
||||
[Export] private string fightingGroupScene;
|
||||
|
||||
private void LoadNext()
|
||||
{
|
||||
var nextRoom = FightWorld.Instance.currentRoom;
|
||||
Debug.Assert(nextRoom != null, "nextRoom!=null");
|
||||
var nextEnemyGroup = FightWorld.Instance.inFightWith;
|
||||
SceneTransitionThreaded.Instance.ChangeSceneToFile(nextEnemyGroup != null
|
||||
? fightingGroupScene
|
||||
: fightRoomScenePath);
|
||||
UnloadAfterDelay();
|
||||
}
|
||||
|
||||
private async void UnloadAfterDelay()
|
||||
{
|
||||
await ToSignal(GetTree().CreateTimer(1.0f), "timeout"); // 1.0f seconds
|
||||
sceneRoot.QueueFree();
|
||||
}
|
||||
|
||||
public void SwitchRoom(int pathIndex)
|
||||
{
|
||||
Debug.Assert(FightWorld.Instance.currentRoom != null, "FightWorld.Instance.currentRoom!=null");
|
||||
|
||||
if (!FightWorld.Instance.currentRoom.paths.TryGetValue(pathIndex, out var nextRoom))
|
||||
throw new Exception("Trying to go down a non-existent path");
|
||||
|
||||
FightWorld.Instance.currentRoom = nextRoom;
|
||||
LoadNext();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
uid://cql8mt5jsmcdl
|
||||
@ -0,0 +1,159 @@
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class FightWorld : Node
|
||||
{
|
||||
public class World
|
||||
{
|
||||
public required List<Room> rooms;
|
||||
}
|
||||
|
||||
public class Room
|
||||
{
|
||||
public required Dictionary<int, Room> paths;
|
||||
public required List<EnemyGroup> enemyGroups;
|
||||
}
|
||||
|
||||
public class EnemyGroup
|
||||
{
|
||||
public required List<Enemy> enemies;
|
||||
}
|
||||
|
||||
public class Enemy
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
Blob,
|
||||
BigBlob,
|
||||
Mavka,
|
||||
YourMom
|
||||
}
|
||||
|
||||
public required Type type;
|
||||
public required int? health = null; // null => initialize to full health on spawn
|
||||
}
|
||||
|
||||
#region AutoLoad ( Contains _EnterTree() )
|
||||
|
||||
public static FightWorld Instance { get; private set; } = null!;
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
Instance = this;
|
||||
MyEnterTree();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public World? world = null;
|
||||
public Room? currentRoom = null;
|
||||
public EnemyGroup? inFightWith = null;
|
||||
|
||||
public void MyEnterTree()
|
||||
{
|
||||
Generate();
|
||||
currentRoom = world!.rooms[0];
|
||||
}
|
||||
|
||||
public void Generate()
|
||||
{
|
||||
world = new Generator().GenerateWorld();
|
||||
}
|
||||
|
||||
private class Generator
|
||||
{
|
||||
public World GenerateWorld()
|
||||
{
|
||||
var world = new World
|
||||
{
|
||||
rooms = GenerateRooms()
|
||||
};
|
||||
return world;
|
||||
}
|
||||
|
||||
private List<Room> GenerateRooms()
|
||||
{
|
||||
var rooms = new List<Room>();
|
||||
|
||||
var roomCount = 2;
|
||||
|
||||
for (var i = 0; i < roomCount; i++)
|
||||
{
|
||||
rooms.Add(GenerateDisconnectedRoom());
|
||||
}
|
||||
|
||||
// Connect rooms linearly
|
||||
for (var i = 0; i < rooms.Count - 1; i++)
|
||||
{
|
||||
rooms[i].paths[0] = rooms[i + 1];
|
||||
rooms[i + 1].paths[1] = rooms[i];
|
||||
}
|
||||
|
||||
return rooms;
|
||||
}
|
||||
|
||||
private Room GenerateDisconnectedRoom()
|
||||
{
|
||||
var room = new Room
|
||||
{
|
||||
paths = new Dictionary<int, Room>(),
|
||||
enemyGroups = GenerateEnemyGroups()
|
||||
};
|
||||
return room;
|
||||
}
|
||||
|
||||
private List<EnemyGroup> GenerateEnemyGroups()
|
||||
{
|
||||
var enemyGroups = new List<EnemyGroup>();
|
||||
|
||||
var enemyGroupCount = GD.RandRange(1, 3);
|
||||
|
||||
for (var i = 0; i < enemyGroupCount; i++)
|
||||
{
|
||||
enemyGroups.Add(GenerateSingleEnemyGroup());
|
||||
}
|
||||
|
||||
return enemyGroups;
|
||||
}
|
||||
|
||||
private EnemyGroup GenerateSingleEnemyGroup()
|
||||
{
|
||||
var enemyGroup = new EnemyGroup
|
||||
{
|
||||
enemies = []
|
||||
};
|
||||
|
||||
var enemyCount = GD.RandRange(1, 3);
|
||||
|
||||
for (var i = 0; i < enemyCount; i++)
|
||||
{
|
||||
enemyGroup.enemies.Add(GenerateSingleEnemy());
|
||||
}
|
||||
|
||||
return enemyGroup;
|
||||
}
|
||||
|
||||
private Enemy GenerateSingleEnemy()
|
||||
{
|
||||
var typeRoll = GD.RandRange(0, 99);
|
||||
|
||||
var type = typeRoll switch
|
||||
{
|
||||
< 50 => Enemy.Type.Blob,
|
||||
< 75 => Enemy.Type.BigBlob,
|
||||
< 90 => Enemy.Type.Mavka,
|
||||
_ => Enemy.Type.YourMom
|
||||
};
|
||||
|
||||
var enemy = new Enemy
|
||||
{
|
||||
type = type,
|
||||
health = null
|
||||
};
|
||||
|
||||
return enemy;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
uid://dqe1i2qmpttwf
|
||||
@ -0,0 +1,19 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class NextRoomTrigger : Area2D
|
||||
{
|
||||
[Export] private int pathIndex;
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
BodyEntered += _OnBodyEnter;
|
||||
}
|
||||
|
||||
private void _OnBodyEnter(Node2D other)
|
||||
{
|
||||
var fss = GetNode<FightSceneSwitcher>("%FightSceneSwitcher");
|
||||
fss.SwitchRoom(pathIndex);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
uid://bryibv73x5iwr
|
||||
@ -0,0 +1,49 @@
|
||||
using System.Diagnostics;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class PathSetup : Node
|
||||
{
|
||||
[Export] private int pathId;
|
||||
|
||||
[ExportCategory("Variants")] [Export] private CanvasItem closedVariant;
|
||||
[Export] private CanvasItem nextRoomVariant;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
SetupPathVariant();
|
||||
}
|
||||
|
||||
private void SetupPathVariant()
|
||||
{
|
||||
Debug.Assert(FightWorld.Instance.currentRoom != null);
|
||||
if (FightWorld.Instance.currentRoom.paths.TryGetValue(pathId, out var nextRoom))
|
||||
{
|
||||
ShowOnlyVariant(nextRoomVariant);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowOnlyVariant(closedVariant);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowOnlyVariant(CanvasItem variantToShow)
|
||||
{
|
||||
HideVariant(closedVariant);
|
||||
HideVariant(nextRoomVariant);
|
||||
ShowVariant(variantToShow);
|
||||
}
|
||||
|
||||
private void ShowVariant(CanvasItem variant)
|
||||
{
|
||||
variant.Visible = true;
|
||||
variant.ProcessMode = ProcessModeEnum.Always;
|
||||
}
|
||||
|
||||
private void HideVariant(CanvasItem variant)
|
||||
{
|
||||
variant.Visible = false;
|
||||
variant.ProcessMode = ProcessModeEnum.Disabled;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
uid://dpkx2gbg7b5xh
|
||||
Loading…
Reference in new issue