Exemplo n.º 1
0
        private void Init()
        {
            MainUI.BreakSecond   += delegate { _isBreakSencond = true; };
            MainUI.UnbreakSecond += delegate { _isBreakSencond = false; };
            MainUI.BreakThird    += delegate { _isBreakThree = true; };
            MainUI.UnbreakThird  += delegate { _isBreakThree = false; };

            BattleEnemyTimer.MachineMusicItems = MusicItems;
            _startButton = ButtonItems[0];
            _life.Add(RelayItems[32]);
            _life.Add(RelayItems[31]);
            _life.Add(RelayItems[30]);
            var buttongroup = ButtonItems.GroupBy(b => b.DeviceNumber).ToDictionary(k => k.Key, v => v.Select(vk => vk).ToList());

            foreach (var buttons in buttongroup)
            {
                var button = buttons.Value.FirstOrDefault();
                if (null == button)
                {
                    continue;
                }
                var hitchecktask = new HitCheckTask.HitCheckTask(SignKey, button);
                _hitCheckTasks.Add(hitchecktask);
            }
            for (var i = 1; i < 31; i++)
            {
                _allHits.Add(ButtonItems[i]);
                Enemies.LoadEnemy(i, ButtonItems[i], RelayItems[i - 1]);
            }
            Enemies.ArrangeEnemey();
            _totalGame = Enemies.GetGamecount();
        }
Exemplo n.º 2
0
        private void InitAppParam()
        {
            //初始化按钮
            _pointLightButtonItems = ButtonItems.Take(20).ToList();
            for (var i = 20; i < 28; i++)
            {
                _questionLightButtonItems.Add(ButtonItems[i]);
            }
            _beginButtonItem = ButtonItems[28];
            //初始化继电器
            _pointLightRelayItems = RelayItems.Take(20).ToList();
            for (var i = 20; i < 28; i++)
            {
                _questionLightRelayItems.Add(RelayItems[i]);
            }
            for (var i = 28; i < 36; i++)
            {
                _styleLightRelayItems.Add(RelayItems[i]);
            }
            for (var i = 36; i < 46; i++)
            {
                _chargeLightRelayItems.Add(RelayItems[i]);
            }
            _roomLightRelayItem = RelayItems[46];

            RoomLightHelper.RoomRelayLight = _roomLightRelayItem;

            MainUI.BreakThird   += MainUI_BreakThird;
            MainUI.BreakUnThird += MainUI_BreakUnThird;
        }
Exemplo n.º 3
0
        internal FormButtonGroup(HtmlForm form, string name, IHtmlElement[] buttonElements)
            : base(form)
        {
            _name       = name;
            ButtonItems = buttonElements.Select(element => CreateGroupItem(element)).ToArray();

            _allowMultiple = ButtonItems.Any(item => item.ButtonType == FormGroupButtonType.CheckBox);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Recreates the jump bar items hold in the <see cref="DW.WPFToolkit.Controls.PagingControl.ButtonItems" /> property as soon the items collection changes.
        /// </summary>
        /// <param name="e">The parameter passed by the caller.</param>
        protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
        {
            base.OnItemsChanged(e);

            ButtonItems.Clear();
            for (int i = 0; i < Items.Count; ++i)
            {
                ButtonItems.Add(i);
            }
        }
Exemplo n.º 5
0
        private void InitAppParam()
        {
            _foodButtonItems = ButtonItems.Take(12).ToList();
            _startButtonItem = ButtonItems[12];
            _speedButtonItem = ButtonItems[13];

            MainUI.BreakSecond   += MainUI_BreakSecond;
            MainUI.UnbreakSecond += MainUI_UnbreakSecond;
            MainUI.BreakThird    += MainUI_BreakThird;
            MainUI.UnbreakThird  += MainUI_UnbreakThird;
        }
Exemplo n.º 6
0
        private async void EyePick()
        {
            while (true)
            {
                try
                {
                    var hitchecktaskasync = new HitCheckTaskAsync(_hitCheckTask, 10 * 60 * 1000);
                    var results           = await hitchecktaskasync.InvokeAsync();

                    if (null != results)
                    {
                        foreach (var result in results)
                        {
                            if (result.SwitchItem.SwitchStatus == SwitchStatus.NO)
                            {
                                continue;
                            }
                            var eye = ButtonItems.FirstOrDefault(r => r.Number == result.SwitchItem.SwitchNumber);
                            if (null == eye)
                            {
                                continue;
                            }
                            //_eyeroller[eye] = result.SwitchItem.SwitchStatus == SwitchStatus.NC ? 1 : 0;
                            var eyebutton = _eyebuttons.FirstOrDefault(e => e.Key.Number == result.SwitchItem.SwitchNumber);
                            if (eyebutton.Value != null)
                            {
                                foreach (var machineRelayItem in _eyebuttons)
                                {
                                    await machineRelayItem.Value.Control(false);
                                }
                                CallOnNotification($"button:{eye.Number} - status:{result.SwitchItem.SwitchStatus} eye:{eyebutton.Value.Number}");
                                await eyebutton.Value.Control(result.SwitchItem.SwitchStatus == SwitchStatus.NC);

                                if (result.SwitchItem.SwitchStatus == SwitchStatus.NC)
                                {
                                    var tick         = DateTime.Now.Ticks;
                                    var randomnumber = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32)).Next(1, 7);
                                    await PlayMusic0(SignKey, $"e{randomnumber}.wav", "eyesound");
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    OnNotification(new NotificationEventArgs(ex.Message));
                }
            }
        }
Exemplo n.º 7
0
        private async void RunePick()
        {
            await _light.Control(true);

            while (true)
            {
                try
                {
                    var hitchecktaskasync = new HitCheckTaskAsync(_hitCheckTask, 10 * 60 * 1000);
                    var results           = await hitchecktaskasync.InvokeAsync();

                    if (null != results)
                    {
                        foreach (var result in results)
                        {
                            var rune = ButtonItems.FirstOrDefault(r => r.Number == result.SwitchItem.SwitchNumber);
                            if (null == rune)
                            {
                                continue;
                            }
                            _runes[rune] = result.SwitchItem.SwitchStatus == SwitchStatus.NC ? 1 : 0;

                            CallOnNotification($"rune: {result.SwitchItem.SwitchNumber} status: {result.SwitchItem.SwitchStatus}");
                            await PlayMusic0(SignKey, "touch.wav", "touching");

                            var runeon  = _runes.Where(r => _runeson.Contains(r.Key));
                            var runeoff = _runes.Where(r => !_runeson.Contains(r.Key));

                            if (runeon.All(r => 1 == r.Value) && runeoff.All(r => 0 == r.Value))
                            {
                                await PauseMusic0(SignKey, "touching");
                                await PlayMusic0(SignKey, "touchsuccess.wav", "touchover");

                                await Task.Delay(4000);

                                await _light.Control(false);

                                OnGameOver();
                                return;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    OnNotification(new NotificationEventArgs(ex.Message));
                }
            }
        }
Exemplo n.º 8
0
        private async void Callback_Notify(object sender, WcfResultInfo e)
        {
            if (e.IsError)
            {
                return;
            }
            var switchItem = e.Data.ToObject <SwitchItem>();
            var buttonItem = ButtonItems.FirstOrDefault(s => s.Number == switchItem.SwitchNumber);

            if (buttonItem != null)
            {
                if (!_timer.Enabled)
                {
                    _timer.Start();
                }
                else
                {
                    return;
                }
                if (_isCompleted)
                {
                    return;
                }
                var findIndex  = ButtonItems.IndexOf(buttonItem) + 1;
                var sudokuData = _sudokuDatas.Find(s => s.ButtonIndex == findIndex);
                foreach (var relayIndex in sudokuData.RelayIndexs)
                {
                    await RelayItems[relayIndex - 1].Control();
                }
                await PlayMusic0(SignKey, "ding.wav");

                //await Task.Delay(1000);
                var result = RelayItems.All(s => s.IsNo);
                if (result)
                {
                    _isCompleted = true;
                    _manualResetEvent.Set();
                }
            }
        }
Exemplo n.º 9
0
        private void InitGameData()
        {
            var gameData = ConfigurationManager.AppSettings[$"{SignKey}Data"];
            var datas    = gameData.Split('|');

            foreach (var data in datas)
            {
                var boxingData = new BoxingData();
                var data2Nums  = data.Split('-');
                boxingData.HitCount = data2Nums[0].ToInt32();
                boxingData.Delay    = data2Nums[1].ToInt32();
                boxingData.Number   = data2Nums[2].Split(',').Select(s => s.ToInt32()).ToList();
                _boxingDatas.Add(boxingData);
            }
            _startButtonItem  = ButtonItems[ButtonItems.Count - 1];
            _checkButtonItems = ButtonItems.Take(8).ToList();

            _isBreakThird         = true;
            MainUI.BreakSecond   += MainUI_BreakSecond;
            MainUI.UnbreakSecond += MainUI_UnbreakSecond;
            MainUI.BreakThird    += MainUI_BreakThird;
            MainUI.UnbreakThird  += MainUI_UnbreakThird;
        }
 public MainViewModel()
 {
     ButtonItems.Add(new ButtonItemViewModel("First Command", "First Item", () => MessageBox.Show("First Item Executed")));
     ButtonItems.Add(new ButtonItemViewModel("Second Command", "Second Item", () => MessageBox.Show("Second Item Executed")));
 }
Exemplo n.º 11
0
 public override void StartGame(DifficultyLevelType diffLevelType, string[] args)
 {
     OnNotification(new NotificationEventArgs(ButtonItems.Select(s => s.Number).ToList().ToText()));
     InitPressButtonItems();
     Task.Factory.StartNew(GameLogic);
 }