Beispiel #1
0
 // public so open all can access it
 public void openCard()
 {
     // Set rotation animation
     animator.SetTrigger("Flip");
     // wait for rotation before turning front off
     StartCoroutine(Wait(15));         // 20 * 0.1 is 2 seconds
     // add item to the inventory
     IC.AddToInventory(CardItem.getID());
 }
 public void AddCurrentItemToInventory(bool Equip)
 {
     if (_gridItem != null)
     {
         Item item = _gridItem.GetItemReference();
         for (int i = 0; i < _gridItem.GetItemCount(); i++)
         {
             Inventory.AddToInventory(item, Equip, true);
         }
         ReleaseCurrentDraggedItem();
     }
 }
Beispiel #3
0
    private void OnItemPickedUpCallBack(PickupableObject obj)
    {
        Item item = obj.GetItemReference();

        if (item.PickupType == Item.PickUpType.Pickupable)
        {
            Debug.Log("Item PickedUp: " + obj.GetItemName());
            FloatingTexts.Instance.Show("Item PickedUp: " + obj.GetItemName(), FloatingTexts.Type.Info);
            InventoryContrtoller.AddToInventory(item, true);
        }
        else
        {
            InventoryContrtoller.ConsumeItem(item);
        }
        Destroy(obj.gameObject);
    }
    void MakeCards()
    {
        if (wait >= 5)
        {
            wait = 0;
        }
        else
        {
            return;
        }

        // Destroy old cards
        for (int i = 0; i < CardHolder.transform.childCount; i++)
        {
            Destroy(CardHolder.transform.GetChild(i).gameObject);
        }
        // Drop Chest
        GameObject ChestDropped = Instantiate(Chest, new Vector3(1, 7, 1), Quaternion.identity);

        Destroy(ChestDropped, 3f);
        // Check IC for how many to open
        int amount = IC.getHowManyToOpen();

        // Create the cards
        for (int i = 0; i < amount; i++)
        {
            GameObject newcard = Instantiate(Card, CardPlaces.transform.GetChild(i).transform.position, Quaternion.identity);
            // Roll RNG
            int id = RNGC.getRandom();

            // Set icon of card
            newcard.transform.GetChild(1).GetComponent <SpriteRenderer>().sprite = IDC.getSprite(id);
            IC.AddToInventory(id);

            newcard.transform.SetParent(CardHolder.transform);
        }

        // Increment IC
        IC.IncrementNumberOpened();
    }
Beispiel #5
0
    void CreateCards()
    {
        if (wait > 4)
        {
            wait = 0;
        }
        else
        {
            return;
        }

        // Delete old CardHolder cards
        for (int i = 0; i < CardHolder.transform.childCount; i++)
        {
            Destroy(CardHolder.transform.GetChild(i).gameObject);
        }

        // Create amount
        int OpenAmount = IC.getHowManyToOpen();

        for (int i = 0; i < OpenAmount; i++)
        {
            GameObject newcard = Instantiate(card, CardPlaces.transform.GetChild(i).position, Quaternion.identity);

            int id = PRC.getRandom();
            // Set the icon
            newcard.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite = IDC.getSprite(id);

            // Add to the inventory
            IC.AddToInventory(id);

            newcard.transform.SetParent(CardHolder.transform);
        }

        // Increment IC
        IC.IncrementNumberOpened();
    }
Beispiel #6
0
        private void Item_OnInteract(object sender, InteractEventArgs e)
        {
            switch (e.interactionType)
            {
            case InteractionType.DoNothing:
                break;

            case InteractionType.GoTo:
                /// Check if object has a requirement to intereact with
                if (e.inventoryItem != null)
                {
                    /// Check if the item selected by the player is equal to the requierement
                    if (e.inventoryItem.Length == 0 || e.inventoryItem[0] == normalInventory.UseItem)
                    {
                        //inventory.RemoveFromInventory(inventory.UseItem);
                        Transform room;
                        if (TryFindRoom(e.nextDoor, out room))
                        {
                            ChangeRoom(room);
                        }
                        else
                        {
                            Debug.LogError($"There's no room index as {e.nextDoor}, please check name or add it on GameController");
                            return;
                        }
                    }
                }
                /// Go to different Room if the object has no requirements
                else
                {
                    Transform room;

                    if (TryFindRoom(e.nextDoor, out room))
                    {
                        Debug.Log("CHANGE SCENE TO " + e.nextDoor);
                        ChangeRoom(room);
                    }
                    else
                    {
                        Debug.LogError($"There's no room index as {e.nextDoor}, please check name or add it on GameController");
                        return;
                    }
                }
                normalInventory.UseItem = null;
                break;

            case InteractionType.InventoryItem:

                ///HAZLO MEJOR PARA LA OTRA
                for (int i = 0; i < e.inventoryItem.Length; i++)
                {
                    switch (e.inventoryItem[i].type)
                    {
                    case InventoryType.Item:
                        if (normalInventory.AddToInventory(e.inventoryItem[i]))
                        {
                            InteractableObject interactable = (InteractableObject)sender;
                            //Debug.Log($"THE ITEM {e.inventoryItem} has been added to you inventory");
                            Destroy(interactable.gameObject);
                        }
                        break;

                    case InventoryType.ItemWithAudio:
                        if (normalInventory.AddToInventory(e.inventoryItem[i]))
                        {
                            InteractableObject interactable = (InteractableObject)sender;
                            SoundManager.Instance.VoiceController.Play(e.Audio);
                            //Debug.Log($"THE ITEM {e.inventoryItem} has been added to you inventory");
                            Destroy(interactable.gameObject);
                        }
                        break;

                    case InventoryType.Document:
                        if (documentInventory.AddToInventory(e.inventoryItem[i]))
                        {
                            InteractableObject interactable = (InteractableObject)sender;
                            //Debug.Log($"THE ITEM {e.inventoryItem} has been added to you inventory");
                            Destroy(interactable.gameObject);
                        }
                        break;

                    case InventoryType.DocumentWithAudio:
                        if (documentInventory.AddToInventory(e.inventoryItem[i]))
                        {
                            InteractableObject interactable = (InteractableObject)sender;
                            SoundManager.Instance.VoiceController.Play(e.Audio);
                            //Debug.Log($"THE ITEM {e.inventoryItem} has been added to you inventory");
                            Destroy(interactable.gameObject);
                        }
                        break;
                    }
                }

                break;

            case InteractionType.Puzzle:
                /// We have only 1 puzzle so, no checking values here.
                PaddlePuzleController puzzle = (PaddlePuzleController)sender;
                if (puzzle == null)
                {
                    return;
                }

                currentPuzzle = puzzle;
                // Check if the inventory contain the puzzle requirements
                // if so, delete requirements from puzzle and objects from inventory
                if (currentPuzzle.requirements != null && currentPuzzle.requirements.Length > 0)
                {
                    InventoryItemModel[] requirements = new InventoryItemModel[puzzle.requirements.Length];
                    for (int i = 0; i < puzzle.requirements.Length; i++)
                    {
                        requirements[i] = normalInventory.FindByItemName(puzzle.requirements[i].itemName);
                        if (requirements[i] == null)
                        {
                            DisplayText("No Cumples con los Requisitos");
                            return;
                        }
                    }

                    puzzle.requirements = null;
                    //for(int i = 0; i < requirements.Length; i++)
                    //{
                    //    inventory.RemoveFromInventory(requirements[i]);
                    //}
                    requirements = null;
                }

                /// Open the puzzle
                currentPuzzle.GetComponent <Collider2D>().enabled = false;
                currentPuzzle.OnPuzzleConfirm += Puzzle_OnPuzzleConfirm;
                currentPuzzle.OnPuzzleClose   += Puzzle_OnPuzzleClose;
                currentPuzzle.Display();
                break;

            case InteractionType.Victory:
                Victory();
                break;
            }
        }
Beispiel #7
0
    public void MakeCards()
    {
        for (int i = 0; i < IC.getHowManyToOpen(); i++)
        {
            // Random is for the different colour bottoms
            int choose = Random.Range(0, 3);
            int id;
            if (choose == 0)
            {
                GameObject CreatedCard = Instantiate(Card1, Positions.transform.GetChild(i).transform.position, Quaternion.identity);
                CreatedCard.transform.SetParent(CardHolder.transform);

                // Image
                SpriteRenderer renderer = CreatedCard.transform.GetChild(1).GetComponent <SpriteRenderer> ();
                // Name
                TextMesh name = CreatedCard.transform.GetChild(2).GetComponent <TextMesh> ();

                // Call rng controller for stuff
                id = RNGC.getRandom();
                Item item = IDC.getItem(id);

                // change icon
                renderer.sprite = IDC.getSprite(id);

                // change name
                name.text = item.getName();

                // add to the inventory
                IC.AddToInventory(id);
            }
            else if (choose == 1)
            {
                GameObject CreatedCard = Instantiate(Card2, Positions.transform.GetChild(i).transform.position, Quaternion.identity);
                CreatedCard.transform.SetParent(CardHolder.transform);

                // Image
                SpriteRenderer renderer = CreatedCard.transform.GetChild(1).GetComponent <SpriteRenderer> ();
                // Name
                TextMesh name = CreatedCard.transform.GetChild(2).GetComponent <TextMesh> ();

                // Call rng controller for stuff
                id = RNGC.getRandom();
                Item item = IDC.getItem(id);

                // change icon
                renderer.sprite = IDC.getSprite(id);

                // change name
                name.text = item.getName();

                // add to the inventory
                IC.AddToInventory(id);
            }
            else if (choose == 2)
            {
                GameObject CreatedCard = Instantiate(Card3, Positions.transform.GetChild(i).transform.position, Quaternion.identity);
                CreatedCard.transform.SetParent(CardHolder.transform);

                // Image
                SpriteRenderer renderer = CreatedCard.transform.GetChild(1).GetComponent <SpriteRenderer> ();
                // Name
                TextMesh name = CreatedCard.transform.GetChild(2).GetComponent <TextMesh> ();

                // Call rng controller for stuff
                id = RNGC.getRandom();
                Item item = IDC.getItem(id);

                // change icon
                renderer.sprite = IDC.getSprite(id);

                // change name
                name.text = item.getName();

                // add to the inventory
                IC.AddToInventory(id);
            }
        }

        // Increment IC
        IC.IncrementNumberOpened();
    }