parent
f27dd199b8
commit
0e315396c9
@ -0,0 +1,18 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://0vm3jb1hnkkb"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://7jsxokx67gpq" path="res://prefabs/fight/fighterVisuals/vesna_fighter_visual.tscn" id="1_80xdf"]
|
||||
[ext_resource type="Texture2D" uid="uid://ccrnmx6bd842k" path="res://art/characters/farm fäulnis blobs.png" id="2_ba6tr"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ane0o"]
|
||||
atlas = ExtResource("2_ba6tr")
|
||||
region = Rect2(1133.19, 93.65, 460.526, 347.391)
|
||||
|
||||
[node name="BlobFighterVisual" instance=ExtResource("1_80xdf")]
|
||||
|
||||
[node name="Sprite2D" parent="Visuals" index="0"]
|
||||
position = Vector2(23, -96)
|
||||
scale = Vector2(0.547474, 0.547474)
|
||||
texture = SubResource("AtlasTexture_ane0o")
|
||||
|
||||
[node name="ChacacterSizeIndicator" parent="Visuals" index="1"]
|
||||
visible = true
|
||||
@ -0,0 +1,58 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://7jsxokx67gpq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://by88f32fou7lh" path="res://scripts/CSharp/Common/Fight/FighterVisual.cs" id="1_hai27"]
|
||||
[ext_resource type="Texture2D" uid="uid://f7htcxiwvuup" path="res://art/animation/vesna/Side/S01-Idle/0001.png" id="2_6l7g5"]
|
||||
[ext_resource type="Script" uid="uid://boprnfciqgixf" path="res://scripts/CSharp/Common/Fight/UI/TargetSelectionClick.cs" id="3_wil2y"]
|
||||
[ext_resource type="Texture2D" uid="uid://qlfwuakhe57t" path="res://art/ui/UI/attack_select_wheel.png" id="4_8ldlc"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wil2y"]
|
||||
atlas = ExtResource("2_6l7g5")
|
||||
region = Rect2(60.818, 51.0213, 660.226, 945.537)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_6l7g5"]
|
||||
size = Vector2(250, 401)
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_6l7g5"]
|
||||
radius = 173.0
|
||||
height = 588.0
|
||||
|
||||
[node name="VesnaFighterVisual" type="Node2D" node_paths=PackedStringArray("_visualParent", "_targetSelectionParent")]
|
||||
script = ExtResource("1_hai27")
|
||||
_visualParent = NodePath("Visuals")
|
||||
_targetSelectionParent = NodePath("TargetSelection")
|
||||
|
||||
[node name="Visuals" type="Node2D" parent="."]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Visuals"]
|
||||
position = Vector2(-31, -199)
|
||||
scale = Vector2(0.451719, 0.451719)
|
||||
texture = SubResource("AtlasTexture_wil2y")
|
||||
|
||||
[node name="ChacacterSizeIndicator" type="CollisionShape2D" parent="Visuals"]
|
||||
editor_description = "This is a reference to the space, a normal sized humanoid character should occupy"
|
||||
visible = false
|
||||
position = Vector2(0, -200.5)
|
||||
shape = SubResource("RectangleShape2D_6l7g5")
|
||||
|
||||
[node name="TargetSelection" type="Node2D" parent="."]
|
||||
process_mode = 4
|
||||
visible = false
|
||||
|
||||
[node name="Click" type="Area2D" parent="TargetSelection"]
|
||||
script = ExtResource("3_wil2y")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TargetSelection/Click"]
|
||||
position = Vector2(-3, -195)
|
||||
shape = SubResource("CapsuleShape2D_6l7g5")
|
||||
|
||||
[node name="HoverIndicator" type="Node2D" parent="TargetSelection"]
|
||||
visible = false
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="TargetSelection/HoverIndicator"]
|
||||
position = Vector2(-3, -227)
|
||||
scale = Vector2(1.65625, 1.65625)
|
||||
texture = ExtResource("4_8ldlc")
|
||||
|
||||
[connection signal="TargetSelected" from="TargetSelection/Click" to="." method="ClickedTarget"]
|
||||
[connection signal="mouse_entered" from="TargetSelection/Click" to="TargetSelection/HoverIndicator" method="show"]
|
||||
[connection signal="mouse_exited" from="TargetSelection/Click" to="TargetSelection/HoverIndicator" method="hide"]
|
||||
@ -0,0 +1,41 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://qfdiudt3vpai"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://lequnojtar76" path="res://scripts/CSharp/Common/Fight/RoamingEnemyGroup.cs" id="1_t3mrx"]
|
||||
[ext_resource type="Texture2D" uid="uid://ccrnmx6bd842k" path="res://art/characters/farm fäulnis blobs.png" id="2_6ftwg"]
|
||||
[ext_resource type="Texture2D" uid="uid://bexymddkb6l0o" path="res://art/characters/Mavka/mavkha.png" id="3_xi5g8"]
|
||||
[ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interactions/interaction_area_2d.tscn" id="4_xi5g8"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_c8fs8"]
|
||||
atlas = ExtResource("2_6ftwg")
|
||||
region = Rect2(1747.17, 156.157, 311.249, 280.596)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kbgcx"]
|
||||
atlas = ExtResource("3_xi5g8")
|
||||
region = Rect2(774.378, 151.512, 1097.48, 1412.67)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6fvcb"]
|
||||
atlas = ExtResource("2_6ftwg")
|
||||
region = Rect2(1149.47, 92.492, 445.652, 353.692)
|
||||
|
||||
[node name="RoamingEnemyGroup" type="Node2D"]
|
||||
script = ExtResource("1_t3mrx")
|
||||
|
||||
[node name="Visuals" type="Node2D" parent="."]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Visuals"]
|
||||
position = Vector2(99, -222)
|
||||
texture = SubResource("AtlasTexture_c8fs8")
|
||||
|
||||
[node name="Sprite2D3" type="Sprite2D" parent="Visuals"]
|
||||
position = Vector2(-108, -337)
|
||||
scale = Vector2(0.43, 0.43)
|
||||
texture = SubResource("AtlasTexture_kbgcx")
|
||||
|
||||
[node name="Sprite2D2" type="Sprite2D" parent="Visuals"]
|
||||
position = Vector2(-41, -109)
|
||||
texture = SubResource("AtlasTexture_6fvcb")
|
||||
|
||||
[node name="InteractionArea" parent="." node_paths=PackedStringArray("_spriteToOutline") instance=ExtResource("4_xi5g8")]
|
||||
_spriteToOutline = [NodePath("../Visuals/Sprite2D"), NodePath("../Visuals/Sprite2D3"), NodePath("../Visuals/Sprite2D2")]
|
||||
|
||||
[connection signal="Interacted" from="InteractionArea" to="." method="StartFight"]
|
||||
@ -0,0 +1 @@
|
||||
uid://e8c8ym0fyprn
|
||||
@ -0,0 +1 @@
|
||||
uid://c8c4t80bqsja5
|
||||
@ -1,34 +1,125 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Babushka.scripts.CSharp.Common.Fight;
|
||||
using Babushka.scripts.CSharp.Common.Fight.ActionDetails;
|
||||
using Babushka.scripts.CSharp.Common.Util;
|
||||
|
||||
public partial class AllFightersVisual : Node
|
||||
{
|
||||
[Export] private Node2D _allyFighters;
|
||||
[Export] private Node2D _enemyFighters;
|
||||
|
||||
[Export] private PackedScene _blobFighterVisual;
|
||||
[Export] private PackedScene _bigBlobFighterVisual;
|
||||
[Export] private PackedScene _mavkaFighterVisual;
|
||||
[Export] private PackedScene _yourMomFighterVisual;
|
||||
[Export] private PackedScene _vesnaFighterVisual;
|
||||
|
||||
public void EnterFighter(FightWorld.Fighter fighter, bool isEnemy)
|
||||
[ExportCategory("References")] [Export]
|
||||
private Node2D _allyFighters = null!;
|
||||
|
||||
[Export] private Node2D _enemyFighters = null!;
|
||||
|
||||
[ExportCategory("Fighter Visual Scenes")]
|
||||
[Export] private PackedScene _blobFighterVisual = null!;
|
||||
[Export] private PackedScene _bigBlobFighterVisual = null!;
|
||||
[Export] private PackedScene _mavkaFighterVisual = null!;
|
||||
[Export] private PackedScene _yourMomFighterVisual = null!;
|
||||
[Export] private PackedScene _vesnaFighterVisual = null!;
|
||||
|
||||
[ExportCategory("Settings")]
|
||||
[Export(PropertyHint.ArrayType)] private float[] _positionDistanceFromCenter = [10, 20, 30];
|
||||
|
||||
private Dictionary<FightWorld.Fighter, FighterVisual> _fighterVisuals = new();
|
||||
|
||||
#region Shortcuts
|
||||
|
||||
private FightWorld.FightHappeningData HappeningData =>
|
||||
FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region State Reactions
|
||||
|
||||
public void FightHappeningStateChange(FightHappening.FightState from, FightHappening.FightState to)
|
||||
{
|
||||
var parent = isEnemy ? _enemyFighters : _allyFighters;
|
||||
if (to == FightHappening.FightState.FightersEnterAnim)
|
||||
{
|
||||
EnterFighter();
|
||||
}
|
||||
|
||||
if (to == FightHappening.FightState.InputActionDetail)
|
||||
{
|
||||
if (HappeningData.actionStaging!.CurrentDetail() is TargetSelectActionDetail targetDetail)
|
||||
{
|
||||
ShowTargetSelect(targetDetail);
|
||||
}
|
||||
}
|
||||
|
||||
var packedScene = fighter.type switch
|
||||
if (from == FightHappening.FightState.InputActionDetail)
|
||||
{
|
||||
FightWorld.Fighter.Type.Blob => _blobFighterVisual,
|
||||
FightWorld.Fighter.Type.BigBlob => _bigBlobFighterVisual,
|
||||
FightWorld.Fighter.Type.Mavka => _mavkaFighterVisual,
|
||||
FightWorld.Fighter.Type.YourMom => _yourMomFighterVisual,
|
||||
FightWorld.Fighter.Type.Vesna => _vesnaFighterVisual,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
var fighterVisual = packedScene.Instantiate<FighterVisual>();
|
||||
fighterVisual.Initialize(fighter);
|
||||
parent.AddChild(fighterVisual);
|
||||
HideTargetSelect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void EnterFighter()
|
||||
{
|
||||
if (HappeningData.fightersEnterStaging == null)
|
||||
return;
|
||||
|
||||
if (!HappeningData.fightersEnterStaging.HasAnyToExecute())
|
||||
return;
|
||||
|
||||
|
||||
foreach (var fighter in HappeningData.fightersEnterStaging.enteringEnemyFighters)
|
||||
{
|
||||
var packedScene = fighter.type switch
|
||||
{
|
||||
FightWorld.Fighter.Type.Blob => _blobFighterVisual,
|
||||
FightWorld.Fighter.Type.BigBlob => _bigBlobFighterVisual,
|
||||
FightWorld.Fighter.Type.Mavka => _mavkaFighterVisual,
|
||||
FightWorld.Fighter.Type.YourMom => _yourMomFighterVisual,
|
||||
FightWorld.Fighter.Type.Vesna => _vesnaFighterVisual,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
var fighterVisual = packedScene.Instantiate<FighterVisual>();
|
||||
fighterVisual.Initialize(fighter);
|
||||
_enemyFighters.AddChild(fighterVisual);
|
||||
fighterVisual.Position = new Vector2(_positionDistanceFromCenter[_enemyFighters.GetChildCount() - 1], 0);
|
||||
_fighterVisuals.Add(fighter, fighterVisual);
|
||||
}
|
||||
|
||||
foreach (var fighter in HappeningData.fightersEnterStaging.enteringAllyFighters)
|
||||
{
|
||||
var packedScene = fighter.type switch
|
||||
{
|
||||
FightWorld.Fighter.Type.Blob => _blobFighterVisual,
|
||||
FightWorld.Fighter.Type.BigBlob => _bigBlobFighterVisual,
|
||||
FightWorld.Fighter.Type.Mavka => _mavkaFighterVisual,
|
||||
FightWorld.Fighter.Type.YourMom => _yourMomFighterVisual,
|
||||
FightWorld.Fighter.Type.Vesna => _vesnaFighterVisual,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
var fighterVisual = packedScene.Instantiate<FighterVisual>();
|
||||
fighterVisual.Initialize(fighter);
|
||||
_allyFighters.AddChild(fighterVisual);
|
||||
fighterVisual.Position = new Vector2(-_positionDistanceFromCenter[_allyFighters.GetChildCount() - 1], 0);
|
||||
_fighterVisuals.Add(fighter, fighterVisual);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowTargetSelect(TargetSelectActionDetail targetDetail)
|
||||
{
|
||||
if (targetDetail.selectEnemy)
|
||||
_fighterVisuals.Where(kv => kv.Key.isEnemy).ForEach(kv => kv.Value.SetTargetSelectionActive(true));
|
||||
|
||||
if (targetDetail.selectAlly)
|
||||
_fighterVisuals.Where(kv => !kv.Key.isEnemy).ForEach(kv => kv.Value.SetTargetSelectionActive(true));
|
||||
}
|
||||
|
||||
private void HideTargetSelect()
|
||||
{
|
||||
foreach (var visual in _fighterVisuals.Values)
|
||||
{
|
||||
visual.SetTargetSelectionActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
uid://dst8xcyiw18uc
|
||||
@ -0,0 +1,53 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class FightHappeningStateDebugger : Node
|
||||
{
|
||||
[Export] private Label _label;
|
||||
|
||||
private FightWorld.FightHappeningData Data => FightWorld.Instance.fightHappeningData!;
|
||||
|
||||
public void StateChange(FightHappening.FightState from, FightHappening.FightState to)
|
||||
{
|
||||
_label.Text += $"State changed from {from} to {to}\n";
|
||||
switch (to)
|
||||
{
|
||||
case FightHappening.FightState.None:
|
||||
break;
|
||||
case FightHappening.FightState.FightStartAnim:
|
||||
break;
|
||||
case FightHappening.FightState.FightersEnter:
|
||||
break;
|
||||
case FightHappening.FightState.FightersEnterAnim:
|
||||
_label.Text +=
|
||||
$" {Data.fightersEnterStaging!.enteringAllyFighters.Count} allies " +
|
||||
$"and {Data.fightersEnterStaging.enteringEnemyFighters.Count} enemies are entering the fight.\n";
|
||||
break;
|
||||
case FightHappening.FightState.NextFighter:
|
||||
break;
|
||||
case FightHappening.FightState.StateCheck:
|
||||
break;
|
||||
case FightHappening.FightState.InputActionSelect:
|
||||
break;
|
||||
case FightHappening.FightState.ActionCheckDetails:
|
||||
break;
|
||||
case FightHappening.FightState.InputActionDetail:
|
||||
break;
|
||||
case FightHappening.FightState.ActionExecute:
|
||||
_label.Text += $" Executing action: {Data.actionStaging!.GetType()}\n";
|
||||
break;
|
||||
case FightHappening.FightState.ActionAnim:
|
||||
break;
|
||||
case FightHappening.FightState.EnemyActionSelect:
|
||||
break;
|
||||
case FightHappening.FightState.PlayerWin:
|
||||
break;
|
||||
case FightHappening.FightState.EnemyWin:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(to), to, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
uid://d2ugtb3dalrg3
|
||||
@ -0,0 +1 @@
|
||||
uid://buiwuf7pjfq8
|
||||
@ -1,21 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using Babushka.scripts.CSharp.Common.Util;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class FightRoomSceneSetup : Node
|
||||
{
|
||||
[Export] private Label debugLabel;
|
||||
[Export(PropertyHint.ArrayType)] private Node2D[] _enemyGroupSpawns;
|
||||
[Export] private PackedScene _roamingEnemyGroupPrefab;
|
||||
[Export] private FightSceneSwitcher _fightSceneSwitcher;
|
||||
|
||||
|
||||
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)
|
||||
|
||||
var i = 0;
|
||||
foreach (var availableParent in _enemyGroupSpawns.Shuffle())
|
||||
{
|
||||
debugLabel.Text += $" {enemyGroup.enemies.Count} enemies:\n";
|
||||
foreach (var enemy in enemyGroup.enemies)
|
||||
{
|
||||
debugLabel.Text += $" {enemy.type}\n";
|
||||
}
|
||||
var enemyGroup = room.enemyGroups[i];
|
||||
var roamingEnemyGroup = _roamingEnemyGroupPrefab.Instantiate<RoamingEnemyGroup>();
|
||||
roamingEnemyGroup.Initialize(enemyGroup, _fightSceneSwitcher);
|
||||
availableParent.AddChild(roamingEnemyGroup);
|
||||
if (i >= room.enemyGroups.Count - 1) break;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
uid://c60jugfee0bpv
|
||||
@ -0,0 +1 @@
|
||||
uid://bahm4ukspymm2
|
||||
@ -0,0 +1 @@
|
||||
uid://b2n37glcxm8wv
|
||||
@ -0,0 +1 @@
|
||||
uid://lequnojtar76
|
||||
@ -0,0 +1,35 @@
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight.UI;
|
||||
|
||||
public partial class ActionSelectUiSetup : CanvasLayer
|
||||
{
|
||||
// shortcuts
|
||||
private FightWorld.FightHappeningData HappeningData =>
|
||||
FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException();
|
||||
private FightWorld.Fighter CurrentFighter => HappeningData.fighterStack.Current;
|
||||
|
||||
// references
|
||||
[Export] private Button _attackActionButton = null!;
|
||||
[Export] private Button _summonActionButton = null!;
|
||||
[Export] private Button _talkActionButton = null!;
|
||||
[Export] private Button _fleeActionButton = null!;
|
||||
|
||||
// gets called from a state reaction enter (InputActionSelect)
|
||||
public void StateEntered()
|
||||
{
|
||||
var actions = CurrentFighter.availableActions;
|
||||
|
||||
_attackActionButton.Visible = actions.Any(a => a.BindToActionButton() == FighterAction.AllyActionButton.Attack);
|
||||
_summonActionButton.Visible = actions.Any(a => a.BindToActionButton() == FighterAction.AllyActionButton.Summon);
|
||||
_talkActionButton.Visible = actions.Any(a => a.BindToActionButton() == FighterAction.AllyActionButton.Talk);
|
||||
_fleeActionButton.Visible = actions.Any(a => a.BindToActionButton() == FighterAction.AllyActionButton.Flee);
|
||||
}
|
||||
|
||||
public void SelectAction(FighterAction.AllyActionButton actionButton)
|
||||
{
|
||||
var action = CurrentFighter.availableActions.First(a => a.BindToActionButton() == actionButton);
|
||||
FightHappening.Instance.ActionSelect(action);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
uid://byf2ywov34g0x
|
||||
@ -0,0 +1,16 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class TargetSelectionClick : Area2D
|
||||
{
|
||||
[Signal]
|
||||
public delegate void TargetSelectedEventHandler();
|
||||
|
||||
public override void _InputEvent(Viewport viewport, InputEvent @event, int shapeIdx)
|
||||
{
|
||||
if (@event is InputEventMouseButton { Pressed: true, ButtonIndex: MouseButton.Left })
|
||||
{
|
||||
EmitSignalTargetSelected();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
uid://boprnfciqgixf
|
||||
@ -0,0 +1 @@
|
||||
uid://bxs7sn7j3vd0n
|
||||
Loading…
Reference in new issue