Example #1
0
        /// <summary>
        /// Инициализирует справку
        /// </summary>
        public void Initialize()
        {
            string text = Resource.Help;

            _helpText = SplitOnStrings(text);
            PaintEvent?.Invoke();
        }
Example #2
0
        /// <summary>
        /// Производит атаку на ячейку
        /// </summary>
        private void AtackCell()
        {
            Cell selectedCell = GetSelectedCell();
            Cell clickedCell  = GetFocusedCell();

            if (selectedCell != null && clickedCell != null)
            {
                if (clickedCell?.Owner == GetActivePlayer())
                {
                    _currentGameState = GameStates.Select;
                    selectedCell.DisactiveCell();
                    clickedCell.ActiveCell();
                }
                else
                {
                    _moveRunner.Move(selectedCell, clickedCell, GetActivePlayer());
                    if (IsFinishedGame())
                    {
                        _currentGameState = GameStates.Finished;
                        FinishedEvent?.Invoke(this, EventArgs.Empty);
                    }
                }
            }

            PaintEvent?.Invoke();
            _button.CallPaintEvent();
        }
Example #3
0
        /// <summary>
        /// Завершает атаку или передает ход
        /// </summary>
        public void CompleteAtackOrPassMove()
        {
            switch (_currentGameState)
            {
            case GameStates.Select:
            case GameStates.Atack:
            {
                UnselectAllCells();
                GetActivePlayer().Score = CalculateScorePlayer();
                _currentGameState       = GameStates.ScoreDistributing;
                _button.Name            = "Pass move";
                break;
            }

            case GameStates.ScoreDistributing:
            {
                UnselectAllCells();
                PassMove();
                _button.Name = "Complete atack";
                break;
            }
            }
            PaintEvent?.Invoke();
            _button.CallPaintEvent();
        }
Example #4
0
 protected override void OnPaint(PaintEventArgs pe)
 {
     base.OnPaint(pe);
     if (AddPaint != null)
     {
         AddPaint.Invoke(pe);
     }
 }
Example #5
0
        /// <summary>
        /// Инициализирует просмотр рекордов
        /// </summary>
        public void Initialize()
        {
            _bestResults = ReadTextFromFile(DEFAULT_FILENAME);

            FilterBestResults(_bestResults);

            PaintEvent?.Invoke();
        }
Example #6
0
        /// <summary>
        /// Удаляет последний символ из текстового поля
        /// </summary>
        public void DeleteLastChar()
        {
            if (_itemStatus == ItemStatuses.Selected && _text.Length > 0)
            {
                _text = _text.Substring(0, _text.Length - 1);
            }

            PaintEvent?.Invoke();
        }
Example #7
0
        /// <summary>
        /// Добавляет символ в текстовое поле
        /// </summary>
        /// <param name="parChar">Добавляемый символ</param>
        public void AddChar(char parChar)
        {
            if (_itemStatus == ItemStatuses.Selected)
            {
                _text += parChar;
            }

            PaintEvent?.Invoke();
        }
 private static void Paint()
 {
     while (true)
     {
         Graphics.FillRectangle(ColorResources.AppBackground, 0, 0, Graphics.ClientWidth, Graphics.ClientHeight);
         PaintEvent?.Invoke(new PaintEventArgs(Graphics));
         Graphics.FlipPages();
         Thread.Sleep(100);
     }
 }
Example #9
0
        /// <summary>
        /// Выбирает ячейку
        /// </summary>
        private void SelectCell()
        {
            Cell clickedCell = GetFocusedCell();

            UnselectAllCells();
            if (clickedCell != null)
            {
                if (clickedCell?.Owner == GetActivePlayer())
                {
                    clickedCell.ActiveCell();
                    _currentGameState = GameStates.Atack;
                }
            }

            PaintEvent?.Invoke();
        }
Example #10
0
 protected override void OnPaint(PaintEventArgs e)
 {
     // Specifically not calling base here since we draw entire area ourselves
     // base.OnPaint(e);
     // Should this be disposed?
     using (e)
         using (var targetGraphics = e.Graphics)
         {
             ReallocBufferedGraphics(targetGraphics);
             // Use buffered graphics object
             var graphics = m_bufferedGraphics.Graphics;
             // Raise paint event
             PaintEvent?.Invoke(this.ClientRectangle, e.ClipRectangle, graphics);
             // Render to target graphics i.e. paint event args graphics
             m_bufferedGraphics.Render(targetGraphics);
         }
 }
Example #11
0
        void DoPaint(Alt.GUI.PaintEventArgs e)
        {
                        #if UNITY_EDITOR
            if (Application.isPlaying)
                        #endif
            {
                OnPaintBackground(e);

                OnPaint(e);
            }

            if (!e.Handled)
            {
                AltGUIControlHost host = gameObject.GetComponentInParent <AltGUIControlHost>();
                if (host != null)
                {
                    host.DoPaint(e);

                                        #if UNITY_EDITOR
                    if (!Application.isPlaying)
                    {
                        return;
                    }
                                        #endif
                }
                                #if UNITY_EDITOR
                else if (!Application.isPlaying)
                {
                    AltSketchPaintHandler.DrawEditorText(e,
                                                         EditorName,
                                                         gameObject != null ? gameObject.name : "Unknown",
                                                         ClientSize,
                                                         MaxFPS,
                                                         RenderType);
                    return;
                }
                                #endif

                if (m_Paint != null)
                {
                    m_Paint(this, e);
                }

                m_onPaint.Invoke(e);
            }
        }
Example #12
0
        /// <summary>
        /// Раздает очки
        /// </summary>
        private void DistributeScore()
        {
            Cell clickedCellCoords = GetFocusedCell();

            if (null != clickedCellCoords)
            {
                if (clickedCellCoords.Owner == GetActivePlayer())
                {
                    if (GetActivePlayer().Score > 0)
                    {
                        GetActivePlayer().Score -= 1;
                        clickedCellCoords.Score += 1;
                    }
                }
                PaintEvent?.Invoke();
                _button.CallPaintEvent();
            }
        }
Example #13
0
        /// <summary>
        /// Thread that loops the Draw and speciesAndAmount events.
        /// </summary>
        private void VisualThread()
        {
            DateTime lastTime = DateTime.Now;

            while (true)
            {
                double passedTime = (DateTime.Now - lastTime).TotalSeconds;
                if (passedTime >= TimeInSecondsBetweenFrames)
                {
                    lastTime = DateTime.Now;
                    PaintEvent?.Invoke(this, new ImageEventArgs {
                        BitMapImage = Draw(Map, DrawPublisher.Draw())
                    });
                    TextEvent?.Invoke(this, new TextEventArgs {
                        ListInformation = DrawPublisher.SpeciesAndAmount()
                    });
                }
            }
        }
Example #14
0
        public void Draw(decimal lat, decimal lng, Color color)
        {
            Graphics g        = Graphics.FromImage(Map);
            var      position = GetMapPosition(lat, lng);
            Pen      pen      = new Pen(color, PointSize);

            //g.DrawRectangle(pen, new Rectangle(
            //    new Point(position.Left - (int)PointSize / 2, position.Top - (int)PointSize / 2),
            //    new Size((int)PointSize, (int)PointSize))
            //    );
            g.DrawEllipse(pen, new Rectangle(
                              new Point(position.Left - (int)PointSize / 2, position.Top - (int)PointSize / 2),
                              new Size((int)PointSize, (int)PointSize))
                          );
            if (PaintEvent != null)
            {
                PaintEvent.Invoke(this, new MapPainterEventArgs {
                    Map = Map.Clone() as Bitmap
                });
            }
        }
Example #15
0
        /// <summary>
        /// Переводит фокус на следующиий элемент меню
        /// </summary>
        public void Next()
        {
            for (int i = 0; i < _menuItems.Count; i++)
            {
                if (_menuItems[i].MenuItemStatus == ItemStatuses.Selected)
                {
                    _menuItems[i].MenuItemStatus = ItemStatuses.Unselected;

                    if (i == _menuItems.Count - 1)
                    {
                        _menuItems[0].MenuItemStatus = ItemStatuses.Selected;
                        break;
                    }
                    else
                    {
                        _menuItems[i + 1].MenuItemStatus = ItemStatuses.Selected;
                        break;
                    }
                }
            }

            PaintEvent?.Invoke();
        }
Example #16
0
        /// <summary>
        /// Переводит фокус на предыдущий элемент меню
        /// </summary>
        public void Previous()
        {
            for (int i = 0; i < _menuItems.Count; i++)
            {
                if (_menuItems[i].MenuItemStatus == ItemStatuses.Selected)
                {
                    _menuItems[i].MenuItemStatus = ItemStatuses.Unselected;

                    if (i == 0)
                    {
                        _menuItems[_menuItems.Count - 1].MenuItemStatus = ItemStatuses.Selected;
                        break;
                    }
                    else
                    {
                        _menuItems[i - 1].MenuItemStatus = ItemStatuses.Selected;
                        break;
                    }
                }
            }

            PaintEvent?.Invoke();
        }
Example #17
0
        /// <summary>
        /// Переводит фокус на предыдущее текстовое поле
        /// </summary>
        public void Previous()
        {
            for (int i = 0; i < _playersFields.Count; i++)
            {
                if (_playersFields[i].ItemStatus == ItemStatuses.Selected)
                {
                    _playersFields[i].ItemStatus = ItemStatuses.Unselected;

                    if (i == 0)
                    {
                        _playersFields[_playersFields.Count - 1].ItemStatus = ItemStatuses.Selected;
                        break;
                    }
                    else
                    {
                        _playersFields[i - 1].ItemStatus = ItemStatuses.Selected;
                        break;
                    }
                }
            }

            PaintEvent?.Invoke();
        }
Example #18
0
 /// <summary>
 /// Вызывает событие перерисовки
 /// </summary>
 public void CallPaintEvent()
 {
     PaintEvent?.Invoke();
 }
Example #19
0
 /// <summary>
 /// Инициализирует меню
 /// </summary>
 public void Initialize()
 {
     PaintEvent?.Invoke();
 }