Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        //get the horizontal value of the controller stick (should be in -1, +1 range)
        float horizontal_axis = Input.GetAxis("Horizontal");

        //get the space key state
        bool space_state = Input.GetKey(KeyCode.Space);

        // get key state for punch
        bool punch_state = Input.GetKeyDown(KeyCode.Q);

        // get key state for item doener
        bool consume_doener_state = Input.GetKeyDown(KeyCode.Alpha1);

        // get key state for item doener
        bool consume_puntigamer_state = Input.GetKeyDown(KeyCode.Alpha2);

        // get key state for item doener
        bool consume_frankfurter_state = Input.GetKeyDown(KeyCode.Alpha3);

        // get grab key state
        bool grab_state = Input.GetKey(KeyCode.R);

        //set the move script input
        move_script.setMoveInput(horizontal_axis * (grab_state ? 0.5f : 1.0f));
        move_script.setJumpInput(space_state);

        // set the combat script input
        combat_script.setPunchState(punch_state);

        // set input for grab script
        grab_script.setGrabState(grab_state);

        // set inventory script input
        inventory_script.setConsumeDoener(consume_doener_state);
        inventory_script.setConsumePuntigamer(consume_puntigamer_state);
        inventory_script.setConsumeFrankfurter(consume_frankfurter_state);

        //reload scene or jump to menu on backspace
        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            //get current scene name
            string current_scene = SceneManager.GetActiveScene().name;

            //jump to menu if in train statiion or tutorial
            if (current_scene.Equals("TrainStation") || current_scene.Equals("Tutorial"))
            {
                //load menu scene
                SceneManager.LoadScene("Menu");
            }
            else
            {
                //reload current scene
                SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            }
        }
    }
Beispiel #2
0
    void disable()
    {
        // dead enemies fall down and just lie there for now
        Rigidbody2D rigidbody = gameObject.GetComponent <Rigidbody2D>();

        // unfreeze rotation so that character falls down
        if (rigidbody != null)
        {
            rigidbody.freezeRotation = false;
        }

        // disable movement
        move_script.animator.SetInteger("WalkState", 0);
        move_script.setMoveInput(0.0f);

        // disable combat
        combat_script.animator.SetInteger("PunchState", 0);
        combat_script.setPunchState(false);
    }