Esempio n. 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;
 }
Esempio n. 2
0
 private object GetInputValue(Iinput iinput)
 {
     if (iinput is NumberSelector)
     {
         return((iinput as NumberSelector).Value);
     }
     return(null);
 }
Esempio n. 3
0
    public void Subscribe(Iinput input)
    {
        if (InputSubscribers.Contains(input))
        {
            return;
        }

        InputSubscribers.Add(input);
    }
Esempio n. 4
0
    private void OnClearSelect(bool state)
    {
        if (!state)
        {
            return;
        }

        currentInput = clearLine;
    }
Esempio n. 5
0
    private void OnDrawSelect(bool state)
    {
        if (!state)
        {
            return;
        }

        currentInput = drawSimpleLine;
    }
Esempio n. 6
0
    void Awake()
    {
        drawSimpleLine = new DrawSimpleLine(this);
        clearLine      = new LineClearer(this);

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

        OnDrawSelect(true);
    }
Esempio n. 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
    }
Esempio n. 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();
            }
        }
Esempio n. 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;
        }
Esempio n. 10
0
 public void Unsubscribe(Iinput input)
 {
     InputSubscribers.Remove(input);
 }
Esempio n. 11
0
 public void Add(Iinput input, bool ignoreOffset)
 {
     Inputs.Add(input, ignoreOffset, false);
 }
Esempio n. 12
0
        //------------------------------------------------------
        //------------------------Methods-----------------------
        //------------------------------------------------------

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