예제 #1
0
 // Start is called before the first frame update
 private void OnEnable()
 {
     input    = GetComponent <Iinput>();
     movement = GetComponent <AgentMovement>();
     input.OnMovementDirectionInput += movement.HandleMovementDirection;
     input.OnMovementInput          += movement.HandleMovement;
 }
예제 #2
0
 private object GetInputValue(Iinput iinput)
 {
     if (iinput is NumberSelector)
     {
         return((iinput as NumberSelector).Value);
     }
     return(null);
 }
예제 #3
0
    public void Subscribe(Iinput input)
    {
        if (InputSubscribers.Contains(input))
        {
            return;
        }

        InputSubscribers.Add(input);
    }
예제 #4
0
    private void OnClearSelect(bool state)
    {
        if (!state)
        {
            return;
        }

        currentInput = clearLine;
    }
예제 #5
0
    private void OnDrawSelect(bool state)
    {
        if (!state)
        {
            return;
        }

        currentInput = drawSimpleLine;
    }
예제 #6
0
    void Awake()
    {
        drawSimpleLine = new DrawSimpleLine(this);
        clearLine      = new LineClearer(this);

        draw.onValueChanged.AddListener(OnDrawSelect);
        clear.onValueChanged.AddListener(OnClearSelect);

        OnDrawSelect(true);
    }
예제 #7
0
    // Update is called once per frame
    void Update()
    {
        if (InputSubscribers.Count == 0)
        {
            return;
        }

        Iinput lastSubscriber = InputSubscribers[InputSubscribers.Count - 1];

#if UNITY_STANDALONE || UNITY_EDITOR
        if (Input.GetMouseButtonDown(0))
        {
            lastSubscriber.OnStart(Input.mousePosition);
        }

        if (Input.GetMouseButton(0))
        {
            lastSubscriber.OnMove(Input.mousePosition);
        }

        if (Input.GetMouseButtonUp(0))
        {
            lastSubscriber.OnEnd(Input.mousePosition);
        }
#endif

#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        if (Input.touchCount > 0)
        {
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                lastSubscriber.OnStart(Input.GetTouch(0).position);
            }
            if (Input.GetTouch(0).phase == TouchPhase.Moved)
            {
                lastSubscriber.OnMove(Input.GetTouch(0).position);
            }
            if (Input.GetTouch(0).phase == TouchPhase.Ended)
            {
                lastSubscriber.OnEnd(Input.GetTouch(0).position);
            }
        }
#endif
    }
예제 #8
0
        public void Add(Iinput input, bool ignoreOffset, bool startFocused)
        {
            if (!ignoreOffset)
            {
                input.Move(origin);
            }

            this.input.Add(input);


            if (startFocused)
            {
                input.Focus();
            }
            else
            {
                input.DeFocus();
            }
        }
예제 #9
0
        private void Awake()
        {
            audioManager   = FindObjectOfType <AudioManager>();
            playerMovement = FindObjectOfType <PlayerMovement>();
            CamFollow2D camFollow2D = FindObjectOfType <CamFollow2D>();

#if UNITY_ANDROID
            Debug.Log("Android");
            inputDevice = new MobileInput(this);
#elif UNITY_STANDALONE_WIN
            if (Input.mousePresent)
            {
                Debug.Log("Windows mouse");
                inputDevice = new MouseInput(this);
            }
#endif
            OnDragDelegate += camFollow2D.OnPlayerMove;
            OnDragDelegate += playerMovement.PushOff;
            OnDragDelegate += (float power, Vector2 direction) => audioManager.soundManager.PlayAudioClip(audioManager.wooshAudio, Mathf.Clamp(power, 0, 1));

            resolution = Screen.currentResolution;
        }
예제 #10
0
 public void Unsubscribe(Iinput input)
 {
     InputSubscribers.Remove(input);
 }
예제 #11
0
 public void Add(Iinput input, bool ignoreOffset)
 {
     Inputs.Add(input, ignoreOffset, false);
 }
예제 #12
0
        //------------------------------------------------------
        //------------------------Methods-----------------------
        //------------------------------------------------------

        public void Add(Iinput Input)
        {
            Inputs.Add(Input, false, false);
        }
예제 #13
0
 public void Add(Iinput input)
 {
     Add(input, false, true);
 }
예제 #14
0
 public void Remove(Iinput Input)
 {
     input.Remove(Input);
 }
예제 #15
0
 public void Add(Iinput input, bool ignoreOffset)
 {
     Add(input, ignoreOffset, true);
 }