示例#1
0
 public void SetDownState()
 {
     CrossPlatformInputManager.SetButtonDown(Name);
 }
示例#2
0
        void Turning()
        {
#if !MOBILE_INPUT
            // Create a ray from the mouse cursor on screen in the direction of the camera.
            Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);

            // Create a RaycastHit variable to store information about what was hit by the ray.
            RaycastHit floorHit;

            // Perform the raycast and if it hits something on the floor layer...
            if (Physics.Raycast(camRay, out floorHit, camRayLength, floorMask))
            {
                // Create a vector from the player to the point on the floor the raycast from the mouse hit.
                Vector3 playerToMouse = floorHit.point - transform.position;

                // Ensure the vector is entirely along the floor plane.
                playerToMouse.y = 0f;

                // Create a quaternion (rotation) based on looking down the vector from the player to the mouse.
                Quaternion newRotatation = Quaternion.LookRotation(playerToMouse);

                // Set the player's rotation to this new rotation.
                playerRigidbody.MoveRotation(newRotatation);
            }
#else
            Vector3 turnDir = new Vector3(CrossPlatformInputManager.GetAxisRaw("Mouse X"), 0f, CrossPlatformInputManager.GetAxisRaw("Mouse Y"));

            if (turnDir != Vector3.zero)
            {
                // Create a vector from the player to the point on the floor the raycast from the mouse hit.
                Vector3 playerToMouse = (transform.position + turnDir) - transform.position;

                // Ensure the vector is entirely along the floor plane.
                playerToMouse.y = 0f;

                // Create a quaternion (rotation) based on looking down the vector from the player to the mouse.
                Quaternion newRotatation = Quaternion.LookRotation(playerToMouse);

                // Set the player's rotation to this new rotation.
                playerRigidbody.MoveRotation(newRotatation);
            }
#endif
        }
示例#3
0
    void Update()
    {
        moveCameraFrente = Vector3.Scale(transformCamera.forward, new Vector3(1, 0, 1)).normalized;                                                                    //rescalona o vetor , frentedaCamera,novoVetor,escaladessenovoVetor
        moveMove         = CrossPlatformInputManager.GetAxis("Vertical") * moveCameraFrente + CrossPlatformInputManager.GetAxis("Horizontal") * transformCamera.right; //eixoXdaCamera

        vetorDirecao.y -= 5.0f * Time.deltaTime;                                                                                                                       //inclementar y para baixo
        objetoCharControler.Move(vetorDirecao * Time.deltaTime);                                                                                                       // reposiciona o personagem
        objetoCharControler.Move(moveMove * velocidade * Time.deltaTime);

        if (moveMove.magnitude > 1f)
        {
            moveMove.Normalize();
        }
        moveMove = transform.InverseTransformDirection(moveMove);

        moveMove = Vector3.ProjectOnPlane(moveMove, normalZeroPiso);
        giro     = Mathf.Atan2(moveMove.x, moveMove.z);
        frente   = moveMove.z;

        objetoCharControler.SimpleMove(Physics.gravity);
        aplicaRotacao();

        if (CrossPlatformInputManager.GetButton("Jump") || Input.GetButton("Jump"))        //acrescentei o input
        {
            if (objetoCharControler.isGrounded == true)
            {
                vetorDirecao.y = pulo;
                jogador.GetComponent <Animation>().Play("jump");
                GetComponent <AudioSource>().PlayOneShot(somPula, 0.7f);
                //				Instantiate(peninhas, new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y+1, this.gameObject.transform.position.z), Quaternion.identity);

                GameObject particula = Instantiate(peninhas);
                particula.transform.position = this.transform.position;
            }
        }
        else
        {
            if ((CrossPlatformInputManager.GetAxis("Horizontal") != 0.0f) || (CrossPlatformInputManager.GetAxis("Vertical") != 0.0f))           //se ta apertado para cima ou baixo o significado do  != 0.0f
            {
                if (!animacao.IsPlaying("jump"))
                {
                    jogador.GetComponent <Animation>().Play("walk");
                }
            }
            else
            {
                if (objetoCharControler.isGrounded == true)
                {
                    jogador.GetComponent <Animation>().Play("idle");
                }
            }
        }
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        Vector3 firstPlayer  = new Vector3(CrossPlatformInputManager.GetAxis("HorizontalLeft") * _invertedX, 0, CrossPlatformInputManager.GetAxis("VerticalLeft") * _invertedY);
        Vector3 secondPlayer = new Vector3(CrossPlatformInputManager.GetAxis("HorizontalRight") * _invertedX, 0, CrossPlatformInputManager.GetAxis("VerticalRight") * _invertedY);

        // Debug.Log(firstPlayer);
        // Debug.Log(secondPlayer);
        if (Mathf.Abs(firstPlayer.x) < MinSwipeSize || Mathf.Abs(firstPlayer.z) < MinSwipeSize)
        {
            return;
        }
        if (Mathf.Abs(secondPlayer.x) < MinSwipeSize || Mathf.Abs(secondPlayer.z) < MinSwipeSize)
        {
            return;
        }
        FirstPlayersGameObject.GetComponent <PlayerComponent> ().Move(firstPlayer * MovementSensetive);
        SecondPlayersGameObject.GetComponent <PlayerComponent> ().Move(secondPlayer * MovementSensetive);
    }
 protected virtual bool GetJumpInput()
 {
     return(CrossPlatformInputManager.GetButtonDown("Jump"));
 }
示例#6
0
 // Used for realtime input.
 public virtual void CheckInput()
 {
     horizontal = CrossPlatformInputManager.GetAxisRaw("Horizontal");
     vertical   = CrossPlatformInputManager.GetAxisRaw("Vertical");
 }
    // Update is called once per frame
    void FixedUpdate()
    {
        Vector3 moveVec    = new Vector3(CrossPlatformInputManager.GetAxis("Horizontal"), 0, CrossPlatformInputManager.GetAxis("Vertical")) * moveForce;
        bool    isBoosting = CrossPlatformInputManager.GetButton("Boost");

        Vector3 lookVec = new Vector3(CrossPlatformInputManager.GetAxis("Horizontal2"), CrossPlatformInputManager.GetAxis("Vertical2"), 4000);

        //This is needed so that the rotation does not snap back to the original if they are not both zero dont snapback
        if (lookVec.x != 0 && lookVec.y != 0)
        {
            transform.rotation = Quaternion.LookRotation(lookVec, Vector3.back);
        }

        Debug.Log(isBoosting ? boostMultipler : 1);
        //a single line if else statment , is the player boosting? if its true its use multiplier if false use 1
        myPlayer.AddForce(moveVec * (isBoosting ? boostMultipler : 1));
    }
    // MAIN FUNCTION USED TO CONTROL ROTATION  - the camera is the last to finish rotating, wait on it.
    private void rotateMain()
    {
        //early escape
        // either no gas or have rotated two times
        if ((cameraRotating && double_turn) || !(ShipSpeed - DecreasePerTurn > MinimumSpeed))
        {
            return;
        }

        // Save the time for the initial rotation
        if (!cameraRotating)
        {
            time_of_rotation_begin = Time.fixedTime;
        }

        // Gotta hit the hot spot
        if (cameraRotating && !double_turn && ((Time.fixedTime - time_of_rotation_begin) > (secondsToRotate * percentForDoubleTapHotSpot)))
        {
            return;
        }

        bool mouseClick = CrossPlatformInputManager.GetButtonDown("Fire1");
        bool touchEvent = Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began;

        if (mouseClick || touchEvent)
        {
            if (just_started)
            {
                just_started         = false;
                myRigidBody.velocity = getMovement();

                if (tooltip)
                {
                    tooltip.gameObject.SetActive(false);
                }
                return;
            }

            // This sound effect sucks
            //MasterAudio.FireCustomEvent("LeftTurn", transform);

            times_rotated = (times_rotated + 1) % 4;

            gasAnimator.SetBool("turning", true);

            if (!double_turn && cameraRotating)
            {
                double_turn          = true;
                ShipSpeed            = ShipSpeed - (DecreasePerTurn * 4);
                myRigidBody.velocity = getMovement();
                return;
            }
            else
            {
                ShipSpeed            = ShipSpeed - DecreasePerTurn;
                myRigidBody.velocity = getMovement();
            }



            // zoom out
            StopAllCoroutines();

            StartCoroutine(rotatePlayerController());

            StartCoroutine(rotateZoom());
            StartCoroutine(rotateCamera());
        }
    }
示例#9
0
        private void GetPlayerInput()
        {
            Ray        ray = new Ray(Harvest_Raycast_SpawnPoint.position, Harvest_Raycast_SpawnPoint.forward);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, Cam_Ray_Length))
            {
                Debug.DrawLine(ray.origin, hit.point);

                gameobjectCollided = hit.collider.gameObject;

                if (gameobjectCollided.GetComponent <PlantModel>() != null)
                {
                    if (gameobjectCollided.GetComponentInParent <Plant_Behaviour>().CanBeHarvested())
                    {
                        playerManager.EnableHarvestIcon();
                    }
                    else
                    {
                        playerManager.DisableHarvestIcon();
                    }

                    if (Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.E))
                    {
                        Harvest(gameobjectCollided);
                    }
                }
                else if (gameobjectCollided.GetComponent <PlantPoint>() != null)
                {
                    PlantPointScript = gameobjectCollided.GetComponent <PlantPoint>();

                    if (!PlantPointScript.HasCrop)
                    {
                        playerManager.EnablePlantIcon();
                    }
                    else
                    {
                        playerManager.DisablePlantIcon();
                    }

                    if (Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.E))
                    {
                        Plant(gameobjectCollided);
                    }
                }
                else if (gameobjectCollided.gameObject.tag == "AmmoChest")
                {
                    playerManager.EnableFillingAmmoIcon();

                    if (Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.E))
                    {
                        shotGunBehaviourScript_.FillBulletsPocket();
                        Debug.Log("Fill ammo now!");
                    }
                }
                else if (gameobjectCollided.gameObject.tag == "HarvestChest")
                {
                    playerManager.EnableFillingHarvestIcon();
                    if (Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.E))
                    {
                        playerManager.updateScore();
                    }
                }
                else
                {
                    DisablePlayerIcons();
                }
            }
            else
            {
                DisablePlayerIcons();
            }

            IfBarrelInsideTheObject(nastyCollidedGameObject);

            RotateView();
            // the jump state needs to read here to make sure it is not missed
            if (!m_Jump)
            {
                m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
            }

            if (!m_PreviouslyGrounded && m_CharacterController.isGrounded)
            {
                StartCoroutine(m_JumpBob.DoBobCycle());
                PlayLandingSound();
                m_MoveDir.y = 0f;
                m_Jumping   = false;
            }
            if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded)
            {
                m_MoveDir.y = 0f;
            }

            m_PreviouslyGrounded = m_CharacterController.isGrounded;
        }
示例#10
0
文件: Player.cs 项目: hlais/Q
    void JumpAttack()
    {
        if ((Mathf.Abs(qRigidBody.velocity.y) > Mathf.Epsilon) && (Input.GetKeyDown(KeyCode.F) || CrossPlatformInputManager.GetButtonDown("Fire1")))
        {
            Physics2D.gravity = new Vector2(0, 0);

            qAnimator.SetTrigger("jumpAttack");


            StartCoroutine("Landing");
        }
    }
示例#11
0
// 以下、メイン処理.リジッドボディと絡めるので、FixedUpdate内で処理を行う.
    void FixedUpdate()
    {
        float h = CrossPlatformInputManager.GetAxis("Horizontal");  // 入力デバイスの水平軸をhで定義
        float v = CrossPlatformInputManager.GetAxis("Vertical");    // 入力デバイスの垂直軸をvで定義

        anim.SetFloat("Speed", v);                                  // Animator側で設定している"Speed"パラメタにvを渡す
        anim.SetFloat("Direction", h);                              // Animator側で設定している"Direction"パラメタにhを渡す
        anim.speed       = animSpeed;                               // Animatorのモーション再生速度に animSpeedを設定する
        currentBaseState = anim.GetCurrentAnimatorStateInfo(0);     // 参照用のステート変数にBase Layer (0)の現在のステートを設定する
        rb.useGravity    = true;                                    //ジャンプ中に重力を切るので、それ以外は重力の影響を受けるようにする

        float rv = CrossPlatformInputManager.GetAxisRaw("Mouse X"); //获取玩家鼠标垂直轴上的移动
        float rh = CrossPlatformInputManager.GetAxisRaw("Mouse Y"); //获取玩家鼠标水平轴上的移动


        // 以下、キャラクターの移動処理
        velocity = new Vector3(0, 0, v);                // 上下のキー入力からZ軸方向の移動量を取得
        // キャラクターのローカル空間での方向に変換
        velocity = transform.TransformDirection(velocity);
        //以下のvの閾値は、Mecanim側のトランジションと一緒に調整する
        if (v > 0.1)
        {
            velocity *= forwardSpeed;                           // 移動速度を掛ける
        }
        else if (v < -0.1)
        {
            velocity *= backwardSpeed;                  // 移動速度を掛ける
        }

        if (CrossPlatformInputManager.GetButtonDown("Jump"))            // スペースキーを入力したら

        //アニメーションのステートがLocomotionの最中のみジャンプできる

        {
            if (currentBaseState.nameHash == locoState)
            {
                //ステート遷移中でなかったらジャンプできる
                if (!anim.IsInTransition(0))
                {
                    Debug.Log("jump");
                    rb.AddForce(Vector3.up * jumpPower, ForceMode.VelocityChange);
                    anim.SetBool("Jump", true);                                         // Animatorにジャンプに切り替えるフラグを送る
                }
            }
        }


        // 上下のキー入力でキャラクターを移動させる
        transform.localPosition += velocity * Time.fixedDeltaTime;

        // 左右のキー入力でキャラクタをY軸で旋回させる
        transform.Rotate(0, h * rotateSpeed, 0);


        // 以下、Animatorの各ステート中での処理
        // Locomotion中
        // 現在のベースレイヤーがlocoStateの時
        if (currentBaseState.nameHash == locoState)
        {
            //カーブでコライダ調整をしている時は、念のためにリセットする
            if (useCurves)
            {
                resetCollider();
            }
        }
        // JUMP中の処理
        // 現在のベースレイヤーがjumpStateの時
        else if (currentBaseState.nameHash == jumpState)
        {
            cameraObject.SendMessage("setCameraPositionJumpView");              // ジャンプ中のカメラに変更
            // ステートがトランジション中でない場合
            if (!anim.IsInTransition(0))
            {
                // 以下、カーブ調整をする場合の処理
                if (useCurves)
                {
                    // 以下JUMP00アニメーションについているカーブJumpHeightとGravityControl
                    // JumpHeight:JUMP00でのジャンプの高さ(0〜1)
                    // GravityControl:1⇒ジャンプ中(重力無効)、0⇒重力有効
                    float jumpHeight     = anim.GetFloat("JumpHeight");
                    float gravityControl = anim.GetFloat("GravityControl");
                    if (gravityControl > 0)
                    {
                        rb.useGravity = false;                          //ジャンプ中の重力の影響を切る
                    }
                    // レイキャストをキャラクターのセンターから落とす
                    Ray        ray     = new Ray(transform.position + Vector3.up, -Vector3.up);
                    RaycastHit hitInfo = new RaycastHit();
                    // 高さが useCurvesHeight 以上ある時のみ、コライダーの高さと中心をJUMP00アニメーションについているカーブで調整する
                    if (Physics.Raycast(ray, out hitInfo))
                    {
                        if (hitInfo.distance > useCurvesHeight)
                        {
                            col.height = orgColHight - jumpHeight;                                      // 調整されたコライダーの高さ
                            float adjCenterY = orgVectColCenter.y + jumpHeight;
                            col.center = new Vector3(0, adjCenterY, 0);                                 // 調整されたコライダーのセンター
                        }
                        else
                        {
                            // 閾値よりも低い時には初期値に戻す(念のため)
                            resetCollider();
                        }
                    }
                }
                // Jump bool値をリセットする(ループしないようにする)
                anim.SetBool("Jump", false);
            }
        }
        // IDLE中の処理
        // 現在のベースレイヤーがidleStateの時
        else if (currentBaseState.nameHash == idleState)
        {
            //カーブでコライダ調整をしている時は、念のためにリセットする
            if (useCurves)
            {
                resetCollider();
            }
            // スペースキーを入力したらRest状態になる
            if (Input.GetButtonDown("Jump"))
            {
                anim.SetBool("Rest", true);
            }
        }
        // REST中の処理
        // 現在のベースレイヤーがrestStateの時
        else if (currentBaseState.nameHash == restState)
        {
            //cameraObject.SendMessage("setCameraPositionFrontView");		// カメラを正面に切り替える
            // ステートが遷移中でない場合、Rest bool値をリセットする(ループしないようにする)
            if (!anim.IsInTransition(0))
            {
                anim.SetBool("Rest", false);
            }
        }
    }
示例#12
0
 public void SetAxisNegativeState()
 {
     CrossPlatformInputManager.SetAxisNegative(Name);
 }
示例#13
0
 public void SetAxisNeutralState()
 {
     CrossPlatformInputManager.SetAxisZero(Name);
 }
示例#14
0
 public void SetUpState()
 {
     CrossPlatformInputManager.SetButtonUp(Name);
 }
示例#15
0
    private void Update()
    {
        _grounded            = Physics2D.Linecast(transform.position, _groundChecker.position, 1 << LayerMask.NameToLayer("Jumpable") | 1 << LayerMask.NameToLayer("Box"));
        _horizontalMoveInput = CrossPlatformInputManager.GetAxis("Horizontal");
        _verticalMoveInput   = CrossPlatformInputManager.GetAxis("Vertical");
        _jumpPressed         = CrossPlatformInputManager.GetButtonDown("Space");
        _changeWeaponPressed = CrossPlatformInputManager.GetButtonDown("Change");

        _attackPressed  = CrossPlatformInputManager.GetButtonDown("RCtrl");
        _targetDistance = (IsDead) ? Vector2.zero : Vector2.right * Time.deltaTime * _moveAcceleration * _horizontalMoveInput;

        if (_attackPressed && !IsDead)
        {
            Attack(_damage);
        }

        if (!_onLadder)
        {
            _rigidbody.gravityScale = 1;
            if (_horizontalMoveInput != 0)
            {
                _anim.SetBool("isWalking", true);
                _anim.SetFloat("inputX", CrossPlatformInputManager.GetAxisRaw("Horizontal"));
            }
            else
            {
                _anim.SetBool("isWalking", false);
            }
        }
        else
        {
            _rigidbody.gravityScale = 0;
            if (_verticalMoveInput != 0)
            {
                _rigidbody.velocity = new Vector2(0, _climbAcceleration * _verticalMoveInput);
            }
        }

        //check if player is on ground and if space has been pressed
        if (_grounded)
        {
            _anim.SetBool("isFalling", false);
            _anim.SetBool("isJumping", false);
            if (_jumpPressed)
            {
                _grounded = false;
                _anim.SetBool("isJumping", true);
                _canRejump           = _skill.Equals(ExtraSkill.Skill.DoubleJump);
                _rigidbody.velocity += Vector2.up * _jumpAcceleration;
            }
            else if (_anim.GetBool("isJumping"))
            {
                _anim.SetBool("isJumping", false);
            }
        }
        else if (!_grounded)
        {
            if (_jumpPressed && _canRejump)
            {
                _canRejump = false;
                transform.Translate(new Vector3(_targetDistance.x, 0, 0), Space.World);
                _rigidbody.velocity  = new Vector2(_rigidbody.velocity.x, 0);
                _rigidbody.velocity += Vector2.up * _jumpAcceleration;
            }
            else if (_rigidbody.velocity.y < 0)
            {
                _anim.SetBool("isFalling", true);
            }
            else
            {
                _anim.SetBool("isFalling", false);
            }
        }

        if (_changeWeaponPressed)
        {
            ChangeWeapon();
        }
    }
示例#16
0
    void ColliderRay(Camera camera)
    {
        target = camera.transform.forward * 100;
        Ray ray = new Ray(origin, target);

        Debug.DrawLine(origin, camera.transform.forward * 100, Color.red);
        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo, 100))
        {
            //Debug.Log("hitInfo:" + hitInfo.collider.name);
            Image rect = hitInfo.collider.GetComponent <Image>();
            if (rect != null)
            {
                hitInfo.collider.GetComponent <RectTransform>().sizeDelta = new Vector2(160, 50);
                rect.color = new Color(0.5f, 1.0f, 0.5f);
            }
            if (CrossPlatformInputManager.GetButtonUp("A"))
            {
                switch (hitInfo.collider.name)
                {
                case "360Photo Demo":
                    demo.ShowScene360Photo();
                    break;

                case "StereoPhoto":
                    demo.ShowStereoImage();
                    break;

                case "Mojing1stC":
                    demo.Mojing1stC();
                    break;

                case "Mojing3rdC":
                    demo.Mojing3rdC();
                    break;

                case "TWEnable":
                    demo.EnableTimeWarp();
                    break;

                case "EyeDemo":
                    demo.EyeDemo();
                    break;

                case "GlassesList":
                    demo.OpenGlassMenu();
                    break;

                case "MojingReport":
                    demo.ReportDemo();
                    break;

                case "MojingLoginPay":
                    demo.LoginPayDemo();
                    break;

                case "DepthOfField":
                    demo.DepthOfField();
                    break;
                }
            }
        }
        else
        {
            for (int j = 0; j < button.Length; j++)
            {
                button[j].sizeDelta = new Vector2(150, 40);
                button[j].gameObject.GetComponent <Image>().color = new Color(1.0f, 1.0f, 1.0f);
            }
        }
    }
示例#17
0
    void FixedUpdate()
    {
        if (flying)
        {
            Vector2 input         = GetInput();
            Vector3 verticalInput = Vector3.up * ((CrossPlatformInputManager.GetButton("Jump") ? 1f : 0f) - (CrossPlatformInputManager.GetButton("Crouch") ? 1f : 0f));

            if ((Mathf.Abs(input.x) > float.Epsilon || Mathf.Abs(input.y) > float.Epsilon) || Mathf.Abs(verticalInput.y) > float.Epsilon)
            {
                Vector3 desiredMove = rigidbodyFPC.cam.transform.forward * input.y + rigidbodyFPC.cam.transform.right * input.x;
                desiredMove += verticalInput;
                desiredMove  = desiredMove.normalized * rigidbodyFPC.movementSettings.CurrentTargetSpeed;
                if (rigidbodyFPC.Velocity.sqrMagnitude <
                    (rigidbodyFPC.movementSettings.CurrentTargetSpeed * rigidbodyFPC.movementSettings.CurrentTargetSpeed))
                {
                    rigidbody.AddForce(desiredMove, ForceMode.Impulse);
                }
            }
        }
    }
示例#18
0
    void JoystickRespond()
    {
        if (CrossPlatformInputManager.GetButtonLongPressed("OK") || CrossPlatformInputManager.GetButtonLongPressed("A"))
        {
            Debug.Log("OK-----Long GetButtonDown");
        }

        if (CrossPlatformInputManager.GetButtonDown("OK"))
        {
            Debug.Log("OK-----GetButtonDown");
        }
        if (CrossPlatformInputManager.GetButton("OK"))
        {
            Debug.Log("OK-----GetButton");
        }
        else if (CrossPlatformInputManager.GetButtonUp("OK") || CrossPlatformInputManager.GetButtonUp("A"))
        {
            Debug.Log("OK-----GetButtonUp");
            if (menu_controller != null && glass_controller != null)
            {
                if (GlassesList.List_Show)//镜片选择的二级菜单
                {
                    glass_controller.PressCurrent();
                }
                else//场景选择的一级菜单
                {
                    menu_controller.PressCurrent();
                }
            }
        }
        if (CrossPlatformInputManager.GetButtonDown("C"))
        {
            Debug.Log("C-----GetButtonDown");
        }
        if (CrossPlatformInputManager.GetButton("C"))
        {
            Debug.Log("C-----GetButton");
        }
        else if (CrossPlatformInputManager.GetButtonUp("C"))
        {
            Debug.Log("C-----GetButtonUp");
        }

        if (CrossPlatformInputManager.GetButtonDown("MENU"))
        {
            Debug.Log("MENU-----GetButtonDown");
        }
        if (CrossPlatformInputManager.GetButton("MENU"))
        {
            Debug.Log("MENU-----GetButton");
        }
        else if (CrossPlatformInputManager.GetButtonUp("MENU") || CrossPlatformInputManager.GetButtonUp("X"))
        {
            Debug.Log("MENU-----GetButtonUp");
            MojingSDK.Unity_ResetSensorOrientation();
        }

        if (CrossPlatformInputManager.GetButton("UP"))
        {
            Debug.Log("UP-----GetButton");
        }
        else if (CrossPlatformInputManager.GetButtonUp("UP"))
        {
            if (menu_controller != null && glass_controller != null)
            {
                if (GlassesList.List_Show)
                {
                    glass_controller.HoverPrev();
                }
                else
                {
                    menu_controller.HoverPrev();
                }
            }
        }

        if (CrossPlatformInputManager.GetButton("DOWN"))
        {
            Debug.Log("DOWN-----GetButton");
        }
        else if (CrossPlatformInputManager.GetButtonUp("DOWN"))
        {
            Debug.Log("DOWN-----GetButtonUp");
            if (menu_controller != null && glass_controller != null)
            {
                if (GlassesList.List_Show)
                {
                    glass_controller.HoverNext();
                }
                else
                {
                    menu_controller.HoverNext();
                }
            }
        }

        if (CrossPlatformInputManager.GetButton("LEFT"))
        {
            Debug.Log("LEFT-----GetButton");
        }
        else if (CrossPlatformInputManager.GetButtonUp("LEFT"))
        {
            if (menu_controller != null && glass_controller != null)
            {
                if (!GlassesList.List_Show)
                {
                    menu_controller.HoverLeft();
                }
            }
        }

        if (CrossPlatformInputManager.GetButton("RIGHT"))
        {
            Debug.Log("RIGHT-----GetButton");
        }
        else if (CrossPlatformInputManager.GetButtonUp("RIGHT"))
        {
            if (menu_controller != null && glass_controller != null)
            {
                if (!GlassesList.List_Show)
                {
                    menu_controller.HoverRight();
                }
            }
        }

        if (CrossPlatformInputManager.GetButton("CENTER"))
        {
        }
        else if (CrossPlatformInputManager.GetButtonUp("CENTER"))
        {
        }
    }
示例#19
0
        private IEnumerator RunTests()
        {
            VoxelPlayer  player;
            GameObject   managerObj;
            ChunkManager manager;

            foreach (var testSuite in GetComponentsInChildren <AbstractTestSuite>())
            {
                if (selectedTestSuiteNames != null && !selectedTestSuiteNames.Contains(testSuite.gameObject.name))
                {
                    continue;//Skip any test suites that were not selected
                }

                testSuite.Initialise();
                var suiteName = testSuite.SuiteName;
                //For each repeat
                for (int repeatIndex = 0; repeatIndex <= NumRepeats; repeatIndex++)
                {
                    //Run all tests in the suite
                    for (int testIndex = 0; testIndex < testSuite.Tests.Length; testIndex++)
                    {
                        managerObj = Worlds.Find(chunkManagerName).gameObject;
                        manager    = managerObj.GetComponent <ChunkManager>();
                        testSuite.SetManagerForNextPass(manager);

                        //Run all passes in the suite
                        foreach (var passDetails in testSuite.Passes())
                        {
                            yield return(null);//Give time for component removals from pass to be applied

                            float startTime = Time.unscaledTime;

                            var groupName     = passDetails.GroupName;
                            var test          = testSuite.Tests[testIndex];
                            var testDirectory = $@"{@TestResultPath}{@suiteName}\{groupName}\";
                            EnsureDirectoryExists(testDirectory);

                            var fileName         = $"{test.TestName}";
                            var completeFilePath = @testDirectory + @fileName + @FileExtension;
                            using (StreamWriter log = new StreamWriter(@TestResultPath + @LogFileName + @FileExtension, true))
                            {
                                var testRunIdentifier = $"{suiteName}\\{groupName}\\{fileName}\\{passDetails.TechniqueName}\\R{repeatIndex}";
                                log.WriteLine($"\n\n\nTest {testRunIdentifier}:");
                                Debug.Log($"Starting test for {testRunIdentifier}");

                                //Reset virtual input
                                virtualPlayer = new VirtualPlayerInput();
                                CrossPlatformInputManager.SetActiveInputMethod(virtualPlayer);

                                managerObj.SetActive(true);
                                player         = FindObjectOfType <VoxelPlayer>();
                                player.enabled = true;

                                //Run the test
                                yield return(StartCoroutine(test.Run(manager)));

                                bool makeHeader = !filesWithHeader.Contains(completeFilePath);

                                //Write outputs
                                using (StreamWriter testResults = new StreamWriter(completeFilePath, true))
                                {
                                    WriteTestLog(log, test);
                                    WriteTestResults(testResults, test, makeHeader, passDetails.TechniqueName, repeatIndex);
                                    filesWithHeader.Add(completeFilePath);
                                }

                                ///Cleanup--------------
                                test.Clear();
                                //reload the scene
                                yield return(SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single));

                                //Do garbage collection
                                GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);

                                yield return(new WaitForSecondsRealtime(2));

                                //Locate Worlds object in scene
                                Worlds = GameObject.Find("VoxelWorlds").transform;
                                //Locate manager again for next pass
                                managerObj = Worlds.Find(chunkManagerName).gameObject;
                                manager    = managerObj.GetComponent <ChunkManager>();
                                testSuite.SetManagerForNextPass(manager);

                                float duration = Time.unscaledTime - startTime;
                                log.WriteLine($"\nFinished after total time of {duration}");
                            }
                        }
                    }
                }
            }

            Debug.Log("All tests done");

            ///Must initalise manager, as it is not guaranteed to exit correctly otherwise
            ///(Stuff needs disposing)
            managerObj = Worlds.Find(chunkManagerName).gameObject;

            ///Ensure manager is in a valid configuration (only one provider and one mesher component)
            AbstractTestSuite.RemoveComponentsOfTypeExceptSubtype <AbstractProviderComponent, DebugProvider>(managerObj);
            AbstractTestSuite.RemoveComponentsOfTypeExceptSubtype <AbstractMesherComponent, CullingMesher>(managerObj);

            managerObj.SetActive(true);
            manager = managerObj.GetComponent <ChunkManager>();
            manager.Initialise();

            manager    = null;
            managerObj = null;
            yield return(SceneManager.LoadSceneAsync("MainMenu"));

            //Do garbage collection
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Default, true);

            //Destroy this object
            Destroy(gameObject);
        }
示例#20
0
        void Update()
        {
            // we make initial calculations from the original local rotation
            this.transform.localRotation = this.m_OriginalRotation;

            // read input from mouse or mobile controls
            float inputH;
            float inputV;

            if (this.relative)
            {
                inputH = CrossPlatformInputManager.GetAxis("Mouse X");
                inputV = CrossPlatformInputManager.GetAxis("Mouse Y");

                // wrap values to avoid springing quickly the wrong way from positive to negative
                if (this.m_TargetAngles.y > 180)
                {
                    this.m_TargetAngles.y -= 360;
                    this.m_FollowAngles.y -= 360;
                }

                if (this.m_TargetAngles.x > 180)
                {
                    this.m_TargetAngles.x -= 360;
                    this.m_FollowAngles.x -= 360;
                }

                if (this.m_TargetAngles.y < -180)
                {
                    this.m_TargetAngles.y += 360;
                    this.m_FollowAngles.y += 360;
                }

                if (this.m_TargetAngles.x < -180)
                {
                    this.m_TargetAngles.x += 360;
                    this.m_FollowAngles.x += 360;
                }

        #if MOBILE_INPUT
// on mobile, sometimes we want input mapped directly to tilt value,
// so it springs back automatically when the look input is released.
                if (autoZeroHorizontalOnMobile)
                {
                    m_TargetAngles.y = Mathf.Lerp(-rotationRange.y * 0.5f, rotationRange.y * 0.5f, inputH * .5f + .5f);
                }
                else
                {
                    m_TargetAngles.y += inputH * rotationSpeed;
                }
                if (autoZeroVerticalOnMobile)
                {
                    m_TargetAngles.x = Mathf.Lerp(-rotationRange.x * 0.5f, rotationRange.x * 0.5f, inputV * .5f + .5f);
                }
                else
                {
                    m_TargetAngles.x += inputV * rotationSpeed;
                }
                                                                                        #else
                // with mouse input, we have direct control with no springback required.
                this.m_TargetAngles.y += inputH * this.rotationSpeed;
                this.m_TargetAngles.x += inputV * this.rotationSpeed;
        #endif

                // clamp values to allowed range
                this.m_TargetAngles.y = Mathf.Clamp(
                    this.m_TargetAngles.y,
                    -this.rotationRange.y * 0.5f,
                    this.rotationRange.y * 0.5f);
                this.m_TargetAngles.x = Mathf.Clamp(
                    this.m_TargetAngles.x,
                    -this.rotationRange.x * 0.5f,
                    this.rotationRange.x * 0.5f);
            }
            else
            {
                inputH = Input.mousePosition.x;
                inputV = Input.mousePosition.y;

                // set values to allowed range
                this.m_TargetAngles.y = Mathf.Lerp(
                    -this.rotationRange.y * 0.5f,
                    this.rotationRange.y * 0.5f,
                    inputH / Screen.width);
                this.m_TargetAngles.x = Mathf.Lerp(
                    -this.rotationRange.x * 0.5f,
                    this.rotationRange.x * 0.5f,
                    inputV / Screen.height);
            }

            // smoothly interpolate current values to target angles
            this.m_FollowAngles = Vector3.SmoothDamp(
                this.m_FollowAngles,
                this.m_TargetAngles,
                ref this.m_FollowVelocity,
                this.dampingTime);

            // update the actual gameobject's rotation
            this.transform.localRotation = this.m_OriginalRotation
                                           * Quaternion.Euler(-this.m_FollowAngles.x, this.m_FollowAngles.y, 0);
        }
示例#21
0
    public void Turning()
    {
        // 1) get to know where the mouse is located at
        // if it is in range, then rotate the character towards the mouse

                #if !MOBILE_INPUT
        Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit floorHit;
        if (Physics.Raycast(camRay, out floorHit, camRayLength, floorMask))
        {
            Vector3 playerToMouse = floorHit.point - transform.position;
            playerToMouse.y = 0.0f;
            Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
            playerRigidBody.MoveRotation(newRotation);
        }
                #else
        Vector3 turnDir = new Vector3(CrossPlatformInputManager.GetAxisRaw("Horizontal"), 0f, CrossPlatformInputManager.GetAxisRaw("Vertical"));
        if (turnDir != Vector3.zero)
        {
            Vector3 playerToMouse = (transform.position + turnDir) - transform.position;
            playerToMouse.y = 0;
            Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
            playerRigidBody.MoveRotation(newRotation);
        }
                #endif
    }
示例#22
0
    //---Player Movement---//
    ////////////////////////
    void PlayerMovement()
    {
        //Move in camera direction
        if (forwardIsCameraDirection)
        {
            Direction   = APR_Parts[0].transform.rotation * new Vector3(CrossPlatformInputManager.GetAxis(leftRight), 0.0f, CrossPlatformInputManager.GetAxis(forwardBackward));
            Direction.y = 0f;
            APR_Parts[0].transform.GetComponent <Rigidbody>().velocity = Vector3.Lerp(APR_Parts[0].transform.GetComponent <Rigidbody>().velocity, (Direction * moveSpeed) + new Vector3(0, APR_Parts[0].transform.GetComponent <Rigidbody>().velocity.y, 0), 0.8f);

            if (CrossPlatformInputManager.GetAxis(leftRight) != 0 || CrossPlatformInputManager.GetAxis(forwardBackward) != 0 && balanced)
            {
                if (!WalkForward && !moveAxisUsed)
                {
                    WalkForward  = true;
                    moveAxisUsed = true;
                    isKeyDown    = true;
                }
            }

            else if (CrossPlatformInputManager.GetAxis(leftRight) == 0 && CrossPlatformInputManager.GetAxis(forwardBackward) == 0)
            {
                if (WalkForward && moveAxisUsed)
                {
                    WalkForward  = false;
                    moveAxisUsed = false;
                    isKeyDown    = false;
                }
            }
        }

        //Move in own direction
        else
        {
            if (CrossPlatformInputManager.GetAxis(forwardBackward) != 0)
            {
                var v3 = APR_Parts[0].GetComponent <Rigidbody>().transform.forward *CrossPlatformInputManager.GetAxis(forwardBackward) * moveSpeed;
                v3.y = APR_Parts[0].GetComponent <Rigidbody>().velocity.y;
                APR_Parts[0].GetComponent <Rigidbody>().velocity = v3;
            }


            if (CrossPlatformInputManager.GetAxis(forwardBackward) > 0)
            {
                if (!WalkForward && !moveAxisUsed)
                {
                    WalkBackward = false;
                    WalkForward  = true;
                    moveAxisUsed = true;
                    isKeyDown    = true;

                    if (isRagdoll)
                    {
                        APR_Parts[7].GetComponent <ConfigurableJoint>().angularXDrive   = PoseOn;
                        APR_Parts[7].GetComponent <ConfigurableJoint>().angularYZDrive  = PoseOn;
                        APR_Parts[8].GetComponent <ConfigurableJoint>().angularXDrive   = PoseOn;
                        APR_Parts[8].GetComponent <ConfigurableJoint>().angularYZDrive  = PoseOn;
                        APR_Parts[9].GetComponent <ConfigurableJoint>().angularXDrive   = PoseOn;
                        APR_Parts[9].GetComponent <ConfigurableJoint>().angularYZDrive  = PoseOn;
                        APR_Parts[10].GetComponent <ConfigurableJoint>().angularXDrive  = PoseOn;
                        APR_Parts[10].GetComponent <ConfigurableJoint>().angularYZDrive = PoseOn;
                        APR_Parts[11].GetComponent <ConfigurableJoint>().angularXDrive  = PoseOn;
                        APR_Parts[11].GetComponent <ConfigurableJoint>().angularYZDrive = PoseOn;
                        APR_Parts[12].GetComponent <ConfigurableJoint>().angularXDrive  = PoseOn;
                        APR_Parts[12].GetComponent <ConfigurableJoint>().angularYZDrive = PoseOn;
                    }
                }
            }

            else if (CrossPlatformInputManager.GetAxis(forwardBackward) < 0)
            {
                if (!WalkBackward && !moveAxisUsed)
                {
                    WalkForward  = false;
                    WalkBackward = true;
                    moveAxisUsed = true;
                    isKeyDown    = true;

                    if (isRagdoll)
                    {
                        APR_Parts[7].GetComponent <ConfigurableJoint>().angularXDrive   = PoseOn;
                        APR_Parts[7].GetComponent <ConfigurableJoint>().angularYZDrive  = PoseOn;
                        APR_Parts[8].GetComponent <ConfigurableJoint>().angularXDrive   = PoseOn;
                        APR_Parts[8].GetComponent <ConfigurableJoint>().angularYZDrive  = PoseOn;
                        APR_Parts[9].GetComponent <ConfigurableJoint>().angularXDrive   = PoseOn;
                        APR_Parts[9].GetComponent <ConfigurableJoint>().angularYZDrive  = PoseOn;
                        APR_Parts[10].GetComponent <ConfigurableJoint>().angularXDrive  = PoseOn;
                        APR_Parts[10].GetComponent <ConfigurableJoint>().angularYZDrive = PoseOn;
                        APR_Parts[11].GetComponent <ConfigurableJoint>().angularXDrive  = PoseOn;
                        APR_Parts[11].GetComponent <ConfigurableJoint>().angularYZDrive = PoseOn;
                        APR_Parts[12].GetComponent <ConfigurableJoint>().angularXDrive  = PoseOn;
                        APR_Parts[12].GetComponent <ConfigurableJoint>().angularYZDrive = PoseOn;
                    }
                }
            }

            else if (CrossPlatformInputManager.GetAxis(forwardBackward) == 0)
            {
                if (WalkForward || WalkBackward && moveAxisUsed)
                {
                    WalkForward  = false;
                    WalkBackward = false;
                    moveAxisUsed = false;
                    isKeyDown    = false;

                    if (isRagdoll)
                    {
                        APR_Parts[7].GetComponent <ConfigurableJoint>().angularXDrive   = DriveOff;
                        APR_Parts[7].GetComponent <ConfigurableJoint>().angularYZDrive  = DriveOff;
                        APR_Parts[8].GetComponent <ConfigurableJoint>().angularXDrive   = DriveOff;
                        APR_Parts[8].GetComponent <ConfigurableJoint>().angularYZDrive  = DriveOff;
                        APR_Parts[9].GetComponent <ConfigurableJoint>().angularXDrive   = DriveOff;
                        APR_Parts[9].GetComponent <ConfigurableJoint>().angularYZDrive  = DriveOff;
                        APR_Parts[10].GetComponent <ConfigurableJoint>().angularXDrive  = DriveOff;
                        APR_Parts[10].GetComponent <ConfigurableJoint>().angularYZDrive = DriveOff;
                        APR_Parts[11].GetComponent <ConfigurableJoint>().angularXDrive  = DriveOff;
                        APR_Parts[11].GetComponent <ConfigurableJoint>().angularYZDrive = DriveOff;
                        APR_Parts[12].GetComponent <ConfigurableJoint>().angularXDrive  = DriveOff;
                        APR_Parts[12].GetComponent <ConfigurableJoint>().angularYZDrive = DriveOff;
                    }
                }
            }
        }
    }
示例#23
0
    private void Movement()
    {
        if (transform.position.y < MainGameTracker.FLOOR_LEVEL + bottomMargin)
        {
            transform.position += Vector3.up * Time.deltaTime * MainGameTracker.GAME_SPEED * MainGameTracker.RISING_SPEED;
        }
        // TODO: Raise umbrella with floor level
        currentHorizontalDirection = 0f;
        if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
        {
            currentHorizontalDirection += 1f;
            transform.localScale        = (Vector3.left * 2) + Vector3.one;
        }
        if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
        {
            currentHorizontalDirection += -1f;
            transform.localScale        = Vector3.one;
        }

        if (CrossPlatformInputManager.GetAxis("Horizontal") > 0)
        {
            transform.localScale = (Vector3.left * 2) + Vector3.one;
        }
        else if (CrossPlatformInputManager.GetAxis("Horizontal") < 0)
        {
            transform.localScale = Vector3.one;
        }

        currentVerticalDirection = 0f;
        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
        {
            currentVerticalDirection += 1f;
        }
        if ((Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) && transform.position.y > MainGameTracker.FLOOR_LEVEL + bottomMargin)
        {
            currentVerticalDirection += -1f;
        }

        if (currentHorizontalDirection != 0f && currentVerticalDirection != 0f)
        {
            currentHorizontalDirection *= sqrtHalf;
            currentVerticalDirection   *= sqrtHalf;
        }
        if (stunStatus == false)
        {
            transform.position += Vector3.right * speed * Time.deltaTime * currentHorizontalDirection * MainGameTracker.GAME_SPEED;
            transform.position += Vector3.up * speed * Time.deltaTime * currentVerticalDirection * MainGameTracker.GAME_SPEED;

            if (mobileControl)
            {
                transform.position += new Vector3(CrossPlatformInputManager.GetAxis("Horizontal"), CrossPlatformInputManager.GetAxis("Vertical"), 0)
                                      * speed * Time.deltaTime * MainGameTracker.GAME_SPEED;
            }

            transform.position = new Vector3(Mathf.Clamp(transform.position.x, lowerHorizontalLimit, upperHorizontalcalLimit),
                                             Mathf.Clamp(transform.position.y, lowerVerticalLimit, upperVericalLimit), transform.position.z);
        }
        else if (Time.time - stunTime >= stunDuration)
        {
            stunStatus = false;
            StopBlinking();
        }
        else
        {
            Blinking();
        }
    }
示例#24
0
    //---Player Rotation---//
    ////////////////////////
    void PlayerRotation()
    {
        if (forwardIsCameraDirection)
        {
            //Camera Direction
            //Turn with camera
            var lookPos = cam.transform.forward;
            lookPos.y = 0;
            var rotation = Quaternion.LookRotation(lookPos);
            APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation = Quaternion.Slerp(APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation, Quaternion.Inverse(rotation), Time.deltaTime * turnSpeed);
        }

        else
        {
            //Self Direction
            //Turn with keys
            if (CrossPlatformInputManager.GetAxis(leftRight) != 0)
            {
                APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation = Quaternion.Lerp(APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation, new Quaternion(APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.x, APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.y - (CrossPlatformInputManager.GetAxis(leftRight) * turnSpeed), APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.z, APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.w), 6 * Time.fixedDeltaTime);
            }

            //reset turn upon target rotation limit
            if (APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.y < -0.98f)
            {
                APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation = new Quaternion(APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.x, 0.98f, APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.z, APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.w);
            }

            else if (APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.y > 0.98f)
            {
                APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation = new Quaternion(APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.x, -0.98f, APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.z, APR_Parts[0].GetComponent <ConfigurableJoint>().targetRotation.w);
            }
        }
    }
示例#25
0
    void FixedUpdate()
    {
        // recording player movement in a vector
        Vector2 moveVector = new Vector2(CrossPlatformInputManager.GetAxis("Horizontal"), CrossPlatformInputManager.GetAxis("Vertical")) * moveForce;

        if (moveVector.sqrMagnitude > 0.01)
        {
            player.MovePosition(player.position + moveVector * moveForce * Time.fixedDeltaTime); // will move the position of the player
        }


        //recording player rotation in a vector
        Vector2 lookVector = new Vector2(CrossPlatformInputManager.GetAxis("Horizontal_2"), CrossPlatformInputManager.GetAxis("Vertical_2"));

        //condition for checking if the look joystick is released
        if (lookVector.sqrMagnitude > 0.01)
        {
            float angle = Mathf.Atan2(lookVector.y, lookVector.x) * Mathf.Rad2Deg;
            player.rotation = angle;
        }
    }
        private void GetInput()
        {
            // Read input
            float horizontal;
            float vertical;

            // InControl input
            inputDevice = InputManager.ActiveDevice;
            if (InputManager.Devices.Count > 0)
            {
                usingController = true;

                horizontal = inputDevice.LeftStick.X;
                vertical   = inputDevice.LeftStick.Y;

                if (inputDevice.RightTrigger)
                {
                    LightCandle();
                }

                if (inputDevice.Action2.WasPressed)
                {
                    Interact();
                }

                if (inputDevice.Action3.WasPressed)
                {
                    if (heldObject)
                    {
                        DropObject();
                    }
                    else
                    {
                        PickupObject();
                    }
                }
            }
            else
            {
                usingController = false;

                horizontal = CrossPlatformInputManager.GetAxis(horizontalAxis);
                vertical   = CrossPlatformInputManager.GetAxis(verticalAxis);

                if (Input.GetButtonDown(lightCandleButton))
                {
                    LightCandle();
                }

                if (Input.GetButtonDown(interactButton))
                {
                    Interact();
                }

                if (Input.GetButtonDown(pickupButton))
                {
                    if (heldObject)
                    {
                        DropObject();
                    }
                    else
                    {
                        PickupObject();
                    }
                }
            }

            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }
        }
示例#27
0
 private void AddButton(string name)
 {
     // we have not registered this button yet so add it, happens in the constructor
     CrossPlatformInputManager.RegisterVirtualButton(new CrossPlatformInputManager.VirtualButton(name));
 }
示例#28
0
    void Update()
    {
        if (gameManager.CurrentGameMode != GameMode.play)
        {
            return;
        }

        if (CrossPlatformInputManager.GetButtonUp("Jump"))
        {
            needSkipFirstAfterPlayback = false;
        }

        switch (CurrentJumpState)
        {
        case JumpState.flyUp:
            CheckTransitionToSlowDownState();
            ProcessUserInput();
            CheckForParachuteActivation();
            break;

        case JumpState.slowDown:
            CheckTransitionToApexState();
            ProcessUserInput();
            CheckForParachuteActivation();
            break;

        case JumpState.apex:
        case JumpState.flyDown:
            ProcessUserInput();
            CheckForDeltaplanActivation();
            CheckForParachuteActivation();
            break;

        case JumpState.jetpack:
            if (gameManager.HasFuel())
            {
                gameManager.ChangeJetpackFuel(-jetpackConfiguration.FuelConsumptionPerSecond * Time.deltaTime);
            }
            else
            {
                TurneOffJetpack();
            }
            ProcessUserInput();
            break;

        case JumpState.deltaplan:
            if (CrossPlatformInputManager.GetButtonDown("Fire2"))
            {
                TurneOffDeltaplan();
            }
            break;

        case JumpState.patachute:
            if (CrossPlatformInputManager.GetButtonDown("Fire3"))
            {
                TurneOffParachute();
            }
            break;

        case JumpState.force:
            return;
        }
    }
示例#29
0
    protected override void Update()
    {
        base.Update();
        this.m_BackpackHint.SetActive(GreenHellGame.IsPadControllerActive() && !Inventory3DManager.Get().IsActive());
        this.m_SortBackpackHint.SetActive(GreenHellGame.IsPadControllerActive() && Inventory3DManager.Get().IsActive());
        Limb limb = Limb.None;

        if (GreenHellGame.IsPCControllerActive())
        {
            for (int i = 0; i < 4; i++)
            {
                if (this.m_SelectionColliders[i].OverlapPoint(Input.mousePosition))
                {
                    limb = (Limb)i;
                    break;
                }
            }
        }
        else if (!HUDItem.Get().enabled)
        {
            float   axis  = CrossPlatformInputManager.GetAxis("LeftStickX");
            float   axis2 = CrossPlatformInputManager.GetAxis("LeftStickY");
            Vector2 zero  = Vector2.zero;
            zero.x = axis;
            zero.y = axis2;
            if (zero.magnitude > 0.08f)
            {
                float num = Vector3.Angle(zero, Vector3.up);
                if (axis > 0f)
                {
                    num = 360f - num;
                }
                if (num <= 90f)
                {
                    limb = Limb.RArm;
                }
                else if (num > 90f && num <= 180f)
                {
                    limb = Limb.RLeg;
                }
                else if (num > 180f && num <= 270f)
                {
                    limb = Limb.LLeg;
                }
                else if (num > 270f)
                {
                    limb = Limb.LArm;
                }
            }
        }
        this.SelectLimb(limb);
        if ((GreenHellGame.IsPCControllerActive() && Input.GetMouseButtonDown(0)) || (GreenHellGame.IsPadControllerActive() && Input.GetKeyDown(InputHelpers.PadButton.L3.KeyFromPad())))
        {
            this.OnClickLimb(limb);
            switch (limb)
            {
            case Limb.LArm:
                BodyInspectionController.Get().m_Inputs.m_ChooseLimbX = -1f;
                BodyInspectionController.Get().m_Inputs.m_ChooseLimbY = 1f;
                break;

            case Limb.RArm:
                BodyInspectionController.Get().m_Inputs.m_ChooseLimbX = 1f;
                BodyInspectionController.Get().m_Inputs.m_ChooseLimbY = 1f;
                break;

            case Limb.LLeg:
                BodyInspectionController.Get().m_Inputs.m_ChooseLimbX = -1f;
                BodyInspectionController.Get().m_Inputs.m_ChooseLimbY = -1f;
                break;

            case Limb.RLeg:
                BodyInspectionController.Get().m_Inputs.m_ChooseLimbX = 1f;
                BodyInspectionController.Get().m_Inputs.m_ChooseLimbY = -1f;
                break;
            }
        }
        this.UpdateArmor();
        this.UpdateSmallIcons();
        this.UpdateArmorTooltip();
    }
示例#30
0
	void Update () {
		//transform.position = Vector.Lerp(m_StartPos, endMarker.position, moveForce);
		//Vector2 moveVec = new Vector2 (CrossPlatformInputManager.GetAxis("x"), CrossPlatformInputManager.GetAxis("y")) * moveForce;
		currX = transform.position.x;
		currY = transform.position.y;
		Vector2 destination = new Vector2 (_hSpeed*-CrossPlatformInputManager.GetAxis ("p2x") +currX, _vSpeed*CrossPlatformInputManager.GetAxis ("p2y")+currY);
		Vector2 moveVec = Vector2.Lerp (transform.position, destination, speed * Time.deltaTime);
		Vector3 appliedVec = new Vector3 (moveVec.x, moveVec.y, transform.position.z);
		transform.position = appliedVec;

		//myBody.AddForce (moveVec);
	}