Esempio n. 1
0
    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);
     }
 }
Esempio n. 3
0
    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;
        }
    }
Esempio n. 5
0
 private void Awake()
 {
     mobileInput     = FindObjectOfType <MobileInput>();
     ballsController = FindObjectOfType <BallsController>();
     blockContainer  = FindObjectOfType <BlockContainer>();
     ballsPreview.gameObject.SetActive(false);
 }
Esempio n. 6
0
 public override void Interact(MobileInput mobileInput)
 {
     if (mobileInput.InputType == InputTypes.PlantDraw)
     {
         ProcessPosition(mobileInput.Value);
     }
 }
Esempio n. 7
0
        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
        }
Esempio n. 8
0
    // 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();
            }
        }
    }
Esempio n. 9
0
    // 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());
    }
Esempio n. 10
0
    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
        }
    }
Esempio n. 11
0
 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;
         }
     }
 }
Esempio n. 12
0
    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");
        }
    }
Esempio n. 13
0
    // 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);
        }
    }
Esempio n. 14
0
 // 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;
     }
 }
Esempio n. 15
0
    // 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
        }
    }
Esempio n. 16
0
    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;
    }
Esempio n. 18
0
    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();
    }
Esempio n. 19
0
    // 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");
        }
    }
Esempio n. 21
0
 void ActivateAttack()
 {
     if (active && !activatedNow && (Input.GetKey(button) || MobileInput.GetTouch(playerSide)))
     {
         gameController.Player2AttackCheck();
         StartCoroutine(AttackTimer());
     }
 }
Esempio n. 22
0
 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;
    }
Esempio n. 24
0
    void Awake()
    {
        Target   = GameObject.Find("Cube").transform;
        camera   = this.gameObject.GetComponent <Camera>();
        Distance = camera.orthographicSize;
        Instance = this;

        ZoomSpeed = ZoomSpeedS;
    }
Esempio n. 25
0
        void OnFocus(int id)
        {
            mobileInputField = (MobileInputField)MobileInput.GetReceiver(id);

            if (keyboardHeight > 0)
            {
                ShowUIHeight();
            }
        }
Esempio n. 26
0
        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
        }
Esempio n. 27
0
    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();
    }
Esempio n. 29
0
    // 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");
        }
    }
Esempio n. 30
0
    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();
    }
Esempio n. 31
0
 // Use this for initialization
 void Start () {
     MobileModel.stats = new Stats { STR = 10, SPD = 8, INT = 10, WLP = 10 };
     PlayerInput = new MobileInput();
     TieAnimationToModel();
 }
Esempio n. 32
0
 void Start()
 {
     vp = GetComponent<VehicleParent>();
     setter = FindObjectOfType<MobileInput>();
 }