private async void Battling() { if (!_alive) { return; } var buttons = Enemies.DeployTroop(_currentGame, _currentRound); switch (_currentGame) { case 0: switch (_currentRound) { case 0: await PlayMusic0(SignKey, "al1.1.wav", "al11"); await Task.Delay(8000); await PlayMusic0(SignKey, "battlebgm.mp3", "round", 0.5, true); break; case 1: await PlayMusic0(SignKey, "al1.2.wav", "al12"); break; case 2: await PlayMusic0(SignKey, "al1.3.wav", "al13"); break; } break; case 1: switch (_currentRound) { case 0: await PlayMusic0(SignKey, "al2.1.wav", "al21"); await Task.Delay(4000); await PlayMusic0(SignKey, "battlebgm.mp3", "round", 0.5, true); break; case 1: await PlayMusic0(SignKey, "al2.2.wav", "al22"); break; case 3: await PlayMusic0(SignKey, "al2.3.wav", "al23"); break; } break; case 2: switch (_currentRound) { case 0: await PlayMusic0(SignKey, "attack_voice.wav", "round31"); await Task.Delay(4000); await PlayMusic0(SignKey, "attack_bgm.wav", "round", 0.5, true); break; } break; } _totalRound = Enemies.GetRoundcount(_currentGame); if (!_alive) { return; } BattleEnemyTimer.LoadButtons(buttons.Item1, buttons.Item2); await BattleEnemyTimer.GameStart(1); }
private async void BattleOn() { RestLife(); Enemies.RestBattle(); while (true) { try { var hitchecktaskasync = new HitCheckTaskAsync(_hitCheckTasks, 15 * 60 * 1000); var results = await hitchecktaskasync.InvokeAsync(); if (null != results) { foreach (var result in results) { if (null == result) { CallOnNotification("empty button message"); continue; } if (result.SwitchItem.SwitchStatus == SwitchStatus.NO) { continue; } var switchnumber = result.SwitchItem.SwitchNumber; if ((switchnumber == _startButton.Number) && (result.DeviceNumber == _startButton.DeviceNumber) && !_alive) { _alive = true; RestLife(); Enemies.RestBattle(); BattleEnemyTimer.Hurting -= BattleEnemyTimerHurting; BattleEnemyTimer.Hurting += BattleEnemyTimerHurting; BattleEnemyTimer.Finishing -= BattleEnemyTimerFinishing; BattleEnemyTimer.Finishing += BattleEnemyTimerFinishing; _currentRound = 0; Battling(); //_roundTimer = new Timer(2 * 60 * 1 * 1000) { AutoReset = false }; //_roundTimer.Start(); continue; } if (Enemies.CheckIfOff(result.DeviceNumber, result.SwitchItem.SwitchNumber)) { continue; } if (_allHits.Any(b => (b.Number == result.SwitchItem.SwitchNumber) && (b.DeviceNumber == result.DeviceNumber))) { var tick = DateTime.Now.Ticks; var randomnumber = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32)).Next(1, 5); var hitsound = $"hit{randomnumber}.wav"; await PlayMusic0(SignKey, hitsound, hitsound); CallOnNotification($"hit : {result.SwitchItem.SwitchNumber} - {result.DeviceNumber}"); ButtonHit(BattleEnemyTimer, result.SwitchItem.SwitchNumber, result.DeviceNumber); } } } } catch (Exception ex) { OnNotification(new NotificationEventArgs(ex.Message)); } } }