Beispiel #1
0
        public override void Update()
        {
            if (!Visible)
            {
                return;
            }

            if (MouseIsIntersecting())
            {
                if (Core.Input.LeftButtonPressed())
                {
                    IsPressed = true;
                }
                else
                {
                    if (IsPressed)
                    {
                        Console.WriteLine("yay!");
                        OnClicked?.Invoke();
                    }

                    IsPressed = false;
                }
            }

            IsHovered = MouseIsIntersecting();
        }
Beispiel #2
0
 protected override void RenderElements(Rect drawArea)
 {
     if (GUILayout.Button(Text, GUILayout.Width(drawArea.width), GUILayout.Height(drawArea.height)))
     {
         OnClicked?.Invoke();
     }
 }
    public void OnInput()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            OnClicked?.Invoke(EInputState.Left);
        }

        else if (Input.GetKeyUp(KeyCode.LeftArrow))
        {
            OnClickedOff?.Invoke();
        }

        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            OnClicked?.Invoke(EInputState.Right);
        }

        else if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            OnClickedOff?.Invoke();
        }

        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            OnClicked?.Invoke(EInputState.Down);
        }

        else if (Input.GetKeyUp(KeyCode.DownArrow))
        {
            OnClickedOff?.Invoke();
        }
    }
Beispiel #4
0
 public void ActivateClick()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke();
     }
 }
Beispiel #5
0
    private void Update()
    {
        transform.position = Vector3.Lerp(transform.position,
                                          player.transform.position + new Vector3(0, 5, -15),
                                          5f * Time.deltaTime);
        if (deScore == 0 || (5 - level - Score) <= 0)
        {
            if ((5 - level - Score) <= 0)
            {
                scoreText.text = "Level Complete!";
            }
            else
            {
                scoreText.text = "You failed!";
            }
        }
        else
        {
            scoreText.text = "Soldiers Needed: " + (5 - level - Score);
        }


        if (GameStatus && (Input.touchCount >= 1))
        {
            GameObject.Find("Button").SetActive(false);
            player.GetComponent <Animator>().Play("Sword Sprint");
            OnClicked?.Invoke();
            GameStatus = false;
        }
    }
Beispiel #6
0
    private void HandleInput()
    {
        if (Input.GetMouseButtonDown(0))
        {
            isGrappling = true;
        }

        if (Input.GetMouseButton(0))
        {
            if (isGrappling)
            {
                isGrappling = false;
                var clickResult = OnClicked?.Invoke(player.transform.position);
                if (clickResult.HasValue)
                {
                    var joint = clickResult.Value.Item1;
                    joint.connectedBody = player;
                    OnAttach?.Invoke(joint.transform.position);

                    TravelAmount = clickResult.Value.Item2 + 1;
                    OnScore?.Invoke(TravelAmount);
                }
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            OnRelease?.Invoke();
        }
    }
 protected override void OnLayoutDraw()
 {
     if (GUILayout.Button(Label, Style, LayoutOptions))
     {
         OnClicked?.Invoke();
     }
 }
 private void ChatItem_Click(object sender, EventArgs e)
 {
     if (getClicked != null)
     {
         getClicked.Invoke(this, e);
     }
 }
Beispiel #9
0
 public void Awake()
 {
     Button.onClick.AddListener(() =>
     {
         OnClicked?.Invoke(this);
     });
 }
Beispiel #10
0
        public UINewspaperItemButton()
        {
            BaseButton = new UINineSliceButton();
            BaseButton.SetNineSlice(15, 15, 15, 15);
            BaseButton.Width          = 180;
            BaseButton.Height         = 48;
            BaseButton.OnButtonClick += (btn) => OnClicked?.Invoke(btn);
            Add(BaseButton);

            Title = new UILabel();
            Title.CaptionStyle       = Title.CaptionStyle.Clone();
            Title.CaptionStyle.Size  = 12;
            Title.CaptionStyle.Color = Color.White;
            Title.Alignment          = TextAlignment.Left | TextAlignment.Top;
            Title.Position           = new Vector2(7, -1);
            Add(Title);

            Body                = new UITextEdit();
            Body.TextStyle      = Body.TextStyle.Clone();
            Body.TextStyle.Size = 9;
            Body.TextStyle.LineHeightModifier = -5;
            Body.SetSize(167, 32);
            Body.Mode     = UITextEditMode.ReadOnly;
            Body.Position = new Vector2(7, 15);
            Body.RemoveMouseEvent();
            Add(Body);
        }
Beispiel #11
0
        public override void onUpdate()
        {
            //only handle the update if the button is enabled and the parent screen is visible
            if (screenVisible && render)
            {
                //hovering logic
                if (isMouseHovering() && selectable && enabled)
                {
                    Parent.FocusedComponent = this;

                    if (isHovered == false)
                    {
                        isHovered = true;
                        if (OnHover != null)
                        {
                            OnHover.Invoke(this, null);
                        }
                    }

                    if (InputManager.IsPressed("gui.click"))
                    {
                        if (isClicked == false)
                        {
                            isClicked = true;
                        }
                    }

                    if (InputManager.Released("gui.click"))
                    {
                        if (isClicked && Parent.FocusedComponent != null && Parent.FocusedComponent == this)
                        {
                            isClicked = false;
                            if (OnClicked != null)
                            {
                                OnClicked.Invoke(this, null);
                            }
                        }
                    }
                }
                //unhover logic
                else
                {
                    if (isHovered)
                    {
                        isHovered = false;
                    }
                    if (!InputManager.IsPressed("gui.click"))
                    {
                        if (isClicked == true)
                        {
                            isClicked = false;
                            if (OnReleased != null)
                            {
                                OnReleased.Invoke(this, null);
                            }
                        }
                    }
                }
            }
        }
Beispiel #12
0
 public void Clicked()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke();
     }
 }
Beispiel #13
0
        protected override void OnUpdate(float dt)
        {
            var hover = TestMouse();

            if (hover != m_hover)
            {
                m_hover = hover;
                if (hover)
                {
                    PlayHighlightSound();
                }
            }
            if (CheckPressed())
            {
                if (Screen.InputMethod == InputMethod.Mouse)
                {
                    PlaySelectSound();
                }
                if (OnClicked != null)
                {
                    OnClicked.Invoke(this, EventArgs.Empty);
                }
            }
            if (ShowShortcutPrompt)
            {
                UpdatePromptText();
            }
            m_frame++;
        }
Beispiel #14
0
 public override void clicked(TaskPositioner positioner)
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this);
     }
 }
Beispiel #15
0
        public override void Update(GameTime gameTime)
        {
            _previousMouse = _currentMouse;
            _currentMouse  = Mouse.GetState();

            var mouseRectangle         = new Rectangle(_currentMouse.X, _currentMouse.Y, 1, 1);
            var previousMouseRectangle = new Rectangle(_previousMouse.X, _previousMouse.Y, 1, 1);

            _isHovering = false;
            _isClicked  = false;

            // If the mouse clicks while it is hovering over the button, this code is executed
            if (mouseRectangle.Intersects(Rectangle) && previousMouseRectangle.Intersects(Rectangle))
            {
                if (_currentMouse.LeftButton == ButtonState.Pressed && _previousMouse.LeftButton == ButtonState.Released)
                {
                    _isHovering = false;
                    _isClicked  = true;

                    OnClicked?.Invoke(this, new EventArgs());
                    if (_playSound)
                    {
                        SoundManager.PlayButtonSound();
                    }
                }
                else
                {
                    _isHovering = true;
                    _isClicked  = false;
                }
            }
        }
Beispiel #16
0
 private void Press(int option)
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this, new TextMenuClickedEventArgs(option));
     }
 }
Beispiel #17
0
        internal override void Update(UIMouseState mouseState)
        {
            if (this.ContainsPoint(mouseState.MouseX, mouseState.MouseY))
            {
                this.Hovered = true;

                if (mouseState.MouseLeftDown && !this.Active)
                {
                    this.Active = true;
                    Invalidate();
                }
                else if (!mouseState.MouseLeftDown && this.Active)
                {
                    this.Active = false;
                    OnClicked?.Invoke(this, EventArgs.Empty);
                    Invalidate();
                }
            }
            else
            {
                if (this.Hovered)
                {
                    if (this.Active)
                    {
                        this.Active = false;
                        Invalidate();
                    }

                    this.Hovered = false;
                }
            }
        }
 void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
 {
     if (!eventData.dragging)
     {
         OnClicked?.Invoke(eventData.position);
     }
 }
Beispiel #19
0
 public void ClickedButton()
 {
     if (clickFunc != null)
     {
         clickFunc.Invoke();
     }
 }
 private void FireOnClicked()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this, EventArgs.Empty);
     }
 }
Beispiel #21
0
        /// <summary>
        /// Called once claim Button is pressed
        /// </summary>
        public void ClaimPressed()
        {
            claimButton.OnClicked -= ClaimPressed;
            visuals.SetActive(false);

            OnClicked?.Invoke();
        }
Beispiel #22
0
 public virtual void Draw()
 {
     if (GUILayout.Button(_ct, GUILayout.Width(50), GUILayout.Height(50)))
     {
         OnClicked?.Invoke();
     }
 }
Beispiel #23
0
 public void invokeClicked()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this, null);
     }
 }
 public void RevertCursor(bool revertBase = false)
 {
     if (revertBase)
     {
         SetBase(0);
     }
     OnClicked.Invoke(CursorSpriteList[_baseNumber]);
 }
Beispiel #25
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var selectedPrediction = predictionList[indexPath.Row];

            OnClicked?.Invoke(this, new CellClickedEventArgs {
                thisPrediction = selectedPrediction
            });
        }
Beispiel #26
0
 protected virtual void OnMouseDown()
 {
     if (GameManager.Instance.State != GameState.Menu)
     {
         return;
     }
     //        Destroy(gameObject);
     OnClicked?.Invoke(this);
 }
Beispiel #27
0
 public override void clicked(TaskPositioner positioner)
 {
     if (OnClicked != null)
     {
         CurrentTaskPositioner = positioner;
         OnClicked.Invoke(this);
         CurrentTaskPositioner = null;
     }
 }
 public override bool ClickInControl()
 {
     _mouseInside = false;
     if (InputManager.Instance.MouseState.LeftButton == ButtonState.Pressed)
     {
         if (_mouseButtonPressed)
         {
             return(true);
         }
         if (Rect.Contains(InputManager.Instance.GetMousePositionToVector2()))
         {
             if (!_isPressed)
             {
                 _isPressed = true;
                 if (OnPressed != null)
                 {
                     OnPressed();
                 }
             }
             _mouseInside = true;
         }
         else
         {
             _mouseButtonPressed = true;
         }
     }
     else
     {
         _mouseButtonPressed = false;
         if (_isPressed)
         {
             _isPressed = false;
             if (Rect.Contains(InputManager.Instance.GetMousePositionToVector2()))
             {
                 double newSubtract = DateTime.Now.Subtract(new DateTime(2010, 1, 1)).TotalMilliseconds;
                 if (Math.Abs(newSubtract - _lastPressed) > 100)
                 {
                     if (OnReleased != null)
                     {
                         OnReleased();
                     }
                     if (OnClicked != null)
                     {
                         OnClicked.Invoke();
                     }
                     _lastPressed = newSubtract;
                 }
                 _mouseInside = true;
             }
         }
         else
         {
             _isPressed = false;
         }
     }
     return(_mouseInside);
 }
Beispiel #29
0
        protected override void OnUpdate(float dt)
        {
            base.OnUpdate(dt);
            UpdateHover(false);

            if (m_highlight && Screen.Mouse.Buttons[MouseButton.Left].Pressed)
            {
                if (m_deleteHover)
                {
                    if (OnDeleteClicked != null)
                    {
                        OnDeleteClicked.Invoke(this, EventArgs.Empty);
                    }
                }
                else if (m_moveLeftHover)
                {
                    if (OnMoveLeftClicked != null)
                    {
                        OnMoveLeftClicked.Invoke(this, EventArgs.Empty);
                    }
                }
                else if (m_moveRightHover)
                {
                    if (OnMoveRightClicked != null)
                    {
                        OnMoveRightClicked.Invoke(this, EventArgs.Empty);
                    }
                }
                else
                {
                    if (OnClicked != null)
                    {
                        OnClicked.Invoke(this, EventArgs.Empty);
                    }
                }
                PlaySelectSound();
            }

            if (m_animTime < ANIM_DURATION)
            {
                var oldAnimTime = m_animTime;
                m_animTime = Math.Min(m_animTime + dt, ANIM_DURATION);
                if (m_justCompleted && oldAnimTime <= 0.0f && m_animTime > 0.0f)
                {
                    Screen.Audio.PlaySound("sound/trophy.wav");
                }
                if (m_justUnlocked && oldAnimTime <= 0.5f && m_animTime > 0.5f)
                {
                    Screen.Audio.PlaySound("sound/unlock.wav");
                }
                if (m_justUnlocked || m_justCompleted)
                {
                    RequestRebuild();
                }
            }
        }
    protected override void InitFormControls()
    {
        base.InitFormControls();

        view = GetView <CellViewFrame>();

        view.Button.onClick.AddListener(() => OnClicked?.Invoke(this));

        initialColor = view.Image.color;
    }