Example #1
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 #2
0
        public Head(Head head)
        {
            this.KeyCode = head.KeyCode;
            tail         = new Tail(KeyCode);

            DisplayKey = head.DisplayKey;
            window.writeln(DisplayKey);

            color_creation = color = GenerateColor();

            this.key = new IKey(KeyCode, DisplayKey, color);
            index    = (byte)ActiveKeys.Count;
            r        = HeadR * SZR;
            v        = IVector.Up;
            pos      = head.pos;

            this.key.points = this.Points = head.Points;
            this.act        = head.act;

            Map.OnStartGame += Reset;
            Map.OnRevive    += Revive;
            Map.OnClear     += clear;
            OnUpdate        += e_update = new Action(Update);
            if (AnimationsEnabled)
            {
                window.DrawHead += draw_event = new PaintEvent(Draw);
            }
        }
Example #3
0
        /// <summary>
        /// Инициализирует справку
        /// </summary>
        public void Initialize()
        {
            string text = Resource.Help;

            _helpText = SplitOnStrings(text);
            PaintEvent?.Invoke();
        }
Example #4
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 #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
 public Animation()
 {
     if (!Program.SyncUpdate)
     {
         return;
     }
     starttick = Program.Tick;
     Program.OnUpdateAnimation += update = new Action(Update);
     Program.window.DrawHead   += draw = new PaintEvent(Draw);
     Program.Map.OnClearRemove += new Action(End);
 }
Example #10
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 #11
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 #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
        private Head()
        {
            index = (byte)ActiveKeys.Count;
            r     = HeadR * SZR;
            v     = IVector.Up;
            pos   = Map.generateSpawn(HeadR);

            draw_event = new PaintEvent(Draw);

            Map.OnStartGame += Reset;
            Map.OnRevive    += Revive;
            Map.OnClear     += clear;
            OnUpdate        += e_update = new Action(Update);
            if (AnimationsEnabled)
            {
                window.DrawHead += draw_event;
            }
        }
Example #14
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 #15
0
        public Coin(IPoint pos, int points, Color color)
        {
            if (points == 0 || !Program.SyncUpdate)
            {
                return;
            }
            this.font = new Font(Program.FONT, 16 * Program.Scale, FontStyle.Bold);
            this.text = "+" + points;
            SizeF sz = (SizeF)Program.window?.CreateGraphics().MeasureString(text, font);

            this.offset = -sz.Width / 2f;
            this.pos    = new PointF((float)pos.X - sz.Width / 2, (float)pos.Y - sz.Height / 2);
            this.shadow = new PointF((float)pos.X - sz.Width / 2 + 1f, (float)pos.Y - sz.Height / 2 + 1f);
            this.m      = new Animatable(-.72f, 0, 100, AnimationTypes.SIN);
            this.c      = new SolidBrush(color);

            Program.OnUpdateAnimation    += update = new Action(Update);
            Program.window.DrawAnimation += draw = new PaintEvent(Draw);
            m.OnEnd += new Action(Remove);
        }
Example #16
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 #17
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 #18
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 #19
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();
        }
    private void AddPaintEventToDict()
    {
        if (PaintEventDictionary.Count != 0)
        {
            PaintEventDictionary.Clear();
        }

        if (scenarioContainer.EventSet.PaintEventList == null)
        {
            Debug.Log("XML파일 EventSet의 PaintEventList가 없다.");
            return;
        }

        for (int k = 0; k < scenarioContainer.EventSet.PaintEventList.Length; k++)
        {
            int        key            = scenarioContainer.EventSet.PaintEventList[k].ID;
            PaintEvent PaintEventInfo = scenarioContainer.EventSet.PaintEventList[k];

            if (!PaintEventDictionary.ContainsKey(key))
            {
                PaintEventDictionary.Add(key, PaintEventInfo);
            }
        }
    }
Example #21
0
 /// <summary>
 /// Вызывает событие перерисовки
 /// </summary>
 public void CallPaintEvent()
 {
     PaintEvent?.Invoke();
 }
Example #22
0
 /// <summary>
 /// Инициализирует меню
 /// </summary>
 public void Initialize()
 {
     PaintEvent?.Invoke();
 }