コード例 #1
0
 void InputUpdate()
 {
     if (SimpleInput.GetButtonUp("pause") | Input.GetKeyDown(KeyCode.Return))
     {
         Time.timeScale = 0;
         PausePanel.SetActive(true);
         Pause_Score.text = GameController.singltone.Score.ToString();
         B_Pause.gameObject.SetActive(false);
     }
     if (SimpleInput.GetButtonUp("return") | Input.GetKeyDown(KeyCode.Return))
     {
         Time.timeScale = 1;
         PausePanel.SetActive(false);
         B_Pause.gameObject.SetActive(true);
     }
     if (SimpleInput.GetButtonUp("restart"))
     {
         GameController.singltone.NewGame();
         Time.timeScale = 1;
         PausePanel.SetActive(false);
         GameOverPanel.SetActive(false);
         WinGamePanel.SetActive(false);
         B_Pause.gameObject.SetActive(true);
         timer = 0;
     }
 }
コード例 #2
0
    private void InputDetection()
    {
        var horizontal = SimpleInput.GetAxis("Horizontal");

        if (horizontal < 0f)
        {
            state.HideShield();
            state.MoveLeft();
        }
        else if (horizontal > 0f)
        {
            state.HideShield();
            state.MoveRight();
        }
        else if (horizontal == 0f)
        {
            state.GetIdle();
        }

        var vertical = SimpleInput.GetAxis("Vertical");

        if (SimpleInput.GetButton("Jump") || vertical > 0f)
        {
            state.MoveUp();
        }
        else if (vertical < 0f)
        {
            state.MoveDown();
        }

        if (SimpleInput.GetButton("Fire1"))
        {
            state.HideShield();
            state.UseWeapon();
        }
        else
        {
            if (SimpleInput.GetButtonDown("Fire2"))
            {
                state.UseShield();
            }
            else if (SimpleInput.GetButtonUp("Fire2"))
            {
                state.HideShield();
            }
        }

        if (SimpleInput.GetButton("Jump"))
        {
            GameManager.S.PauseUnpause();
        }

        if (Application.platform == RuntimePlatform.Android)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                GameManager.S.PauseUnpause();
            }
        }
    }
コード例 #3
0
    private void PcControlls()
    {
        if (SimpleInput.GetButtonDown("Jump"))
        {
            OnPressJump();
        }
        else if (SimpleInput.GetButtonUp("Jump"))
        {
            OnReleaseJump();
        }

        if (SimpleInput.GetButtonDown("Dash") && dashEnabled)
        {
            OnPressDash();
        }
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        horizontalMove = SimpleInput.GetAxisRaw("Horizontal") * runSpeed;

        if (SimpleInput.GetButtonDown("Jump"))
        {
            jump = true;
        }

        if (SimpleInput.GetButtonDown("Crouch"))
        {
            crouch = true;
        }
        else if (SimpleInput.GetButtonUp("Crouch"))
        {
            crouch = false;
        }
    }
コード例 #5
0
 private void FixedUpdate()
 {
     pointsScreen.SetActive(!StaticClass.disableInput && SimpleInput.GetButton("Points Screen"));
     if (StaticClass.disableInput)
     {
         Move(0, false, false);
     }
     else
     {
         vertical = SimpleInput.GetAxis("Vertical");
         Move(SimpleInput.GetAxis("Horizontal"), SimpleInput.GetButton("Jump"), SimpleInput.GetButton("Run"));
         if (SimpleInput.GetButtonUp("Fire2"))
         {
             Drop();
             GetComponent <AudioSource>().PlayOneShot(openSound);
         }
     }
 }
コード例 #6
0
ファイル: Player.cs プロジェクト: onethree-13/PaLace
    void Update()
    {
        if (enableControl)
        {
            horizontalMove = SimpleInput.GetAxisRaw("Horizontal") * runSpeed;

            if (SimpleInput.GetButtonDown("Crouch"))
            {
                crouch = true;
            }
            else if (SimpleInput.GetButtonUp("Crouch"))
            {
                crouch = false;
            }

            if (SimpleInput.GetButtonDown("Jump") && isGrounded && jump == false)
            {
                // The player starts to jump from any ground
                jump = true;
            }
            else if (SimpleInput.GetButtonUp("Jump") && !isGrounded && jumpCancel == false)
            {
                // The player starts to cancel jumping in the air
                jumpCancel = true;
            }

            // Player begins to attack
            if (SimpleInput.GetButtonDown("Fire1") && !attack)
            {
                StartCoroutine(AttackCoroutine());
            }
        }

        // Update animation
        m_Animator.SetFloat("Speed", Mathf.Abs(horizontalMove));
        m_Animator.SetBool("IsGrounded", isGrounded);
        m_Animator.SetBool("Sneaking", crouch);

        // Play SFX
        if (jump)
        {
            m_PlayerSFXource.PlayOneShot(jumpSFXClip);
        }
    }
コード例 #7
0
    /// <summary>
    /// Find user input. Should put this in its own class but im lazy
    /// </summary>
    private void MyInput()
    {
        x         = SimpleInput.GetAxisRaw("Horizontal");
        y         = SimpleInput.GetAxisRaw("Vertical");
        jumping   = SimpleInput.GetButton("Jump");
        crouching = SimpleInput.GetButton("Crouch");
        if (SimpleInput.GetKeyDown(KeyCode.Q))
        {
            DamagePlayer();
        }

        //Crouching
        if (SimpleInput.GetButtonDown("Crouch"))
        {
            StartCrouch();
        }
        if (SimpleInput.GetButtonUp("Crouch"))
        {
            StopCrouch();
        }
    }
コード例 #8
0
    protected override void ComputeVelocity()
    {
        Vector2 move = Vector2.zero;

        //move.x = CrossPlatformInputManager.GetAxis("Horizontal");
        move.x = SimpleInput.GetAxis("Horizontal");

        if (move.x > 0)
        {
            walkingDirection = true;
            animator.SetBool("bWalkingRight", true);
        }
        else if (move.x < 0)
        {
            walkingDirection = false;
            animator.SetBool("bWalkingRight", false);
        }
        else if (move.x == 0)
        {
            animator.SetBool("bWalkingRight", walkingDirection);
        }

        if (SimpleInput.GetButtonDown("Jump") && grounded)
        {
            velocity.y = jumpTakeOffSpeed;
        }
        else if (SimpleInput.GetButtonUp("Jump"))
        {
            if (velocity.y > 0)
            {
                velocity.y = velocity.y * 0.5f;
            }
        }

        targetVelocity = move * maxSpeed;

        PlayerStats.Instance.bWalkingDirection = walkingDirection;
    }
コード例 #9
0
ファイル: TankShooting.cs プロジェクト: Yaugan/Tanks
        public void Update()
        {
            // 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(m_CurrentLaunchForce, 1);
            }
            // Otherwise, if the fire button has just started being pressed...
            else if (SimpleInput.GetButtonDown(m_FireButton))
            {
                // ... 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 ();
            }
            // Otherwise, if the fire button is being held and the shell hasn't been launched yet...
            else if (SimpleInput.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 (SimpleInput.GetButtonUp(m_FireButton) && !m_Fired)
            {
                // ... launch the shell.
                Fire(m_CurrentLaunchForce, 1);
            }
        }
コード例 #10
0
 // Update is called once per frame
 void Update()
 {
     time += Time.deltaTime;
     if (SimpleInput.GetButton("Fire"))
     {
         if (Time.time - lastfired > 1 / Firerate && Bullets > 0)
         {
             lastfired = Time.time;
             shoot     = true;
             Instantiate(Bullet, new Vector3(Gunpoint.transform.position.x, Gunpoint.transform.position.y, 0), Quaternion.identity);
             Muzzle.Play();
             Bullets--;
             manager.Shoot(2);
         }
     }
     if (SimpleInput.GetButton("Rocket"))
     {
         if (time > Missilerate && Missiles > 0)
         {
             shoot = true;
             Instantiate(Missile, Gunpoint.transform.position, Quaternion.identity);
             time = 0f;
             Missiles--;
             manager.Shoot(1);
         }
     }
     if (SimpleInput.GetButtonUp("Fire"))
     {
         shoot = false;
         Muzzle.Stop();
     }
     if (SimpleInput.GetButtonUp("Rocket"))
     {
         shoot = false;
     }
     animator.SetBool("Shoot", shoot);
 }
コード例 #11
0
 public bool IsAttackButtonUp() =>
 SimpleInput.GetButtonUp(Button);
コード例 #12
0
    void Update()
    {
        //if (!GameStates.gameActive) return;
        // Get device type
        if (SystemInfo.deviceType == DeviceType.Desktop)
        {
            // Input for keyboard (mostly for testing purposes)
            float horizontal = Input.GetAxisRaw("Horizontal");

            if (Input.GetMouseButton(0))
            {
                ps.Aim();
                //if (OnStateChange != null) OnStateChange(PlayerStates.firingWeapon);
            }
            else if (Input.GetMouseButtonUp(0))
            {
                ps.StopAim();
            }

            if ((Input.GetKeyDown(KeyCode.Space)) || (Input.GetMouseButtonDown(1)))
            {
                if (OnStateChange != null)
                {
                    OnStateChange(PlayerStates.jump);
                }
            }
            if (horizontal != 0f)
            {
                if (horizontal < 0f)
                {
                    if (OnStateChange != null)
                    {
                        OnStateChange(PlayerStates.left);
                    }
                    facingRight = !facingRight;
                }
                else
                {
                    if (OnStateChange != null)
                    {
                        OnStateChange(PlayerStates.right);
                    }
                    facingRight = !facingRight;
                }
            }
            else
            {
                if (OnStateChange != null)
                {
                    OnStateChange(PlayerStates.idle);
                }
            }
        }
        else if (SystemInfo.deviceType == DeviceType.Handheld)
        {
            // Mobile input
            if (SimpleInput.GetButton("Attack"))
            {
                ps.Aim();
                //if (OnStateChange != null) OnStateChange(PlayerStates.firingWeapon);
            }
            else if (SimpleInput.GetButtonUp("Attack"))
            {
                ps.StopAim();
            }

            if (SimpleInput.GetButtonDown("Jump"))
            {
                if (OnStateChange != null)
                {
                    OnStateChange(PlayerStates.jump);
                }
            }

            if (SimpleInput.GetButton("Left"))
            {
                if (OnStateChange != null)
                {
                    OnStateChange(PlayerStates.left);
                }
            }
            else if (SimpleInput.GetButton("Right"))
            {
                if (OnStateChange != null)
                {
                    OnStateChange(PlayerStates.right);
                }
            }
            else
            {
                if (OnStateChange != null)
                {
                    OnStateChange(PlayerStates.idle);
                }
            }
        }
    }
コード例 #13
0
ファイル: InputController.cs プロジェクト: macadamc/Afterlife
 public void Evaluate(string buttonName)
 {
     pressed  = SimpleInput.GetButtonDown(buttonName);
     held     = SimpleInput.GetButton(buttonName);
     released = SimpleInput.GetButtonUp(buttonName);
 }