Exemple #1
0
    //Test Button Script
    public void TestItemSpawn()
    {
        spawnItemCounter++;
        AddGameLog("DEBUG: TestItemSpawn() " + spawnItemCounter.ToString());
        Vector2     playerPos = player.transform.position;
        GameObject  dpItem    = Instantiate(droppedItem, new Vector3(Mathf.Round(playerPos.x), Mathf.Round(playerPos.y), 0), Quaternion.identity);
        DroppedItem ditem     = dpItem.GetComponent <DroppedItem>();

        ditem.SetItem(new Item(Random.Range(1, 21), 1, 0));
    }
Exemple #2
0
    public static DroppedItem SpawnDroppedItemToWorld(Vector3 position, ItemData item, int amount)
    {
        Transform transform = Instantiate(GameAssets.Instance.droppedItemPf, position, Quaternion.identity);

        DroppedItem droppedItem = transform.GetComponent <DroppedItem>();

        droppedItem.SetItem(item);
        item.amount = amount;

        return(droppedItem);
    }
Exemple #3
0
    public void DropItem(game_item item, Vector2 pos)
    {
        foreach (DroppedItem item_d in DroppedItems)
        {
            if (!item_d.gameObject.activeSelf)
            {
                item_d.gameObject.SetActive(true);
                item_d.SetItem(item);
                item_d.transform.position = pos;
                return;
            }
        }

        Transform   child = Instantiate(item_dropped).transform;
        DroppedItem ditem = child.GetComponent <DroppedItem>();

        ditem.SetItem(item);

        child.SetParent(Items_t);
        child.localPosition = pos;
        child.localScale    = new Vector3(50, 50, 1);
    }