Exemple #1
0
    // Update is called once per frame
    protected void Update()
    {
        if (receivedWantedItem && tc.renderQueue.Count == 0 && endLevel)
        {
            Move();
        }
        if (CheckDistance() && GetComponent <SpriteRenderer>().color.a > 0)
        {
            if (Input.GetKeyDown(KeyCode.Space) && !pc.isTalking && !pc.isChecking && tc.renderQueue.Count == 0)
            {
                isTalking = true;
                if (receivedWantedItem)
                {
                    tc.add(essentialReceiveText);
                }
                else
                {
                    Talk();     //we only want this to be called once now because it pushes all the dialogue at once
                    if (itemName != "" && !inv.contains(itemName))
                    {
                        tc.add(inv.ReceiveItem(this.name, itemName));
                        NPCItem = null;
                        if (!inv.itemdb.getItemByName(itemName).essential)
                        {
                            itemName = "";
                        }
                    }
                }
            }
        }

        //if they've said everything and the player has seen all their dialogue
        if (!talked &&
            currentConversation == conversations.Length - 1 &&
            tc.renderQueue.Count == 0 &&
            talkedOnce)
        {
            talked = true;
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (CheckDistance())
        {
            //you can't interact with invisible objects
            SpriteRenderer sprite  = GetComponent <SpriteRenderer>();
            bool           visible = sprite.color.a > 0;
            if (Input.GetKeyDown(KeyCode.Space) && pc.isTalking == false && pc.isChecking == false && visible)
            {
                tc.add(message);

                if (itemName != "")
                {
                    inv.ReceiveItem(this.name, itemName);
                    if (inv.itemdb.getItemByName(itemName).essential)
                    {
                        itemName = "";
                    }
                }
            }
        }
    }
Exemple #3
0
    //player presses I to toggle menu on & off
    void Update()
    {
        #region TOGGLE MENU WITH I
        if (Input.GetKeyDown(KeyCode.I))
        {
            if (!menuBox.activeSelf && !pc.frozen)
            {
                menuBox.SetActive(true);
                numItems = inv.itemList.Count;
                DisplayInventory();
                pc.isChecking = true;
            }
            else
            {
                menuBox.SetActive(false);
                pc.isChecking = false;
            }
        }
        #endregion

        if (menuBox.activeSelf)
        {
            currentItem = inv.itemList[currentItemNum].name;
            #region NAVIGATE MENU WITH ARROW KEYS
            //moving down through list or options
            //these if statements are to keep it within the bounds of the list
            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                if (currentItemNum < numItems - 1 && !selected)
                {
                    currentItemNum++;
                    DisplayInventory();
                }
                else if (currentOptionNum < options.Length - 1 && selected)
                {
                    currentOptionNum++;
                    DisplayOptions(currentItem);
                }
            }
            //moving up through list or options
            //again, same thing
            else if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                if (currentItemNum > 0 && !selected)
                {
                    currentItemNum--;
                    DisplayInventory();
                }
                else if (currentOptionNum > 0 && selected)
                {
                    currentOptionNum--;
                    DisplayOptions(currentItem);
                }
            }
            #endregion
            //selecting an item and displaying options
            if (Input.GetKeyDown(KeyCode.Space))
            {
                #region NAVIGATE OPTIONS
                currentItem = inv.itemList[currentItemNum].name;
                //making sure the box isn't already in "options" mode
                if (!selected)
                {
                    DisplayOptions(currentItem);
                }
                else
                {
                    //making sure only one message is in the queue at a time
                    if (textController.renderQueue.Count > 0)
                    {
                        textController.renderQueue.Dequeue();
                    }
                    if (currentOptionNum == 0)                     //the "use" option
                    {
                        textController.add(inv.UseItem(currentItem));
                    }
                    else if (currentOptionNum == 1)                     //the "give" option
                    {
                        textController.add(inv.GiveItem(currentItem));
                    }
                    else if (currentOptionNum == 2)                     //the "drop" option
                    {
                        textController.add(inv.TossItem(currentItem));
                    }
                    if (inv.itemList.Count != numItems)
                    {
                        ResetInventory();
                    }
                }
                #endregion
            }
            if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.Escape))
            //go back to the main inventory page
            {
                DisplayInventory();
            }
        }
    }
Exemple #4
0
 void giveHug()
 {
     tc.add("MOM gives you a Warm Hug.");
     inv.ReceiveItem("Warm Hug");
 }