void HandlePlayerInputMobile() { MobileInput.InputType input = MobileInput.getInput(); if (!isRotating) { if (input == MobileInput.InputType.right) { playerFacing = (Directions)(((int)playerFacing + 1) % 4); StartCoroutine(rotatePlayer(transform.rotation, transform.rotation * Quaternion.Euler(0, -90, 0), rotationDuration)); } else if (input == MobileInput.InputType.left) { StartCoroutine(rotatePlayer(transform.rotation, transform.rotation * Quaternion.Euler(0, 90, 0), rotationDuration)); playerFacing = (Directions)(((int)playerFacing + 3) % 4); //mod on negative doesn't work, this is equivalent to subtracting 1 } } if (!weaponDelayActive) { if (input == MobileInput.InputType.up) { spawners[(int)playerFacing].playerSwing(currentWeapon); StartCoroutine(inputController()); } } if (input == MobileInput.InputType.down) { currentWeapon = (PlayerWeapons)(((int)currentWeapon + 1) % numberOfWeapons); playerAudioSource.PlayOneShot(weaponEquipSound[(int)currentWeapon], 0.3f); weaponDelayActive = false; } }
//function to wait for user input IEnumerator WaitForKeyDown(KeyCode keyCode, MobileInput.InputType m_input) { while (!Input.GetKeyDown(keyCode) && m_input != MobileInput.getInput()) { yield return(null); } }
private void Update() { if (testJoystick) { transform.position += transform.right * MobileInput.GetJoystickAxis(JoystickAxis.Horizontal) * Time.deltaTime; transform.position += transform.up * MobileInput.GetJoystickAxis(JoystickAxis.Vertical) * Time.deltaTime; } if (testSwipe) { #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR // touch inputs here #else // Touch position emulation. Vector2 touchPos = Input.mousePosition; // Touch start emulation. if (Input.GetMouseButtonDown(0)) { } // Touch update emulation. if (Input.GetMouseButton(0)) { } // Touch end emulation. if (Input.GetMouseButtonUp(0)) { } #endif } }
void Awake() { Rb = GetComponent <Rigidbody2D>(); Anim = GetComponent <Animator>(); PlaceToSpawn = transform.GetChild(0); PlaceToSpawnRotation = Quaternion.Euler(180, 0, 0); if (MobileInput) { _mobileInput = GetComponent <MobileInput>(); _mobileInput.enabled = true; _keyboardInput = GetComponent <KeyboardInput>(); _keyboardInput.enabled = false; } else { _mobileInput = GetComponent <MobileInput>(); _mobileInput.enabled = false; _keyboardInput = GetComponent <KeyboardInput>(); _keyboardInput.enabled = true; } }
private void Awake() { mobileInput = FindObjectOfType <MobileInput>(); ballsController = FindObjectOfType <BallsController>(); blockContainer = FindObjectOfType <BlockContainer>(); ballsPreview.gameObject.SetActive(false); }
public override void Interact(MobileInput mobileInput) { if (mobileInput.InputType == InputTypes.PlantDraw) { ProcessPosition(mobileInput.Value); } }
private void Update() { #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR SwipeInput.Swipe swipe = MobileInput.GetSwipe(0); if (swipe != null) { RaycastHit2D hit2D = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(swipe.Position), Vector2.zero); if (hit2D.collider != null && hit2D.collider.CompareTag("Link")) { Destroy(hit2D.collider.gameObject); } } #else if (Input.GetMouseButton(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Physics.Raycast(ray.origin, ray.direction, out RaycastHit hit); if (hit.collider != null && hit.collider.CompareTag("Link")) { Rope rope = hit.collider.GetComponentInParent <Rope>(); rope.CutDelayed(hit.collider.gameObject); } } #endif }
// Update is called once per frame void Update() { if (rotating) { // Get rotation delta float previousAngle = rotationCurve.Evaluate(rotationValue / rotationTime); rotationValue += Time.deltaTime; if (rotationValue > 1) { rotating = false; rotationValue = 1; } float newAngle = rotationCurve.Evaluate(rotationValue / rotationTime); float rotationDelta = (newAngle - previousAngle) * totalDesiredRotationDelta; // Rotate around y axis transform.Rotate(Vector3.up, rotationDelta, Space.Self); } else { if (Input.GetKeyDown("right") || MobileInput.GetSwipedLeft()) { RotateToNextObject(); } else if (Input.GetKeyDown("left") || MobileInput.GetSwipedRight()) { RotateToPreviousObject(); } else if (Input.GetKeyDown("space") || Input.GetKeyDown("enter") || Input.GetMouseButtonDown(0) || MobileInput.GetTouchUp()) { menuOptions[selectedMenuOption].PerformAction(); } } }
// Update is called once per frame void Update() { //If running on Unity Android, run this block to use mobile input controls #if UNITY_ANDROID MobileInput.InputType input = MobileInput.getInput(); if (input == MobileInput.InputType.up) { SceneManager.LoadScene(Load.lastPlayedGame, LoadSceneMode.Single); } if (input == MobileInput.InputType.down) { SceneManager.LoadScene("TitleScreen", LoadSceneMode.Single); } #endif //Run desktop keyboard/mouse controls if (Input.GetKeyDown("up")) { SceneManager.LoadScene(Load.lastPlayedGame, LoadSceneMode.Single); } else if (Input.GetKeyDown("down")) { SceneManager.LoadScene("TitleScreen", LoadSceneMode.Single); } //This function returns the game to main menu after 3 seconds //StartCoroutine(gameOverScreen()); }
void Update() { if (testJoystick) { transform.position += transform.forward * MobileInput.GetJoystickAxis(JoystickAxis.Vertical) * Time.deltaTime; transform.position += transform.right * MobileInput.GetJoystickAxis(JoystickAxis.Horizontal) * Time.deltaTime; } if (testSwipe) { #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR //mobile input here #else if (Input.GetMouseButtonDown(0)) //left click start { } if (Input.GetMouseButton(0)) //left click update { } if (Input.GetMouseButtonUp(0)) //left click end { } Vector2 touchPos = Input.mousePosition; #endif } }
public void OnInputAcquired(MobileInput inp) { if (inp.InputType == InputTypes.Movement) { InputHorizontalAxis = inp.Value.x; InputVerticalAxis = inp.Value.y; } if (inp.InputType == InputTypes.Jump) { if (inp.Value.y > 0) { if (InputJump && !InputJumpDown) { InputJumpUp = true; InputJumpDown = false; } InputJump = false; } else if (inp.Value.y < 0) { if (!InputJump) { InputJumpDown = true; InputJumpUp = false; } InputJump = true; } } }
public void OnInputAcquired(MobileInput mobileInput) { if (mobileInput.InputType == InputTypes.Movement) { LookingUp = mobileInput.Value.y >= 0; SetClosest(); return; } if (currentClosest == null) { return; } if (currentClosest.PowerType == InputTypes.PlantDraw && InputTypes.PlantDraw == mobileInput.InputType) { currentClosest.Interact(mobileInput); return; } if (currentClosest.PowerType == InputTypes.PlantInteract) { interacting = mobileInput.Value.y < 0; Debug.Log("swapping input"); } }
// Update is called once per frame void Update() { if (isUsersTurn) { if (!inputDelayActive) { HandlePlayerInput(); } } #if UNITY_ANDROID MobileInput.InputType input2 = MobileInput.getInput(); if (input2 == MobileInput.InputType.hold) { SceneManager.LoadScene("TitleScreen"); } #endif //if user hits escape, go back to main menu if (Input.GetKeyDown("escape")) { print("ESCAPE"); SceneManager.LoadScene("TitleScreen"); } //user should be able to reload scene if (Input.GetKeyDown(KeyCode.R)) { print("attempting scene reload"); Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name); } }
// Update is called once per frame void Update() { if (fadingOut) { fadeTime -= Time.deltaTime; if (fadeTime <= 0) { SceneManager.LoadScene(menuSceneName); } else { Color originalColor = fadeInOutImage.color; originalColor.a = 1 - fadeInOutCurve.Evaluate(fadeTime / fadeOutDuration); fadeInOutImage.color = originalColor; } } else if (fadeTime < fadeInDuration) { fadeTime = Mathf.Min(fadeTime + Time.deltaTime, fadeInDuration); Color originalColor = fadeInOutImage.color; originalColor.a = 1 - fadeInOutCurve.Evaluate(fadeTime / fadeInDuration); fadeInOutImage.color = originalColor; } else if (fadeOutEnabled && (Input.GetMouseButtonDown(0) || MobileInput.GetTouchUp())) { fadingOut = true; fadeTime = fadeOutDuration; } }
// Update is called once per frame void Update() { if (TestJoystick) { transform.position += transform.forward * MobileInput.GetJoystickAxis(JoystickAxis.Vertical) * Time.deltaTime; transform.position += transform.right * MobileInput.GetJoystickAxis(JoystickAxis.Horizontal) * Time.deltaTime; } if (testSwipe) { #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR #else if (Input.GetMouseButtonDown(0)) { //get inputs from SwipeInput.script } if (Input.GetMouseButton(0)) { } if (Input.GetMouseButtonUp(0)) { } Vector2 touchPos = Input.mousePosition; #endif } }
public IEnumerator OnStart() { direction_noise.PlayOneShot(instructions); while (!Input.GetKeyDown("return") && direction_noise.isPlaying && MobileInput.getInput() != MobileInput.InputType.tap) { yield return(null); } direction_noise.Stop(); yield return(new WaitForSeconds(0.2f)); direction_noise.PlayOneShot(welcome); while (!Input.GetKeyDown("return") && direction_noise.isPlaying && MobileInput.getInput() != MobileInput.InputType.tap) { yield return(null); } direction_noise.Stop(); StartCoroutine(show_sequence()); }
void MovePlacementTemplateBuildingInput() { Vector2 lastTouched_WorldPos = Camera.main.ScreenToWorldPoint(MobileInput.GetInstance().GetLastTouchedPosition()); Vector2 startTouch_WorldPos = Camera.main.transform.position;//Camera.main.ScreenToWorldPoint(MobileInput.GetInstance().GetStartTouchPosition()); m_TemplateBuildingPlacementOffset = lastTouched_WorldPos - startTouch_WorldPos; }
void Movement() { lastPosition = position; if (gameController.gameState == GameState.GamePlay) { if (Input.GetKey(button) || MobileInput.GetTouch(playerSide)) { if (controlsActive) { position += speed; } } else { if (controlsActive) { position -= speed; } } if (forceBack) { position -= speed; } } SetPosition(); }
// Update is called once per frame void Update() { if (testJoystick) { //Test joystick transform.position += transform.forward * MobileInput.GetJoystickAxis(JoystickAxis.Vertical) * Time.deltaTime; transform.position += transform.right * MobileInput.GetJoystickAxis(JoystickAxis.Horizontal) * Time.deltaTime; } if (testSwipe) { //Platform directives - similar to regions but as an if statement #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR //Platform specific //Mobile Input HERE #else //Touch start emulation if (Input.GetMouseButtonDown(0)) //Left click { } //Touch update emulation if (Input.GetMouseButtonDown(0)) { } //Touch end emulation if (Input.GetMouseButtonUp(0)) { } //Touch position emulator Vector2 touchPos = Input.mousePosition; #endif } }
// Update is called once per frame void Update() { //if on android, tap will go to arcade game screen #if UNITY_ANDROID MobileInput.InputType input = MobileInput.getInput(); if (input == MobileInput.InputType.hold) { SceneManager.LoadScene("TitleScreen"); } else if (input == MobileInput.InputType.left) { SceneManager.LoadScene("RMTutorial"); } else if (input == MobileInput.InputType.up) { source.Stop(); rhythm_game.SetGameMode(Rhythm.GameMode.normal); rhythm_game.enabled = true; play_menu_prompt = false; this.enabled = false; } else if (input == MobileInput.InputType.right) { source.Stop(); rhythm_game.SetGameMode(Rhythm.GameMode.normal); rhythm_game.enabled = true; play_menu_prompt = false; this.enabled = false; } else if (input == MobileInput.InputType.down) { SceneManager.LoadScene("MinigameScreen"); } #endif if (Input.GetKeyDown("left")) //"Tutorial level", just for explaining gameplay { SceneManager.LoadScene("RMTutorial"); } else if (Input.GetKeyDown("up")) //Beginning mode { source.Stop(); rhythm_game.SetGameMode(Rhythm.GameMode.normal); rhythm_game.enabled = true; this.enabled = false; play_menu_prompt = false; } else if (Input.GetKeyDown("right")) //Intermediate { source.Stop(); rhythm_game.SetGameMode(Rhythm.GameMode.hard); rhythm_game.enabled = true; this.enabled = false; play_menu_prompt = false; } else if (Input.GetKeyDown("down")) { SceneManager.LoadScene("MinigameScreen"); } }
void ActivateAttack() { if (active && !activatedNow && (Input.GetKey(button) || MobileInput.GetTouch(playerSide))) { gameController.Player2AttackCheck(); StartCoroutine(AttackTimer()); } }
void Awake() { if (instance != null) { return; } instance = this; }
void MoveCameraInput() { float moveSpeed = 15.0f; Vector2 swipeDelta = MobileInput.GetInstance().GetSwipeDelta(); swipeDelta.Normalize(); swipeDelta = -swipeDelta * moveSpeed * Time.deltaTime; m_TargetCameraPosition += (Vector3)swipeDelta; }
void Awake() { Target = GameObject.Find("Cube").transform; camera = this.gameObject.GetComponent <Camera>(); Distance = camera.orthographicSize; Instance = this; ZoomSpeed = ZoomSpeedS; }
void OnFocus(int id) { mobileInputField = (MobileInputField)MobileInput.GetReceiver(id); if (keyboardHeight > 0) { ShowUIHeight(); } }
public override void PostLoad() { base.PostLoad(); #if UNITY_ANDROID var mobileInputFab = Resources.Load(MOBILE_INPUT_FAB_PATH); var ui = ClientUIManager.Instance; _mobileInputUi = Object.Instantiate((GameObject)mobileInputFab, ui.MainCanvas.GetComponent <RectTransform>()).GetComponent <MobileInput>(); #endif }
private void Start() { var player = GameObject.FindGameObjectWithTag("Player"); _movement = player.GetComponent <MobileInput>(); _movement.InputV = 0.0f; _movement.InputH = 0.0f; }
private void Start() { movePosition = transform.position; playerController = GetComponent <CharacterController>(); myAnimator = GetComponent <Animator>(); touchInput = GetComponent <MobileInput>(); levelLength = LevelManager.instance.GetLevelLength(); }
// Update is called once per frame void Update() { //if on android, tap will go to arcade game screen #if UNITY_ANDROID MobileInput.InputType input = MobileInput.getInput(); if (input == MobileInput.InputType.hold) { SceneManager.LoadScene("TitleScreen"); } else if (input == MobileInput.InputType.left) { SceneManager.LoadScene("SCTutorial"); } else if (input == MobileInput.InputType.up) { source.Stop(); script.SetGameMode(SwordCombat.GameMode.normal); script.enabled = true; Destroy(this); } else if (input == MobileInput.InputType.right) { source.Stop(); script.SetGameMode(SwordCombat.GameMode.hard); script.enabled = true; Destroy(this); } else if (input == MobileInput.InputType.down) { SceneManager.LoadScene("MinigameScreen"); } #endif if (Input.GetKeyDown("left")) //"Tutorial level" { SceneManager.LoadScene("SCTutorial"); } else if (Input.GetKeyDown("up")) //Beginning mode { source.Stop(); script.SetGameMode(SwordCombat.GameMode.normal); script.enabled = true; Destroy(this); } else if (Input.GetKeyDown("right")) //Intermediate { source.Stop(); script.SetGameMode(SwordCombat.GameMode.hard); script.enabled = true; Destroy(this); } else if (Input.GetKeyDown("down")) { SceneManager.LoadScene("MinigameScreen"); } }
protected override void OnSetup(params object[] _params) { string username = (string)_params[0]; Vector3 spawnPoint = (Vector3)_params[1]; nameplate.text = username; transform.position = spawnPoint; MobileInput.Initialise(); }
// Use this for initialization void Start () { MobileModel.stats = new Stats { STR = 10, SPD = 8, INT = 10, WLP = 10 }; PlayerInput = new MobileInput(); TieAnimationToModel(); }
void Start() { vp = GetComponent<VehicleParent>(); setter = FindObjectOfType<MobileInput>(); }