Exemple #1
0
    protected void DropItems()
    {
        if (drops != null)
        {
            for (int i = 0; i < drops.Length; i++)
            {
                if (Random.Range(0, drops [i].probabilityToDrop) == 0)
                {
                    for (int q = 0; q < Random.Range(drops[i].minToDrop, drops[i].maxToDrop + 1); q++)
                    {
                        if (drops[i].dropReference != null)
                        {
                            DropUtilities.InstantiateDroppedItem(new ResourceReferenceWithStack(drops[i].dropReference, 1), transform, 0);
                        }
                        else
                        {
                            Debug.Log("DropReference was null!!! (DropsItems)");
                        }
                    }
                }
            }
        }
        else
        {
            Debug.Log("Drops were null (DropsItems)");
        }

        if (experienceToDrop > 0)
        {
            for (int i = 0; i < experienceToDrop; i++)
            {
                GameObject expDropped = (GameObject)(Instantiate(expDrop.dropReference.playerHoldingPrefab, transform.position, Quaternion.identity));
                expDropped.AddComponent <DroppedItemProperties> ();
                expDropped.GetComponent <DroppedItemProperties> ().localResourceReference = new ResourceReferenceWithStack(expDrop.dropReference, 1);
                expDropped.GetComponent <DroppedItemProperties> ().Initialize();
            }
        }
        else
        {
            Debug.Log("Did not drop any experience, experience to drop was 0. (DropsItems)");
        }

        if (cashToDrop > 0)
        {
            for (int i = 0; i < cashToDrop; i++)
            {
                GameObject cashDropped = (GameObject)(Instantiate(coinDrop.dropReference.playerHoldingPrefab, transform.position, Quaternion.identity));
                cashDropped.AddComponent <DroppedItemProperties> ();
                cashDropped.GetComponent <DroppedItemProperties> ().localResourceReference = new ResourceReferenceWithStack(coinDrop.dropReference, 1);
                cashDropped.GetComponent <DroppedItemProperties> ().Initialize();
            }
        }
        else
        {
            Debug.Log("Did not drop any experience, experience to drop was 0. (DropsItems)");
        }
    }
Exemple #2
0
    //Used when a player has to drop an item.
    IEnumerator CheckForPlayerDropItem()
    {
        while (true)
        {
            //Right click + shift.
            if (Input.GetMouseButtonDown(1) && Input.GetKey(KeyCode.LeftShift) && hotbarSlots[currentlyActiveSlot].GetCurrentlyAssigned() != null)
            {
                //Instantiate the item.
                DropUtilities.InstantiateDroppedItem(hotbarSlots [currentlyActiveSlot].GetCurrentlyAssigned(), playerObject.transform, 15 * playerObject.GetComponent <PlayerAction> ().GetFacingDirection());

                //Used to remove the current item from the hotbar.
                ModifyStackOfSelectedItem(1);
            }

            yield return(null);
        }
    }