예제 #1
0
        //Handle render and controls
        void Update()
        {
            //Controls
            PlatformerControls controls = PlatformerControls.Get(player_id);

            move_input = controls.GetMove();
            jump_press = controls.GetJumpDown();
            jump_hold  = controls.GetJumpHold();

            if (jump_press)
            {
                TryJump();
            }

            //Reset when fall
            if (transform.position.y < level_bottom - GetSize().y)
            {
                Teleport(GetLastGround());
            }

            //Items
            take_item_timer += Time.deltaTime;
            if (carry_item && controls.GetActionDown())
            {
                carry_item.UseItem();
            }

            //Anims
            animator.SetBool("Jump", IsJumping());
            animator.SetBool("InAir", !IsGrounded());
            animator.SetBool("Crouch", IsCrouching());
            animator.SetFloat("Speed", move.magnitude);
            animator.SetBool("Hold", GetHoldingItem() != null);

            if (Input.GetKeyDown(KeyCode.E))
            {
                if (this.name == "Character_red")
                {
                    animator.Play("red_action");
                }
                else if (this.name == "Character_blue")
                {
                    animator.Play("blue_action");
                }
                else if (this.name == "Character_green")
                {
                    animator.Play("green_action");
                }
            }
        }
예제 #2
0
        //Handle render and controls
        void Update()
        {
            move_input = Vector2.zero;
            jump_press = false;
            jump_hold  = false;

            //Controls
            if (!disable_controls)
            {
                PlatformerControls controls = PlatformerControls.Get(player_id);
                move_input = controls.GetMove();
                jump_press = controls.GetJumpDown();
                jump_hold  = controls.GetJumpHold();

                if (jump_press)
                {
                    TryJump();
                }

                //Items
                take_item_timer += Time.deltaTime;
                if (carry_item && controls.GetActionDown())
                {
                    carry_item.UseItem();
                }
            }

            //Reset when fall
            if (transform.position.y < level_bottom - GetSize().y)
            {
                Teleport(GetLastGround());
            }

            //Anims
            animator.SetBool("Jump", IsJumping());
            animator.SetBool("InAir", !IsGrounded());
            animator.SetBool("Crouch", IsCrouching());
            animator.SetFloat("Speed", move.magnitude);
            animator.SetBool("Hold", GetHoldingItem() != null);
        }
예제 #3
0
 public static PlatformerControls[] GetAll()
 {
     PlatformerControls[] list = new PlatformerControls[controls.Count];
     controls.Values.CopyTo(list, 0);
     return(list);
 }
예제 #4
0
        //Handle render and controls
        void Update()
        {
            move_input = Vector2.zero;
            jump_press = false;
            jump_hold  = false;

            //Controls
            if (!disable_controls)
            {
                PlatformerControls controls = PlatformerControls.Get(player_id);
                move_input = controls.GetMove();
                jump_press = controls.GetJumpDown();
                jump_hold  = controls.GetJumpHold();

                if (controls.GetPausePressed())
                {
                }

                if (controls.GetCaughtPressed())
                {
                    gameManager.ShowCaptureCinematic();
                    return;
                }

                if (controls.GetVictoryPressed())
                {
                    gameManager.ShowEndCinematic();
                    return;
                }

                if (controls.GetExitPressed())
                {
                    gameManager.ShowTitleScreen();
                    return;
                }

                if (jump_press)
                {
                    TryJump();
                }

                //Items
                take_item_timer += Time.deltaTime;
                if (carry_item && controls.GetActionDown())
                {
                    carry_item.UseItem();
                }
            }

            //Reset when fall
            if (transform.position.y < level_bottom - GetCollSize().y)
            {
                Teleport(GetLastGround());
            }

            //Anims
            animator.SetBool("Jump", IsJumping());
            animator.SetBool("InAir", !IsGrounded());
            animator.SetBool("Hide", IsHiding());
            animator.SetBool("Crouch", IsCrouching());
            animator.SetFloat("Speed", move.magnitude);
            animator.SetBool("Hold", GetHoldingItem() != null);
        }