コード例 #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();
        }
コード例 #2
0
 protected override void RenderElements(Rect drawArea)
 {
     if (GUILayout.Button(Text, GUILayout.Width(drawArea.width), GUILayout.Height(drawArea.height)))
     {
         OnClicked?.Invoke();
     }
 }
コード例 #3
0
    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();
        }
    }
コード例 #4
0
ファイル: Announcement.cs プロジェクト: svifylabs/dwarfcorp
 public void ActivateClick()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke();
     }
 }
コード例 #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;
        }
    }
コード例 #6
0
ファイル: GameManager.cs プロジェクト: punsal/Swing-Hero
    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();
        }
    }
コード例 #7
0
 protected override void OnLayoutDraw()
 {
     if (GUILayout.Button(Label, Style, LayoutOptions))
     {
         OnClicked?.Invoke();
     }
 }
コード例 #8
0
 private void ChatItem_Click(object sender, EventArgs e)
 {
     if (getClicked != null)
     {
         getClicked.Invoke(this, e);
     }
 }
コード例 #9
0
ファイル: UIAbility.cs プロジェクト: darkhunterbg/RushForDawn
 public void Awake()
 {
     Button.onClick.AddListener(() =>
     {
         OnClicked?.Invoke(this);
     });
 }
コード例 #10
0
ファイル: UINewspaperEOD.cs プロジェクト: terrynoya/FreeSO
        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);
        }
コード例 #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);
                            }
                        }
                    }
                }
            }
        }
コード例 #12
0
 public void Clicked()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke();
     }
 }
コード例 #13
0
ファイル: Button.cs プロジェクト: xiuzhifu/Redirection
        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++;
        }
コード例 #14
0
 public override void clicked(TaskPositioner positioner)
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this);
     }
 }
コード例 #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;
                }
            }
        }
コード例 #16
0
 private void Press(int option)
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this, new TextMenuClickedEventArgs(option));
     }
 }
コード例 #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);
     }
 }
コード例 #19
0
 public void ClickedButton()
 {
     if (clickFunc != null)
     {
         clickFunc.Invoke();
     }
 }
コード例 #20
0
 private void FireOnClicked()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this, EventArgs.Empty);
     }
 }
コード例 #21
0
        /// <summary>
        /// Called once claim Button is pressed
        /// </summary>
        public void ClaimPressed()
        {
            claimButton.OnClicked -= ClaimPressed;
            visuals.SetActive(false);

            OnClicked?.Invoke();
        }
コード例 #22
0
 public virtual void Draw()
 {
     if (GUILayout.Button(_ct, GUILayout.Width(50), GUILayout.Height(50)))
     {
         OnClicked?.Invoke();
     }
 }
コード例 #23
0
ファイル: Draggable.cs プロジェクト: qzmp/TKGJ2019
 public void invokeClicked()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this, null);
     }
 }
コード例 #24
0
 public void RevertCursor(bool revertBase = false)
 {
     if (revertBase)
     {
         SetBase(0);
     }
     OnClicked.Invoke(CursorSpriteList[_baseNumber]);
 }
コード例 #25
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var selectedPrediction = predictionList[indexPath.Row];

            OnClicked?.Invoke(this, new CellClickedEventArgs {
                thisPrediction = selectedPrediction
            });
        }
コード例 #26
0
 protected virtual void OnMouseDown()
 {
     if (GameManager.Instance.State != GameState.Menu)
     {
         return;
     }
     //        Destroy(gameObject);
     OnClicked?.Invoke(this);
 }
コード例 #27
0
 public override void clicked(TaskPositioner positioner)
 {
     if (OnClicked != null)
     {
         CurrentTaskPositioner = positioner;
         OnClicked.Invoke(this);
         CurrentTaskPositioner = null;
     }
 }
コード例 #28
0
 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);
 }
コード例 #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();
                }
            }
        }
コード例 #30
0
    protected override void InitFormControls()
    {
        base.InitFormControls();

        view = GetView <CellViewFrame>();

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

        initialColor = view.Image.color;
    }