// FixedUpdate
        void FixedUpdate()
        {
            if (axesInputType == AxesInputType.BindAxes && !binded)
            {
                TCKInput.BindAxes("Joystick", BindPlayerAxes);
                binded = true;
                return;
            }

            if (axesInputType != AxesInputType.BindAxes && binded)
            {
                TCKInput.UnBindAxes("Joystick", BindPlayerAxes);
                binded = false;
                return;
            }


            if (axesInputType != AxesInputType.GetAxis)
            {
                return;
            }

            if (axesGetType == GetAxesMethod.GetByName)
            {
                float moveX = TCKInput.GetAxis("Joystick", "Horizontal");
                float moveY = TCKInput.GetAxis("Joystick", "Vertical");
                PlayerMovement(moveX, moveY);
            }
            else
            {
                float moveX = TCKInput.GetAxis("Joystick", AxisType.X);
                float moveY = TCKInput.GetAxis("Joystick", AxisType.Y);
                PlayerMovement(moveX, moveY);
            }
        }
示例#2
0
        // FixedUpdate
        void FixedUpdate()
        {
            if (axesInputType == AxesInputType.BindAxes && !binded)
            {
                TCKInput.BindAxes("Joystick", BindPlayerAxes);
                binded = true;
                return;
            }

            if (axesInputType != AxesInputType.BindAxes && binded)
            {
                TCKInput.UnbindAxes("Joystick", BindPlayerAxes);
                binded = false;
                return;
            }

            if (axesInputType != AxesInputType.GetAxis)
            {
                return;
            }

            float moveX = TCKInput.GetAxis("Joystick", EAxisType.Horizontal);
            float moveY = TCKInput.GetAxis("Joystick", EAxisType.Vertical);

            PlayerMovement(moveX, moveY);
        }
示例#3
0
    // Update is called once per frame
    void LateUpdate()
    {
        float horizontal = TCKInput.GetAxis("Joystick", EAxisType.Horizontal);

        if (horizontal < 0)
        {
            transform.localScale = new Vector3(-scale.x, transform.localScale.y, transform.localScale.z);
        }
        else if (horizontal > 0)
        {
            transform.localScale = new Vector3(scale.x, transform.localScale.y, transform.localScale.z);
        }

        if (horizontal != 0 && isWalking == false && !isFlying)
        {
            Anim.SetTrigger("4Walk");
            isWalking = true;
        }
        if (horizontal == 0 && isWalking == true)
        {
            Anim.SetTrigger("4Idle");
            isWalking = false;
        }

        if (TCKInput.GetAction("jumpBtn", EActionEvent.Down))
        {
            Anim.SetTrigger("4Jump");
            isFlying = true;
        }
    }
示例#4
0
    void FixedUpdate()
    {
        //Android joystick or Windows arrow controls
        Vector2 move = Vector2.zero;

#if UNITY_ANDROID
        move = TCKInput.GetAxis("Joystick");
#elif UNITY_EDITOR_WIN
        if (Input.GetKey(upKey))
        {
            move = Vector2.up;
        }
        else if (Input.GetKey(downKey))
        {
            move = Vector2.down;
        }
        if (Input.GetKey(leftKey))
        {
            move += Vector2.left;
        }
        else if (Input.GetKey(rightKey))
        {
            move += Vector2.right;
        }
#endif
        //Player movement in the air while spawning
        if (!characterController.isGrounded)
        {
            move.x *= 4;
            move.y *= 4;
        }

        movePlayer(move.x, move.y);
    }
示例#5
0
        // FixedUpdate
        void FixedUpdate()
        {
            float horizontal = TCKInput.GetAxis("DPad", AxisType.X);

            horizontal = Mathf.Clamp(horizontal, -1f, 1f);

            anim.SetFloat("Speed", Mathf.Abs(horizontal));

            if (horizontal * m_Rigidbody2D.velocity.x < maxSpeed)
            {
                m_Rigidbody2D.AddForce(Vector2.right * horizontal * moveForce);
            }

            if (Mathf.Abs(m_Rigidbody2D.velocity.x) > maxSpeed)
            {
                m_Rigidbody2D.velocity = new Vector2(Mathf.Sign(m_Rigidbody2D.velocity.x) * maxSpeed, m_Rigidbody2D.velocity.y);
            }

            if (horizontal > 0f && !facingRight)
            {
                Flip();
            }
            else if (horizontal < 0f && facingRight)
            {
                Flip();
            }

            if (jump)
            {
                anim.SetTrigger("Jump");
                m_Rigidbody2D.AddForce(new Vector2(0f, jumpForce * 1.5f));
                jump = false;
            }
        }
示例#6
0
    // Update is called once per frame
    void Update()
    {
        defence = Input.GetKey(keyB) || TCKInput.GetAction("defenceBtn", EActionEvent.Press);;
        run     = Input.GetKey(keyD) || TCKInput.GetAction("runBtn", EActionEvent.Press);
        //bool newjump = Input.GetKey(keyA);
        //if(newjump == true && newjump != lastjump)
        //{
        //    jump = true;
        //}
        //else
        //{
        //    jump = false;
        //}
        //lastjump = newjump;

        trigger(keyA, "jumpBtn", ref lastjump, ref jump);

        trigger(keyC, "attackBtn", ref lastattack, ref attack);
        if (MouseEnable == true)
        {
            //Jup = (Input.GetKey(keyJUp) ? 1.0f : 0) - (Input.GetKey(keyJDown) ? 1.0f : 0);
            //Jright = (Input.GetKey(keyJLeft) ? 0 : 1.0f) - (Input.GetKey(keyJRight) ? 0 : 1.0f);

            Jup    = Input.GetAxis("Mouse Y") * 3.5f;
            Jright = Input.GetAxis("Mouse X") * 2.5f;

            targetDup    = (Input.GetKey(keyUp) ? 1.0f : 0) - (Input.GetKey(keyDown) ? 1.0f : 0);
            targetDright = (Input.GetKey(keyLeft) ? 0 : 1.0f) - (Input.GetKey(keyRight) ? 0 : 1.0f);
        }
        else
        {
            Vector2 look = TCKInput.GetAxis("Touchpad");
            Jup    = look.y;
            Jright = look.x;

            Vector2 move = TCKInput.GetAxis("Joystick"); // NEW func since ver 1.5.5

            targetDup    = move.y;
            targetDright = move.x;
        }

        if (inputeEnabled == false)
        {
            targetDup    = 0;
            targetDright = 0;
        }

        Dup    = Mathf.SmoothDamp(Dup, targetDup, ref velocityDup, 0.1f);
        Dright = Mathf.SmoothDamp(Dright, targetDright, ref velocityDright, 0.1f);


        if (MouseEnable == false)
        {
            Vector2 temp = SquareToCircle(new Vector2(Dup, Dright));
            Dup    = temp.x;
            Dright = temp.y;
        }
        Dmag = Mathf.Sqrt(Dup * Dup + Dright * Dright);
        Dvec = Dright * transform.right + Dup * transform.forward;
    }
示例#7
0
    private void Update()
    {
        Vector2 look = TCKInput.GetAxis("Touchpad");

        this.transform.Rotate(Vector3.up * look.x * 500 * Time.deltaTime);

        cam.transform.Rotate(Vector3.left * look.y * 500 * Time.deltaTime);

        Vector3 currentRotation = cam.transform.localRotation.eulerAngles;

        currentRotation.x           = Mathf.Clamp(currentRotation.x, minRotation, maxRotation);
        cam.transform.localRotation = Quaternion.Euler(currentRotation);



        if (Input.GetKeyDown(KeyCode.Q))
        {
            StartCoroutine(laserCoroutine());
        }
        if (Input.GetKeyDown(KeyCode.T))
        {
            this.gameObject.GetComponent <Animator>().SetBool("carry", true);

            GameObject x = Instantiate(carrylady, carryladypos.transform.position, carryladypos.transform.rotation) as GameObject;
            x.transform.SetParent(Carry_Parent.transform);
        }
    }
示例#8
0
        // Update
        void Update()
        {
            if (weapReady == false)
            {
                weapReadyTime += Time.deltaTime;
                if (weapReadyTime > .15f)
                {
                    weapReady     = true;
                    weapReadyTime = 0f;
                }
            }


            if (TCKInput.GetAction("jumpBtn", EActionEvent.Down))
            {
                Jumping();
            }

            if (TCKInput.GetAction("fireBtn", EActionEvent.Press))
            {
                PlayerFiring();
            }

            Vector2 look = TCKInput.GetAxis("Touchpad");

            PlayerRotation(look.x, look.y);
        }
    void FixedUpdate()
    {
        Vector2 move          = TCKInput.GetAxis("Joystick0");
        Vector3 moveDirection = myTransform.forward * move.x;
        //moveDirection += myTransform.right * move.y;

        //player.transform.position = moveDirection;
    }
示例#10
0
        // FixedUpdate
        void FixedUpdate()
        {
            /*float moveX = TCKInput.GetAxis( "Joystick", EAxisType.Horizontal );
             * float moveY = TCKInput.GetAxis( "Joystick", EAxisType.Vertical );*/
            Vector2 move = TCKInput.GetAxis("Joystick");   // NEW func since ver 1.5.5

            PlayerMovement(move.x, move.y);
        }
示例#11
0
    void Update()
    {
        rb.velocity = new Vector2(TCKInput.GetAxis("Joystick", EAxisType.Horizontal) * Speed, rb.velocity.y);;

        if (TCKInput.GetAction("jumpBtn", EActionEvent.Down))
        {
            rb.AddForce(Vector2.up * Jumpforce, ForceMode2D.Impulse);
        }
    }
示例#12
0
        public void Run()
        {
            Vector2 move = TCKInput.GetAxis("Joystick");               // NEW func since ver 1.5.5

            //if (new Vector2(x, y).sqrMagnitude > 0.01f)
            //{
            for (int i = 0; i < _playerFilter.EntitiesCount; i++)
            {
                _playerFilter.Components1[i].Force.X = move.x;
                _playerFilter.Components1[i].Force.Y = move.y;
            }
            //}
        }
示例#13
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (!this.killed)
        {
            //Attack
            if (TCKInput.GetButtonDown("Button0") && Time.time > nextFire)
            {
                attack = true;
            }

            // Store the input axes.
    #if UNITY_EDITOR
            // h = Input.GetAxisRaw("Horizontal");
            // v = Input.GetAxisRaw("Vertical");
    #endif
    #if UNITY_ANDROID
            h = TCKInput.GetAxis("Joystick0", AxisType.X);
            v = TCKInput.GetAxis("Joystick0", AxisType.Y);
    #endif

            // Move the player around the scene.
            Move(h, v);

            // Turn the player to face the mouse cursor.
            Turning(h, v);

            if (attack)
            {
                Shoot();
                attack = false;
            }
        }
        else
        {
            // Player is dead, play dead sound once...
            if (!cried)
            {
                audio.PlayOneShot(cry);
                cried = true;
            }
            // ... and make it smaller until is almost invisble and destroy it.
            GetComponent <Animator>().enabled = false;
            Vector3 scale    = transform.localScale;
            Vector3 newScale = new Vector3(scale.x * 0.95f, scale.y * 0.95f, scale.z * 0.95f);
            transform.localScale = newScale;
            if (newScale.x < 0.1f)
            {
                gameController.GameOver();
            }
        }
    }
示例#14
0
    private void MovimentarLados()
    {
        speedSide = GetComponent <Rigidbody>().velocity.x;

        float x = TCKInput.GetAxis("Joystick", EAxisType.Horizontal);

        if (x > 0)//dir
        {
            resetSideVelocity = true;
            GetComponent <Rigidbody>().AddForce(new Vector3(8000 * x * Time.deltaTime, 0, 0));
        }

        if (x < 0) //esq
        {
            resetSideVelocity = false;
            GetComponent <Rigidbody>().AddForce(new Vector3(8000 * x * Time.deltaTime, 0, 0));
        }

        /*if (Input.GetTouch(0).deltaPosition.x > 0)
         * {
         *  resetSideVelocity = true;
         *  GetComponent<Rigidbody>().AddForce(new Vector3(500, 0, 0));
         * } else
         * if (Input.GetTouch(0).deltaPosition.x < 0)
         * {
         *  resetSideVelocity = false;
         *  GetComponent<Rigidbody>().AddForce(new Vector3(-500, 0, 0));
         * }*/

        //limitar movimento laterais---------------------------------------------------------------------------
        if (resetSideVelocity == true && speedSide < 0)
        {
            GetComponent <Rigidbody>().velocity = new Vector3(0, GetComponent <Rigidbody>().velocity.y, GetComponent <Rigidbody>().velocity.z);
        }
        if (resetSideVelocity == false && speedSide > 0)
        {
            GetComponent <Rigidbody>().velocity = new Vector3(0, GetComponent <Rigidbody>().velocity.y, GetComponent <Rigidbody>().velocity.z);
        }

        if (speedSide >= limitaVelMax)
        { //30 max velocidade
            GetComponent <Rigidbody>().velocity = new Vector3(limitaVelMax, GetComponent <Rigidbody>().velocity.y, GetComponent <Rigidbody>().velocity.z);
        }

        if (speedSide <= limitaVelMin)
        {
            GetComponent <Rigidbody>().velocity = new Vector3(limitaVelMin, GetComponent <Rigidbody>().velocity.y, GetComponent <Rigidbody>().velocity.z);
        }
    }
 private void FixedUpdate()
 {
     if (hornetController.MobileControls)
     {
         Vector2 move = TCKInput.GetAxis("Joystick");
         if (cp.InverseReverse && move.y < 0)
         {
             hornetController.MotionControl(move.y * cp.FlySensitivity, -move.x * cp.TurnSensitivity);
         }
         else
         {
             hornetController.MotionControl(move.y * cp.FlySensitivity, move.x * cp.TurnSensitivity);
         }
     }
 }
示例#16
0
    // Update
    void Update()
    {
        float horizontal = TCKInput.GetAxis("steeringWheel", AxisType.X) + Input.GetAxis("Horizontal");
        float vertical   = TCKInput.GetAxis("moveJoystick", AxisType.Y) + Input.GetAxis("Vertical");

        if (vertical != 0f)
        {
            m_Transform.Rotate(0f, horizontal, 0f);
        }

        Vector3 moveVector = (m_Transform.forward * vertical) * 5f;

        moveVector *= Time.deltaTime;
        controller.Move(moveVector);
    }
示例#17
0
        public void Execute()
        {
            var direction = TCKInput.GetAxis("Joystick");
            var active    = direction != Vector2.zero;

            foreach (var entity in _group.GetEntities())
            {
                if (active)
                {
                    entity.direction.Value = direction.normalized;
                    entity.movement.Move   = true;
                    continue;
                }

                entity.movement.Move = false;
            }
        }
示例#18
0
    public void Update()
    {
        if (WorldController.Instance.gameMode == GameMode.PlayMode)
        {
            // Get joystick move and update Animator
            Vector2 move = TCKInput.GetAxis("Joystick");
            joyMoveDT = new Vector3(move.x, 0, move.y);
            playerAnim.SetFloat("speed", joyMoveDT.magnitude);

            // get canMove from player Animator
            bool canMove = playerAnim.GetBool("canMove");
            // Get button press
            pressedAttack = TCKInput.GetAction("AtkButton", EActionEvent.Down);

            if (pressedAttack)
            {
                ATKOn = true;
            }

            // Set ATK with interval time
            if (ATKOn              //&& canMove
                )
            {
                ATKtimecounter += Time.deltaTime;
                //Debug.Log(ATKtimecounter);
                if (ATKtimecounter < p.ATKAnimTime)
                {
                    if (normalAttack == false)
                    {
                        PlayerNormalAttack();
                    }
                }
                else if (ATKtimecounter >= p.ATKIntervalTime + p.ATKAnimTime)
                {
                    ATKtimecounter = 0;
                    ATKOn          = false;
                }
                else
                {
                    // Not Attack
                }
            }
            //camController.MoveCamOnPlayerMove(move);
        }
    }
示例#19
0
    public void Update()
    {
        if (WorldController.Instance.gameMode == GameMode.PlayMode)
        {
            // Get joystick move and update Animator
            Vector2 move = TCKInput.GetAxis("Joystick");
            joyMoveDT = new Vector3(move.x, 0, move.y);
            playerAnim.SetFloat("speed", joyMoveDT.magnitude);

            // get canMove from player Animator
            bool canMove = playerAnim.GetBool("canMove");
            // Get button press
            pressedAttack = TCKInput.GetAction("AtkButton", EActionEvent.Down);

            if (pressedAttack && canMove)
            {
                PlayerNormalAttack();
            }
            //camController.MoveCamOnPlayerMove(move);
        }
    }
示例#20
0
    void Update()
    {
        groundedPlayer = controller.isGrounded;
        if (groundedPlayer && playerVelocity.y < 0)
        {
            playerVelocity.y = 0f;
        }

        if (isControl)
        {
            if (Input.GetAxis("Horizontal") != 0 || TCKInput.GetAxis("Joystick", EAxisType.Horizontal) != 0 ||
                Input.GetAxis("Vertical") != 0 || TCKInput.GetAxis("Joystick", EAxisType.Vertical) != 0)
            {
                GetComponent <Controller_PC>().state = "Control";
            }

            if (GetComponent <Controller_PC>().state != "MoveToTarget")
            {
                //Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
                Vector3 move = new Vector3(TCKInput.GetAxis("Joystick", EAxisType.Horizontal) + Input.GetAxis("Horizontal"), 0, TCKInput.GetAxis("Joystick", EAxisType.Vertical) + Input.GetAxis("Vertical"));
                controller.Move(move * Time.deltaTime * playerSpeed);

                if (move != Vector3.zero)
                {
                    gameObject.transform.forward = move;
                }
            }
        }

        // Changes the height position of the player..
        //if (Input.GetButtonDown("Jump") && groundedPlayer)
        //{
        //    playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue);
        //}

        playerVelocity.y += gravityValue * Time.deltaTime;
        controller.Move(playerVelocity * Time.deltaTime);
    }
示例#21
0
    float checkMovementButtons()
    {
        float check1 = Input.GetAxis("Horizontal");
        float check2 = 0.0f;

        string currentController    = Game.GetComponent <AssignController>().controllerString;
        int    currentControllerNum = Game.GetComponent <AssignController>().controllerNum;

        if (currentControllerNum != 3)
        {
            check2 = TCKInput.GetAxis(currentController, EAxisType.Horizontal);
        }
        else
        {
            ControllerStickyScript cSticky = GameObject.Find("Controller-STICKY").GetComponent <ControllerStickyScript>();
            if (cSticky.left)
            {
                check2 = -1.0f;
            }
            if (cSticky.right)
            {
                check2 = +1.0f;
            }
        }

        if (check1 != 0.0f)
        {
            return(check1);
        }
        else if (check2 != 0.0f)
        {
            return(check2);
        }
        else
        {
            return(0.0f);
        }
    }
示例#22
0
    private void MovimentarVertical()
    {
        float y = TCKInput.GetAxis("Joystick", EAxisType.Vertical);

        GetComponent <Rigidbody>().AddForce(-transform.forward * y * speedBase * Time.deltaTime, ForceMode.Impulse);

        if (GetComponent <Rigidbody>().velocity.y >= limitaVelMaxUp)
        {
            GetComponent <Rigidbody>().velocity = new Vector3(GetComponent <Rigidbody>().velocity.x, limitaVelMaxUp, GetComponent <Rigidbody>().velocity.z);
        }
        if (GetComponent <Rigidbody>().velocity.z >= limitaVelMaxUp)
        {
            GetComponent <Rigidbody>().velocity = new Vector3(GetComponent <Rigidbody>().velocity.x, GetComponent <Rigidbody>().velocity.y, limitaVelMaxUp);
        }
        if (GetComponent <Rigidbody>().velocity.y <= limitaVelMinDown)
        {
            GetComponent <Rigidbody>().velocity = new Vector3(GetComponent <Rigidbody>().velocity.x, limitaVelMinDown, GetComponent <Rigidbody>().velocity.z);
        }
        if (GetComponent <Rigidbody>().velocity.z <= limitaVelMinDown)
        {
            GetComponent <Rigidbody>().velocity = new Vector3(GetComponent <Rigidbody>().velocity.x, GetComponent <Rigidbody>().velocity.y, limitaVelMinDown);
        }
    }
示例#23
0
    void Update()
    {
        if (!GetComponent <CarProfile>().isActive)
        {
            FMotor.motorSpeed = 0;
            RMotor.motorSpeed = 0;

            FWheel.motor = FMotor;
            RWheel.motor = RMotor;

            return;
        }

        FWheel.motor = FMotor;
        RWheel.motor = RMotor;

        float horizontal = TCKInput.GetAxis("Joystick", EAxisType.Horizontal);

        if (horizontal < 0 && rb.velocity.x < 0)
        {
            transform.localScale = new Vector3(-scale.x, transform.localScale.y, transform.localScale.z);
        }
        else
        if (horizontal > 0 && rb.velocity.x > 0)
        {
            transform.localScale = new Vector3(scale.x, transform.localScale.y, transform.localScale.z);
        }

        float radius = GetComponentInChildren <CircleCollider2D>().radius *transform.localScale.y *GetComponentsInChildren <Transform>()[1].localScale.y;



        Speed = 180 / (radius * 10) * Mathf.PI * maxSpeed / 3.6f * -horizontal;



        txt_speedometr.text = $"{Mathf.Abs(Mathf.RoundToInt(rb.velocity.x * 3.6f))}";


        FMotor.motorSpeed = Speed;
        RMotor.motorSpeed = Speed;

        RMotor.maxMotorTorque = maxTorque;
        FMotor.maxMotorTorque = maxTorque;


        List <int> layers = new List <int>
        {
            LayerMask.NameToLayer("Car"),
            LayerMask.NameToLayer("Ignore Character"),
        };

        if (TCKInput.GetAction("jumpBtn", EActionEvent.Down))
        {
            int lastLayer = -1;
            foreach (var layer in layers)
            {
                Physics2D.IgnoreLayerCollision(layer, layer, true);
                if (lastLayer != -1)
                {
                    Physics2D.IgnoreLayerCollision(layer, lastLayer, true);
                }
                lastLayer = layer;
            }
        }
        if (TCKInput.GetAction("jumpBtn", EActionEvent.Up))
        {
            int lastLayer = -1;
            foreach (var layer in layers)
            {
                Physics2D.IgnoreLayerCollision(layer, layer, false);
                if (lastLayer != -1)
                {
                    Physics2D.IgnoreLayerCollision(layer, lastLayer, false);
                }
                lastLayer = layer;
            }
        }
    }
示例#24
0
 // Update
 void Update()
 {
     tiltVector.x             = TCKTilt.forwardAxis + TCKInput.GetAxis("dPad", AxisType.X);
     tiltVector.z             = -TCKTilt.sidewaysAxis + TCKInput.GetAxis("dPad", AxisType.Y);
     cameraTransform.position = new Vector3(m_Transform.position.x, cameraTransform.position.y, m_Transform.position.z - 5f);
 }
示例#25
0
    // Update is called once per frame
    void Update()
    {
        // Debug.Log(this.gameObject.GetComponent<Rigidbody2D>().velocity);


        // Debug.Log(this.gameObject.GetComponent<Rigidbody2D>().velocity);



        move = TCKInput.GetAxis("Joystick");

        if (bulletObj.activeInHierarchy)
        {
            line.gameObject.SetActive(true);

            line.SetPositions(
                new Vector3[]
            {
                this.transform.position,
                bulletObj.transform.position
            }
                );
        }
        else
        {
            line.gameObject.SetActive(false);
        }


        if (isTrapped)
        {
            sj.connectedAnchor = bulletObj.transform.position;

            isTrapped = false;
        }



        if (!this.gameObject.GetComponent <SpringJoint2D>().enabled)
        {
            // line.gameObject.SetActive(false);
            if (!isTouch && this.gameObject.GetComponent <Rigidbody2D>().velocity.y < 0)
            {
                if (isSlowDrop)
                {
                    Debug.Log("缓慢下落");                    //SlowFall

                    this.gameObject.GetComponent <Rigidbody2D>().velocity /= 1.2f;

                    t += Time.deltaTime;
                    if (t > 3)
                    {
                        isSlowDrop = false;
                    }
                }
                else
                {
                    Debug.Log("下落");                    //Fall
                }
            }
        }
    }
示例#26
0
        // TouchKit Input
        private void TouchKitInput()
        {
            if (TCKInput.CheckController(actions.pause) && TCKInput.GetAction(actions.pause, TCKActionEvent.Down))
            {
                Pause();
            }

            runAction = (TCKInput.CheckController(actions.run) && TCKInput.GetAction(actions.run, TCKActionEvent.Press));

            if (TCKInput.CheckController(actions.jump) && TCKInput.GetAction(actions.jump, TCKActionEvent.Down))
            {
                FirstPersonController.Jump();
            }
            if (TCKInput.CheckController(actions.crouch) && TCKInput.GetAction(actions.crouch, TCKActionEvent.Down))
            {
                FirstPersonController.Crouch();
            }

            if (TCKInput.CheckController(actions.use) && TCKInput.GetAction(actions.use, TCKActionEvent.Down))
            {
                PlayerCamera.UseItem();
            }

            if (TCKInput.CheckController(actions.reloadWeapon) && TCKInput.GetAction(actions.reloadWeapon, TCKActionEvent.Down))
            {
                WeaponsManager.ReloadWeapon();
            }
            if (TCKInput.CheckController(actions.nextFiremode) && TCKInput.GetAction(actions.nextFiremode, TCKActionEvent.Down))
            {
                WeaponsManager.SwitchFiremode();
            }
            if (TCKInput.CheckController(actions.nextAmmotype) && TCKInput.GetAction(actions.nextAmmotype, TCKActionEvent.Down))
            {
                WeaponsManager.SwitchAmmotype();
            }
            if (TCKInput.CheckController(actions.toSubweapon) && TCKInput.GetAction(actions.toSubweapon, TCKActionEvent.Down))
            {
                WeaponsManager.SwitchToSubWeapon();
            }
            if (TCKInput.CheckController(actions.dropWeapon) && TCKInput.GetAction(actions.dropWeapon, TCKActionEvent.Down))
            {
                WeaponsManager.DropCurrentWeapon();
            }
            if (TCKInput.CheckController(actions.prevWeapon) && TCKInput.GetAction(actions.prevWeapon, TCKActionEvent.Down))
            {
                WeaponsManager.SelectPreviousWeapon();
            }
            if (TCKInput.CheckController(actions.nextWeapon) && TCKInput.GetAction(actions.nextWeapon, TCKActionEvent.Down))
            {
                WeaponsManager.SelectNextWeapon();
            }


            if (TCKInput.CheckController(axes.moveJoystick))
            {
                moveHorizontal = Mathf.Clamp(TCKInput.GetAxis(axes.moveJoystick, TCKAxisType.Horizontal), -1f, 1f);
                moveVertical   = runAction ? 1f : Mathf.Clamp(TCKInput.GetAxis(axes.moveJoystick, TCKAxisType.Vertical), -1f, 1f);
            }

            if (TCKInput.CheckController(axes.lookTouchpad))
            {
                lookHorizontal = TCKInput.GetAxis(axes.lookTouchpad, TCKAxisType.Horizontal) * GameSettings.GetLookSensitivityByInvert_X;
                lookVertical   = TCKInput.GetAxis(axes.lookTouchpad, TCKAxisType.Vertical) * GameSettings.GetLookSensitivityByInvert_Y;
            }

            if (TCKInput.CheckController(actions.zoom))
            {
                zoomAction     = TCKInput.GetAction(actions.zoom, TCKActionEvent.Press);
                zoomActionDown = TCKInput.GetAction(actions.zoom, TCKActionEvent.Down);
                zoomActionUp   = TCKInput.GetAction(actions.zoom, TCKActionEvent.Up);
            }

            if (TCKInput.CheckController(actions.fire))
            {
                bool fireAction = TCKInput.GetAction(actions.fire, TCKActionEvent.Press);
                // Fire and Reset Weapon
                if (fireAction && !FirstPersonController.isRunning)
                {
                    WeaponsManager.WeaponFire();
                }
                else
                {
                    WeaponsManager.WeaponReset();
                }
            }
        }
示例#27
0
    // Update is called once per frame
    void Update()
    {
        this.transform.rotation = Quaternion.identity;


        //UI显示用(当前可射出分身数量)
        text.GetComponent <Text>().text = count.ToString();

        this.gameObject.transform.localScale = new Vector2(count / 5, count / 5);

        if (TCKInput.GetTouchPhase("Joystick") == ETouchPhase.Stationary || TCKInput.GetTouchPhase("Joystick") == ETouchPhase.Moved)
        {
            if (Energy.GetComponent <Energy>().time > 0)
            {
                Energy.GetComponent <Energy>().time -= Time.deltaTime;

                //子弹时间开启
                Time.timeScale = 0.3f;
            }

            if (pressTime >= 0)
            {
                pressTime -= Time.deltaTime;
            }

            if (Energy.GetComponent <Energy>().time <= 0)
            {
                //子弹时间关闭
                Time.timeScale = 1.0f;
            }

            if (pressTime <= 0)
            {
                joystick.GetComponent <TCKJoystick>().touchDown  = false;
                joystick.GetComponent <TCKJoystick>().touchPhase = ETouchPhase.NoTouch;

                isOverTime    = true;
                isTouchUp     = true;
                isCancelShoot = false;
            }

            //获取移动方向
            move = TCKInput.GetAxis("Joystick");

            if (Mathf.Abs(move.x) <= 0.3f && Mathf.Abs(move.y) <= 0.3f)
            {
                //取消发射判定
                isCancelShoot = true;
            }
            else
            {
                isCancelShoot = false;
            }
        }
        else
        {
            Time.timeScale = 1.0f;

            if (Energy.GetComponent <Energy>().time <= 3)
            {
                Energy.GetComponent <Energy>().time += 0.05f * Time.deltaTime;
            }
        }

        //移动(生成分身)
        if (isTouchUp && count > 1 && !isCancelShoot)
        {
            // Debug.Log("Shoot");
            // rigid.velocity += move;

            Shoot(move);

            //如果已经有移动线程 先关闭
            if (coroutine != null)
            {
                StopCoroutine(coroutine);
                coroutine = null;
            }

            //移动线程
            coroutine = StartCoroutine(Move(move.normalized * 2));
        }

        // //重置开火状态
        isTouchUp = false;
    }