Beispiel #1
0
        public ArtificialIntelligence(UserInterface userInterface, VisualCortex visualCortex)
        {
            if (logicTimer != null)
            {
                logicTimer.Stop();
            }
            // 0 = 40fps when set to 1ms, 8fps screen, 15fps is 7.5fps
            // 1 = 65fps when set to 1ms, 8fps screen, 40fps is 8fps
            // 2 = 1000fps when set to 1ms, 6 fps screen, 60fps is 6.35 fps
            // 3 = 1000fps when set to 1ms, 7.5 fps screen, 60fps is 7.65 fps, 200fps is 8fps
            logicTimer = new ATimer(3, 1, new ATimer.ElapsedTimerDelegate(() => { logic(); }));



            this.userInterface = userInterface;
            this.visualCortex  = visualCortex;

            timerPerformanceStopwatch         = new High_Performance_Timer.Stopwatch();
            screenCapturePerformanceStopWatch = new High_Performance_Timer.Stopwatch();

            basicAI   = new BasicAI();
            autoQueue = new AutoQueueManager();

            logicTimer.Start();
        }
Beispiel #2
0
 void _EndedDragMode()
 {
     if (!_isDragMode)
     {
         return;
     }
     //AOutput.Write("END");
     _isDragMode = _isProcess2 = false;
     _timer.Stop();
     if (!_wTransparent.Is0)
     {
         _wTransparent.Post(Api.WM_USER);                                //let it close self
     }
 }
Beispiel #3
0
 void _DocChanged(SciCode doc, bool opened)
 {
     _doc          = doc;
     _update       = false;
     _visibleLines = default;
     _modTimer?.Stop();
     _modFromEnd  = int.MaxValue;
     _diagCounter = 0;
     _cancelTS?.Cancel(); _cancelTS = null;
     if (opened)
     {
         _StylingAndFoldingVisibleFrom0(doc, firstTime: true);
     }
 }
Beispiel #4
0
        public Entity(Vector2 position, int maxHealth)
        {
            airTime = new ATimer();
            airTime.Interval = 100f;
            airTime.TimerType = ATimerType.MilliSeconds;
            airTime.Stop();

            startPosition = Vector2.Zero;
            DrawColor = Color.White;
            CollisionRectangle = new Rectangle(0, 0, WIDTH, HEIGHT);
            Health = new GameAttribute(0, maxHealth);
            Position = position;
            Friction = 0.2f;
            HasGravity = true;
            HasWorldCollision = true;
        }
Beispiel #5
0
            /// <summary>
            /// Starts or stops capturing.
            /// Does nothing if already in that state.
            /// </summary>
            public void StartStop(bool start)
            {
                if (start == Capturing)
                {
                    return;
                }
                var wForm = (AWnd)_form;

                if (start)
                {
                    //let other forms stop capturing
                    wForm.Prop.Set(c_propName, 1);
                    AWnd.Find(null, "WindowsForms*", also: o => {
                        if (o != wForm && o.Prop[c_propName] == 1)
                        {
                            o.Send(c_stopMessage);
                        }
                        return(false);
                    });

                    if (!Api.RegisterHotKey(wForm, 1, 0, KKey.F3))
                    {
                        ADialog.ShowError("Failed to register hotkey F3", owner: _form);
                        return;
                    }
                    Capturing = true;

                    //set timer that shows AO rect
                    if (_timer == null)
                    {
                        _osr   = TUtil.CreateOsdRect();
                        _timer = new ATimer(t => {
                            //Don't capture too frequently.
                            //	Eg if the callback is very slow. Or if multiple timer messages are received without time interval (possible in some conditions).
                            long t1 = ATime.PerfMilliseconds, t2 = t1 - _prevTime; _prevTime = t1; if (t2 < 100)
                            {
                                return;
                            }

                            //show rect of UI object from mouse
                            AWnd w = AWnd.FromMouse(WXYFlags.NeedWindow);
                            RECT?r = default;
                            if (!(w.Is0 || w == wForm || w.OwnerWindow == wForm))
                            {
                                r = _cbGetRect();
                            }
                            if (r.HasValue)
                            {
                                var rr = r.GetValueOrDefault();
                                rr.Inflate(2, 2);                                 //2 pixels inside, 2 outside
                                _osr.Rect = rr;
                                _osr.Show();
                            }
                            else
                            {
                                _osr.Visible = false;
                            }
                        });
                    }
                    _timer.Every(250);
                }
                else
                {
                    Capturing = false;
                    Api.UnregisterHotKey(wForm, 1);
                    wForm.Prop.Remove(c_propName);
                    _timer.Stop();
                    _osr.Hide();
                }
            }
Beispiel #6
0
 private void StopAnimation(string status)
 {
     ATimer.Stop();
     StatusTxt.Text = status;
 }
Beispiel #7
0
 public override void MouseDoubleClick(TreeNodeAdvMouseEventArgs args)
 {
     _editFlag = false;
     _timer?.Stop();
 }