From 8591cd034eb1350df7fc4133d1db6077acb1bcec Mon Sep 17 00:00:00 2001 From: dicenull Date: Thu, 7 Sep 2023 19:12:18 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8D=20=E5=9B=9E=E3=81=97=E3=81=9F?= =?UTF-8?q?=E7=9E=AC=E9=96=93=E3=81=AB=E7=A2=BA=E5=AE=9A=E3=81=95=E3=81=9B?= =?UTF-8?q?=E3=81=A6=E6=BB=91=E3=82=8A=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/feature_slot/reel_component.dart | 11 +++++++---- lib/feature_slot/slot_component.dart | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/feature_slot/reel_component.dart b/lib/feature_slot/reel_component.dart index 0833d29..359976c 100644 --- a/lib/feature_slot/reel_component.dart +++ b/lib/feature_slot/reel_component.dart @@ -14,12 +14,14 @@ class ReelComponent extends PositionComponent with HasGameRef { // state bool isRoll = false; + int stopIndex = -1; final speed = 800; + int get length => _symbols.length; + bool onCheckStopCurrent = false; _SuberiState? _suberiState; double reelPosition = 0; - int stopIndex = -1; ReelComponent(this._symbols, this.symbolSize) : _reel = <_SymbolState>[], reelHeight = symbolSize * _symbols.length { @@ -66,7 +68,8 @@ class ReelComponent extends PositionComponent with HasGameRef { }); } - void roll() { + void roll(int index) { + stopIndex = index; isRoll = true; } @@ -140,9 +143,9 @@ class ReelComponent extends PositionComponent with HasGameRef { void _stopCurrent() { if (!isRoll) return; - final index = _calcCenterIndex(); - var symbol = _reel[index].symbol; + var symbol = _reel[stopIndex].symbol; _suberiState = _SuberiState(symbol, 1); + print(_suberiState?.symbol.toString()); } } diff --git a/lib/feature_slot/slot_component.dart b/lib/feature_slot/slot_component.dart index c86be29..07f4e43 100644 --- a/lib/feature_slot/slot_component.dart +++ b/lib/feature_slot/slot_component.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:math' as math; import 'package:app/feature_slot/reel_component.dart'; import 'package:app/feature_slot/slot_core.dart'; @@ -47,7 +48,9 @@ class SlotComponent extends PositionComponent with HasGameRef { } for (var reel in reels) { - reel.roll(); + // どこに止まるかを確定させる + final index = math.Random().nextInt(reel.length); + reel.roll(index); } inBet = true; }