Exemplo n.º 1
0
    public void OnDrop(PointerEventData eventData)
    {
        ItemData2 droppedItem = eventData.pointerDrag.GetComponent <ItemData2>();

        if (inv.items [id].ID == -1)
        {
            inv.items [droppedItem.slot_number] = new Item();
            inv.items [id]          = droppedItem.item;
            droppedItem.slot_number = id;
        }
        else if (droppedItem.slot_number != id)
        {
            Transform item = this.transform.GetChild(0);
            item.GetComponent <ItemData2> ().slot_number = droppedItem.slot_number;
            item.transform.SetParent(inv.slots [droppedItem.slot_number].transform);
            item.transform.position = inv.slots [droppedItem.slot_number].transform.position;

            droppedItem.slot_number = id;
            droppedItem.transform.SetParent(this.transform);
            droppedItem.transform.position = this.transform.position;

            inv.items [droppedItem.slot_number] = item.GetComponent <ItemData2> ().item;
            inv.items [id] = droppedItem.item;
        }
    }
Exemplo n.º 2
0
    /**
     * 打开收集系统初始数据请求返回
     * @param itemData1 抽奖券
     * @param itemData2 碎片数量
     */
    public void GC_COLLECT_INIT(InputMessage data)
    {
        int       i, size;
        ArrayList itemData1 = new ArrayList();

        size = data.GetShort();
        for (i = 0; i < size; i++)
        {
            ItemData1 itemData1_Datas = new ItemData1();
            itemData1_Datas.cardType = data.GetInt();       //1 铜 2 银 3 金
            itemData1_Datas.num      = data.GetInt();       //数量
            itemData1.Add(itemData1_Datas);
        }
        ArrayList itemData2 = new ArrayList();

        size = data.GetShort();
        for (i = 0; i < size; i++)
        {
            ItemData2 itemData2_Datas = new ItemData2();
            itemData2_Datas.Itemid = data.GetInt();         //碎片物品ID
            itemData2_Datas.num    = data.GetInt();         //数量
            itemData2.Add(itemData2_Datas);
        }
        CollectHandler.Instance().GC_COLLECT_INIT(itemData1, itemData2);
    }
        static void SaveData()
        {
            ItemData2 item = new ItemData2();

            item.id          = 4;
            item.name        = "dfg";
            item.isStackable = true;

            ItemData item0 = new ItemData();

            item0.id          = item.id;
            item0.isStackable = item.isStackable;
            item0.name        = item.name;

            Quest quest = new Quest();

            quest.id   = 0;
            quest.name = "45fgh";

            ClassSave Save1 = new ClassSave();

            Save1.ListItem = new List <ItemData>();
            Save1.ListItem.Add(item0);
            Save1.ListQuest = new List <Quest>();
            Save1.ListQuest.Add(quest);
            Save1.ListInt = new List <int>();
            Save1.ListInt.Add(4);
            Save1.ListInt.Add(2);
            Save1.ListInt.Add(5);
            Save1.ListInt.Add(6);
            Save1.id     = 0;
            Save1.bool1  = true;
            Save1.stroka = "Привет. Как дела?";
            if (!Directory.Exists(Directory.GetCurrentDirectory() + "/saves"))
            {
                Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/saves");
            }
            FileStream      fs         = new FileStream(Directory.GetCurrentDirectory() + "/saves/save1.art", FileMode.Create);
            BinaryFormatter bformatter = new BinaryFormatter();

            bformatter.Serialize(fs, Save1);
            fs.Close();
        }
Exemplo n.º 4
0
    public void Update_subscript(int slot_location, ref List <Item> item, ref List <GameObject> slots, ref int number)
    {
        ItemData2 data = slots [slot_location].transform.GetChild(0).GetComponent <ItemData2> ();

        if (data.amount > 2)
        {
            number--;
            data.transform.GetChild(0).GetComponent <Text> ().text = data.amount.ToString();
        }
        else if (data.amount > 1)
        {
            number--;
            data.transform.GetChild(0).GetComponent <Text> ().text = "";
        }
        else
        {
            item [slot_location] = new Item();
            Destroy(slots [slot_location].transform.GetChild(0).transform.GetChild(0));
            Destroy(slots [slot_location].transform.GetChild(0));
            Debug.Log(slot_location);
        }
    }
Exemplo n.º 5
0
    public void AddItem(int id)
    {
        Item Pending_Item = database.FetchItemByID(id);

        if (Pending_Item.Stackable == true && Inventory_check(Pending_Item) == true)
        {
            for (int i = 0; i < items.Count; i++)
            {
                if (items [i].ID == id)
                {
                    ItemData2 data = slots [i].transform.GetChild(0).GetComponent <ItemData2> ();
                    data.amount++;
                    data.transform.GetChild(0).GetComponent <Text> ().text = data.amount.ToString();
                    break;
                }
            }
        }
        if (Pending_Item.Stackable == false || Inventory_check(Pending_Item) == false)
        {
            for (int i = 0; i < items.Count; i++)
            {
                if (items [i].ID == -1)
                {
                    items [i] = Pending_Item;
                    GameObject itemObj = Instantiate(InventoryItem);
                    itemObj.GetComponent <ItemData2> ().item        = Pending_Item;
                    itemObj.GetComponent <ItemData2> ().amount      = 1;
                    itemObj.GetComponent <ItemData2> ().slot_number = i;
                    itemObj.transform.SetParent(slots [i].transform);
                    itemObj.GetComponent <Image> ().sprite = Pending_Item.Icon;
                    itemObj.transform.position             = (slots[i].transform.position);
                    itemObj.name = Pending_Item.Title;
                    break;
                }
            }
        }
    }