Exemple #1
0
    void Update()
    {
        //an addition by lachlan to skip levels as we please
        if (Input.GetKeyDown(KeyCode.P))
        {
            int p = Application.loadedLevel;
            Application.LoadLevel(p + 1);
        }
        if (Input.GetKeyDown(KeyCode.O))
        {
            int o = Application.loadedLevel;
            Application.LoadLevel(o - 1);
        }

        grappling_hook.update();
        if (grappling_hook.grapple_state == GrapplingHook.GrappleState.NONE)
        {
            update_scale();
            player_movement.update();
        }
        health.update();
        weapon_control.update();

        pos = transform.position;

        float   world_bounds = 4.0f;
        Vector3 top_left     = Camera.main.ScreenToWorldPoint(Vector3.zero);
        Vector3 bot_right    = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height));

        if (pos.x < top_left.x - world_bounds || pos.x > bot_right.x + world_bounds ||
            pos.y < top_left.y - world_bounds || pos.y > bot_right.y + world_bounds)
        {
            //Lachlan changed this to restart current level not the first level
            //ie it used to restart the game on death (you should probably call void destroy here)
            Application.LoadLevel(Application.loadedLevel);
        }
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            weapon_inventory.equip_weapon(weapon_inventory.weapons[0]);
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            weapon_inventory.equip_weapon(weapon_inventory.weapons[1]);
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            weapon_inventory.equip_weapon(weapon_inventory.weapons[2]);
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            weapon_inventory.equip_weapon(weapon_inventory.weapons[3]);
        }
        if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            weapon_inventory.equip_weapon(weapon_inventory.weapons[4]);
        }
        if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            weapon_inventory.equip_weapon(weapon_inventory.weapons[5]);
        }

        current_node = Map.grid.get_node(Map.grid.world_to_grid(pos));
    }