public static Vector3 GetMovementInput(Camera relativeCamera, SimpleTouchController touch)
    {
        Vector3 moveVector;
        float   horizontalAxis = touch.GetTouchPosition.x;
        float   verticalAxis   = touch.GetTouchPosition.y;

//		float horizontalAxis = Input.GetAxis("Horizontal");
//		float verticalAxis = Input.GetAxis("Vertical");


        if (relativeCamera != null)
        {
            // Calculate the move vector relative to camera rotation
            Vector3 scalerVector  = new Vector3(1f, 0f, 1f);
            Vector3 cameraForward = Vector3.Scale(relativeCamera.transform.forward, scalerVector).normalized;
            Vector3 cameraRight   = Vector3.Scale(relativeCamera.transform.right, scalerVector).normalized;

            moveVector = (cameraForward * verticalAxis + cameraRight * horizontalAxis);
        }
        else
        {
            // Use world relative directions
            moveVector = (Vector3.forward * verticalAxis + Vector3.right * horizontalAxis);
        }

        if (moveVector.magnitude > 1f)
        {
            moveVector.Normalize();
        }

        return(moveVector);
    }
Example #2
0
    public override void Update(Character character, SimpleTouchController touch, FixedTouchField field)
    {
        base.Update(character, touch, field);

        if (character.IsGrounded)
        {
            this.ToState(character, CharacterStateBase.GROUNDED_STATE);
        }
    }
Example #3
0
    void Start()
    {
        screenTouch = GameObject.Find("Canvas").transform.Find("SimpleTouch").GetComponent <SimpleTouchController>();

        characterController  = GetComponent <CharacterController>();
        moveTarget           = new Vector3(0, 0, RunSpeed);
        highFiveController   = GetComponent <HighFiveController>();
        currentHandDirection = HandDirection.Normal;
        OnHandDirectionChanged();
    }
Example #4
0
    //public Transform COM;

    // Use this for initialization
    void Start()
    {
        flags              = new bool[4];
        leftController     = GameObject.FindObjectOfType <SimpleTouchController>();
        meta               = GameObject.Find("A");
        transform.position = meta.transform.position;
        body               = GetComponent <Rigidbody>();
        //body.centerOfMass = COM.position;
        //Turn off Vuforia
        //VuforiaBehaviour.Instance.enabled = false;
    }
Example #5
0
    // Use this for initialization
    void Awake()
    {
        if (leftController == null)
        {
            leftController = GameObject.Find("SimpleTouch Joystick").GetComponent <SimpleTouchController>();
        }

        if (powerBar == null)
        {
            powerBar = GameObject.Find("PowerBar").GetComponent <powerBarController>();
        }
    }
Example #6
0
    void Update()
    {
        BarBehaviour = EnergyUI.GetComponent <ProgressBarBehaviour>();
        TouchControl = GetComponent <SimpleTouchController> ();

        print(TouchControl.touchPresent);
        if (TouchControl.touchPresent == true)
        {
            //yield return new WaitForSeconds (UpdateDelay);
            BarBehaviour.Value += 1;
            //print ("new value: " + BarBehaviour.Value);
        }
        else
        {
            //print ("new value: " + BarBehaviour.Value);
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        simpleTouchControllerCam = GameObject.Find("/Canvas/SimpleTouch JoystickCam").GetComponent <SimpleTouchController>();
        Vector3 rot = transform.localRotation.eulerAngles;

        rotY = rot.y;
        rotX = rot.x;
        // wylacza widok kursora
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;

        blackStripes = (new GameObject("blackStripes")).AddComponent <BlackStripes>();
        mainCamera   = GameObject.Find("CameraHolder/Main Camera");
        Debug.Log(mainCamera.name + " = main camera name");

        cameraCollision = GameObject.Find("CameraHolder/Main Camera").GetComponent <CameraCollison>();
        sphereCaster    = GameObject.Find("CameraHolder/Main Camera").GetComponent <SphereCaster>();
    }
    private void Awake()
    {
        List <SimpleTouchController> controllerUIs = new List <SimpleTouchController>(FindObjectsOfType <SimpleTouchController>());

        foreach (var controllerUI in controllerUIs)
        {
            if (controllerUI.name.Contains("Left"))
            {
                playerControllerUI = controllerUI;
                break;
            }
        }

        transformingRobotCharacter = GetComponent <TransformingRobotCharacter> ();
        mainShootButton            = FindObjectOfType <MainShootButton>();
        secondShootButton          = FindObjectOfType <SecondShootButton>();
        sssButton    = FindObjectOfType <SSSButton>();
        skillManager = FindObjectOfType <SkillManager>();
    }
Example #9
0
    void Start()
    {
        switch (device)
        {
        case Device.PC:
            playerInput = new InputAdapterPC();
            break;

        case Device.Mobile:
            GameObject joystick = Instantiate(virtualJoystickPrefab);
            virtualJoystick = joystick.GetComponent <SimpleTouchController>();
            UIManager.Instance.AddVirtualJoystick(joystick);
            playerInput = new InputAdapterMobile();
            break;

        default:
            break;
        }
    }
Example #10
0
    // Update is called once per frame
    void Update()
    {
        if (hasAuthority)
        {
            if (!leftController && !rightController)
            {
                leftController  = GameObject.FindGameObjectWithTag("Left Controller").GetComponent <SimpleTouchController>();
                rightController = GameObject.FindGameObjectWithTag("Right Controller").GetComponent <SimpleTouchController>();
            }
            myRigidBody.MovePosition(transform.position + (transform.up * leftController.GetTouchPosition.y * Time.deltaTime * moveSpeed) +
                                     (transform.right * leftController.GetTouchPosition.x * Time.deltaTime * moveSpeed));

            waitToFire -= Time.deltaTime;
            if (waitToFire < 0)
            {
                if (rightController.GetTouchPosition.x > 0.9f || rightController.GetTouchPosition.y > 0.9f || rightController.GetTouchPosition.x < -0.9f || rightController.GetTouchPosition.y < -0.9f)
                {
                    CmdAttack(rightController.GetTouchPosition, bottleSpeed);

                    waitToFire = fireWaitTime;
                }
            }

            if (leftController.GetTouchPosition.x > 0f)
            {
                CmdFlipMe(true);
            }
            else
            {
                CmdFlipMe(false);
            }

            if (leftController.GetTouchPosition == new Vector2(0, 0))
            {
                CmdStanding(true);
            }
            else if (anim.GetBool("Standing") == true)
            {
                CmdStanding(false);
            }
        }
    }
Example #11
0
    //"No Bluetooth" "No Connection" "Ready"


    // Use this for initialization
    void Start()
    {
        string dia = "Welcome to Dual Wheel Roller app, version " + GameManager.version;

        dia += ". To complete the preparation, press Settings on the top left first.";
        PopUpBubbleManager.CreatePop("", dia, null, false);

        Resources.UnloadUnusedAssets();
        LboostScrollBar  = GameObject.Find("Canvas/Lboost").GetComponent <Scrollbar>();
        RboostScrollBar  = GameObject.Find("Canvas/Rboost").GetComponent <Scrollbar>();
        MboostScrollBar  = GameObject.Find("Canvas/Mboost").GetComponent <Scrollbar>();
        servoScrollBar   = GameObject.Find("Canvas/Servo").GetComponent <Scrollbar>();
        scaleScrollBar   = GameObject.Find("Canvas/Scale").GetComponent <Scrollbar>();
        LboostDisplay    = GameObject.Find("Canvas/Lboost/value").GetComponent <Text>();
        RboostDisplay    = GameObject.Find("Canvas/Rboost/value").GetComponent <Text>();
        MboostDisplay    = GameObject.Find("Canvas/Mboost/value").GetComponent <Text>();
        servoDisplay     = GameObject.Find("Canvas/Servo/value").GetComponent <Text>();
        scaleDisplay     = GameObject.Find("Canvas/Scale/value").GetComponent <Text>();
        usingFuncDisplay = GameObject.Find("Canvas/UsingFunc/value").GetComponent <Text>();
        statusDisplay    = GameObject.Find("Canvas/Status/value").GetComponent <Text>();
        joyStick         = GameObject.Find("Canvas/SimpleTouch Joystick").GetComponent <SimpleTouchController>();
    }
Example #12
0
    public override void Update(Character character, SimpleTouchController touch, FixedTouchField field)
    {
        base.Update(character, touch, field);

        character.ApplyGravity(true); // Apply extra gravity

        if (PlayerInput.GetToggleWalkInput())
        {
            character.ToggleWalk();
        }

        character.IsSprinting = PlayerInput.GetSprintInput();

        if (PlayerInput.GetJumpInput())
        {
            character.Jump();
            this.ToState(character, CharacterStateBase.JUMPING_STATE);
        }
        else if (!character.IsGrounded)
        {
            this.ToState(character, CharacterStateBase.IN_AIR_STATE);
        }
    }
    protected virtual void Awake()
    {
        // 获取相机位置控制器
        List <SimpleTouchController> controllerUIs = new List <SimpleTouchController>(FindObjectsOfType <SimpleTouchController>());

        foreach (var controllerUI in controllerUIs)
        {
            if (controllerUI.name.Contains("Right"))
            {
                cameraController = controllerUI;
            }
        }

        // 获取后期组件
        postProcessVolume = FindObjectOfType <PostProcessVolume>();
        postProcessVolume.profile.TryGetSettings(out depthOfField);

        // 恢复相机位置
        if (savedCameraPos != Vector3.zero)
        {
            transform.localPosition = savedCameraPos;
        }
    }
Example #14
0
 void Awake()
 {
     leftController = GameObject.FindWithTag("Canvas").GetComponentInChildren <SimpleTouchController>();
     _rigidbody     = GetComponent <Rigidbody>();
 }
Example #15
0
 public InputAdapterMobile()
 {
     joystick = InputManager.Instance.GetJoystick();
 }
Example #16
0
 public virtual void Update(Character character, SimpleTouchController touchControoller, FixedTouchField field)
 {
     character.ApplyGravity();
     character.MoveVector      = PlayerInput.GetMovementInput(character.Camera, touchControoller);
     character.ControlRotation = PlayerInput.GetMouseRotationInput(field.TouchDist.x * 0.75f, field.TouchDist.y * 0.15f);
 }