// 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; }
private object GetInputValue(Iinput iinput) { if (iinput is NumberSelector) { return((iinput as NumberSelector).Value); } return(null); }
public void Subscribe(Iinput input) { if (InputSubscribers.Contains(input)) { return; } InputSubscribers.Add(input); }
private void OnClearSelect(bool state) { if (!state) { return; } currentInput = clearLine; }
private void OnDrawSelect(bool state) { if (!state) { return; } currentInput = drawSimpleLine; }
void Awake() { drawSimpleLine = new DrawSimpleLine(this); clearLine = new LineClearer(this); draw.onValueChanged.AddListener(OnDrawSelect); clear.onValueChanged.AddListener(OnClearSelect); OnDrawSelect(true); }
// 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 }
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(); } }
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; }
public void Unsubscribe(Iinput input) { InputSubscribers.Remove(input); }
public void Add(Iinput input, bool ignoreOffset) { Inputs.Add(input, ignoreOffset, false); }
//------------------------------------------------------ //------------------------Methods----------------------- //------------------------------------------------------ public void Add(Iinput Input) { Inputs.Add(Input, false, false); }
public void Add(Iinput input) { Add(input, false, true); }
public void Remove(Iinput Input) { input.Remove(Input); }
public void Add(Iinput input, bool ignoreOffset) { Add(input, ignoreOffset, true); }