コード例 #1
0
        /// <summary>
        /// Запуск бота в выбранном режиме (по умолчанию Mode.Default)
        /// </summary>
        public void RunAsync()
        {
            if (status < State.Ready)
            {
                throw new BotNotInitException("bot not init");
            }
            if (status == State.Active)
            {
                return;
            }

            if (cv == null)
            {
                cv = new BotCV(WinDescriptor, 118, 140, 140, 120, 255, 255);
            }

            cts = new CancellationTokenSource();
            CancellationToken token = cts.Token;
            bool startState         = false;

            switch (_mode)
            {
            case Mode.Default: startState = botWork(token); break;

            case Mode.Learning: startState = botLearning(token); break;
            }
            if (startState)
            {
                Status = State.Active;
            }
        }
コード例 #2
0
ファイル: BotLearning.cs プロジェクト: MaslovArt/botiloid
        public BotLearning(BotCV bc)
        {
            pressedKeys  = new List <Keys>(4);
            gkl.KeyDown += Gkl_KeyDown;
            gkl.KeyUp   += Gkl_KeyUp;

            GlobalVarialbles gv = GlobalVarialbles.Constructor();

            maxAllowFps = Convert.ToInt32(gv.learning["times"]);
            template    = gv.learning["template"];
            filePath    = gv.learning["path"];
            com_fire    = (byte)gv.botKeys["fire"];

            com_down       = (byte)gv.botKeys["down"];
            com_up         = (byte)gv.botKeys["up"];
            com_left       = (byte)gv.botKeys["left"];
            com_right      = (byte)gv.botKeys["right"];
            com_esRight    = (byte)gv.botKeys["esRight"];
            com_esLeft     = (byte)gv.botKeys["esLeft"];
            com_flaps_next = (byte)gv.botKeys["flaps-next"];
            com_flaps_prev = (byte)gv.botKeys["flaps-prev"];

            this.bc = bc;
        }