Esempio n. 1
0
        protected virtual void HandleTouchStart()
        {
            Vector2 jPosition = m_Joystick.GetPosition();

            if (OnJoystickTouchStart != null)
            {
                OnJoystickTouchStart(jPosition);
            }
        }
Esempio n. 2
0
        void Update()
        {
            // Store the input positions
            movePosition  = UltimateJoystick.GetPosition("Movement");
            shootPosition = UltimateJoystick.GetPosition("Shooting");

            // If the user cannot control the player, then return.
            if (canControl == false)
            {
                return;
            }

            // If the shooting joystick is being used and the shooting timer is ready...
            if (UltimateJoystick.GetJoystickState("Shooting") && shootingTimer <= 0)
            {
                // Then reset the timer and shoot a bullet.
                shootingTimer = shootingCooldown;
                CreateBullets();
            }

            // If the shoot timer is above zero, reduce it.
            if (shootingTimer > 0)
            {
                shootingTimer -= Time.deltaTime;
            }
        }
Esempio n. 3
0
        void FixedUpdate()
        {
            Vector2 launchStick = UltimateJoystick.GetPosition("LaunchStick");

            if (launchStick.magnitude > 0)
            {
                this.ForceAmount = Mathf.Lerp(this.ForceAmountMin, this.ForceAmountMax, launchStick.magnitude);
            }

            if ((launchStick.x > 0) && (launchStick.y >= 0))
            {
                if (this.PathRenderer != null)
                {
                    this.PathRenderer.Enable();
                }
                this.ForceAngle = Vector2.Angle(launchStick, Vector2.right);
                this.ForceAngle = Mathf.Clamp(this.ForceAngle, this.ForceAngleMin, this.ForceAngleMax);
            }
            else if ((launchStick.x < 0) && (launchStick.y <= 0))
            {
                if (this.PathRenderer != null)
                {
                    this.PathRenderer.Enable();
                }
                this.ForceAngle = Vector2.Angle(launchStick, Vector2.left);
                this.ForceAngle = Mathf.Clamp(this.ForceAngle, 0.0f, 45.0f);
            }
            else if ((launchStick.x == 0) && (launchStick.y == 0))
            {
                if (this.PathRenderer != null)
                {
                    this.PathRenderer.Disable();
                }
            }
        }
Esempio n. 4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        pushObjectBackInFrustum(Player);
        Vector2 moveDirection = UltimateJoystick.GetPosition("Movement");
        Vector2 movement      = new Vector2(moveDirection.x, moveDirection.y);

        transform.Translate(movement * Speed * Time.deltaTime);
    }
        public override void UpdateInput()
        {
            Vector2 movePosition = UltimateJoystick.GetPosition(MoveJoystickName);

            if (OnMove != null)
            {
                OnMove(movePosition);
            }
        }
Esempio n. 6
0
    Vector2 GetJoystickDir()
    {
        Vector2 dir = UltimateJoystick.GetPosition("MoveJoystick");

        if (dir.magnitude > 0)
        {
            if (Mathf.Abs(dir.x) > Mathf.Abs(dir.y))
            {
                return(Mathf.Sign(dir.x) * Vector2.up);
            }
            else
            {
                return(-Mathf.Sign(dir.y) * Vector2.right);
            }
        }
        return(Vector2.zero);
    }
Esempio n. 7
0
    public void FixedUpdate()
    {
        if (_assist)
        {
            if (isRunning && !isDeath)
            {
                autorun.TypeRun(this.gameObject.transform);
            }

            if (!isRunning)
            {
                Mathf.Lerp(autorun.speedRun, 0, Time.deltaTime);
            }
            else if (isRunning)
            {
                //Mathf.Lerp (autorun.speedRun, autorun.maxSpeedRun, Time.deltaTime);
            }
            if (SceneManager.GetActiveScene().name == "Medieval City")
            {
                FollowPath();
            }
        }
        else
        {
//			Debug.Log ();
            //Get touch movement direction
            Vector3 TouchMovementDirection = new Vector3(UltimateJoystick.GetPosition("Movement").x, 0, UltimateJoystick.GetPosition("Movement").y);

            //Get gamepad movement direction
            Vector3 GamepadMovementDirection = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);

            //Decide touch or gamepad movement and smooth result
            if (GamepadMovementDirection.magnitude >= TouchMovementDirection.magnitude)
            {
                MovementDirection = Vector3.SmoothDamp(MovementDirection, GamepadMovementDirection, ref MovementVelocity, .2f);
            }
            else
            {
                MovementDirection = Vector3.SmoothDamp(MovementDirection, TouchMovementDirection, ref MovementVelocity, .2f);
            }

            //Get touch action direction
//		Vector3 TouchActionDirection = rightJoyStick.joyStick;

            //Get gamepad action direction
//		Vector3 GamepadActionDirection = new Vector3(Input.GetAxis("ActionHorizontal"), Input.GetAxis("ActionVertical"), 0);

            //Decide touch or gamepad action
//		if (GamepadActionDirection.magnitude >= TouchActionDirection.magnitude) ActionDirection = GamepadActionDirection;
//		else ActionDirection = TouchActionDirection;

//		ActionAngle = Mathf.Atan2(ActionDirection.y, ActionDirection.x) * Mathf.Rad2Deg;

            //print("ActionAngle: " + ActionAngle + " - Right Joy Stick: " + ActionDirection);

            _blends.SetFloat(AnimatorVelocityX_ID, MovementDirection.x);
            _blends.SetFloat(AnimatorVelocityZ_ID, MovementDirection.z);

            //if (animInCall || MovementDirection.y < .25f || ActionDirection.magnitude < .25f)
            //{
            //	return;
            //}

            //Skill();

            this.gameObject.transform.Translate(MovementDirection * Time.fixedDeltaTime);
        }


        if (transform.position.y <= -1)
        {
            LevelManager.Instance.FinishLevel(LevelManager.FinishingLevelReason.Death);
        }

        if (Input.GetKeyDown(KeyCode.JoystickButton0))
        {
            BtnJump1();                                                      //Button A
        }
        else if (Input.GetKeyDown(KeyCode.JoystickButton2))
        {
            BtnSlide2();                                                           //Button X
        }
    }