Ejemplo n.º 1
0
 public void InputDataChanged()
 {
     if (OnInputChanged != null)
     {
         OnInputChanged.Invoke(this);
     }
 }
Ejemplo n.º 2
0
    protected virtual void ProcessInput()
    {
        #region Movement

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            OnInputChanged?.Invoke(Vector2.up, true);
        }

        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            OnInputChanged?.Invoke(Vector2.down, true);
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            OnInputChanged?.Invoke(Vector2.right, true);
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            OnInputChanged?.Invoke(Vector2.left, true);
        }

        if (Input.GetKeyUp(KeyCode.UpArrow))
        {
            OnInputChanged?.Invoke(Vector2.up, false);
        }

        if (Input.GetKeyUp(KeyCode.DownArrow))
        {
            OnInputChanged?.Invoke(Vector2.down, false);
        }

        if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            OnInputChanged?.Invoke(Vector2.right, false);
        }

        if (Input.GetKeyUp(KeyCode.LeftArrow))
        {
            OnInputChanged?.Invoke(Vector2.left, false);
        }

        #endregion

        if (Input.GetKeyDown(KeyCode.Space))
        {
            OnActionPressed?.Invoke();
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 0 = key, 1 = touch, other = reset
    /// </summary>
    /// <param name="type"></param>
    private void OnInputChanged(int type, int changed)
    {
        #if UNITY_EDITOR
        if (Root.logicPaused)
        {
            return;
        }
        #endif

        int cc = changed, mask0 = 0;
        for (var i = 0; i < cc; ++i)
        {
            var key = m_changedKeys[i];
            if (!key.fired || key.mutexKeys.Count < 1)
            {
                continue;
            }

            var mks = key.mutexKeys;
            foreach (var k in mks)
            {
                if (!k.fired || mask0.BitMask(k.ID))
                {
                    continue;
                }
                mask0 = mask0.BitMask(k.ID, true);

                if ((k.UpdateFiredState(0) || k.SetFired(false)))
                {
                    AddChangedKey(k, ref changed);
                }
            }
        }

        onInputChanged?.Invoke(m_changedKeys, changed);
    }