Example #1
0
    // Update is called once per frame
    void Update()
    {
        transform.Translate(transform.forward * currentSpeed * Time.deltaTime);
        Quaternion tempRot = Quaternion.identity;
        float      t       = 0;

        if (CrossPlatformInputManager.GetButtonDown("Right"))
        {
            //var posi = transform.position;
            //posi.x = transform.position.x + turnRadius * Time.deltaTime;
            //transform.position = posi;

            //Quaternion target = Quaternion.Euler(0, turnRadius , 0);
            //transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * 2.0f);

            transform.Rotate(transform.up, bullStats.TurnRate * Time.deltaTime);
            RTap = true;
        }

        if (CrossPlatformInputManager.GetButtonUp("Right"))
        {
            RTap    = false;
            tempRot = transform.rotation;
            t       = 0;
        }
        if (RTap == true)
        {
            transform.Rotate(transform.up, +bullStats.TurnRate * Time.deltaTime);
        }



        if (CrossPlatformInputManager.GetButtonDown("Left"))
        {
            //    var posi = transform.position;
            //    posi.x = transform.position.x - turnRate * Time.deltaTime;
            //    transform.position = posi;

            //    Quaternion target = Quaternion.Euler(0, -turnRate, 0);
            //    transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * 2.0f);
            LTap = true;
        }

        if (CrossPlatformInputManager.GetButtonUp("Left"))
        {
            LTap = false;
        }

        if (LTap == true)
        {
            transform.Rotate(transform.up, -bullStats.TurnRate * Time.deltaTime);
        }

        if ((!RTap || !LTap) && !(!RTap && !LTap))
        {
            Quaternion.Lerp(tempRot, Quaternion.identity, t);
            t += Time.deltaTime;
        }
    }
 void Mobile_Input()
 {
     // Set Target.
     if (CrossPlatformInputManager.GetButtonDown("Target_Press"))
     {
         isTracking = true;
                         #if UNITY_EDITOR
         Cast_Ray_Sphere(Input.mousePosition, true);
                         #else
         Cast_Ray_Sphere(Input.touches [Input.touches.Length - 1].position, true);
                         #endif
     }
     else if (CrossPlatformInputManager.GetButtonDown("LockOff"))
     {
         isTracking      = false;
         targetTransform = null;
     }
     // Control GunCam and Aiming.
     if (CrossPlatformInputManager.GetButtonDown("GunCam_Press"))
     {
         isButtonDown = true;
                         #if UNITY_EDITOR
         previousMousePos = Input.mousePosition;
                         #else
         fingerID         = Input.touches.Length - 1;
         previousMousePos = Input.touches [fingerID].position;
                         #endif
         return;
     }
     if (isButtonDown && CrossPlatformInputManager.GetButton("GunCam_Press"))
     {
         if (gunCamFlag)
         {
                                 #if UNITY_EDITOR
             Vector3 currentMousePos = Input.mousePosition;
                                 #else
             Vector3 currentMousePos = Input.touches [fingerID].position;
                                 #endif
             adjustAng       += (currentMousePos - previousMousePos) * 0.02f;
             previousMousePos = currentMousePos;
         }
         else
         {
             if (Mathf.Abs(targetAng) < 5.0f)
             {
                 gunCamFlag = true;
                 gunCameraScript.GunCam_On();
             }
         }
         return;
     }
     if (CrossPlatformInputManager.GetButtonUp("GunCam_Press"))
     {
         gunCamFlag   = false;
         isButtonDown = false;
         adjustAng    = Vector3.zero;
         gunCameraScript.GunCam_Off();
     }
 }
Example #3
0
        public override TaskStatus OnUpdate()
        {
#if CROSSPLATFORMINPUT
            return(CrossPlatformInputManager.GetButtonUp(buttonName.Value) ? TaskStatus.Success : TaskStatus.Failure);
#else
            return(Input.GetButtonUp(buttonName.Value) ? TaskStatus.Success : TaskStatus.Failure);
#endif
        }
Example #4
0
 // Update is called once per frame
 void Update()
 {
     if (CrossPlatformInputManager.GetButtonUp("ChangeProjSet"))
     {
         activateCurrentChild();
         currentSetIndex = (currentSetIndex + 1) % transform.childCount;
     }
 }
Example #5
0
 private void onDrop()
 {
     if (CrossPlatformInputManager.GetButtonUp("Fire1") && isDragged)
     {
         HandleDropPosition();
         isDragged = false;
     }
 }
Example #6
0
 private void Gravity()
 {
     if (CrossPlatformInputManager.GetButtonUp("Vertical") || CrossPlatformInputManager.GetButtonUp("Jump"))
     {
         Vector2 jumpVelocityToSubtraction = new Vector2(0f, stoppingVelocity);
         rb.velocity -= jumpVelocityToSubtraction;
     }
 }
Example #7
0
        void Update()
        {
            // 首先判断游戏是否正在进行中
            if (GameManager.Instance.CurrentGameState != GameManager.GameState.Play)
            {
                return;
            }
            // 判断玩家是否存活
            if (currentMotionState == MotionState.Dead)
            {
                return;
            }

            if (currentMotionState == MotionState.Idling || currentMotionState == MotionState.Attacking)
            {
                if (CrossPlatformInputManager.GetButtonUp("L"))
                {
                    if (currentMotionState == MotionState.Idling)
                    {
                        currentMotionState = MotionState.Attacking;
                    }
                    else
                    {
                        currentMotionState = MotionState.Idling;
                        ResetMove();
                        ResetAimAngle();
                    }
                }
            }

            switch (currentMotionState)
            {
            case MotionState.Idling:
            case MotionState.Moving:
                MoveAndRotate();
                break;

            case MotionState.Interaction:
                Interaction();
                break;

            case MotionState.Attacking:
                Attack();
                break;

            case MotionState.UnderAttacking:
                UnderAttack();
                break;

            case MotionState.SpinKicking:
                SpinKick();
                break;

            case MotionState.Dying:
                Dead();
                break;
            }
        }
        public override void UpdateInput(float timeStep)
        {
            Horizontal = Input.GetAxisRaw("Horizontal");
            Horizontal = joystick.Horizontal;

            /**
             * if (joystick.Horizontal >= .2f)
             * {
             *  Horizontal = runSpeed;
             * }
             * else if (joystick.Horizontal <= -.2f)
             * {
             *  Horizontal = -runSpeed;
             * }
             * else {
             *  Horizontal = 0f;
             * }
             **/
            //Jump naman


            //Vertical = Input.GetAxisRaw("Vertical");
            //Vertical = joystick.Vertical;
            Jump = Input.GetButtonDown("Jump");

            //Jump = Input.("Vertical");
            //Convert pa Axis try

            float Vertical = Input.GetAxisRaw("Vertical");

            /**if (Vertical >= .5f) {
             *  anim.SetBool("SpeedY");
             * }**/

            //Jump Button and DashButton

            //Dash = Input.GetButtonDown("Fire3");

            /** if(Dash = )
             * {
             *   Get
             * }**/



            /**Dash = Input.GetButtonDown("Fire3");
            *
            *  HoldingDash = Input.GetButton("Fire3**/

            dashBtn();


            HoldingJump = CrossPlatformInputManager.GetButton("Jump");



            ReleaseJump = CrossPlatformInputManager.GetButtonUp("Jump");
        }
Example #9
0
        private void Update()
        {
            if (Time.timeScale == 1)
            {
                // Read button down inputs in Update so button presses aren't missed.
                if (!input.interactDown)
                {
                    input.interactDown = CrossPlatformInputManager.GetButtonDown("Player" + player.playerNumber + "Interact");
                }
                if (!input.fireDown)
                {
                    input.fireDown = CrossPlatformInputManager.GetButtonDown("Player" + player.playerNumber + "Fire");
                }
                if (!input.buildUpgradeDown)
                {
                    input.buildUpgradeDown = CrossPlatformInputManager.GetButtonDown("Player" + player.playerNumber + "Build/Upgrade");
                }
                if (!input.buildUpgradeUp)
                {
                    input.buildUpgradeUp = CrossPlatformInputManager.GetButtonUp("Player" + player.playerNumber + "Build/Upgrade");
                }
                if (!input.sellDown)
                {
                    input.sellDown = CrossPlatformInputManager.GetButtonDown("Player" + player.playerNumber + "Sell");
                }
                if (!input.sellUp)
                {
                    input.sellUp = CrossPlatformInputManager.GetButtonUp("Player" + player.playerNumber + "Sell");
                }
                if (!input.cancelDown)
                {
                    input.cancelDown = CrossPlatformInputManager.GetButtonDown("Player" + player.playerNumber + "Cancel");
                }


                if (CrossPlatformInputManager.GetAxis("Player" + player.playerNumber + "Vertical") > 0)
                {
                    input.lastDirection = Vector3.up;
                    input.upHold        = true;
                }
                if (CrossPlatformInputManager.GetAxis("Player" + player.playerNumber + "Vertical") < 0)
                {
                    input.lastDirection = Vector3.down;
                    input.downHold      = true;
                }
                if (CrossPlatformInputManager.GetAxis("Player" + player.playerNumber + "Horizontal") < 0)
                {
                    input.lastDirection = Vector3.left;
                    input.leftHold      = true;
                }
                if (CrossPlatformInputManager.GetAxis("Player" + player.playerNumber + "Horizontal") > 0)
                {
                    input.lastDirection = Vector3.right;
                    input.rightHold     = true;
                }
            }
        }
Example #10
0
    protected override void JumpingAndDucking()
    {
        if (enableJumping == true)
        {
            if (CrossPlatformInputManager.GetButtonDown("Duck"))
            {
                anim.SetBool("isDown", true);
                col.size   = new Vector2(col.size.x, 0.54f);
                col.offset = new Vector2(col.offset.x, col.offset.y - 0.25f);
                moveSpeed  = moveSpeed / 2;
            }

            if (CrossPlatformInputManager.GetButtonUp("Duck"))
            {
                anim.SetBool("isDown", false);
                col.offset = new Vector2(col.offset.x, col.offset.y + 0.25f);
                col.size   = new Vector2(col.size.x, 1);
                moveSpeed  = moveSpeed * 2;
            }

            //TESTING !!!!!!!!!!!!!
            //if (Input.GetKeyDown(KeyCode.Space) && controller.collisions.below)
            if (CrossPlatformInputManager.GetButtonDown("Jump") && controller.collisions.below)
            {
                //velocity.y = maxJumpVelocity;
                velocity.y = 20;
            }

            //if (Input.GetKeyUp(KeyCode.Space))
            if (CrossPlatformInputManager.GetButtonUp("Jump"))
            {
                if (velocity.y > minJumpVelocity)
                {
                    //velocity.y = minJumpVelocity;
                    velocity.y = 9;
                }
            }
        }


        if (jump > 0 && controller.collisions.below)
        {
            switch (jump)
            {
            case 1:
                velocity.y = minJumpVelocity;
                jump       = 0;

                break;

            case 2:
                velocity.y = maxJumpVelocity;
                jump       = 0;
                break;
            }
        }
    }
Example #11
0
    // Update is called once per frame
    void Update()
    {
        CheckInteract();

        if (CrossPlatformInputManager.GetButtonUp("Respawn"))
        {
            Respawn();
        }
    }
Example #12
0
 // Update is called once per frame
 void Update()
 {
     if (dialogueBox.activeInHierarchy &&
         CrossPlatformInputManager.GetButtonUp("Fire1") &&
         FindObjectOfType <GameManager>().GetDialogueActive())
     {
         ContinueDialogue();
     }
 }
Example #13
0
    void Update()
    {
        if (health <= 0)
        {
            GetComponent <Animator>().SetTrigger("die");
        }
        if (health < 0)
        {
            health = 0;
        }

        horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
        vertical   = CrossPlatformInputManager.GetAxis("Vertical");


        bool walking = Mathf.Abs(horizontal) > 0.4f;

        animator.SetBool("walking", walking && isTurn);
        animator.SetBool("aiming", !walking && isTurn && isDangerous && currentWeapon.arms != null);

        if (isTurn)
        {
            currentWeapon = gameManager.currentWeapon;
            // Handle Walking and Aiming.
            float tempAngle = angle;
            if (walking)
            {
                HandleWalking();
            }
            else if (Mathf.Abs(vertical) > joystickThreshold / 2f)
            {
                HandleAiming();
            }
            else
            {
                rbody.constraints = RigidbodyConstraints2D.FreezeRotation | RigidbodyConstraints2D.FreezePositionX;
            }

            // Handle Shooting.
            if (CrossPlatformInputManager.GetButton("Fire") && isDangerous)
            {
                power += Time.deltaTime;
            }

            if ((CrossPlatformInputManager.GetButtonUp("Fire") || power >= 1f) && isDangerous)
            {
                StartCoroutine(Shoot());
            }
        }
        else
        {
            if (!attacked)
            {
                rbody.constraints = RigidbodyConstraints2D.FreezeRotation | RigidbodyConstraints2D.FreezePositionX;
            }
        }
    }
 void Update()
 {
     //if the player hits the fire button, fire bullet
     //this button has the name "Jump" in the input manager
     if (CrossPlatformInputManager.GetButtonUp("Jump"))
     {
         Fire();
     }
 }
Example #15
0
 private void HandleUserSkillInput()
 {
     if (CrossPlatformInputManager.GetButtonUp("Fire2"))
     {
         if (Mathf.Approximately(playerState.GetChargeBarPercentage(), 1))
         {
             UseChargeAttack();
         }
     }
 }
Example #16
0
 void Update()
 {
     if (idScript.isPlayer)
     {
                         #if UNITY_ANDROID || UNITY_IPHONE
         if (CrossPlatformInputManager.GetButtonDown("Zoom_Press"))
         {
             isButtonDown = true;
                         #if UNITY_EDITOR
             previousMousePos = Input.mousePosition;
                         #else
             fingerID         = Input.touches.Length - 1;
             previousMousePos = Input.touches [fingerID].position;
                         #endif
             return;
         }
         if (isButtonDown && CrossPlatformInputManager.GetButton("Zoom_Press"))
         {
                         #if UNITY_EDITOR
             Vector3 currentMousePos = Input.mousePosition;
                         #else
             Vector3 currentMousePos = Input.touches [fingerID].position;
                         #endif
             float vertical = (currentMousePos.y - previousMousePos.y);
             targetPosX      += vertical * 0.1f;
             targetPosX       = Mathf.Clamp(targetPosX, 3.0f, 20.0f);
             previousMousePos = currentMousePos;
         }
         else if (CrossPlatformInputManager.GetButtonUp("Zoom_Press"))
         {
             isButtonDown = false;
         }
                         #else
         float axis = Input.GetAxis("Mouse ScrollWheel");
         if (axis != 0)
         {
                                 #if UNITY_WEBGL
             targetPosX -= axis * 10.0f;
                                 #else
             targetPosX -= axis * 30.0f;
                                 #endif
             targetPosX = Mathf.Clamp(targetPosX, 3.0f, 20.0f);
         }
                         #endif
         if (posX != targetPosX)
         {
             posX = Mathf.MoveTowards(posX, targetPosX, speed * Time.deltaTime);
             thisTransform.localPosition = new Vector3(posX, thisTransform.localPosition.y, thisTransform.localPosition.z);
         }
         else
         {
             Cast_Ray();
         }
     }
 }
Example #17
0
 private void Update()
 {
     if (!grabbing)
     {
         grabbing = CrossPlatformInputManager.GetButtonDown("Interact" + player);
     }
     else if (CrossPlatformInputManager.GetButtonUp("Interact" + player))
     {
         grabbing = false;
     }
 }
 private void Update()
 {
     m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
     m_Swap = CrossPlatformInputManager.GetButtonDown("Swap");
     m_A1   = CrossPlatformInputManager.GetButtonDown("Active1");
     m_A2   = CrossPlatformInputManager.GetButtonDown("Active2");
     m_M1   = CrossPlatformInputManager.GetButtonDown("Fire1");
     m_M1Up = CrossPlatformInputManager.GetButtonUp("Fire1");
     m_M2   = CrossPlatformInputManager.GetButtonDown("Fire2");
     m_M2Up = CrossPlatformInputManager.GetButtonUp("Fire2");
 }
Example #19
0
 void ProcessFiring()
 {
     if (CrossPlatformInputManager.GetButton("Fire"))
     {
         ActivateGuns(true);
     }
     else if (CrossPlatformInputManager.GetButtonUp("Fire"))
     {
         ActivateGuns(false);
     }
 }
    void cltshoot()
    {
        // The slider should have a default value of the minimum launch force.
        m_AimSlider.value = m_MinLaunchForce;

        // If the max force has been exceeded and the shell hasn't yet been launched...
        if (m_CurrentLaunchForce >= m_MaxLaunchForce && !m_Fired)
        {
            // ... use the max force and launch the shell.
            m_CurrentLaunchForce = m_MaxLaunchForce;

            Fire();
        }

        // Otherwise, if the fire button has just started being pressed...
        //else if (Input.GetButtonDown(m_FireButton))
        else if (CrossPlatformInputManager.GetButtonDown(m_FireButton))
        {
            if (Time.realtimeSinceStartup >= start + m_FireDelay)
            {
                // ... reset the fired flag and reset the launch force.
                m_Fired = false;
                m_CurrentLaunchForce = m_MinLaunchForce;

                // Change the clip to the charging clip and start it playing.
                m_ShootingAudio.clip = m_ChargingClip;
                m_ShootingAudio.Play();
                Debug.Log("fire");
            }
            else
            {
                Debug.Log("delay happened");
            }
        }

        // Otherwise, if the fire button is being held and the shell hasn't been launched yet...
        //else if (Input.GetButton(m_FireButton) && !m_Fired)
        else if (CrossPlatformInputManager.GetButton(m_FireButton) && !m_Fired)
        {
            // Increment the launch force and update the slider.
            m_CurrentLaunchForce += m_ChargeSpeed * Time.deltaTime;

            m_AimSlider.value = m_CurrentLaunchForce;
        }

        // Otherwise, if the fire button is released and the shell hasn't been launched yet...
        //else if (Input.GetButtonUp(m_FireButton) && !m_Fired)
        else if (CrossPlatformInputManager.GetButtonUp(m_FireButton) && !m_Fired)
        {
            start = Time.realtimeSinceStartup;
            // ... launch the shell.
            Fire();
        }
    }
 // Update is called once per frame
 protected override void Update()
 {
     if (CrossPlatformInputManager.GetButton(inputName))
     {
         abilityCastingState.SetState(true);
     }
     if (CrossPlatformInputManager.GetButtonUp(inputName))
     {
         abilityCastingState.SetState(false);
     }
 }
Example #22
0
        void Update()
        {
            if (holdingLantern == null)
            {
                if ((LanternIndicator.Focus != null) && (CrossPlatformInputManager.GetButtonUp("Fire1") == true))
                {
                    // Remove the lantern from the lantern indicator
                    Lantern lantern = LanternIndicator.Focus;
                    LanternIndicator.Focus = null;

                    // Remove the lantern physics
                    lantern.IsInInventory = true;

                    // Attach the lantern to the inventory
                    holdingLantern = lantern;

                    // Play the sound effect
                    pickUpSound.Play();
                }
            }
            else if (CrossPlatformInputManager.GetButtonUp("Fire1") == true)
            {
                // Figure out the location to drop the lantern
                Transform dropPosition = dropBottom;
                switch (player.Facing)
                {
                case PlayerCharacter.Direction.Up:
                    dropPosition = dropTop;
                    break;

                case PlayerCharacter.Direction.Left:
                    dropPosition = dropLeft;
                    break;

                case PlayerCharacter.Direction.Right:
                    dropPosition = dropRight;
                    break;
                }

                // Move the lantern to the drop position
                holdingLantern.transform.position = dropPosition.position;

                // Re-enable the lantern physics
                holdingLantern.IsInInventory = false;

                // Remove the lantern from the inventory
                holdingLantern = null;
            }
            else
            {
                // Have the lantern follow the player
                holdingLantern.transform.position = transform.position;
            }
        }
Example #23
0
 // Update is called once per frame
 void Update()
 {
     if (CrossPlatformInputManager.GetButtonDown("Replay"))
     {
         BroadcastMessage("OnSetRecording", false);
     }
     else if (CrossPlatformInputManager.GetButtonUp("Replay"))
     {
         BroadcastMessage("OnSetRecording", true);
     }
 }
Example #24
0
    // Update is called once per frame
    void Update()
    {
        Vector3 movement;

        bool jbd = CrossPlatformInputManager.GetButtonDown("Jump");

        bool jbu = CrossPlatformInputManager.GetButtonUp("Jump");


        if (jbd)
        {
            print("jbd");
            m_Speed *= 2;
        }
        if (jbu)
        {
            print("jbu");

            m_Speed /= 2;
        }
        float speed = m_Speed;

        if (!(jbd || jbu))
        {
            if (Input.GetAxis("Jump") > 0)
            {
                speed = m_Speed * 2;
            }
        }

        //		float h = Input.GetAxis ("Horizontal");

        float h = CrossPlatformInputManager.GetAxis("Horizontal");

        float v = CrossPlatformInputManager.GetAxis("Vertical");

        if (h == 0)
        {
            h = Input.GetAxis("Horizontal");
        }
        if (v == 0)
        {
            v = Input.GetAxis("Vertical");
        }
        movement = new Vector3(h, v, 0.0F);

        movement = Vector3.ClampMagnitude(movement, 1);


        //		FP.setMovement (movement);
        movement *= speed;

        fishSwim.setDrivingForce(movement);
    }
Example #25
0
 private void HandleInput()
 {
     if (CrossPlatformInputManager.GetButtonDown(Statics.FIRE_BUTTON))
     {
         EventManager.TouchBegin();
     }
     else if (CrossPlatformInputManager.GetButtonUp(Statics.FIRE_BUTTON))
     {
         EventManager.TouchEnd();
     }
 }
Example #26
0
 private void ProcessFire()
 {
     if (CrossPlatformInputManager.GetButtonDown(CommonAxis.Fire1.ToString()))
     {
         ActivateGuns();
     }
     else if (CrossPlatformInputManager.GetButtonUp(CommonAxis.Fire1.ToString()))
     {
         DeactivateGuns();
     }
 }
Example #27
0
    private void ProcessFiring()
    {
        if (CrossPlatformInputManager.GetButton("Fire"))
        {
            SetGunsActive(true);
        }

        if (CrossPlatformInputManager.GetButtonUp("Fire"))
        {
            SetGunsActive(false);
        }
    }
    void Update()
    {
        if (CrossPlatformInputManager.GetButtonDown(nombreAccion))
        {
            InvokeRepeating("Disparar", 0, repeatRate);
        }

        if (CrossPlatformInputManager.GetButtonUp(nombreAccion))
        {
            CancelInvoke("Disparar");
        }
    }
Example #29
0
    /*
     * When the player presses down the "Fire1" key, the coroutine NeverEndingFireLaser() is triggered.
     * Input.GetButtonDown("Fire1")
     * Input.GetButtonUp("Fire1")
     */

    private void HumanPlayerFireLaser()
    {
        if (CrossPlatformInputManager.GetButtonDown("Attack"))
        {
            field_coroutine_blueLaserFireCoroutine = StartCoroutine(NeverEndingFireLaser());
        }
        if (CrossPlatformInputManager.GetButtonUp("Attack"))
        {
            // StopAllCoroutines(); In case of other coroutines this is a bad idea.
            StopCoroutine(field_coroutine_blueLaserFireCoroutine);
        }
    }
Example #30
0
 protected override void Update()
 {
     base.Update();
     if (CrossPlatformInputManager.GetButtonDown("Fire1") | Input.GetKeyDown("z"))
     {
         Time.timeScale = slowRate;
     }
     if (CrossPlatformInputManager.GetButtonUp("Fire1") | Input.GetKeyUp("z"))
     {
         Time.timeScale = 1;
     }
 }