Beispiel #1
0
    public void KeyInit()
    {
        index = new List <int>()
        {
            0, 0, 0, 0, 0
        };
        AllOnList = new List <int>();

        for (int i = 0; i < KeyList.Count; i++)
        {
            if (KeyInfoList[i].Count > 0)   //noteが存在するなら
            {
                KeyList[i] = new List <int>()
                {
                    KeyInfoList[i][index[i]].key
                };
                TextUpdate(KeyText[i], KeyList[i]);
                TextUpdate(OnKeyText[i], OnList[i]);

                AutoPlay AP = AutoManager[i];
                AP.subIndex    = 0;
                AP.OnIndex     = new List <int>();
                AutoManager[i] = AP;
                CheckAutoPlay(i);
            }
        }
        MakeTagforNotes();

        for (int i = 0; i < KeyInfoList.Count; i++)
        {
            WriteCsv(KeyInfoList[i], i);
        }
    }
Beispiel #2
0
    public void CheckAutoPlay(int finger_num)
    {
        AutoPlay   AP        = AutoManager[finger_num];
        List <int> _offIndex = new List <int>();

        foreach (int j in AutoManager[finger_num].OnIndex)             //自動演奏中のすべてのnoteについて
        {
            if (!AutoManager[finger_num].LastOffNoteIndex.Contains(j)) //最後のノートでなければ,NoteOff
            {
                m_oscSend.NoteOn(KeyInfoList[finger_num][j].key, 0);
                KeyList[finger_num].Remove(KeyInfoList[finger_num][j].key);
                OnList[finger_num].Remove(KeyInfoList[finger_num][j].key);
                AllOnList.Remove(KeyInfoList[finger_num][j].key);
                _offIndex.Add(j);
            }
        }
        foreach (int val in _offIndex)
        {
            AP.OnIndex.Remove(val);
        }

        AP.pressed = false;
        AP.OnIndex = new List <int>();

        AP.NofAutoNote      = CheckAutoNote(finger_num, index[finger_num]) + 1;
        AP.subIndex         = 0;
        AP.LastOffNoteIndex = LastNote(finger_num, index[finger_num], AP.NofAutoNote);
        AP.OnIndex.Add(index[finger_num]);
        AutoManager[finger_num] = AP;
    }
Beispiel #3
0
        /// <summary>
        /// 実際に指された手を盤上で再現します。
        /// </summary>
        private void PlayDoMoveAutoPlay(AutoPlay autoPlay)
        {
            var shogi = Global.ShogiControl;

            if (shogi == null)
            {
                return;
            }

            if (shogi.AutoPlayState == AutoPlayState.Playing)
            {
                shogi.StopAutoPlay();

                // もし変化再生中だったら少し時間を空けて指します。
                autoPlay.BeginningInterval = TimeSpan.FromSeconds(1);
            }

            // 局面を進める手を再生します。
            this.currentDoMoveAutoPlay = autoPlay;

            // モデル側のBoardを先に変更しないと、
            // WPFのバンディングが切れてしまいます。
            Board = autoPlay.Board;
            shogi.StartAutoPlay(autoPlay);
        }
Beispiel #4
0
 void Start()
 {
     ball = GameObject.FindObjectOfType<Ball>();
     try {
     ap = GameObject.FindObjectOfType<AutoPlay>();
         apAutoPlay = ap.autoPlay;
         }
     catch (System.NullReferenceException e){}
 }
Beispiel #5
0
 void Awake()
 {
     if(instance != null) {
         Destroy (gameObject);
         //	print (" GameObject destroyed");
     }else {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
    void Start()
    {
        autoPlay = FindObjectOfType <AutoPlay>();

        AudioManager.Instance.PlaySound("Music");
        state = State.SPLASH_SCREEN;
        if (autoPlay.isEnabled)
        {
            StartGame();
        }
    }
Beispiel #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - Width,
                                 Screen.PrimaryScreen.WorkingArea.Height - Height);
            LogTextBox = logTextBox;
            _logger    = new Logger(this);
            _logger.LogC($"版本 {Version}, 由 Nutr1t07 (Nelson Xiao) 制作");

            _cfg            = Config.ParseConfig("WBAData\\config.txt", _logger);
            _infos          = new List <UsbInfo>(UsbInfo.ReadBasicInfos());
            _copier         = new Copier(_logger, ref _cfg, ref _infos);
            _autoPlay       = new AutoPlay(_logger);
            _desktopArrange = new DesktopArrange(_copier, _logger);
            _wallpaper      = new WallpaperMain(_logger, _copier);
            _recentFiles    = new List <FileWatcher.RecentFile>(FileWatcher.RecentFile.ReadRecentFiles());
            _fileWatcher    = new FileWatcher(_copier, _cfg, _logger, _recentFiles);
            _fileWatcher.RecentFileAdded += FileWatcherOnRecentFileAdded;
            _keyboardDetect = new KeyboardDetect(_cfg, _logger);


            if (!Directory.Exists("WBAData"))
            {
                Directory.CreateDirectory("WBAData");
                Directory.CreateDirectory("WBAData\\log");
            }

            if (_cfg.RefreshWallpaper)
            {
                Task.Factory.StartNew(() => _wallpaper.PickWallIfTimePermit());
            }
            if (_cfg.AutoPlayFtp)
            {
                Task.Factory.StartNew(() => new AutoPlay(_logger).CheckFtp(this));
            }
            if (_cfg.AutoPlayEnAudio)
            {
                Task.Factory.StartNew(() =>
                                      AutoPlay.CheckEnglishAudio(_cfg.AutoPlayEnAudioUnit, _cfg.AutoPlayEnAudioFileName));
            }

            Task.Factory.StartNew(() => _copier.StartCopierListen());
            Task.Factory.StartNew(() => _fileWatcher.Listen());
            _keyboardDetect.StartHook();

            InitialConfigPage();
            RefreshUsbInfos();
            InitRecentFileListViewUi();

            _copier.UsbChange += (insert, info) => RefreshUsbInfos();
        }
Beispiel #8
0
    public void NoteOn(int finger, int velocity = 100)
    {
        pressing[finger] = true;
        AutoPlay AP = AutoManager[finger];

        AP.pressed          = true;
        AutoManager[finger] = AP;

        for (int i = 0; i < KeyList[finger].Count; i++)
        {
            m_oscSend.NoteOn(KeyList[finger][i], velocity);
        }

        OnList[finger].AddRange(KeyList[finger]);
        AllOnList.AddRange(KeyList[finger]);
        TextUpdate(OnKeyText[finger], OnList[finger]);
    }
Beispiel #9
0
        /// <summary>
        /// 実際に指された手を盤上で再現します。
        /// </summary>
        private void AddDoMoveAutoPlay(Board board, BoardMove bmove)
        {
            var shogi = Global.ShogiControl;

            if (shogi == null)
            {
                return;
            }

            // 引数にboardを渡すことで、boardそのものを変えながら
            // 自動再生を行います。
            var autoPlay = new AutoPlay(board, new[] { bmove })
            {
                IsChangeBackground = false,
            };

            autoPlay.Stopped += PlayDoMove_Stopped;

            this.doMoveAutoPlayList.Add(autoPlay);
        }
Beispiel #10
0
        /// <summary>
        /// 連続して手を進めます。
        /// </summary>
        private static void ExecuteMoveRedoContinue(ShogiUIElement3D control)
        {
            if (control.EditMode != EditMode.Normal)
            {
                return;
            }

            var board = GetBoard(control);

            if (board == null)
            {
                return;
            }

            var autoPlay = new AutoPlay(board, AutoPlayType.Redo)
            {
                Interval = control.AutoPlayInterval,
            };

            control.StartAutoPlay(autoPlay);
        }
        private static Capability GetAutoPlay([NotNull] string handler, [NotNull] RegistryKey hive, [NotNull, ItemNotNull] IEnumerable<ComparableTuple<string>> autoPlayAssocs, [NotNull] CommandMapper commandMapper)
        {
            #region Sanity checks
            if (handler == null) throw new ArgumentNullException("handler");
            if (hive == null) throw new ArgumentNullException("hive");
            if (autoPlayAssocs == null) throw new ArgumentNullException("autoPlayAssocs");
            if (commandMapper == null) throw new ArgumentNullException("commandMapper");
            #endregion

            using (var handlerKey = hive.OpenSubKey(DesktopIntegration.Windows.AutoPlay.RegKeyHandlers + @"\" + handler))
            {
                if (handlerKey == null) return null;

                string progID = handlerKey.GetValue(DesktopIntegration.Windows.AutoPlay.RegValueProgID, "").ToString();
                string verbName = handlerKey.GetValue(DesktopIntegration.Windows.AutoPlay.RegValueVerb, "").ToString();

                using (var progIDKey = Registry.ClassesRoot.OpenSubKey(progID))
                {
                    if (progIDKey == null) throw new IOException(progID + " key not found");
                    var autoPlay = new AutoPlay
                    {
                        ID = handler,
                        Provider = handlerKey.GetValue(DesktopIntegration.Windows.AutoPlay.RegValueProvider, "").ToString(),
                        Descriptions = {handlerKey.GetValue(DesktopIntegration.Windows.AutoPlay.RegValueDescription, "").ToString()},
                        Verb = GetVerb(progIDKey, commandMapper, verbName)
                    };

                    autoPlay.Events.AddRange(
                        from autoPlayAssoc in autoPlayAssocs
                        where autoPlayAssoc.Value == handler
                        select new AutoPlayEvent {Name = autoPlayAssoc.Key});

                    return autoPlay;
                }
            }
        }
 /// <inheritdoc/>
 public AutoPlayModel(AutoPlay capability, bool used)
     : base(capability, used)
 {
     _autoPlay = capability;
 }
Beispiel #13
0
        /// <summary>
        /// 連続して手を進めます。
        /// </summary>
        private static void ExecuteMoveRedoContinue(ShogiUIElement3D control)
        {
            if (control.EditMode != EditMode.Normal)
            {
                return;
            }

            var board = GetBoard(control);
            if (board == null)
            {
                return;
            }

            var autoPlay = new AutoPlay(board, AutoPlayType.Redo)
            {
                Interval = control.AutoPlayInterval,
            };

            control.StartAutoPlay(autoPlay);
        }
Beispiel #14
0
        /// <summary>
        /// 指し手を連続して戻します。
        /// </summary>
        public static void ExecuteUndoContinue(GLShogiElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            try
            {
                var autoPlay = new AutoPlay(
                    element.Board, true, AutoPlayType.Undo)
                {
                    IsUseEffect = false,
                };
                element.StartAutoPlay(autoPlay);
            }
            catch (Exception ex)
            {
                Util.ThrowIfFatal(ex);
                DialogUtil.ShowError(
                    "指し手を連続して戻すことに失敗しました ( ̄ω ̄;)");
            }
        }
Beispiel #15
0
        private void AutoPlay_Ended()
        {
            if (this.autoPlay == null)
            {
                return;
            }

            // コントロールは消去しておきます。
            var autoPlay = this.autoPlay;
            this.autoPlay.ShogiElement = null;
            this.autoPlay = null;

            Board = this.oldBoard;
            this.oldBoard = null;

            AutoPlayState = AutoPlayState.None;

            // Boardが変更されるとAutoPlayはすべてクリアされます。
            // Stopの中でBoardが変更されると少し面倒なことになるため、
            // Stopメソッドはすべての状態が落ち着いた後に呼びます。
            autoPlay.Stop();
        }
Beispiel #16
0
        /// <summary>
        /// 自動再生を開始します。
        /// </summary>
        public void StartAutoPlay(AutoPlay autoPlay)
        {
            if (autoPlay == null)
            {
                return;
            }

            if (AutoPlayState == AutoPlayState.Playing)
            {
                return;
            }

            // this.autoPlayを変える前に局面を変更します。
            // 局面変更時は自動再生を自動で止めるようになっているので、
            // this.autoPlayフィールドを変更した後に局面を変えると、
            // すぐに止まってしまいます。
            this.oldBoard = Board;
            Board = autoPlay.Board;

            autoPlay.ShogiElement = this;
            this.autoPlay = autoPlay;

            AutoPlayState = AutoPlayState.Playing;
        }
        private void AutoPlay_Ended()
        {
            if (this.autoPlay == null)
            {
                return;
            }

            var autoPlay = this.autoPlay;
            this.autoPlay = null;
            AutoPlayState = AutoPlayState.None;

            // Boardが変更されるとAutoPlayはすべてクリアされます。
            // Stop中にBoardが変更されると少し面倒なことになるため、
            // Stopメソッドはすべての状態が落ち着いた後に呼びます。
            autoPlay.Stop();
        }
        /// <summary>
        /// 自動再生を開始します。
        /// </summary>
        public void StartAutoPlay(AutoPlay autoPlay)
        {
            if (autoPlay == null)
            {
                return;
            }

            if (AutoPlayState == AutoPlayState.Playing)
            {
                return;
            }

            // コントロールを事前に設定する必要があります。
            var brush =
                (AutoPlayBrush != null && AutoPlayBrush.IsFrozen ?
                 AutoPlayBrush.Clone() :
                 AutoPlayBrush);
            AutoPlayBrush = brush;
            autoPlay.Background = brush;

            // ここで局面を変更します。
            // 局面変更時は自動再生を自動で止めるようになっているので、
            // autoPlayフィールドを変更した後に局面を変えると、
            // すぐに止まってしまいます。
            Board = autoPlay.Board;

            this.autoPlay = autoPlay;
            AutoPlayState = AutoPlayState.Playing;
        }
Beispiel #19
0
 void Start()
 {
     ap = GameObject.FindObjectOfType<AutoPlay>();
     Destroy (ap.gameObject);
 }