Esempio n. 1
0
        private async void GameLogic()
        {
            //await PlayTextMusicFromFirstItem("游戏开始");
            var start = 0;

            while (true)
            {
                bool isTouchingBeginPoint;
                if (start == 0)
                {
                    isTouchingBeginPoint = true;
                }
                else
                {
                    if (!_isRepeatPlayMusic)
                    {
                        //await PlayTextMusicFromFirstItem("请重新触摸起点开始游戏");
                        //await PauseMusic0(SignKey, "Voice");
                    }
                    _isRepeatPlayMusic   = true;
                    isTouchingBeginPoint = await SendWcfCommandPluginsHelper.InvokerQueryDiaitalSwitchWithAutoUpload(_beginButtonItem, 60000);
                }
                if (isTouchingBeginPoint)
                {
                    await _errorRelayItem.Control(false);

                    //await PlayTextMusicFromFirstItem("开始走位");
                    var touchingButtonItem = await SendWcfCommandPluginsHelper.NotificationButtonPressAsyncTask(new List <MachineButtonItem> {
                        _midwayButtonItem, _endButtonItem
                    }, 60000 * 9);

                    if ((touchingButtonItem != null) && (touchingButtonItem.Number == _endButtonItem.Number))
                    {
                        break;
                    }
                    await _errorRelayItem.Control(true);

                    //PlayTextMusicFromFirstItem("");
                    await PauseMusic0(SignKey, "Voice");
                    await PlayMusic0(SignKey, "line2.wav", "Voice");

                    //PlayTextMusicFromFirstItem("请触碰起点,红灯熄灭,开始游戏。");
                    //await Task.Delay(3000);
                    _isRepeatPlayMusic = false;
                }
                await Task.Delay(1000);

                start++;
            }
            GameCompleted();
        }
Esempio n. 2
0
        private async void GameLogic()
        {
            await _relayButton.Control(true);

            while (true)
            {
                var result = await SendWcfCommandPluginsHelper.InvokerQueryDiaitalSwitchWithAutoUpload(_listenButton, 10000);

                if (result)
                {
                    await PlayMusic0(SignKey, "success.wav");

                    await Task.Delay(9000);
                }
            }
        }
Esempio n. 3
0
        private async Task <bool> CheckStartButton()
        {
            try
            {
                var resultItem = await SendWcfCommandPluginsHelper.InvokerQueryDiaitalSwitchWithAutoUpload(_startButtonItem, 60000);

                if (resultItem)
                {
                    await PlayMusic0(SignKey, "Go.wav", "Go");

                    await Task.Delay(2000);

                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 4
0
        private async void GameLogic()
        {
            while (true)
            {
                for (var i = 0; i < _gameCount; i++)
                {
                    if (_isBreakThird && (i >= 2))
                    {
                        GameCompleted();
                        break;
                    }
                    var count = i + 1;
ReBegin:
                    var isBegin = await SendWcfCommandPluginsHelper.InvokerQueryDiaitalSwitchWithAutoUpload(_beginButtonItem, _queryTime);

                    if (isBegin)
                    {
                        await PlayTextMusicFromFirstItem("游戏开始");
                        await PlayMusic0("HitMouse", "P5_mixdown.mp3", "back", 0.2, true);

                        //关闭所有灯
                        await CloseAllLight();

                        await _roomLightRelayItem.Control(true);

                        //await PlayTextMusicFromFirstItem($"第{count}轮游戏开始");
                        //开始击打
                        //重建击打行为数据
                        var hitDatas = GetHitDatas();
                        switch (_hitBuff)
                        {
                        case HitType.Default:
                            await HitTask.HitActionForDefault(hitDatas, this, hitDatas[0].ChargeHitCount);

                            break;

                        case HitType.Buff1:
                            await HitTask.HitActionForDefault(hitDatas, this, hitDatas[0].ChargeHitCount);

                            break;

                        case HitType.Buff2:
                            await HitTask.HitActionForDefault(hitDatas, this, hitDatas[0].ChargeHitCount);

                            break;

                        case HitType.Buff3:
                            await HitTask.HitActionForDefault(hitDatas, this, hitDatas[0].ChargeHitCount + 5);

                            break;

                        case HitType.Buff4:
                            await HitTask.HitActionForDefault(hitDatas, this, hitDatas[0].ChargeHitCount, true);

                            break;

                        case HitType.Buff5:
                            await HitTask.HitActionForDefault(hitDatas, this, hitDatas[0].ChargeHitCount);

                            break;

                        case HitType.Buff6:
                            await HitTask.HitActionForDefault(hitDatas, this, hitDatas[0].ChargeHitCount);

                            break;

                        case HitType.Buff7:
                            //全局的背景灯切换
                            RoomLightHelper.Start();
                            await HitTask.HitActionForBuffer7(hitDatas, this, hitDatas[0].ChargeHitCount);

                            //结束背景灯切换
                            await RoomLightHelper.Stop();

                            break;

                        case HitType.Buff8:
                            await HitTask.HitActionForDefault(hitDatas, this, hitDatas[0].ChargeHitCount);

                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                        await PauseMusic0("HitMouse", "back");

                        //await PlayTextMusicFromFirstItem($"第{count}轮游戏结束");
                        //选择招式
                        if (i + 1 != _gameCount)
                        {
                            if (_isBreakThird && (i >= 1))
                            {
                                //await PlayTextMusicFromFirstItem("本轮游戏胜利。");
                            }
                            else
                            {
                                await PlayTextMusicFromFirstItem("本轮游戏胜利,请选择下一轮游戏所要启动的招式。");
                            }
                            foreach (var questionLightRelayItem in _questionLightRelayItems)
                            {
                                await questionLightRelayItem.Control(true);
                            }
                            foreach (var styleLightRelayItem in _styleLightRelayItems)
                            {
                                await styleLightRelayItem.Control(true);
                            }
                            for (var j = 0; j < _chargeLightRelayItems.Count; j++)
                            {
                                if (j != _chargeLightRelayItems.Count - 1)
                                {
                                    await _chargeLightRelayItems[j].Control(false);
                                }
                            }
                            await _roomLightRelayItem.Control(false);

                            var hitSelector = _hitTypes.FirstOrDefault(s => s.Item1 == count);
                            _hitBuff = (HitType)Enum.ToObject(typeof(HitType), hitSelector.Item2);

                            var isPressQuestionButton = false;
                            while (!isPressQuestionButton)
                            {
                                if (_isBreakThird && (i >= 1))
                                {
                                    break;
                                }
                                var pressQuestionButtonItem = await SendWcfCommandPluginsHelper.NotificationButtonPressAsyncTask(_questionLightButtonItems, _queryTime);

                                if (pressQuestionButtonItem != null)
                                {
                                    await _chargeLightRelayItems[_chargeLightRelayItems.Count - 1].Control(false);
                                    await PlayMusic0("HitMouse", hitSelector.Item3, "buff");

                                    await Task.Delay(2000);

                                    isPressQuestionButton = true;
                                }
                            }
                            //var pressQuestionButtonItemIndex = _questionLightButtonItems.IndexOf(pressQuestionButtonItem);
                            for (var j = 0; j < _questionLightRelayItems.Count; j++)
                            {
                                await _questionLightRelayItems[j].Control(false);
                            }

                            //切换对应招式行为
                            //while (true)
                            //{
                            //    var tick = DateTime.Now.Ticks;
                            //    var random = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
                            //    var buttonIndex = random.Next(1, 8);
                            //    var hitType = (HitType)Enum.Parse(typeof(HitType), buttonIndex.ToString());
                            //    _hitBuff = hitType;
                            //}
                            var hitStyleData = _hitStyleDatas.FirstOrDefault(s => s.QuestionLightButtonIndex == _hitBuff.ToInt32());
                            if (hitStyleData == null)
                            {
                                throw new ArgumentNullException();
                            }

                            if (_isBreakThird && (i >= 1))
                            {
                                foreach (var hitStyleDataItem in _hitStyleDatas)
                                {
                                    foreach (var i1 in hitStyleDataItem.LightIndexs)
                                    {
                                        var   index = i1 - 1;
                                        await _styleLightRelayItems[index].Control(false);
                                    }
                                }
                            }
                            else
                            {
                                var usedStyleLightRelayItemIndexs = new List <int>();
                                foreach (var styleLightIndex in hitStyleData.LightIndexs)
                                {
                                    var index = styleLightIndex - 1;
                                    usedStyleLightRelayItemIndexs.Add(index);
                                    await _styleLightRelayItems[index].Control(true);
                                }
                                //关闭不需要的招式灯
                                await CloseStyleLights(usedStyleLightRelayItemIndexs);
                                await PlayTextMusicFromFirstItem(_hitBuff.GetEnumAttribute <TextToMusicAttribute>().Text);
                            }
                        }
                        else
                        {
                            GameCompleted();
                        }
                    }
                    else
                    {
                        goto ReBegin;
                    }
                }
                break;
            }
        }
Esempio n. 5
0
        private async void GameLogic()
        {
            while (true)
            {
                var gameIndex = 0;

                foreach (var cookingData in _cookingDatas)
                {
                    if ((gameIndex == 1) && _isBreakSecond)
                    {
                        gameIndex++;
                        continue;
                    }
                    if ((gameIndex == 2) && _isBreakThird)
                    {
                        continue;
                    }
Repeat:
                    var result = await SendWcfCommandPluginsHelper.InvokerQueryDiaitalSwitchWithAutoUpload(_startButtonItem, 60000 * 9);

                    if (!result)
                    {
                        goto Repeat;
                    }
                    await PlayStartBack(gameIndex);

                    if (cookingData.Excute(this))
                    {
                        var musicIndex = gameIndex;
                        if ((gameIndex == 0) && _isBreakSecond)
                        {
                            musicIndex++;
                        }
                        if ((gameIndex == 1) && _isBreakThird)
                        {
                            musicIndex++;
                        }
                        if (gameIndex == 0)
                        {
                            if (!(_isBreakSecond && _isBreakThird))
                            {
                                await PlayMusic0(SignKey, "第一轮结束.wav");
                            }
                        }
                        else
                        {
                            if (gameIndex == 1)
                            {
                                if (!_isBreakThird)
                                {
                                    await PlayMusic0(SignKey, "第二轮结束.wav");
                                }
                            }
                        }

                        await Task.Delay(2000);

                        gameIndex++;
                    }
                    else
                    {
                        await PlayTextMusicFromFirstItem("游戏超时,请重新开始");

                        goto Repeat;
                    }
                }
                break;
            }
            await PlayMusic0(SignKey, "line4.wav");

            GameCompleted();
        }