Exemplo n.º 1
0
    protected void AddItemComponentToNewlyConvertedItem(List <ItemData> items)
    {
        GameObject itemComponentInitialierObj = GameObject.Find("ItemComponents");

        if (itemComponentInitialierObj != null)
        {
            ItemComponentInitalizer.InitializeItemWithComponents(items, AddComponetTo.container);
        }
    }
Exemplo n.º 2
0
    public void DropItemIntoWorld(ItemData item, Vector3 dropPosition, GameObject dropModelDefault)
    {
        if (item != null)
        {
            List <ItemData> items = new List <ItemData>();
            items.Add(item);
            List <GameObject> dropItems = ItemConverter.ConvertToItemDropObject(items, true);

            if (dropParentObject == null)
            {
                dropParentObject = new GameObject("DroppedItems");
            }

            foreach (GameObject dropItem in dropItems)
            {
                item.AssetBundle(
                    (UnityEngine.Object bundleObj) =>
                {
                    GameObject dropObject;

                    if (bundleObj != null)
                    {
                        dropObject = GameObjectInitilizer.initilizer.InitilizeGameObject(bundleObj);
                    }
                    else
                    {
                        dropObject = GameObjectInitilizer.initilizer.InitilizeGameObject(dropModelDefault);
                    }

                    ItemData itemData = dropObject.AddComponent <ItemData>();

                    itemData.SetItemData(item);

                    ItemComponentInitalizer.InitializeItemWithComponents(dropObject.GetComponent <ItemData>(), AddComponetTo.prefab);

                    dropObject.transform.position = dropPosition;
                    dropObject.transform.parent   = dropParentObject.transform;

                    if (postDropObjectAction != null)
                    {
                        postDropObjectAction.DoGameObjectAction(dropObject);
                    }
                }
                    );

                Destroy(dropItem);
            }
        }
    }
Exemplo n.º 3
0
    public override List <ItemData> ConvertItems(ItemDataList generatedItems, int GenerationID)
    {
        List <ItemData> convertedItems = new List <ItemData>();

        for (int i = 0, imax = generatedItems.Count; i < imax; i++)
        {
            SocialPlay.Data.ItemData item = generatedItems[i];
            //GameObject go = new GameObject();
            ItemData itemData = new ItemData(); //go.AddComponent<ItemData>();
            //go.name = item.Name;
            itemData.baseEnergy = item.BaseItemEnergy;

            //TODO fix behaviour conversion
            //itemData.behaviours = item.Behaviours;

            itemData.description        = item.Description;
            itemData.itemName           = item.Name;
            itemData.imageName          = item.Image;
            itemData.classID            = item.Type;
            itemData.quality            = item.Quality;
            itemData.salePrice          = item.SellPrice;
            itemData.ItemID             = item.ItemID;
            itemData.CollectionID       = int.Parse(item.BaseItemID.ToString());
            itemData.stackSize          = item.Amount;
            itemData.totalEnergy        = item.Energy;
            itemData.stackID            = item.StackLocationID;
            itemData.stats              = ConvertItemDetail(item);
            itemData.assetURL           = item.AssetBundleName;
            itemData.tags               = ConvertTags(item);
            itemData.persistantLocation = item.Location;
            itemData.GenerationID       = GenerationID;
            itemData.IsGenerated        = true;
            convertedItems.Add(itemData);
        }

        Resources.UnloadUnusedAssets();

        ItemComponentInitalizer.InitializeItemWithComponents(convertedItems, AddComponetTo.prefab);

        return(convertedItems);
    }
Exemplo n.º 4
0
    private Vector3 DropItem(ItemData item, Vector3 dropPosition, GameObject dropModelDefault, UnityEngine.Object bundleObj, int dropAmount)
    {
        GameObject dropObject = GameObject.Instantiate(bundleObj != null ? bundleObj : dropModelDefault) as GameObject;

        ItemData itemData = dropObject.AddComponent <ItemDataComponent>().itemData;

        itemData.SetItemData(item);
        itemData.stackSize = dropAmount;

        dropObject.name = item.itemName + " (ID: " + item.CollectionID + ")";

        ItemComponentInitalizer.InitializeItemWithComponents(dropObject.GetComponent <ItemDataComponent>().itemData, AddComponetTo.prefab);

        dropObject.transform.position = dropPosition;
        dropObject.transform.parent   = dropParentObject.transform;

        if (postDropObjectAction != null)
        {
            postDropObjectAction.DoGameObjectAction(dropObject);
        }
        return(dropPosition);
    }
 void itemContainer_AddedItem(ItemData item, bool isSaved)
 {
     ItemComponentInitalizer.InitializeItemWithComponents(item, AddComponetTo.container);
 }