Пример #1
0
    public void DropLoot()
    {
        List <WorldItem> theDrop = lootTable.CreateDrop();

        if (theDrop != null && theDrop.Count > 0)
        {
            foreach (var item in theDrop)
            {
                GameObject itemBeingCreated = Instantiate(Resources.Load("BlankItem")) as GameObject;
                WorldItem  wI = itemBeingCreated.GetComponent <WorldItem>();

                wI.inventoryItem      = item.inventoryItem.Clone();
                wI.transform.position = new Vector3(UnityEngine.Random.Range(-.25f, .25f) + transform.position.x, .25f + transform.position.y, UnityEngine.Random.Range(-.25f, .25f) + transform.position.z);
                wI.transform.LookAt(transform);
                wI.transform.Rotate(0, 180, 0);
                wI.GetComponent <Rigidbody>().velocity = itemBeingCreated.transform.forward * UnityEngine.Random.Range(4f, 7f);
                wI.transform.rotation = UnityEngine.Random.rotation;
                wI.transform.SetParent(GameObject.Find("Items").transform);
                wI.gameObject.SetActive(true);
            }
        }
    }