Example #1
0
 // Use this for initialization
 void Start()
 {
     activeslotsnumber = GameObject.FindGameObjectWithTag("ActiveSlot").GetComponent <SaveActiveSlotNumber>().getslotnumber();
     Blueprints        = GameObject.FindGameObjectWithTag("Craft").GetComponent <Craft>().Blueprints;
     Items             = GameObject.FindGameObjectWithTag("Inventory").GetComponent <Inventory> ().Items;
     itemdb            = GameObject.FindGameObjectWithTag("ItemDatabase").GetComponent <ItemsDB>();
     inventory         = GameObject.FindGameObjectWithTag("Inventory").GetComponent <Inventory>();
 }
    //------------------------------------//
    //--------------METHODS---------------//
    //------------------------------------//

    private void Awake()
    {
        if (instance != null)
        {
            return;
        }
        instance = this;
    }
Example #3
0
        private ItemsDB ItemsTable(ItemsDB a_items)
        {
            ItemsDB items = new ItemsDB
            {
                UserId = a_items.UserId,
                Id     = a_items.Id,
                Title  = a_items.Title,
                Body   = a_items.Body
            };

            return(items);
        }
Example #4
0
        private void IsPresent(int a_id)
        {
            ItemsDB data = null;

            try
            {
                data = db.Get <ItemsDB>(a_id);
                Console.WriteLine($"data: {data.ToString()}");
            }
            catch (Exception)
            {
                isRecordPresent = true;
            }
        }
Example #5
0
        public async Task GetItems(CommandContext ctx, string itemName, int batch)
        {
            await ctx.RespondAsync("เดี๋ยวไปเปิดสมุดดูแปบนึงนะ");

            var result = await ItemsDB.GetItemMaterials(itemName, batch);

            result.ForEach(async mat => {
                await ctx.RespondAsync(mat);
            });
            if (result.Count == 0)
            {
                await ctx.RespondAsync("บอกอะไรมา หาไม่เจออะ");
            }
        }
Example #6
0
        public async Task SetItems(CommandContext ctx, string builder)
        {
            await ctx.RespondAsync("เดี๋ยวไปหยิบปากกามาเขียนแปบนะ");

            var result = await ItemsDB.AddItem(builder);

            if (result == true)
            {
                await ctx.RespondAsync("เขียนเพิ่มรายการเรียบร้อยแล้วนะ");
            }
            else
            {
                await ctx.RespondAsync("ปากกาหมึกหมด ไว้มาใหม่ทีหลังนะ");
            }
        }
Example #7
0
    void drawslotsBp()
    {
        x  = -81; y = 112;
        x1 = -100; y1 = -95;
        Slots.Clear();
        Blueprints.Clear();
        int slotFreeAmount = 25;        //почему 25? потому что все слоты представлены одним листом и поэтому чтобы создать новые слоты необходимо начать с той позиции в которой заканчивается инвентарь

        Blueprintdb = GameObject.FindGameObjectWithTag("BlueprintDatabase").GetComponent <BlueprintDB>();
        itemdb      = GameObject.FindGameObjectWithTag("ItemDatabase").GetComponent <ItemsDB>();
        for (int i = 1; i < 4; i++)         // создаем 12 слотов под наше чертежи и приписываем к каждому слоты чертеж
        {
            for (int j = 1; j < 5; j++)
            {
                GameObject slot = (GameObject)Instantiate(slots);
                slot.GetComponent <Slot> ().slotNumber        = slotFreeAmount;
                slot.GetComponentInChildren <Text> ().enabled = false;
                slot.GetComponent <Slot> ().slotType          = Slot.SlotType.bp;
                Slots.Add(slot);
                Blueprints.Add(new Blueprint());
                slot.name             = "slotbp " + ((j - 1) + 4 * (i - 1));
                slot.transform.parent = this.gameObject.transform;
                slot.GetComponent <RectTransform> ().localPosition = new Vector3(x, y, 0);
                x += 55;
                if (j == 4)
                {
                    x  = -81;
                    y -= 55;
                }
                slotFreeAmount++;
            }
        }

        for (int j = 1; j < 6; j++)         //а здесь мы создаем 5 слотов под ресурсы - итого 37 слотов
        {
            GameObject slot = (GameObject)Instantiate(slots);
            slot.GetComponent <Slot> ().slotNumber       = slotFreeAmount;
            slot.GetComponentInChildren <Text>().enabled = false;
            slot.GetComponent <Slot> ().slotType         = Slot.SlotType.res;
            Slots.Add(slot);
            Blueprints.Add(new Blueprint());
            slot.name             = "slotres " + ((j - 1));
            slot.transform.parent = this.gameObject.transform;
            slot.GetComponent <RectTransform> ().localPosition = new Vector3(x1, y1, 0);
            x1 += 55;
            slotFreeAmount++;
        }
    }
Example #8
0
    private void OnGUI()
    {
        if (dataLoaded == false)
        {
            if (GUILayout.Button("Load Data"))
            {
                ItemsDatabase.LoadFromDatabase();
                tileDatabase  = Resources.Load <TileProperties>("Databases/TileDB");
                itemsDatabase = Resources.Load <ItemsDB>("Databases/ItemDB");
                EditorUtility.SetDirty(tileDatabase);
                EditorUtility.SetDirty(itemsDatabase);
                dataLoaded = true;
            }
        }


        if (dataLoaded == true)
        {
            // Create the upper selection bar (itemsdb, attributes, etc). Switch to GUILayout.SelectionGrid for multiple rows
            //toolbarInt = GUILayout.Toolbar(toolbarInt, toolbarStrings);
            toolbarInt = GUILayout.SelectionGrid(toolbarInt, toolbarStrings, 4);


            switch (toolbarInt)
            {
            case 0:
                ItemsListTab();
                break;

            case 1:
                CreateAttributesTab();
                break;

            case 2:
                TileListTab();
                break;

            case 3:
                TilePrefsTab();
                break;
            }
        }
    }
Example #9
0
        private void InsertIntoDatabase(ItemsDB a_item)
        {
            if (!File.Exists(dbPath))
            {
                dbPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Items_Test"); //Call Database
                db     = new SQLiteConnection(dbPath);
                //var data = db.Table<ItemsDB>(); //Call Table
                db.CreateTable <ItemsDB>();
            }

            IsPresent(a_item.Id);

            if (isRecordPresent)
            {
                isRecordPresent = false;
                return;
            }
            db.Insert(ItemsTable(a_item));
        }
Example #10
0
    public int x = -110, y = 112;                                 //позиция отрисовки слотов инвентаря
    // Use this for initialization
    void Start()                                                  //получаем доступ ко всем нужным сущностям
    {
        int slotFreeAmount = 0;

        Blueprints  = GameObject.FindGameObjectWithTag("Craft").GetComponent <Craft>().Blueprints;
        Blueprintdb = GameObject.FindGameObjectWithTag("BlueprintDatabase").GetComponent <BlueprintDB>();
        itemdb      = GameObject.FindGameObjectWithTag("ItemDatabase").GetComponent <ItemsDB>();
        for (int i = 1; i < 6; i++)         //создаем и инициализируем 25 слотов. К каждому слоту присваиваем один предмет
        {
            for (int j = 1; j < 6; j++)
            {
                GameObject slot = (GameObject)Instantiate(slots);
                slot.GetComponent <Slot> ().slotNumber = slotFreeAmount;
                slot.GetComponent <Slot> ().slotType   = Slot.SlotType.item;
                Slots.Add(slot);
                Items.Add(new Item());
                slot.name             = "slot " + ((j - 1) + (i - 1) * 5);
                slot.transform.parent = this.gameObject.transform;
                slot.GetComponent <RectTransform> ().localPosition = new Vector3(x, y, 0);
                x += 55;
                if (j == 5)
                {
                    x  = -110;
                    y -= 55;
                }
                slotFreeAmount++;
            }
        }

        for (int i = 0; i < 20; i++)        // добавялем предметы в инвентарь
        {
            for (int j = 0; j < 13; j++)
            {
                addItem(j);
            }
        }
    }
Example #11
0
    // Use this for initialization

    void Start()
    {
        itemdb           = GameObject.FindGameObjectWithTag("ItemDatabase").GetComponent <ItemsDB>();
        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[1]);
        Items_to_consume.Add(itemdb.items[4]);
        Blueprints.Add(new Blueprint("bonfire", 0, "bonfire", Blueprint.BlueprintType.Structure, 1, Items_to_consume));

        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[4]);
        Blueprints.Add(new Blueprint("furnace", 1, "furance", Blueprint.BlueprintType.Structure, 1, Items_to_consume));

        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[5]);
        Items_to_consume.Add(itemdb.items[5]);
        Items_to_consume.Add(itemdb.items[5]);
        Items_to_consume.Add(itemdb.items[5]);
        Items_to_consume.Add(itemdb.items[5]);
        Blueprints.Add(new Blueprint("straw_base", 2, "straw platform", Blueprint.BlueprintType.Structure, 1, Items_to_consume));

        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[5]);
        Items_to_consume.Add(itemdb.items[5]);
        Items_to_consume.Add(itemdb.items[5]);
        Blueprints.Add(new Blueprint("straw_wall", 3, "straw wall", Blueprint.BlueprintType.Structure, 1, Items_to_consume));

        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Blueprints.Add(new Blueprint("wooden_door", 4, "wooden door", Blueprint.BlueprintType.Structure, 1, Items_to_consume));

        Items_to_consume = new List <Item> ();
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Blueprints.Add(new Blueprint("wooden_wall", 5, "wooden wall", Blueprint.BlueprintType.Structure, 1, Items_to_consume));

        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Blueprints.Add(new Blueprint("wooden_base", 6, "wooden platform", Blueprint.BlueprintType.Structure, 1, Items_to_consume));

        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[0]);
        Items_to_consume.Add(itemdb.items[0]);
        Blueprints.Add(new Blueprint("wooden_fence", 7, "wooden fence", Blueprint.BlueprintType.Structure, 1, Items_to_consume));


        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[2]);
        Items_to_consume.Add(itemdb.items[3]);
        Items_to_consume.Add(itemdb.items[4]);
        Items_to_consume.Add(itemdb.items[4]);
        Items_to_consume.Add(itemdb.items[4]);
        Blueprints.Add(new Blueprint("workbench", 8, "workbench", Blueprint.BlueprintType.Structure, 1, Items_to_consume));

        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[3]);
        Blueprints.Add(new Blueprint("metal_ingot", 9, "metal ignot", Blueprint.BlueprintType.Material, 1, Items_to_consume));

        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[7]);
        Blueprints.Add(new Blueprint("flask", 10, "flask", Blueprint.BlueprintType.Consumable, 1, Items_to_consume));

        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[11]);
        Blueprints.Add(new Blueprint("bottle", 11, "bottle", Blueprint.BlueprintType.Consumable, 1, Items_to_consume));

        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[9]);
        Blueprints.Add(new Blueprint("fish_02", 12, "bottle", Blueprint.BlueprintType.Consumable, 1, Items_to_consume));

        Items_to_consume = new List <Item>();
        Items_to_consume.Add(itemdb.items[10]);
        Blueprints.Add(new Blueprint("fish_01", 13, "bottle", Blueprint.BlueprintType.Consumable, 1, Items_to_consume));
    }