示例#1
0
 public ButtonStates Update()
 {
     if (Visible && intersect.IntersectionCheck(new Vector2(MouseControl.X, MouseControl.Y)))
     {
         return(ButtonStates.ENTERED);
     }
     return(ButtonStates.NONE);
 }
示例#2
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);
     }
 }