コード例 #1
0
        //Handle render and controls
        void Update()
        {
            if (TheGame.IsGamePaused())
            {
                return;
            }

            hit_timer   += Time.deltaTime;
            state_timer += Time.deltaTime;
            //grounded_timer += Time.deltaTime;

            //Controls
            PlayerControls controls = PlayerControls.Get(player_id);

            if (state == PlayerCharacterState.Normal)
            {
                if (controls.GetJumpDown())
                {
                    Jump();
                }

                Ladder ladder = Ladder.GetOverlapLadder(gameObject);
                if (ladder && controls.GetMove().y > 0.1f && state_timer > 0.7f)
                {
                    Climb();
                }
            }

            if (state == PlayerCharacterState.Climb)
            {
                Ladder ladder = Ladder.GetOverlapLadder(gameObject);
                if (ladder == null)
                {
                    state       = PlayerCharacterState.Normal;
                    state_timer = 0f;
                }

                if (controls.GetJumpDown())
                {
                    Jump(true);
                }
            }

            //Reset when fall
            if (!IsDead() && transform.position.y < fall_pos_y - GetSize().y)
            {
                TakeDamage(fall_damage);
                if (reset_when_fall)
                {
                    Teleport(last_ground_pos);
                }
            }
        }
コード例 #2
0
        //Handle render and controls
        void Update()
        {
            if (is_dead)
            {
                return;
            }

            hit_timer      += Time.deltaTime;
            grounded_timer += Time.deltaTime;

            //Controls
            PlayerControls controls = PlayerControls.Get(player_id);

            move_input = !disable_controls?controls.GetMove() : Vector2.zero;

            jump_press = !disable_controls?controls.GetJumpDown() : false;

            jump_hold = !disable_controls?controls.GetJumpHold() : false;

            if (jump_press || move_input.y > 0.5f)
            {
                Jump();
            }

            //Reset when fall
            if (transform.position.y < fall_pos_y - GetSize().y)
            {
                TakeDamage(max_hp * fall_damage_percent);
                if (reset_when_fall)
                {
                    Teleport(last_ground_pos);
                }
            }
        }
コード例 #3
0
        //Handle render and controls
        void Update()
        {
            if (is_dead)
            {
                return;
            }

            hit_timer      += Time.deltaTime;
            grounded_timer += Time.deltaTime;

            //Controls
            PlayerControls controls = PlayerControls.Get(player_id);

            move_input = !disable_controls?controls.GetMove() : Vector2.zero;

            jump_press = !disable_controls?controls.GetJumpDown() : false;

            jump_hold = !disable_controls?controls.GetJumpHold() : false;

            if (jump_press || move_input.y > 0.5f)
            {
                Jump();
            }

            //Reset when fall
            if (transform.position.y < fall_pos_y - GetSize().y)
            {
                TakeDamage(max_hp * fall_damage_percent);
                if (reset_when_fall)
                {
                    Teleport(last_ground_pos);
                }
            }

            if (grayness < 1 && (
                    (rigid.position.x >= 20 && rigid.position.x <= 24 && rigid.position.y > -1 && rigid.position.y < 0) ||
                    (rigid.position.x >= 39 && rigid.position.x <= 41 && rigid.position.y > 7 && rigid.position.y < 8) ||
                    (rigid.position.x >= 54 && rigid.position.x <= 56 && rigid.position.y > 22 && rigid.position.y < 23) ||
                    (rigid.position.x >= 80 && rigid.position.y > -3 && rigid.position.y < -2)
                    ))
            {
                grayness += 0.01f;
            }
            else if (grayness > 0)
            {
                grayness -= 0.001f;
            }

            character.GetComponent <SpriteRenderer>().color = new Color(grayness, grayness, grayness, 1);
        }