Exemple #1
0
        /// <summary>Обновляемся</summary>
        /// <param name="state">Состояние мышки</param>
        public void Update(MouseState state)
        {
            if (Dead)
            {
                return;
            }
            if (CurrentMagic <= 0)
            {
                Dead = true;
                _Tile.CurrentFrame += 23;
            }
            if (RegenDelay != 0)
            {
                RegenDelay--;
            }
            else
            {
                CurrentMagic += Regen;
                RegenDelay    = 100;
            }

            if (CurrentMagic >= MaxMagic)
            {
                CurrentMagic = MaxMagic;
            }

            _Movement.Update();
        }
Exemple #2
0
        /// <summary>Обновляем состояние выполняющейся магии</summary>
        private void UpdateExecuted()
        {
            bool IsEnd = false;

            //Если начало и конец одинаковые, то выполняем магию в текущей ячейке
            if (_FromCell == _ToCell)
            {
                _CurrentRectangle = new Rectangle(_ToCell.Rect.X + _ToCell.Rect.Width / 2 - _Width / 2, _ToCell.Rect.Y + _ToCell.Rect.Height / 2 - _Height / 2, _Width, _Height);
                if (_UpdateDelay != 0)
                {
                    _UpdateDelay--;
                    return;
                }
                _Sprite.UpdateInRange(From, To);
                _UpdateDelay = 5;
                IsEnd        = (_Sprite.CurrentFrame == To);
            }
            else
            {
                if (_CurrentRectangle == null || _CurrentRectangle == new Rectangle(0, 0, 0, 0))
                {
                    _CurrentRectangle = new Rectangle(_FromCell.Rect.X + _FromCell.Rect.Width / 2 - _Width / 2, _FromCell.Rect.Y + _FromCell.Rect.Height / 2 - _Height / 2, _Width, _Height);
                    _Movement.Move(_FromCell, _ToCell, _CurrentRectangle);
                }
                _Movement.Update();
                _CurrentRectangle = _Movement.CurrentState;
                IsEnd             = _Movement.IsEnd;
            }


            if (IsEnd)
            {
                _Executed            = false;
                Finished             = true;
                _Sprite.CurrentFrame = Static;
                _Reload           = Convert.ToInt32(_Node.SelectSingleNode("Reload").InnerText) * 100;
                Selected          = false;
                _CurrentRectangle = new Rectangle(0, 0, 0, 0);
            }
        }