158 lines
5.3 KiB
Plaintext
158 lines
5.3 KiB
Plaintext
@using KoogleApp.Model
|
|
@using KoogleApp.Store.Game
|
|
@using KoogleApp.Store.Game.ThrowPanel
|
|
@using KoogleApp.Store.Game.UndoRedo
|
|
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
|
|
|
@inherits FluxorComponent
|
|
|
|
@inject IState<ThrowPanelState> ThrowPanelState
|
|
@inject IState<UndoRedoState> UndoRedoState
|
|
@inject IDispatcher Dispatcher
|
|
|
|
@if (ThrowPanelState.Value.IsStated)
|
|
{
|
|
<MudGrid>
|
|
|
|
<NumberPinPanel/>
|
|
@if ((@UndoRedoState.Value.CanRedo && _locked) && (!_correcting))
|
|
{
|
|
<MudItem xs="6">
|
|
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
|
|
@if (!CanUnlock)
|
|
{
|
|
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.DirectionsRun"></MudIcon>
|
|
<MudText>Wurf: @(ThrowPanelState.Value.ThrowCounter + 1) von XX um YY</MudText>
|
|
}
|
|
else
|
|
{
|
|
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.AccessibilityNew"></MudIcon>
|
|
<MudText>Bild: @((UndoRedoState.Value.Version / 2) + 1)</MudText>
|
|
}
|
|
</MudPaper>
|
|
</MudItem>
|
|
|
|
<MudItem xs="6">
|
|
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
|
|
<MudButton OnClick="UnlockClick"
|
|
Disabled="!CanUnlock">
|
|
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.ChangeHistory"
|
|
Color="@(!CanUnlock ? Color.Dark : Color.Secondary)"
|
|
Style="font-size: 3rem;"/>
|
|
<MudText>@(CanUnlock ? "ab hier Wurf korrigieren" : "nur Bilder sind korrigierbar")</MudText>
|
|
</MudButton>
|
|
</MudPaper>
|
|
</MudItem>
|
|
}
|
|
else
|
|
{
|
|
<MudItem xs="4">
|
|
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
|
|
<MudButton OnClick="SinkLeftClick"
|
|
Disabled="@Disabled">
|
|
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.ArrowCircleLeft"
|
|
Color="@(Disabled ? Color.Dark : Color.Error)"
|
|
Style="font-size: 3rem;"/>
|
|
Gosse
|
|
</MudButton>
|
|
</MudPaper>
|
|
</MudItem>
|
|
<MudItem xs="4">
|
|
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
|
|
<MudButton OnClick="ThrowClick" Disabled="Disabled">
|
|
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.ArrowCircleUp"
|
|
Color="@(Disabled ? Color.Dark : Color.Success)"
|
|
Style="font-size: 3rem;"/>
|
|
Wurf
|
|
</MudButton>
|
|
</MudPaper>
|
|
</MudItem>
|
|
<MudItem xs="4">
|
|
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
|
|
<MudButton OnClick="SinkRightClick"
|
|
Disabled="@Disabled">
|
|
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.ArrowCircleRight"
|
|
Color="@(Disabled ? Color.Dark : Color.Error)"
|
|
Style="font-size: 3rem;"/>
|
|
Gosse
|
|
</MudButton>
|
|
</MudPaper>
|
|
</MudItem>
|
|
}
|
|
</MudGrid>
|
|
}
|
|
|
|
|
|
@code {
|
|
private bool CanUnlock => ThrowPanelState.Value.ThrowPanelStateStatus == ThrowPanelStateStatus.AfterThrow || ThrowPanelState.Value.ThrowPanelStateStatus == ThrowPanelStateStatus.GameStart;
|
|
private bool _locked = true;
|
|
|
|
private bool Disabled => (UndoRedoState.Value.CanRedo && _locked) && !_correcting;
|
|
private bool _correcting = false;
|
|
private int _version = 0;
|
|
|
|
protected override void OnAfterRender(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
Dispatcher.Dispatch(new LoadStateFromSessionAction());
|
|
}
|
|
_locked = true;
|
|
|
|
if (_version != UndoRedoState.Value.Version)
|
|
{
|
|
_version = UndoRedoState.Value.Version;
|
|
_correcting = false;
|
|
_locked = true;
|
|
}
|
|
|
|
|
|
base.OnAfterRender(firstRender);
|
|
}
|
|
|
|
private void SinkLeftClick(MouseEventArgs obj)
|
|
{
|
|
DoThrow(true, false);
|
|
}
|
|
|
|
private void SinkRightClick(MouseEventArgs obj)
|
|
{
|
|
DoThrow(false, true);
|
|
}
|
|
|
|
private void ThrowClick(MouseEventArgs obj)
|
|
{
|
|
DoThrow(false, false);
|
|
}
|
|
|
|
private void DoThrow(bool leftSink, bool rightSink)
|
|
{
|
|
_correcting = false;
|
|
Dispatcher.Dispatch(new ThrowAction(LeftSink: leftSink, RightSink: rightSink));
|
|
}
|
|
|
|
private async Task UnlockClick(MouseEventArgs obj)
|
|
{
|
|
if (!CanUnlock)
|
|
return;
|
|
|
|
// if (!CanUnlock)
|
|
// {
|
|
// Dispatcher.Dispatch(new UndoAction());
|
|
// await Task.Run(() =>
|
|
// {
|
|
// Task.Delay(200);
|
|
// _correcting = true;
|
|
// _locked = false;
|
|
// Task.Delay(200);
|
|
// });
|
|
// }
|
|
// else
|
|
// {
|
|
_correcting = true;
|
|
_locked = false;
|
|
// }
|
|
}
|
|
|
|
}
|