예제 #1
0
 public virtual void OnMouseDown(UserAction action)
 {
     if (!action.MultiFocus.Contains(this))
     {
         action.MultiFocus.Add(this);
     }
     Focus       = true;
     Pressed     = true;
     PressTime   = action.EventTicks;
     RawPosition = action.CanPosition;
     if (AutoColor)
     {
         Color a;
         a.r = g_color.r * 0.8f;
         a.g = g_color.g * 0.8f;
         a.b = g_color.b * 0.8f;
         a.a = g_color.a;
         Context.MainColor = a;
     }
     if (PointerDown != null)
     {
         PointerDown(this, action);
     }
     entry       = true;
     FocusAction = action;
     mVelocity   = Vector2.zero;
     UIAudioManager.PointerDown();
 }
예제 #2
0
 void Awake() {
     if (instance == null) {
         instance = this;
     } else if (instance != this) {
         Destroy(gameObject);
     }
 }
예제 #3
0
    public void OnPointerDown(PointerEventData eventData)
    {
        if (!_isInteractable)
        {
            return;
        }

        switch (eventData.button)
        {
        case PointerEventData.InputButton.Left:
            _onLeftDown?.Invoke();
            break;

        case PointerEventData.InputButton.Right:
            _onRightDown?.Invoke();
            break;

        case PointerEventData.InputButton.Middle:
            _onScrollDown?.Invoke();
            break;

        default:
            break;
        }

        if (_playClickSFX)
        {
            UIAudioManager.Play(UISoundType.Click);
        }
    }
예제 #4
0
 protected virtual void Start()
 {
     _serviceManager = ServiceManager.Instanse;
     _audioManager   = UIAudioManager.Instance;
     _exit.onClick.AddListener(OnQuitClicked);
     _option.onClick.AddListener(OnOptionClicked);
     _closeSettings.onClick.AddListener(OnOptionClicked);
 }
 protected virtual void Start()
 {
     _serviceManager = ServiceManager.Instance;
     _audioManager   = UIAudioManager.Instance;
     _quit.onClick.AddListener(OnQuuitClicked);
     _settings.onClick.AddListener(OnSettingsCliked);
     _closeSettings.onClick.AddListener(OnSettingsCliked);
 }
예제 #6
0
 protected virtual void OnMouseMove(UserAction action)
 {
     if (!entry)
     {
         entry     = true;
         EntryTime = UserAction.Ticks;
         if (PointerEntry != null)
         {
             PointerEntry(this, action);
         }
         LastPosition = action.CanPosition;
         UIAudioManager.PointerEntry();
     }
     else
     {
         StayTime = action.EventTicks - EntryTime;
         if (action.CanPosition == LastPosition)
         {
             if (HoverTime < ClickTime)
             {
                 HoverTime += UserAction.TimeSlice * 10000;
                 if (HoverTime >= ClickTime)
                 {
                     if (Pressed)
                     {
                         if (HoldPress != null)
                         {
                             HoldPress(this, action);
                         }
                     }
                     else
                     {
                         if (PointerHover != null)
                         {
                             PointerHover(this, action);
                         }
                     }
                 }
             }
             else
             {
                 HoverTime += UserAction.TimeSlice * 10000;
             }
         }
         else
         {
             HoverTime    = 0;
             LastPosition = action.CanPosition;
             if (PointerMove != null)
             {
                 PointerMove(this, action);
             }
         }
     }
 }
예제 #7
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
예제 #8
0
    public void OnPointerExit(PointerEventData eventData)
    {
        if (_playEnterExitSFX)
        {
            UIAudioManager.Play(UISoundType.EnterExit);
        }
        if (_highlightOnHover)
        {
            ResetColors();
        }

        _onExit?.Invoke();
    }
예제 #9
0
    void Toggle()
    {
        for (int i = 0; i < _tabs.Length; i++)
        {
            _tabs[i].tab.SetActive(_tabs[i] == this ? !_tabs[i].tab.activeSelf : false);
        }

        if (!tab.activeSelf)
        {
            Tooltip.Close();
        }

        UIAudioManager.Play(_toggleSound);
    }
예제 #10
0
    void Awake()
    {
        instance = this;

        _clips = new AudioClip[][]
        {
            _inventoryToggles,
            _characterToggles,
            _skillToggles,
            _clicks,
            _enterExits,
            _itemAdded,
            _itemRemoved,
            _itemConsumed
        };
    }
예제 #11
0
 internal virtual void OnMouseLeave(UserAction action)
 {
     entry = false;
     if (AutoColor)
     {
         if (!forbid)
         {
             Context.MainColor = g_color;
         }
     }
     if (PointerLeave != null)
     {
         PointerLeave(this, action);
     }
     UIAudioManager.PointerLeave();
 }
예제 #12
0
    private void Start()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }

        float sound;

        DataContainer.instance.GetSettingInfo(out sound);

        audioMixer.SetFloat("EFF", sound);
    }
예제 #13
0
        protected virtual void OnMouseUp(UserAction action)
        {
            entry = false;
            if (AutoColor)
            {
                if (!forbid)
                {
                    Context.MainColor = g_color;
                }
            }
            bool press = Pressed;

            Pressed = false;
            if (PointerUp != null)
            {
                PointerUp(this, action);
            }
            UIAudioManager.PointerUp();
            if (press)
            {
                long r = DateTime.Now.Ticks - PressTime;
                if (r <= ClickTime)
                {
                    float x = RawPosition.x - action.CanPosition.x;
                    float y = RawPosition.y - action.CanPosition.y;
                    x *= x;
                    y *= y;
                    x += y;
                    if (x < ClickArea)
                    {
                        OnClick(action);
                    }
                    UIAudioManager.OnClick();
                }
            }
        }