private void Update()
 {
     if (CrossPlatformInput.GetButtonDown("Jump"))
     {
         this.jump = true;
     }
 }
Example #2
0
    // Update is called once per frame
    void Update()
    {
#if CROSS_PLATFORM_INPUT
        if (CrossPlatformInput.GetButtonDown("Jump"))
        {
            playerJump();
        }
        float h = CrossPlatformInput.GetAxis("Horizontal");
#else
        if (Input.GetButtonDown("Jump"))
        {
            playerJump();
        }
        float h = Input.GetAxis("Horizontal");
#endif
        charged = Input.GetKey(KeyCode.LeftControl);
        if (Input.GetButtonDown("Fire1") && inventory.menuItems.Count != 0 && behaviour.currentItem != 0)
        {
            behaviour.useItem();
        }
        if (Input.GetAxis("Mouse ScrollWheel") != 0 && inventory.menuItems.Count != 0)
        {
            behaviour.switchItem((int)Mathf.Sign(Input.GetAxis("Mouse ScrollWheel")));
        }
        playerMove(h);
    }
Example #3
0
    void Update()
    {
        float realDeltaTime = Time.realtimeSinceStartup - lastRealTime;

        if (CrossPlatformInput.GetButtonDown("Speed"))
        {
            // toggle slow motion state
            slowMo = !slowMo;

            // update button texture
            guiTexture.texture = slowMo ? SlowSpeedTex : FullSpeedTex;

            targetTime = slowMo ? slowSpeed : fullSpeed;
        }


        if (Time.timeScale != targetTime)
        {
            // lerp towards target time
            Time.timeScale = Mathf.Lerp(Time.timeScale, targetTime, realDeltaTime * 2);
            if (alsoScalePhysicsTimestep)
            {
                Time.fixedDeltaTime = fixedTimeRatio * Time.timeScale;
            }

            // snap if close enough:
            if (Mathf.Abs(Time.timeScale - targetTime) < 0.01f)
            {
                Time.timeScale = targetTime;
            }
        }


        lastRealTime = Time.realtimeSinceStartup;
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            grab = true;
        }
        // Read the jump input in Update so button presses aren't missed.
                #if CROSS_PLATFORM_INPUT
        if (CrossPlatformInput.GetButtonDown("Jump"))
        {
            jump = true;
        }
                #else
        if (Input.GetButtonDown("Jump"))
        {
            jump = true;
        }
                #endif

        if (Input.GetKeyDown(KeyCode.RightShift))
        {
            punch = true;
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.RightArrow))
        {
            run++;
            Debug.Log(run);
        }
        if (Input.GetAxis("Horizontal") == 0)
        {
            run = 0;
        }
    }
    void Update()
    {
        // Read the jump input in Update so button presses aren't missed.

        if (CrossPlatformInput.GetButtonDown("Jump"))
        {
            if (character.pause)
            {
                character.pause = false;
            }
            else
            {
                jump = true;
            }
        }
        if (Input.touchCount > 0)
        {
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                if (character.pause)
                {
                    character.pause = false;
                }
                else
                {
                    jump = true;
                }
            }
        }
    }
 void Update()
 {
     // Read the jump input in Update so button presses aren't missed.
     if (CrossPlatformInput.GetButtonDown("Jump"))
     {
         jump = true;
     }
 }
Example #7
0
 void Update()
 {
     // if we have forced a reset ...
     if (CrossPlatformInput.GetButtonDown("ResetObject"))
     {
         //... reload the scene
         SceneManager.LoadScene(SceneManager.GetActiveScene().name);
     }
 }
Example #8
0
 void Update()
 {
     // if we have forced a reset ...
     if (CrossPlatformInput.GetButtonDown("ResetObject"))
     {
         //... reload the scene
         Application.LoadLevelAsync(Application.loadedLevelName);
     }
 }
    void Update()
    {
        // Read the jump input in Update so button presses aren't missed.
#if CROSS_PLATFORM_INPUT
        if (CrossPlatformInput.GetButtonDown("Jump"))
        {
            jump = true;
        }
#else
        if (Input.GetButtonDown("Jump"))
        {
            jump = true;
        }
#endif
        if (Input.GetButtonDown("E"))
        {
            int currentWeapon = player.playerStats.CurrentEquippedWeaponIndex;
            int weaponsSize   = player.playerStats.Weapons.Count;

            if (weaponsSize == 0)
            {
                return;
            }
            if (currentWeapon < weaponsSize - 1)
            {
                character.EquipWeapon(currentWeapon + 1);
            }
            else
            {
                character.EquipWeapon(0);
            }
        }
        if (Input.GetButtonDown("Q"))
        {
            int currentWeapon = player.playerStats.CurrentEquippedWeaponIndex;
            int weaponsSize   = player.playerStats.Weapons.Count;

            if (weaponsSize == 0)
            {
                return;
            }
            if (currentWeapon > 0)
            {
                character.EquipWeapon(currentWeapon - 1);
            }
            else
            {
                character.EquipWeapon(weaponsSize - 1);
            }
        }
        //if right mouse click
        if (Input.GetButtonDown("Fire2"))
        {
            ThrowGrenade();
        }
    }
Example #10
0
    // Update is called once per frame
    void Update()
    {
        //------------Player movement And Fire Button-------------//
                #if CROSS_PLATFORM_INPUT
        rotation     = -CrossPlatformInput.GetAxis("Horizontal");
        acceleration = Mathf.Lerp(CrossPlatformInput.GetAxis("Vertical") * accelerationForce, 0f, 0.8f);

        if (CrossPlatformInput.GetButtonDown("Jump"))
        {
            BulleteFire();
        }
                # else
Example #11
0
 void Update()
 {
     if (CrossPlatformInput.GetButtonDown(m_Button.buttonName) && !down)
     {
         guiTexture.texture = activeTexture;
         down = true;
     }
     if (CrossPlatformInput.GetButtonUp("NextCamera") && down)
     {
         guiTexture.texture = idleTexture;
         down = false;
     }
 }
Example #12
0
 private void Update()
 {
     if (CrossPlatformInput.GetButtonDown("NextCamera"))
     {
         int num = (this.currentActiveObject + 1 < this.objects.Length) ? (this.currentActiveObject + 1) : 0;
         for (int i = 0; i < this.objects.Length; i++)
         {
             this.objects[i].SetActive(i == num);
         }
         this.currentActiveObject  = num;
         this.camSwitchButton.text = this.objects[this.currentActiveObject].name;
     }
 }
Example #13
0
    void Update()
    {
        if (CrossPlatformInput.GetButtonDown("NextCamera"))
        {
            int nextactiveobject = currentActiveObject + 1 >= objects.Length ? 0 : currentActiveObject + 1;

            for (int i = 0; i < objects.Length; i++)
            {
                objects[i].SetActive(i == nextactiveobject);
            }

            currentActiveObject  = nextactiveobject;
            camSwitchButton.text = objects[currentActiveObject].name;
        }
    }
Example #14
0
 void UpdateGravityRotation()
 {
     if (((Time.time - timeHitRotateButton) > gapBetweenRotateCalls) && (rotateEverything.IsAnimated == false))
     {
         if (CrossPlatformInput.GetButtonDown("Rotate Clockwise") == true)
         {
             rotationDirection   = RotateDirection.Clockwise;
             timeHitRotateButton = Time.time;
         }
         else if (CrossPlatformInput.GetButtonDown("Rotate CounterClockwise") == true)
         {
             rotationDirection   = RotateDirection.CounterClockwise;
             timeHitRotateButton = Time.time;
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        // Read the jump input in Update so button presses aren't missed.

        if (CrossPlatformInput.GetButtonDown("Jump"))
        {
            jump = true;
            Debug.Log("Jump");
        }
        if (Input.touchCount > 0)
        {
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                jump = true;
                Debug.Log("Jump2");
            }
        }
    }
Example #16
0
    void Update()
    {
        if (CurrentMode == Mode.Playing)
        {
            // Read the jump input in Update so button presses aren't missed.
            if (CrossPlatformInput.GetButtonDown("Jump") == true)
            {
                jump = true;
            }

            // Read in gravity input
            if (enableGravityTilting == true)
            {
                UpdateGravityRotation();
            }

            // Check if we're picking up something
            UpdateItemPickup();

            // Check if we're pausing the game
            if (CrossPlatformInput.GetButtonDown("Pause") == true)
            {
                CurrentMode = Mode.Paused;
                PauseMenu.Show(AfterPauseMenuClosed);
            }
        }
        else if (CurrentMode == Mode.Respawn)
        {
            UpdateTeleportPosition(RespawnCheckPoint);
        }
        else if (CurrentMode == Mode.Teleport)
        {
            UpdateTeleportPosition(teleportPoint);
        }
        else if (CurrentMode == Mode.Teleport)
        {
            if (CrossPlatformInput.GetButtonDown("Pause") == true)
            {
                PauseMenu.Hide();
            }
        }
    }
Example #17
0
    void UpdateItemPickup()
    {
        if ((currentSlot != null) && (currentSlot.IsInteractable == true) && (CrossPlatformInput.GetButtonDown("Pickup") == true))
        {
            if ((currentSlot.HeldItem != null) && (carriedItem == null))
            {
                // Move the slot item to the player
                carriedItem          = currentSlot.HeldItem;
                currentSlot.HeldItem = null;

                // Animate carrying items
                carriedItem.AnimatePositioningItem(carryPosition, null, ItemPickup.AudioType.PickUp);
            }
            else if ((currentSlot.HeldItem == null) && (carriedItem != null))
            {
                // Moved the carried item to the slot
                currentSlot.HeldItem = carriedItem;
                carriedItem          = null;
            }
        }
    }
    void Update()
    {
        if (canMove)
        {
            return;
        }

        // Read the jump input in Update so button presses aren't missed.
        #if CROSS_PLATFORM_INPUT
        if (CrossPlatformInput.GetButtonDown("Jump"))
        {
            jump = true;
        }
        #else
        if (Input.GetButtonDown("Jump"))
        {
            jump = true;
        }
        Debug.Log("pressed spacejump");
#endif
    }
 void Update()
 {
     // Read the jump input in Update so button presses aren't missed.
             #if CROSS_PLATFORM_INPUT
     if (CrossPlatformInput.GetButtonDown("Jump"))
     {
         jump = true; anim.SetBool("jump", jump);
     }
             #else
     if (Input.GetButtonDown("Jump"))
     {
         jump = true;
     }
             #endif
     if (jump && grounded)
     {
         // Add a vertical force to the player.
         anim.SetBool("Ground", false);
         rigidbody2D.AddForce(new Vector2(0f, jumpForce));
         jump = false;
     }
 }
Example #20
0
    void Update()
    {
        demoCam.localPosition = Vector3.SmoothDamp(demoCam.localPosition, Vector3.forward * -selected.camOffset, ref camOffsetVelocity, 1);

        if (CrossPlatformInput.GetButtonDown("NextParticleSystem"))
        {
            selectedIndex++;
            if (selectedIndex == demoParticles.items.Length)
            {
                selectedIndex = 0;
            }
            Select(selectedIndex);
            return;
        }
        if (CrossPlatformInput.GetButtonDown("PreviousParticleSystem"))
        {
            selectedIndex--;
            if (selectedIndex == -1)
            {
                selectedIndex = demoParticles.items.Length - 1;
            }
            Select(selectedIndex);
            return;
        }

        if (selected.mode == Mode.Activate)
        {
            // this is for a particle system that just needs activating, and needs no interaction (eg, duststorm)
            return;
        }


        bool oneShotClick = (Input.GetMouseButtonDown(0) && selected.mode == Mode.Instantiate);
        bool repeat       = (Input.GetMouseButton(0) && selected.mode == Mode.Trail);

        if (oneShotClick || repeat)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                var rot = Quaternion.LookRotation(hit.normal);

                if (selected.align == AlignMode.Up)
                {
                    rot = Quaternion.identity;
                }

                var pos = hit.point + hit.normal * distFromSurface;

                if ((pos - lastPos).magnitude > selected.minDist)
                {
                    if (selected.mode != Mode.Trail || instance == null)
                    {
                        instance = (Transform)Instantiate(selected.transform, pos, rot);

                        if (particleMultiplier != null)
                        {
                            instance.GetComponent <ParticleSystemMultiplier>().multiplier = multiply;
                        }

                        currentParticleList.Add(instance);

                        if (selected.maxCount > 0 && currentParticleList.Count > selected.maxCount)
                        {
                            if (currentParticleList[0] != null)
                            {
                                Destroy(currentParticleList[0].gameObject);
                            }
                            currentParticleList.RemoveAt(0);
                        }
                    }
                    else
                    {
                        instance.position = pos;
                        instance.rotation = rot;
                    }

                    if (selected.mode == Mode.Trail)
                    {
                        var emission = instance.transform.GetComponent <ParticleSystem>().emission;
                        emission.enabled = false;
                        instance.transform.GetComponent <ParticleSystem>().Emit(1);
                    }

                    instance.parent = hit.transform;
                    lastPos         = pos;
                }
            }
        }
    }
    private void Update()
    {
        this.demoCam.localPosition = Vector3.SmoothDamp(this.demoCam.localPosition, Vector3.forward * (float)(-(float)ParticleSceneControls.selected.camOffset), ref this.camOffsetVelocity, 1f);
        if (CrossPlatformInput.GetButtonDown("NextParticleSystem"))
        {
            ParticleSceneControls.selectedIndex++;
            if (ParticleSceneControls.selectedIndex == this.demoParticles.items.Length)
            {
                ParticleSceneControls.selectedIndex = 0;
            }
            this.Select(ParticleSceneControls.selectedIndex);
            return;
        }
        if (CrossPlatformInput.GetButtonDown("PreviousParticleSystem"))
        {
            ParticleSceneControls.selectedIndex--;
            if (ParticleSceneControls.selectedIndex == -1)
            {
                ParticleSceneControls.selectedIndex = this.demoParticles.items.Length - 1;
            }
            this.Select(ParticleSceneControls.selectedIndex);
            return;
        }
        if (ParticleSceneControls.selected.mode == ParticleSceneControls.Mode.Activate)
        {
            return;
        }
        bool flag  = Input.GetMouseButtonDown(0) && ParticleSceneControls.selected.mode == ParticleSceneControls.Mode.Instantiate;
        bool flag2 = Input.GetMouseButton(0) && ParticleSceneControls.selected.mode == ParticleSceneControls.Mode.Trail;

        if (flag || flag2)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit raycastHit;
            if (Physics.Raycast(ray, out raycastHit))
            {
                Quaternion rotation = Quaternion.LookRotation(raycastHit.normal);
                if (ParticleSceneControls.selected.align == ParticleSceneControls.AlignMode.Up)
                {
                    rotation = Quaternion.identity;
                }
                Vector3 vector = raycastHit.point + raycastHit.normal * this.distFromSurface;
                if ((vector - this.lastPos).magnitude > ParticleSceneControls.selected.minDist)
                {
                    if (ParticleSceneControls.selected.mode != ParticleSceneControls.Mode.Trail || this.instance == null)
                    {
                        this.instance = (Transform)UnityEngine.Object.Instantiate(ParticleSceneControls.selected.transform, vector, rotation);
                        if (this.particleMultiplier != null)
                        {
                            this.instance.GetComponent <ParticleSystemMultiplier>().multiplier = this.multiply;
                        }
                        this.currentParticleList.Add(this.instance);
                        if (ParticleSceneControls.selected.maxCount > 0 && this.currentParticleList.Count > ParticleSceneControls.selected.maxCount)
                        {
                            if (this.currentParticleList[0] != null)
                            {
                                UnityEngine.Object.Destroy(this.currentParticleList[0].gameObject);
                            }
                            this.currentParticleList.RemoveAt(0);
                        }
                    }
                    else
                    {
                        this.instance.position = vector;
                        this.instance.rotation = rotation;
                    }
                    if (ParticleSceneControls.selected.mode == ParticleSceneControls.Mode.Trail)
                    {
                        this.instance.transform.GetComponent <ParticleSystem>().enableEmission = false;
                        this.instance.transform.GetComponent <ParticleSystem>().Emit(1);
                    }
                    this.instance.parent = raycastHit.transform;
                    this.lastPos         = vector;
                }
            }
        }
    }
Example #22
0
    void Update()
    {
        // Read the jump input in Update so button presses aren't missed.
#if CROSS_PLATFORM_INPUT
        if (CrossPlatformInput.GetButtonDown("Jump"))
        {
            jump = true;
        }
#else
//		touch = t1.senseTouch();
//		if(touch == "SwipeUp")
//			jump = true;
//		if (touch == "SwipeDown") c = true;
        if (Input.GetKey(KeyCode.X))
        {
            c = true;
        }
        if (Input.GetKey(KeyCode.Space))
        {
            jump = true;
        }

        /////////////////////////////////////////////////////////////////////////////////////////////

        /////////////////////////Touch Begin////////////////////////////////
        if (Input.touchCount == 1)
        {
            if (Input.GetTouch(0).position.x < Screen.width / 2)
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    v2previous = Input.GetTouch(0).position;
                }
                /////////////////////////Touch Stationary////////////////////////////////
                if (Input.GetTouch(0).phase == TouchPhase.Stationary)
                {
                    v2current   = Input.GetTouch(0).position;
                    fTouchDelta = v2current.magnitude - v2previous.magnitude;

                    if (Mathf.Abs(fTouchDelta) < minSwipeLenght)
                    {
                        if (Input.GetTouch(0).tapCount == 1)
                        {
                            jump = true;
                        }
                    }
                }
                /////////////////////////Touch End////////////////////////////////
                if (Input.GetTouch(0).phase == TouchPhase.Ended)
                {
                    jump = false;
                }
            }
            else
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    v2previous = Input.GetTouch(0).position;
                }
                /////////////////////////Touch Move////////////////////////////////
                if (Input.GetTouch(0).phase == TouchPhase.Moved)
                {
                    v2current   = Input.GetTouch(0).position;
                    fTouchDelta = v2current.magnitude - v2previous.magnitude;

                    if (Mathf.Abs(fTouchDelta) > minSwipeLenght)
                    {
                        if (fTouchDelta > 0)
                        {
                            // SwipeUp
                        }
                        else
                        {
                            c = true;
                        }
                    }
                }
            }
        }

        //////////////////////////////////////////////////////////////////////////////////////////////
#endif
    }
Example #23
0
    private void UpdateTouchActions()
    {
        if (Input.touchCount > 0)
        {
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                acc_dt_touch = 0;
                Vector3 screen_pos = new Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y, 0);
                Vector3 world_pos  = Camera.main.ScreenToWorldPoint(screen_pos);
                //world_pos.z = -10;
                RaycastHit hit;
                if (Physics.Raycast(world_pos, Camera.main.transform.forward, out hit, 20, TouchRaycaster_LayerMask))
                {
                    Debug.Log("collision raycast <tag: " + hit.collider.tag + ">< name: " + hit.collider.name + "> <layer: " + hit.collider.gameObject.layer + ">");
                    if (hit.collider.tag == "Frog")
                    {
                        hit.collider.GetComponent <Comp_IA_Frog>().SelfDestroy();
                        GameLogicManager.Instance.AddFrogs(1);
                    }
                }
                else
                {
                    jump();
                }
            }
            else if (Input.GetTouch(0).phase == TouchPhase.Moved)
            {
                if (acc_dt_touch < COMP_JUMP_CONSTANTS.HOLD_TIME_JUMP)
                {
                    addJumpVelocity();
                }
            }
            else if (Input.GetTouch(0).phase == TouchPhase.Stationary)
            {
                if (acc_dt_touch < COMP_JUMP_CONSTANTS.HOLD_TIME_JUMP)
                {
                    addJumpVelocity();
                }
            }
            else if (Input.GetTouch(0).phase == TouchPhase.Ended)
            {
            }
        }
        else
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector3    world_pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(world_pos, Camera.main.transform.forward, out hit, 20, TouchRaycaster_LayerMask))
                {
                    Debug.Log("collision raycast <tag: " + hit.collider.tag + ">< name: " + hit.collider.name + "> <layer: " + hit.collider.gameObject.layer + ">");
                    if (hit.collider.tag == "Frog")
                    {
                        hit.collider.GetComponent <Comp_IA_Frog>().SelfDestroy();
                        GameLogicManager.Instance.AddFrogs(1);
                    }
                }
            }
        }

        // Modificado para que nos devuelva botones compatibles con multiple touch screen en pantallas táctiles
        if (CrossPlatformInput.GetButtonDown("Jump"))
        {
            dash();
        }
    }