예제 #1
0
 void FixedUpdate()
 {
     //left right jump movement movement
     if (CnInputManager.GetAxis("Horizontal") > 0)
     {
         moveRight();
     }
     if (CnInputManager.GetAxis("Horizontal") < 0)
     {
         moveLeft();
     }
     if (CnInputManager.GetButtonDown("Jump"))
     {
         jump();
     }
     //stop
     if (playerRb.velocity.x == 0)
     {
         stopPlayer();
     }
     if (CnInputManager.GetButtonDown("Jump") && playerRb.velocity.x == 0)
     {
         sjump();
     }
 }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        Vel_Y = RB.velocity.y;

        Move = CnInputManager.GetAxis("Horizontal") * Time.deltaTime * Move_Speed;
        transform.position = transform.position + new Vector3(Move, 0, 0);

        if (Move > 0 || (CnInputManager.GetButtonDown("Horizontal")))
        {
            transform.localEulerAngles = new Vector3(0, 0, 0);
            AnimGato.SetBool("isWalking", true);
        }
        else if (Move < 0 || (CnInputManager.GetButtonDown("Horizontal")))
        {
            transform.localEulerAngles = new Vector3(0, 180, 0);
            AnimGato.SetBool("isWalking", true);
        }
        else if (!Input.anyKey)
        {
            AnimGato.SetBool("isWalking", false);
        }

        if ((Input.GetButton("Jump") || CnInputManager.GetButtonDown("Jump")) && Grounded == true && Space_Down == false)
        {
            audio.clip = Salto;
            audio.Play();
            AnimGato.SetBool("Jump", true);
            RB.AddForce(0, Jump, 0);
            Space_Down = true;
        }

        if (Input.GetKey(KeyCode.Space) != true)
        {
            Space_Down = false;
        }

        if (RB.velocity.y < 0)
        {
            AnimGato.SetBool("Jump", false);
            AnimGato.SetBool("Falling", true);
        }

        if (Grounded == true)
        {
            AnimGato.SetBool("Falling", false);
        }

        if (transform.position.y < -4.9f)
        {
            audio.clip = Muerte;
            audio.Play();
            transform.position = new Vector3(-0.28f, 2.3f, 5);
            Destroy(GameObject.FindGameObjectWithTag("Pajaro"));
            if (Vidas != 0)
            {
                GameObject.Find("Vida" + Vidas).SetActive(false);
                Vidas--;
            }
        }
    }
예제 #3
0
// UPDATE
    void Update()
    {
        timeLeft         -= Time.deltaTime;
        timeText.text     = timeLeft.ToString("F1");
        timeTextBack.text = timeLeft.ToString("F1");

        // Gameover at 0:00
        if (timeLeft <= 0.0)
        {
            gameObject.SetActive(false);
            GameOver();
        }
        countText.text     = count + "";     //display score
        countTextBack.text = count + "";     //display score

        if (CnInputManager.GetButtonDown("Jump"))
        {
            PlaySound(2);
            rb2d.AddForce(Vector2.up * jumpHeight);
        }

        if (CnInputManager.GetButtonDown("Mute"))
        {
            MuteButton();
        }
    }
예제 #4
0
    // Update is called once per frame
    void Update()
    {
        if (grounded && (Input.GetKeyDown(KeyCode.C) || CnInputManager.GetButtonDown("Jump")))
        {
            textForDebug.text = "touchCount" + Input.touchCount;
            anim.SetBool("Ground", false);
            rigidBody2D.AddForce(Vector2.up * jumpForce, ForceMode2D.Force);
            //rigidBody2D.velocity = new Vector2(rigidBody2D.velocity.x, rigidBody2D.velocity.y - jumpForce);
        }

        if (Input.GetKeyDown(KeyCode.R) || CnInputManager.GetButtonDown("ChangeWeapon"))
        {
            anim.SetTrigger("ChangeWeapon");

            int curWeaponState = anim.GetInteger("WeaponState");

            if (curWeaponState == 0)
            {
                anim.SetInteger("WeaponState", 1);
                curWeaponState = 1;
            }
            else if (curWeaponState == 1)
            {
                anim.SetInteger("WeaponState", 0);
                curWeaponState = 0;
            }
        }
        //if (Input.GetKeyDown(KeyCode.T))
        //{
        //
        //    anim.SetTrigger("ChangeWeapon");
        //    anim.SetInteger("WeaponState", 0);
        //}
    }
예제 #5
0
 // Update is called once per frame
 void Update()
 {
     if (CnInputManager.GetButtonDown("ReturnToMenu"))
     {
         SceneManager.LoadScene("mainMenu");
     }
 }
예제 #6
0
 // Update is called once per frame
 void Update()
 {
     if (!isLocalPlayer || skill.isCooldown())
     {
         return;
     }
     if (CnInputManager.GetButtonDown(simpleButtonName))
     {
         skill.ButtonDown();
     }
     if (CnInputManager.GetButtonUp(simpleButtonName) && !cancelSkill)
     {
         skill.ButtonUp();
     }
     if (CnInputManager.GetButtonUp(simpleButtonName) && cancelSkill)
     {
         skill.ButtonCancel();
     }
     if (!isPressButton && CnInputManager.GetButton(simpleButtonName))
     {
         skill.ButtonDirection(CnInputManager.GetAxis(verticalButtonName), CnInputManager.GetAxis(horizontalButtonName));
     }
     if (CnInputManager.GetButtonDown("CancelSkill"))
     {
         cancelSkill = true;
     }
     if (CnInputManager.GetButtonUp("CancelSkill"))
     {
         cancelSkill = false;
     }
 }
예제 #7
0
    void JumpInput()
    {
        if (CnInputManager.GetButtonDown("JumpBtn") && isGrounded)
        {
            isJumping       = true;
            jumpTimeCounter = jumpTime;
            rb.velocity     = new Vector2(rb.velocity.x, jumpForce);
        }

        if (CnInputManager.GetButton("JumpBtn") && isJumping)
        {
            if (jumpTimeCounter > 0)
            {
                rb.velocity      = Vector2.up * jumpForce;
                jumpTimeCounter -= Time.deltaTime;
            }
            else
            {
                isJumping = false;
            }
        }

        if (CnInputManager.GetButtonUp("JumpBtn"))
        {
            isJumping = false;
        }
    }
    void FixedUpdate()
    {
        State = DarthState.stoping;


        CheckGround();

        if (Convert.ToBoolean(CnInputManager.GetAxis("Horizontal")))
        {
            Run();
        }
        if (isGrounded && CnInputManager.GetButtonDown("Jump"))
        {
            Jump();
        }
        if (CnInputManager.GetButtonDown("Attack"))
        {
            Shoot();
        }

        ////чтобы часто не стрелять
        //shotsTimeCounter -= Time.deltaTime;



        //фича высоко не прыгать
        if (gameObject.transform.position.y >= 5.500000F)
        {
            gameObject.transform.position = new Vector2(gameObject.transform.position.x, 5.500000F);
        }
    }
예제 #9
0
 private void Update()
 {
     if (CnInputManager.GetButtonDown("Jump") && IsGrounded())
     {
         _jumpNextFixedUpdate = true;
     }
 }
    // handle the buttons to select weapon
    private void handleWeaponSelect()
    {
        if (Input.GetButtonDown("Weapon1") ||
            CnInputManager.GetButtonDown("Weapon1"))
        {
            loadWeapon(weapons.Bolt);

            // For laser
            ((LaserWeapon)weapons.Laser).endFire();
        }

        else if (Input.GetButtonDown("Weapon2") ||
                 CnInputManager.GetButtonDown("Weapon2"))
        {
            loadWeapon(weapons.Sphere);

            // For laser
            ((LaserWeapon)weapons.Laser).endFire();
        }

        else if (Input.GetButtonDown("Weapon3") ||
                 CnInputManager.GetButtonDown("Weapon3"))
        {
            loadWeapon(weapons.Laser);
        }
    }
예제 #11
0
    protected virtual bool IsJumping(bool isGrounded)
    {
        if (localPlayer)
        {
            if (justJumped)
            {
                return(false);
            }

            bool pressedJump = CnInputManager.GetButtonDown("Jump Button") && !justJumped;

            bool isJumping = pressedJump && isGrounded;

            if (isJumping && !remoteJumping)
            {
                remoteJumping = true;
                SendPlayerDataToServer();
            }
            else if (!isJumping && remoteJumping)
            {
                remoteJumping = false;
                SendPlayerDataToServer();
            }
        }

        return(remoteJumping);
    }
예제 #12
0
        private void _ready(IEntity entity)
        {
            var isDashing = CnInputManager.GetButtonDown("Dash");

            if (isDashing)
            {
                var playerComponent = entity.GetComponent <PlayerComponent>();
                var viewComponent   = entity.GetComponent <ViewComponent>();
                var go              = viewComponent.View.gameObject;
                var rigidbody2D     = go.GetComponent <Rigidbody2D>();
                var directionVector = new Vector2(
                    CnInputManager.GetAxisRaw("DirectionHorizontal"),
                    CnInputManager.GetAxisRaw("DirectionVertical")
                    );
                var ghostEffect = go.GetComponent <GhostEffect>();

                directionVector = directionVector.sqrMagnitude > 0.001f
                    ? directionVector
                    : (Vector2)go.transform.up;
                _originalVelocity           = rigidbody2D.velocity;
                rigidbody2D.velocity        = directionVector.normalized * 3.5f;
                ghostEffect.ghostingEnabled = true;
                playerComponent.isDashing   = true;
                _dashState = DashState.Dashing;
            }
        }
예제 #13
0
 /// <summary>
 /// Update is called every frame, if the MonoBehaviour is enabled.
 /// </summary>
 void Update()
 {
     if (CnInputManager.GetButtonDown("Jump"))
     {
         star_scene();
     }
 }
예제 #14
0
    // Update is called once per frame
    void Update()
    {
        if (Time.realtimeSinceStartup > delayTime + .5f && delayed == false)
        {
            delayed = true;
        }

        if (Physics2D.Raycast(transform.position, Vector2.down, 1, playerLayer) && CnInputManager.GetButtonDown("Jump") && !signOpen && Player_Controller.player_controller.lastMove.y == 1 && Camera_Controller.paused == false && Player_Controller.player_controller.inDialogue == false)
        {
            canvas.SetActive(true);
            Player_Controller.player_controller.disableControls = true;
            Player_Controller.player_controller.inDialogue      = true;
            signOpen  = true;
            delayed   = false;
            delayTime = Time.realtimeSinceStartup;
        }
        if (CnInputManager.GetButtonDown("Jump") && signOpen == true && delayed)
        {
            signOpen = false;
            canvas.SetActive(false);
            Player_Controller.player_controller.disableControls = false;
            Player_Controller.player_controller.inDialogue      = false;
        }

        if (text.text != signText)
        {
            text.text = signText;
        }
    }
예제 #15
0
 public void Update()
 {
     if (CnInputManager.GetButtonDown("Fire"))
     {
         Shoot();
     }
 }
예제 #16
0
 void Update()
 {
     if (CnInputManager.GetButtonDown("Fire3"))
     {
         Instantiate(a, this.transform.position, this.transform.rotation);
     }
 }
예제 #17
0
        public override bool IsActionDown(string action)
        {
            foreach (var i in inputsMap)
            {
                if (i.action == action)
                {
          #if UP_USE_CN_INPUT_MANAGER
                    if (SystemInfo.deviceType == DeviceType.Handheld)
                    {
                        return(CnInputManager.GetButtonDown(i.handheld));
                    }
          #endif

          #if UP_USE_WII_INPUT_MANAGER
                    if (remote != null)
                    {
                        return(GetWiiButton(i.wii));
                    }
          #endif

                    return(Input.GetButtonDown(i.keyboard));
                }
            }

            Debug.LogWarning("Cannot find action: " + action);
            return(false);
        }
 void Jump()
 {
     if (CnInputManager.GetButtonDown("Jump"))
     {
         StartCoroutine("JumpStop");
     }
 }
예제 #19
0
    void FixedUpdate()
    {
        if (Input.GetKey(KeyCode.RightArrow))
        {
            direction = TankController.goDirection.right;
        }
        else if (Input.GetKey(KeyCode.LeftArrow))
        {
            direction = TankController.goDirection.left;
        }
        else if (Input.GetKey(KeyCode.UpArrow))
        {
            direction = TankController.goDirection.up;
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
            direction = TankController.goDirection.down;
        }
        else
        {
            direction = TankController.goDirection.stay;
        }

        MobileMove();

        if (Input.GetKeyDown(KeyCode.Space) || CnInputManager.GetButtonDown("Jump"))
        {
            controller.Shoot();
        }

        controller.direction = direction;
    }
예제 #20
0
 private void Update()
 {
     if (!Jump)
     {
         Jump = CnInputManager.GetButtonDown("Jump");
     }
 }
예제 #21
0
 // Update is called once per frame
 void Update()
 {
     if (CnInputManager.GetButtonDown("Pause"))
     {
         Time.timeScale = 1.0f;
         gameObject.SetActive(false);
     }
 }
예제 #22
0
 private void Update()
 {
     if (!m_Jump)
     {
         // Read the jump input in Update so button presses aren't missed.
         m_Jump = CnInputManager.GetButtonDown("Jump");
     }
 }
예제 #23
0
    //opens the level
    void OnTriggerStay2D(Collider2D col)
    {
        button.SetActive(true);

        if (CnInputManager.GetButtonDown("Fire1"))
        {
            SceneManager.LoadScene(levelName);
        }
    }
예제 #24
0
 protected virtual void Update()
 {
     button?.SetActive(currentTime <= 0f);
     currentTime -= Time.deltaTime;
     if (CnInputManager.GetButtonDown("Ultra") && currentTime <= 0f)
     {
         Ult();
     }
 }
예제 #25
0
 void Update()
 {
     if (CnInputManager.GetButtonDown("Restart"))
     {
         StartCoroutine(go());
         animt.SetTrigger("clicked");
         AudioSource.PlayClipAtPoint(clickSound, transform.position);
     }
 }
예제 #26
0
 private void Update()
 {
     // 왼쪽 키를 누르면
     //if (Input.GetKeyDown(KeyCode.LeftControl))
     if (CnInputManager.GetButtonDown("LaserFire"))
     {
         Shot(); // 발포
     }
 }
예제 #27
0
    private SpecialAbility GetAbility()
    {
        if (CnInputManager.GetButtonDown(ButtonName))
        {
            return(ChosenAbility);
        }

        return(SpecialAbility.Nothing);
    }
예제 #28
0
 // Update is called once per frame
 void Update()
 {
     if (CnInputManager.GetButtonDown("Cancel"))
     {
         //Application.Quit ();
         Time.timeScale = 0.0f;
         PausePanel.SetActive(true);
     }
 }
예제 #29
0
 private void Update()
 {
     if (isOnGround && CnInputManager.GetButtonDown("Jump"))
     {
         rigidBody.AddForce(new Vector2(0, jumpForce));
         playerAnim.SetBool("Ground", false);
         playerAudio.PlayOneShot(jumpAudioClip);
     }
 }
예제 #30
0
    void Move()
    {
        CorectROT();

        position = new Vector3(CnInputManager.GetAxis("Horizontal"), 0f, 0f);



        if (position.x > 0)
        {
            if (CnInputManager.GetButtonDown("Run"))
            {
                speed = run;
                Debug.Log(run);
            }
            else
            {
                // transform.rotation = Quaternion.Euler(0, 0, 0);


                speed = memor_speed;
                Debug.Log(memor_speed);
            }
            gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime);
            RandL = true;
            gameG.SetBool("RandL", RandL);
        }
        else if (position.x < 0)
        {
            if (CnInputManager.GetButtonDown("Run"))
            {
                speed = run;
                Debug.Log(run);
            }
            else
            {
                speed = memor_speed;
                Debug.Log(memor_speed);
            }
            gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime);
            RandL = false;
            gameG.SetBool("RandL", RandL);
        }
        else if (position.x == 0)
        {
            gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime);
        }

        if (CnInputManager.GetButtonUp("Jump") && isJump)
        {
            gameG.ResetTrigger("idle");
            gameG.SetTrigger("Jump");

            GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, Jump), ForceMode2D.Impulse);
        }
    }