예제 #1
0
 /// <summary>
 /// Создает кнопку без текста
 /// </summary>
 /// <param name="Position">Координаты кнопки</param>
 /// <param name="Texture">Текстура кнопки</param>
 /// <param name="FrameSizeX">Размер кадра по X</param>
 /// <param name="FPS">Кол-во кадров в секунду в анимациях</param>
 /// <param name="NotSelectedFrame">Кадр, когда кнопка не выбрана</param>
 /// <param name="Selected">Анимация, когда кнопка выбрана</param>
 /// <param name="ClickedFrame">Кадр, когда кнопка нажата</param>
 /// <param name="Layer">Слой, на котором расположена кнопка</param>
 public Button(Vector2 Position, Texture2D Texture, int FrameSizeX, int FPS, int NotSelectedFrame, Animation Selected, int ClickedFrame, int DisabledFrame, float Layer = DefaultLayer) : base(Position, Texture, FrameSizeX, FPS, Layer + 0.0001f)
 {
     AddAnimation("Selected", Selected);
     this.NotSelectedFrame = NotSelectedFrame;
     this.ClickedFrame     = ClickedFrame;
     this.DisabledFrame    = DisabledFrame;
     Intersector           = new Intersector(Position, new Vector2(Position.X + FrameSize.X, Position.Y), new Vector2(Position.X + FrameSize.X, Position.Y + FrameSize.Y), new Vector2(Position.X, Position.Y + FrameSize.Y));
     _Text   = null;
     Enabled = true;
 }
예제 #2
0
 /// <summary>
 /// Создает кнопку
 /// </summary>
 /// <param name="Position">Координаты кнопки</param>
 /// <param name="Texture">Текстура кнопки</param>
 /// <param name="Text">Текст кнопки</param>
 /// <param name="Font">Шрифт</param>
 /// <param name="color">Цвет шрифта</param>
 /// <param name="FrameSizeX">Размер кадра по X</param>
 /// <param name="FPS">Кол-во кадров в секунду в анимациях</param>
 /// <param name="NotSelectedFrame">Кадр, когда кнопка не выбрана</param>
 /// <param name="Selected">Анимация, когда кнопка выбрана</param>
 /// <param name="ClickedFrame">Кадр, когда кнопка нажата</param>
 /// <param name="Layer">Слой, на котором расположена кнопка</param>
 public Button(Vector2 Position, Texture2D Texture, string Text, SpriteFont Font, Color color, int FrameSizeX, int FPS, int NotSelectedFrame, Animation Selected, int ClickedFrame, int DisabledFrame, float Layer = DefaultLayer) : base(Position, Texture, FrameSizeX, FPS, Layer + 0.0001f)
 {
     AddAnimation("Selected", Selected);
     this.NotSelectedFrame = NotSelectedFrame;
     this.ClickedFrame     = ClickedFrame;
     this.DisabledFrame    = DisabledFrame;
     Intersector           = new Intersector(Position, new Vector2(Position.X + FrameSize.X, Position.Y), new Vector2(Position.X + FrameSize.X, Position.Y + FrameSize.Y), new Vector2(Position.X, Position.Y + FrameSize.Y));
     _Text   = new BasicText(new Vector2(Position.X + (FrameSize.X - Font.MeasureString(Text).X) / 2, Position.Y + (FrameSize.Y - Font.MeasureString(Text).Y) / 2), Text, Font, color, Layer);
     Enabled = true;
 }
예제 #3
0
        public UI_Resource_Info(Vector2 Position, Color LineColor, Color RectColor, SpriteFont Font, Texture2D Icon, Color TextColor, Color AddTextColor, string MainText, string AddText, GraphicsDevice GrDevice, float Layer = BasicSprite.DefaultLayer)
        {
            _Icon     = new BasicSprite(new Vector2(Position.X + 5, Position.Y + 2), Icon, Layer - 0.0001f);
            _MainText = new BasicText(new Vector2(Position.X + 5 + Icon.Width, Position.Y + 2), MainText, Font, TextColor, Layer - 0.0001f);
            var textwidth = _MainText.Font.MeasureString(MainText) * _MainText.Scale + new Vector2(Icon.Width, 0);

            _AdditionalText = new BasicText(new Vector2(Position.X + 5 + textwidth.X, Position.Y + 2), AddText, Font, AddTextColor, Layer - 0.0001f);
            textwidth       = new Vector2(textwidth.X + _AdditionalText.Font.MeasureString(AddText).X *_AdditionalText.Scale.X, textwidth.Y);
            _Rect           = new SimpleRectangle(Position, textwidth + new Vector2(9, 3), LineColor, RectColor, GrDevice, Layer);
            intersect       = new Intersector(new Rectangle(_Rect.Position.ToPoint(), _Rect.WidthHeight.ToPoint()));
            this.Position   = Position;
            Scale           = new Vector2(1);
            this.Layer      = Layer;
            Visible         = true;
        }
예제 #4
0
        public Tile(Vector2 Position, Texture2D Texture, Texture2D HighLitedTexture, Texture2D DecorationTexture, int FrameSizeX, int FPS, int NotSelectedFrame, Animation Selected, int ClickedFrame, int MovingPointsNeeded, int GiveArmor, string TileName, float Layer = DefaultLayer) : base(Position, Texture, FrameSizeX, FPS, NotSelectedFrame, Selected, ClickedFrame, NotSelectedFrame, Layer)
        {
            this.TileName           = TileName;
            TileContains            = MapTiles.NONE;
            this.MovingPointsNeeded = MovingPointsNeeded;
            this.GiveArmor          = GiveArmor;
            this.HighLitedTexture   = HighLitedTexture;
            MainTexture             = Texture;
            Decoration = new BasicSprite(Position, DecorationTexture, Layer + 0.003f);

            Intersector.GetPointsFromOffsets
            (
                new Vector2(_Position.X, _Position.Y + _FrameSize.Y * _Scale.Y / 2),
                new Vector2(_FrameSize.X * _Scale.X / 4, -_FrameSize.Y * _Scale.Y / 2),
                new Vector2(3 * _FrameSize.X * _Scale.X / 4, -_FrameSize.Y * _Scale.Y / 2),
                new Vector2(_FrameSize.X * _Scale.X, 0),
                new Vector2(3 * _FrameSize.X * _Scale.X / 4, _FrameSize.Y * _Scale.Y / 2),
                new Vector2(_FrameSize.X * _Scale.X / 4, _FrameSize.Y * _Scale.Y / 2)
            );
        }
예제 #5
0
 /// <summary>
 /// Обновление кнопки
 /// </summary>
 /// <param name="DontUpdBtnAnims"> True - Не обновлять анимации</param>
 /// <returns></returns>
 public virtual ButtonStates Update(bool DontUpdBtnAnims = false, Camera cam = null)
 {
     if (Visible)
     {
         if (!Enabled)
         {
             CurrentFrame = DisabledFrame;
             return(ButtonStates.NONE);
         }
         //Если отображение разрешено
         //Определить пересечение с курсором
         LastIntersectionCheckResult = IntersectionCheckResult;
         if (cam == null)
         {
             IntersectionCheckResult = Intersector.IntersectionCheck(new Vector2(MouseControl.X, MouseControl.Y));
         }
         else
         {
             IntersectionCheckResult = Intersector.IntersectionCheck(MouseControl.MouseToWorldCoords(cam));
         }
         if (IntersectionCheckResult)
         {
             if (MouseControl.LeftBtn == MouseButtonStates.PRESSED)
             {
                 if (!DontUpdBtnAnims)
                 {
                     StopAnimation(true, NotSelectedFrame);
                     CurrentFrame = ClickedFrame;
                 }
                 return(ButtonStates.PRESSED);
             }
             else
             if (MouseControl.LeftBtn == MouseButtonStates.RELEASED)
             {
                 return(ButtonStates.CLICKED);
             }
             else
             {
                 if (!DontUpdBtnAnims)
                 {
                     if (CurrAnim == null)
                     {
                         PlayAnimation("Selected");
                     }
                 }
                 return(ButtonStates.ENTERED);
             }
         }
         if (!DontUpdBtnAnims)
         {
             StopAnimation(true, NotSelectedFrame);
             CurrentFrame = NotSelectedFrame;
         }
         return(ButtonStates.NONE);
     }
     else
     {
         //Если отображение запрещено
         if (!DontUpdBtnAnims)
         {
             if (CurrAnim != null)
             {
                 StopAnimation(true, NotSelectedFrame);
             }
         }
         return(ButtonStates.NONE);
     }
 }