Exemple #1
0
 public override void Clear()
 {
     base.Clear();
     _timerNode?.Cancel();
     onChangeState = null;
     onMaxPressure = null;
 }
Exemple #2
0
        public void Open(MapItem p_object)
        {
            _nodeClose?.Cancel();

            foreach (GameObject __child in _menuPanel.GetComponentsInChildren <Button>().Select(c => c.gameObject))
            {
                Destroy(__child);
            }

            Vector2 __point;

            RectTransformUtility.ScreenPointToLocalPointInRectangle(_menuCanvas, Input.mousePosition, _view, out __point);

            IInteractable __actions = p_object as IInteractable;

            Vector2 __buttonSize = _menuButton.GetComponent <RectTransform>().sizeDelta;

            _menuPanel.sizeDelta = new Vector2(_menuPanel.sizeDelta.x, 26f + __buttonSize.y * __actions.ListAction.Count + 3 * __actions.ListAction.Count);
            _menuPanel.position  = _menuCanvas.TransformPoint(__point);
            _menuText.text       = p_object.ItemName;
            __actions.ListAction.Select(p_objectAction =>
            {
                RectTransform __actionButton = Instantiate(_menuButton).GetComponent <RectTransform>();

                ButtonSettings __settings = __actionButton.GetComponent <ButtonSettings>();

                __settings.Text        = p_objectAction.GetDescription();
                __settings.ClickAction = () =>
                {
                    ActivateContextMenu(false);
                    onClickAction?.Invoke(null, new OnClickActionEventArgs(p_objectAction, p_object));
                };

                return(__actionButton);
            }).ToList().ForEach(b =>
            {
                b.SetParent(_menuPanel);
                b.localScale    = Vector3.one;
                b.localRotation = Quaternion.identity;
                b.localPosition = Vector3.zero;

                b.offsetMax = Vector2.down * 12 * (_menuPanel.childCount - 1);
                b.offsetMin = Vector2.down * 12 * _menuPanel.childCount;

                b.sizeDelta = new Vector2(90f, 15f);
            });

            ActivateContextMenu(true);

            _nodeClose = Timer.WaitSeconds(2f, () => ActivateContextMenu(false));
        }
Exemple #3
0
 public void SimulateMouseTap(int p_id, Vector3 p_position)
 {
     PressFinger(p_id, p_position);
     if (_tapTimerNodule != null)
     {
         _tapTimerNodule.Cancel();
     }
     _tapTimerNodule = Timer.WaitSeconds(0.1f, delegate
     {
         ReleaseFinger(p_id, p_position);
     });
 }