Esempio n. 1
0
    IEnumerator item_pickup()
    {
        if (settings.already_interacting)
        {
            yield break;
        }
        settings.already_interacting = true;

        player_controller.bool_cutscene     = true;
        player_controller.bool_player_moves = false;
        player_controller.float_movexaxis   = 0f;
        player_controller.float_moveyaxis   = 0f;


        yield return(new WaitForSeconds(1f));

        //Add item to inventory

        if (Inventory.item_add(item))
        {
            Destroy(gameObject);
        }
        else
        {
            StartCoroutine(say_inventory_full());
        }
        player_controller.bool_cutscene = false;

        settings.already_interacting = false;
    }
Esempio n. 2
0
//Functions that contains exact crafting
    bool craft_id1_id1001(int slot2)
    {
        Inventory.item_remove(Inventory.items [slot2]);

        if (Inventory.items.Count < Inventory.inventory_space)
        {
            Inventory.item_add(Resources.Load <Item>("Inventory/Items/Timber"));
        }
        else
        {
            drop_item(Resources.Load <Item>("Inventory/Items/Timber"));
        }


        string said_text   = "I've managed to create Timber stick.";
        float  wanted_time = 3f;

        StartCoroutine(crafting_response(said_text, wanted_time, 2f));

        return(true);
    }
Esempio n. 3
0
    IEnumerator interact()
    {
        if (settings.already_interacting)
        {
            yield break;
        }
        settings.already_interacting = true;

        playercontroller.bool_cutscene = true;

        playercontroller.bool_player_moves = false;
        playercontroller.float_movexaxis   = 0f;
        playercontroller.float_moveyaxis   = 0f;

        string say_this;
        string say_this_cze;
        float  want_time;
        float  current_time;



        say_this     = "I need a branch from this tree.";
        say_this_cze = "Potřebuji větev z tohoto stromu.";
        want_time    = 2f;

        StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

        want_time   += 0.1f;
        current_time = 0f;

        while (current_time < want_time)
        {
            current_time += Time.deltaTime;

            if (settings.GetComponent <Settings>().cutscene_skip)
            {
                break;
            }

            yield return(null);
        }
        yield return(null);


        Inventory_ui.interactive_open = true;
        if (!settings.inventory_opened)
        {
            Inventory_ui.open_close_inventory();
        }

        yield return(new WaitForSeconds(0.01f));

        int got_id = -1;

        if (Inventory_ui.interactive_open)
        {
            switch (Inventory_ui.selected_slot)
            {
            case 10:
                if (Inventory.melee_weapon != null)
                {
                    got_id = wanted_id;
                }
                break;

            case 11:
                got_id = -1;
                break;

            default:
                if (Inventory.items.Count > Inventory_ui.selected_slot)
                {
                    got_id = Inventory.items [Inventory_ui.selected_slot].ID;
                }
                break;
            }
        }
        if (got_id == wanted_id)
        {
            yield return(new WaitForSeconds(2f));

            if (Inventory.item_add(item))
            {
                say_this     = "I sucessfuly cut a branch.";
                say_this_cze = "Úspěšně jsem usekl větev.";
                want_time    = 2f;

                StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

                current_time = 0f;

                while (current_time < want_time)
                {
                    current_time += Time.deltaTime;

                    if (settings.GetComponent <Settings>().cutscene_skip)
                    {
                        break;
                    }

                    yield return(null);
                }
                yield return(null);
            }
            else
            {
                GameObject dropped_object = new GameObject(item.name);
                GameObject player         = playercontroller.gameObject;         //GameObject.Find ("player");
                dropped_object.transform.position = new Vector3(player.transform.position.x, player.transform.position.y - 0.3f, player.transform.position.z);
                dropped_object.transform.SetParent(GameObject.Find("Pickables").transform);

                SpriteRenderer dropped_object_renderer = dropped_object.AddComponent <SpriteRenderer> ();
                dropped_object_renderer.sprite           = item.icon;
                dropped_object_renderer.sortingLayerName = "Pickable";

                BoxCollider2D dropped_object_collider = dropped_object.AddComponent <BoxCollider2D> ();
                dropped_object_collider.isTrigger = true;
                dropped_object_collider.size      = new Vector2(0.5f, 0.5f);
                dropped_object_collider.offset    = new Vector2(0f, 0f);

                item_picker dropped_object_trigger = dropped_object.AddComponent <item_picker> ();
                dropped_object_trigger.item = item;

                say_this     = "I sucessfuly cut a branch, but I can't carry it now.";
                say_this_cze = "Úspěšně jsem usekl větev, ale teď ji fakt už neunesu.";
                want_time    = 3f;

                StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

                current_time = 0f;

                while (current_time < want_time)
                {
                    current_time += Time.deltaTime;

                    if (settings.GetComponent <Settings>().cutscene_skip)
                    {
                        break;
                    }

                    yield return(null);
                }
                yield return(null);
            }



            game_manager.pine01_t_interactiondone = true;
            GameObject.Find("cutscene_object").GetComponent <cutscene01> ().cutscene3_prepare();
        }
        else
        {
            yield return(new WaitForSeconds(0.5f));

            say_this     = "I need something else to cut that branch.";
            say_this_cze = "Na useknutí větve budu potřebovat něco jiného.";
            want_time    = 2.5f;

            StartCoroutine(dialog.say_something(dialog.player_name, say_this, say_this_cze, want_time, dialog.player_portrait[player_head.GetInteger("emotion")], player_head));

            current_time = 0f;

            while (current_time < want_time)
            {
                current_time += Time.deltaTime;

                if (settings.GetComponent <Settings>().cutscene_skip)
                {
                    break;
                }

                yield return(null);
            }
            yield return(null);
        }

        yield return(null);


        playercontroller.bool_cutscene = false;

        settings.already_interacting = false;
    }