コード例 #1
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;
                }
            }
        }
コード例 #2
0
ファイル: UIAbility.cs プロジェクト: darkhunterbg/RushForDawn
 public void Awake()
 {
     Button.onClick.AddListener(() =>
     {
         OnClicked?.Invoke(this);
     });
 }
コード例 #3
0
 public override void clicked(TaskPositioner positioner)
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this);
     }
 }
コード例 #4
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);
                            }
                        }
                    }
                }
            }
        }
コード例 #5
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();
        }
コード例 #6
0
 protected override void RenderElements(Rect drawArea)
 {
     if (GUILayout.Button(Text, GUILayout.Width(drawArea.width), GUILayout.Height(drawArea.height)))
     {
         OnClicked?.Invoke();
     }
 }
コード例 #7
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();
        }
    }
コード例 #8
0
ファイル: Announcement.cs プロジェクト: svifylabs/dwarfcorp
 public void ActivateClick()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke();
     }
 }
コード例 #9
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;
        }
    }
コード例 #10
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();
        }
    }
コード例 #11
0
 protected override void OnLayoutDraw()
 {
     if (GUILayout.Button(Label, Style, LayoutOptions))
     {
         OnClicked?.Invoke();
     }
 }
コード例 #12
0
 private void FireOnClicked()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this, EventArgs.Empty);
     }
 }
コード例 #13
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);
        }
コード例 #14
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++;
        }
コード例 #15
0
 public Constructor(GameStateSlot prototype, string id, GameStateMap state = null,
                    OnClicked onClicked = null, OnDeleteClicked onDeleteClicked = null)
     : base(prototype, id, onClicked)
 {
     ConstructedSlot.State = state;
     ConstructedSlot.onDeleteClickedAction = onDeleteClicked;
 }
コード例 #16
0
 private void Press(int option)
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this, new TextMenuClickedEventArgs(option));
     }
 }
コード例 #17
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;
                }
            }
        }
コード例 #18
0
        /// <summary>
        /// Called once claim Button is pressed
        /// </summary>
        public void ClaimPressed()
        {
            claimButton.OnClicked -= ClaimPressed;
            visuals.SetActive(false);

            OnClicked?.Invoke();
        }
コード例 #19
0
 /// <summary>
 /// If you use this constructor, this tab control will possibly remove/add cards from that dictionary as it is only passing in a reference.
 /// This will happen if you have set up click events to move cards to places like in an editing screen.
 /// Just be careful that this dictionary is being passed as a REFERENCE.
 /// </summary>
 /// <param name="cardData"></param>
 /// <param name="size"></param>
 /// <param name="localPosition"></param>
 /// <param name="textureAsset"></param>
 public CardTypesTabControl(Dictionary <string, Dictionary <string, CardData> > cardData, Vector2 tabsTotalSize, Vector2 cardPagesSize, Vector2 localPosition, OnClicked cardOnLeftClicked = null, string textureAsset = AssetManager.DefaultEmptyTextureAsset) :
     base(tabsTotalSize, localPosition, textureAsset)
 {
     CardData            = cardData;
     CardGridControlSize = cardPagesSize;
     CardOnLeftClicked   = cardOnLeftClicked;
 }
コード例 #20
0
ファイル: Draggable.cs プロジェクト: qzmp/TKGJ2019
 public void invokeClicked()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke(this, null);
     }
 }
コード例 #21
0
 public void Clicked()
 {
     if (OnClicked != null)
     {
         OnClicked.Invoke();
     }
 }
 void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
 {
     if (!eventData.dragging)
     {
         OnClicked?.Invoke(eventData.position);
     }
 }
コード例 #23
0
 public virtual void Draw()
 {
     if (GUILayout.Button(_ct, GUILayout.Width(50), GUILayout.Height(50)))
     {
         OnClicked?.Invoke();
     }
 }
コード例 #24
0
 public LocationMessageItem(float timeToDisplay, string text, Vector3 location,
                            OnClicked callbackOnClicked) : base(timeToDisplay)
 {
     this.text             = text;
     this.location         = location;
     this.OnClickedAction += callbackOnClicked;
 }
コード例 #25
0
ファイル: delegate.cs プロジェクト: hun-a/csharp-tutorial
        public static void Main(string[] args)
        {
            OnClicked clicked = new OnClicked(Func);

            clicked += Func;

            ButtonPressed(clicked);
        }
コード例 #26
0
 public void RevertCursor(bool revertBase = false)
 {
     if (revertBase)
     {
         SetBase(0);
     }
     OnClicked.Invoke(CursorSpriteList[_baseNumber]);
 }
コード例 #27
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var selectedPrediction = predictionList[indexPath.Row];

            OnClicked?.Invoke(this, new CellClickedEventArgs {
                thisPrediction = selectedPrediction
            });
        }
コード例 #28
0
 protected virtual void OnMouseDown()
 {
     if (GameManager.Instance.State != GameState.Menu)
     {
         return;
     }
     //        Destroy(gameObject);
     OnClicked?.Invoke(this);
 }
コード例 #29
0
 public override void clicked(TaskPositioner positioner)
 {
     if (OnClicked != null)
     {
         CurrentTaskPositioner = positioner;
         OnClicked.Invoke(this);
         CurrentTaskPositioner = null;
     }
 }
コード例 #30
0
        public ToolbarClickListener(Android.Support.V4.Widget.DrawerLayout layout, Toolbar toolbar, OnClicked callback)
        {
            _layout   = layout;
            _toolbar  = toolbar;
            _callback = callback;

            MustGoBack = false;
            Enabled    = false;
        }
コード例 #31
0
ファイル: MessageWindow.cs プロジェクト: niguerrac/UnityUI
        public LocationMessageItem(float timeToDisplay, string text, Vector3 location,
		                           OnClicked callbackOnClicked)
            : base(timeToDisplay)
        {
            this.text = text;
            this.location = location;
            this.OnClickedAction += callbackOnClicked;
        }