Added minigame to attack action
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Babushka"
|
config/name="Babushka"
|
||||||
run/main_scene="uid://c1dsbe7ryaije"
|
run/main_scene="uid://bopv10dqm1knc"
|
||||||
config/features=PackedStringArray("4.4", "C#", "Forward Plus")
|
config/features=PackedStringArray("4.4", "C#", "Forward Plus")
|
||||||
run/max_fps=120
|
run/max_fps=120
|
||||||
boot_splash/fullsize=false
|
boot_splash/fullsize=false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=11 format=3 uid="uid://cjshlwk8ajpnp"]
|
[gd_scene load_steps=13 format=3 uid="uid://cjshlwk8ajpnp"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cnhpnn8o0gybd" path="res://scripts/CSharp/Common/Fight/FightHappeningSceneSetup.cs" id="1_fiutj"]
|
[ext_resource type="Script" uid="uid://cnhpnn8o0gybd" path="res://scripts/CSharp/Common/Fight/FightHappeningSceneSetup.cs" id="1_fiutj"]
|
||||||
[ext_resource type="Script" uid="uid://c76mhhqyk4lgh" path="res://scripts/CSharp/Common/Fight/FightHappening.cs" id="1_gsk03"]
|
[ext_resource type="Script" uid="uid://c76mhhqyk4lgh" path="res://scripts/CSharp/Common/Fight/FightHappening.cs" id="1_gsk03"]
|
||||||
@@ -8,7 +8,9 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://7jsxokx67gpq" path="res://prefabs/fight/fighterVisuals/vesna_fighter_visual.tscn" id="4_qo0gi"]
|
[ext_resource type="PackedScene" uid="uid://7jsxokx67gpq" path="res://prefabs/fight/fighterVisuals/vesna_fighter_visual.tscn" id="4_qo0gi"]
|
||||||
[ext_resource type="PackedScene" uid="uid://0vm3jb1hnkkb" path="res://prefabs/fight/fighterVisuals/blob_fighter_visual.tscn" id="4_vp8s0"]
|
[ext_resource type="PackedScene" uid="uid://0vm3jb1hnkkb" path="res://prefabs/fight/fighterVisuals/blob_fighter_visual.tscn" id="4_vp8s0"]
|
||||||
[ext_resource type="Script" uid="uid://buiwuf7pjfq8" path="res://scripts/CSharp/Common/Fight/FightHappeningStateReaction.cs" id="4_ydj1i"]
|
[ext_resource type="Script" uid="uid://buiwuf7pjfq8" path="res://scripts/CSharp/Common/Fight/FightHappeningStateReaction.cs" id="4_ydj1i"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bydwj3pbvqrhb" path="res://prefabs/minigame/minigame.tscn" id="8_2b3cf"]
|
||||||
[ext_resource type="Script" uid="uid://byf2ywov34g0x" path="res://scripts/CSharp/Common/Fight/UI/ActionSelectUiSetup.cs" id="8_bkwsr"]
|
[ext_resource type="Script" uid="uid://byf2ywov34g0x" path="res://scripts/CSharp/Common/Fight/UI/ActionSelectUiSetup.cs" id="8_bkwsr"]
|
||||||
|
[ext_resource type="Script" uid="uid://bwm0nhvt1083k" path="res://scripts/CSharp/Common/Fight/FightMinigameHandler.cs" id="8_falfe"]
|
||||||
[ext_resource type="Script" uid="uid://d2ugtb3dalrg3" path="res://scripts/CSharp/Common/Fight/FightHappeningStateDebugger.cs" id="8_tv7cl"]
|
[ext_resource type="Script" uid="uid://d2ugtb3dalrg3" path="res://scripts/CSharp/Common/Fight/FightHappeningStateDebugger.cs" id="8_tv7cl"]
|
||||||
|
|
||||||
[node name="BabushkaSceneFightHappening" type="Node2D"]
|
[node name="BabushkaSceneFightHappening" type="Node2D"]
|
||||||
@@ -44,6 +46,14 @@ _positionDistanceFromCenter = PackedFloat32Array(300, 550, 800)
|
|||||||
|
|
||||||
[node name="EnvironmentVisuals" type="Node2D" parent="."]
|
[node name="EnvironmentVisuals" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="MinigameHandler" type="Node2D" parent="." node_paths=PackedStringArray("_minigameController")]
|
||||||
|
script = ExtResource("8_falfe")
|
||||||
|
_minigameController = NodePath("Minigame")
|
||||||
|
|
||||||
|
[node name="Minigame" parent="MinigameHandler" instance=ExtResource("8_2b3cf")]
|
||||||
|
process_mode = 4
|
||||||
|
visible = false
|
||||||
|
|
||||||
[node name="FightSceneSwitcher" parent="." instance=ExtResource("2_phrlx")]
|
[node name="FightSceneSwitcher" parent="." instance=ExtResource("2_phrlx")]
|
||||||
|
|
||||||
[node name="ActionSelect" type="CanvasLayer" parent="." node_paths=PackedStringArray("_attackActionButton", "_summonActionButton", "_talkActionButton", "_fleeActionButton")]
|
[node name="ActionSelect" type="CanvasLayer" parent="." node_paths=PackedStringArray("_attackActionButton", "_summonActionButton", "_talkActionButton", "_fleeActionButton")]
|
||||||
@@ -191,6 +201,7 @@ text = "Hello world"
|
|||||||
[connection signal="SignalTransitionState" from="FightHappening" to="FightVisuals" method="FightHappeningStateChange"]
|
[connection signal="SignalTransitionState" from="FightHappening" to="FightVisuals" method="FightHappeningStateChange"]
|
||||||
[connection signal="SignalTransitionState" from="FightHappening" to="ActionSelect/StateReactionInputActionSelect" method="FightHappeningStateTransitioned"]
|
[connection signal="SignalTransitionState" from="FightHappening" to="ActionSelect/StateReactionInputActionSelect" method="FightHappeningStateTransitioned"]
|
||||||
[connection signal="SignalTransitionState" from="FightHappening" to="StateMachineDebugger" method="StateChange"]
|
[connection signal="SignalTransitionState" from="FightHappening" to="StateMachineDebugger" method="StateChange"]
|
||||||
|
[connection signal="SignalTransitionToState" from="FightHappening" to="MinigameHandler" method="OnStateEnter"]
|
||||||
[connection signal="OnStateEntered" from="ActionAnimationController/StateReactionActionAnimation" to="ActionAnimationController" method="StateEnter"]
|
[connection signal="OnStateEntered" from="ActionAnimationController/StateReactionActionAnimation" to="ActionAnimationController" method="StateEnter"]
|
||||||
[connection signal="OnStateExited" from="ActionAnimationController/StateReactionActionAnimation" to="ActionAnimationController" method="StateExit"]
|
[connection signal="OnStateExited" from="ActionAnimationController/StateReactionActionAnimation" to="ActionAnimationController" method="StateExit"]
|
||||||
[connection signal="pressed" from="ActionSelect/BottomPanel/VBoxContainer/MarginContainer/HBoxContainer/MarginContainer/AttackButton" to="ActionSelect" method="SelectAction" binds= [1]]
|
[connection signal="pressed" from="ActionSelect/BottomPanel/VBoxContainer/MarginContainer/HBoxContainer/MarginContainer/AttackButton" to="ActionSelect" method="SelectAction" binds= [1]]
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Babushka.scripts.CSharp.Common.Fight.ActionDetails;
|
||||||
|
|
||||||
|
public class MinigameActionDetail : FighterAction.FighterActionDetail
|
||||||
|
{
|
||||||
|
// settings
|
||||||
|
|
||||||
|
|
||||||
|
// result
|
||||||
|
public List<int>? damageHits = null;
|
||||||
|
|
||||||
|
public MinigameActionDetail()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool DetailComplete()
|
||||||
|
{
|
||||||
|
return damageHits != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetResult()
|
||||||
|
{
|
||||||
|
damageHits = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Babushka.scripts.CSharp.Common.Fight.ActionDetails;
|
using Babushka.scripts.CSharp.Common.Fight.ActionDetails;
|
||||||
using Babushka.scripts.CSharp.Common.Util;
|
using Babushka.scripts.CSharp.Common.Util;
|
||||||
@@ -15,6 +16,8 @@ public class AllyAttackAction : FighterAction
|
|||||||
selectAlly = false
|
selectAlly = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public MinigameActionDetail minigameDetail = new();
|
||||||
|
|
||||||
public override Variant<float, Func<bool>> GetAnimationEnd()
|
public override Variant<float, Func<bool>> GetAnimationEnd()
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
@@ -22,12 +25,12 @@ public class AllyAttackAction : FighterAction
|
|||||||
|
|
||||||
public override bool NextDetail()
|
public override bool NextDetail()
|
||||||
{
|
{
|
||||||
return !targetSelect.DetailComplete();
|
return !targetSelect.DetailComplete() || !minigameDetail.DetailComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override FighterActionDetail CurrentDetail()
|
public override FighterActionDetail CurrentDetail()
|
||||||
{
|
{
|
||||||
return targetSelect;
|
return targetSelect.DetailComplete() ? minigameDetail : targetSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override AllyActionButton BindToActionButton()
|
public override AllyActionButton BindToActionButton()
|
||||||
@@ -38,11 +41,13 @@ public class AllyAttackAction : FighterAction
|
|||||||
public override void Reset()
|
public override void Reset()
|
||||||
{
|
{
|
||||||
targetSelect.ResetResult();
|
targetSelect.ResetResult();
|
||||||
|
minigameDetail.ResetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ExecuteAction()
|
public override void ExecuteAction()
|
||||||
{
|
{
|
||||||
targetSelect.GetTarget().AddHealth(-5);
|
var totalDamage = minigameDetail.damageHits!.Sum(dh => dh);
|
||||||
|
targetSelect.GetTarget().AddHealth(-totalDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task AnimateAction(AllFightersVisual allFightersVisual)
|
public override async Task AnimateAction(AllFightersVisual allFightersVisual)
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Babushka.scripts.CSharp.Common.Fight;
|
||||||
|
using Babushka.scripts.CSharp.Common.Fight.ActionDetails;
|
||||||
|
using Babushka.scripts.CSharp.Common.Minigame;
|
||||||
|
|
||||||
|
public partial class FightMinigameHandler : Node
|
||||||
|
{
|
||||||
|
#region Shortcuts
|
||||||
|
|
||||||
|
private FightWorld.FightHappeningData HappeningData => FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
[Export] private MinigameController _minigameController;
|
||||||
|
|
||||||
|
|
||||||
|
public void OnStateEnter(FightHappening.FightState to)
|
||||||
|
{
|
||||||
|
if(to!=FightHappening.FightState.InputActionDetail) return;
|
||||||
|
|
||||||
|
var currentDetail = HappeningData.actionStaging!.CurrentDetail();
|
||||||
|
if(currentDetail is not MinigameActionDetail minigameDetail) return;
|
||||||
|
|
||||||
|
_minigameController.Run(new MinigameController.Builder<int>()
|
||||||
|
.AddRegion(4)
|
||||||
|
.AddRegion(0).RegionWithProportion(1.5f)
|
||||||
|
.AddRegion(8).RegionWithProportion(0.5f)
|
||||||
|
.AddRegion(0).RegionWithProportion(1.5f)
|
||||||
|
.AddRegion(3)
|
||||||
|
.AddRegion(5)
|
||||||
|
.WithHitCount(3)
|
||||||
|
).ContinueWith(task =>
|
||||||
|
{
|
||||||
|
minigameDetail.damageHits = task.Result;
|
||||||
|
//FightHappening.Instance.DetailFilled();
|
||||||
|
// Apparently ContinueWith spawn a new Thread, but methods on a node only want to be called from the main thread
|
||||||
|
FightHappening.Instance.CallDeferred("DetailFilled");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bwm0nhvt1083k
|
||||||
Reference in New Issue
Block a user