Esempio n. 1
0
    private bool IsItemCombination(Item.ItemType newItemType)
    {
        switch (itemLastEaten.itemType)
        {
        case Item.ItemType.Cola:
            if (newItemType == Item.ItemType.Mints)
            {
                return(true);
            }
            return(false);

        case Item.ItemType.Banana:
            if (newItemType == Item.ItemType.Soda)
            {
                return(true);
            }
            return(false);

        case Item.ItemType.Soda:
            if (newItemType == Item.ItemType.Banana)
            {
                return(true);
            }
            return(false);

        default:
            return(false);
        }
    }
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.GetComponent <Item>())
     {
         itemInsideTrigger = other.GetComponent <Item>().itemType;
     }
 }
 private void OnTriggerExit(Collider other)
 {
     if (other.gameObject.GetComponent <Item>())
     {
         itemInsideTrigger = Item.ItemType.None;
     }
 }
Esempio n. 4
0
    public void AddItem(Item.ItemType itemType, int amount)
    {
        bool itemAlreadyInInventory = false;

        foreach (Item inventoryItem in itemList)
        {
            if (inventoryItem.itemType == itemType)
            {
                inventoryItem.amount  += amount;
                itemAlreadyInInventory = true;
                break;
            }
        }
        if (!itemAlreadyInInventory)
        {
            Item newItem = new Item();
            newItem.itemType = itemType;
            newItem.amount   = amount;
            newItem.isdrink  = itemIconDB.GetWater(newItem.itemType);
            newItem.icon     = itemIconDB.GetSprite(newItem.itemType);
            newItem.filling  = itemIconDB.GetFullness(newItem.itemType);
            itemList.Add(newItem);
        }
        OnItemListChanged?.Invoke(this, EventArgs.Empty);
        SaveList();
    }
Esempio n. 5
0
    public void AddItem(Item.ItemType itemType, int amount)
    {
        bool itemAdded = false;

        // Check if there is already the same item in the slot and stack is not full
        for (int i = 0; i < inventoryItems.Length; i++)
        {
            if (inventoryItems[i] != null)
            {
                if (inventoryItems[i].itemType == itemType && inventoryItems[i].amount < inventoryItems[i].maxStack)
                {
                    inventoryItems[i].amount += amount;
                    itemAdded = true;
                    DisplayInventory();
                    break;
                }
            }
        }

        // There is no same item
        if (itemAdded == false)
        {
            for (int i = 0; i < inventoryItems.Length; i++)
            {
                if (inventoryItems[i] == null)
                {
                    inventoryItems[i] = new Item(itemType, amount);

                    DisplayInventory();
                    break;
                }
            }
        }
    }
Esempio n. 6
0
    //
    public void ShowItem(Transform tf)
    {
        GameObject item = GetItem();

        if (MyUtility.IsNull(item, "Item") == true)
        {
            return;
        }
        //
        int itemKey = MyUtility.GetValueFromRates(itemRates);

        Item.ItemType type = (Item.ItemType)itemKey;
        // Item.ItemType type = (Item.ItemType)listItemOrder[order];
        //
        item.SetActive(true);
        item.GetComponent <Item>().SetItem(type);
        //
        item.transform.SetParent(tf);
        item.transform.localPosition = Vector3.zero;
        //
        //order++;
        //if (order == cItemOrderCount)
        //{
        //    order = 0;
        //    MyUtility.ShuffleList(listItemOrder);
        //}
    }
Esempio n. 7
0
        private void LoadItemsData()
        {
            gameItem = new Dictionary <string, Item>();
            string[] content = File.ReadAllText(Hardware.DATA_PATH + "items.dat").Split(Hardware.NL.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string rawInfo in content)
            {
                string[]      info        = rawInfo.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                string        keyName     = info[0];
                string        name        = info[1];
                string        description = info[2];
                Item.ItemType type        = Hardware.ParseEnum <Item.ItemType>(info[3]);

                string[]          targetsData = info[4].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                Item.ItemTarget[] targets     = new Item.ItemTarget[targetsData.Length];
                for (int i = 0; i < targets.Length; ++i)
                {
                    targets[i] = Hardware.ParseEnum <Item.ItemTarget>(targetsData[i]);
                }

                string[] bonusesData = info[5].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                int[]    bonuses     = new int[bonusesData.Length];
                for (int i = 0; i < bonusesData.Length; ++i)
                {
                    bonuses[i] = Convert.ToInt32(bonusesData[i]);
                }

                gameItem.Add(keyName,
                             new Item {
                    Name = name, Description = description, Type = type, Target = targets, Bonus = bonuses
                });
            }
        }
Esempio n. 8
0
    public static string stringFromItem(Item.ItemType itemType)
    {
        string obj;

        switch (itemType)
        {
        default:
        case Item.ItemType.AddRoom: obj = "AddRoom"; break;

        case Item.ItemType.Aesthetics: obj = "Aesthetics"; break;

        case Item.ItemType.Medicine: obj = "Medicine"; break;

        case Item.ItemType.CommonKit: obj = "CommonKit"; break;

        case Item.ItemType.ExpensiveKit: obj = "ExpensiveKit"; break;

        case Item.ItemType.DeluxeKit: obj = "DeluxeKit"; break;

        case Item.ItemType.RoomFailure: obj = "RoomFailure"; break;

        case Item.ItemType.EquipmentFailure: obj = "EquipmentFailure"; break;

        case Item.ItemType.Cylinder: obj = "Cylinder"; break;

        case Item.ItemType.Ventilator: obj = "Ventilator"; break;
        }
        return(obj);
    }
Esempio n. 9
0
    public bool LoseItems(Item.ItemType iType)
    {
        int LostItem = Random.Range(0, 2);

        if (LostItem == 0)
        {
            if (gold >= 100)
            {
                gold -= 100;

                UpdateUI();
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {
            int index = Random.Range(0, 8);
            inventory[lt.ToSimpleInventory(index)].itemAmount -= 1;
            UpdateUI();
            return(true);
        }
    }
Esempio n. 10
0
    public void SubstractCoinAmmo(Item.ItemType type, int count)
    {
        Slot coinAmmoSlot = FindSlot(type);

        coinAmmoSlot.slotItem.quantity -= count;
        coinAmmoSlot.qtyText.text       = coinAmmoSlot.slotItem.quantity.ToString();
    }
Esempio n. 11
0
 public void setInventorySlot(int slotNumber, ItemManager itemManager, Item.ItemType itemName)
 {
     itemManager.CreateItemInInventory(itemName);
     slots[slotNumber]          = new Item();
     slots[slotNumber].itemType = itemName;
     filledInventorySlots       = filledInventorySlots + 1;
 }
Esempio n. 12
0
    //create new item
    public void CreateItemButtonOnClick()
    {
        if (!IsThereEmptyPlace())//ınventory is full?
        {
            return;
        }

        #region cerate new item obj
        string itemName = itemNameField.text;

        Dropdown.OptionData typeData = itemTypeSelection.options[itemTypeSelection.value];
        Item.ItemType       itemType = Item.GetTypeFromString(typeData.text);

        Dropdown.OptionData rareData = rareSelection.options[rareSelection.value];
        Item.ItemRarity     itemRare = Item.GetRareFromString(rareData.text);

        Dropdown.OptionData disenchantData = disenchantSelection.options[disenchantSelection.value];
        Item disenchantItem = Item.GetDisenchantItemFromString(disenchantData.text);

        bool isItemUpgradable     = upgradeToggle.isOn;
        bool isItemDisenchantable = disenchantToggle.isOn;

        List <Stat> stats = new List <Stat>(temporaryStatList);

        Item newItem = new Item(itemName, itemType, itemRare, stats, disenchantItem, isItemUpgradable, isItemDisenchantable);

        temporaryStatList.Clear();
        #endregion

        //create new item on inventory
        CreateInventoryItem(newItem);
        //item created event
        ItemCreatedEvent(newItem);
        ResetStatDropDown();
    }
Esempio n. 13
0
    void Soil()
    {
        Soil soil = gameObject.transform.Find("plant").gameObject.GetComponent <Soil>();

        Debug.Log(itemType.ToString());

        if (soil.harvestTime)
        {
            soil.HarvestTime(itemType);
            itemType = Item.ItemType.None;
        }
        else
        {
            switch (UIStatics.CURRENT_PICK)
            {
            case "Timba": if (isClicked)
                {
                    BucketCommand();
                }
                break;                                             // didilig

            case "Pala": if (itemType == Item.ItemType.None && isClicked)
                {
                    PopUpSystem.Instance.PopUpSeedBox(gameObject);
                }
                break;
            }
        }
    }
Esempio n. 14
0
 public ItemInstance(Item.ItemType pi_Type, Item.ItemVersion pi_Version, int pi_iMaxUses)
 {
     Type          = pi_Type;
     Version       = pi_Version;
     MaxUses       = pi_iMaxUses;
     RemainingUses = pi_iMaxUses;
 }
Esempio n. 15
0
    private void CreateItemButton(Item.ItemType itemType, Sprite itemSprite, string itemName, int itemCost, int happinessValue, int expValue, int positionIndex)
    {
        Debug.Log("Entro a create");

        Transform     giftsTemplateTransform     = Instantiate(giftsTemplate, giftsContainer);
        RectTransform giftsTemplateRectTransform = giftsTemplate.GetComponent <RectTransform>();
        Transform     buttonSelect = giftsTemplateTransform.Find("Select");

        float giftTemplateHeight = 200f;

        giftsTemplateRectTransform.anchoredPosition = new Vector2(0, -giftTemplateHeight * positionIndex);
        giftsTemplateTransform.gameObject.SetActive(true);

        giftsTemplateTransform.Find("Name").GetComponent <TextMeshProUGUI>().SetText(itemName);
        buttonSelect.Find("Price").GetComponent <TextMeshProUGUI>().SetText(itemCost.ToString());
        giftsTemplateTransform.Find("HappinessValue").GetComponent <TextMeshProUGUI>().SetText(happinessValue.ToString());
        giftsTemplateTransform.Find("EXPValue").GetComponent <TextMeshProUGUI>().SetText(expValue.ToString());
        giftsTemplateTransform.Find("Icon").GetComponent <Image>().sprite = itemSprite;

        buttonSelect.GetComponent <Button>().onClick.AddListener(() =>
        {
            int cost      = Item.GetCost(itemType);
            int happiness = Item.GetHappinessValue(itemType);
            TryBuyItem(cost, happiness);
        });
    }
Esempio n. 16
0
    /// <summary>
    /// 解析物品信息
    /// </summary>
    void ParseItemJson()
    {
        itemList = new List <Item>();
        //文本在unity中是textAsset类型
        TextAsset itemText  = Resources.Load <TextAsset>("Items");
        string    itemsJson = itemText.text;//物品信息的json格式
        JsonData  iJsonData = JsonMapper.ToObject(itemsJson);

        foreach (JsonData i in iJsonData)
        {
            //Debug.Log(i["name"].ToString());  测试
            string        typeString  = i["type"].ToString();
            Item.ItemType type        = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), typeString);//根据字符串来获取枚举值
            int           id          = int.Parse(i["id"].ToString());
            string        name        = i["name"].ToString();
            string        description = i["description"].ToString();
            int           capacity    = int.Parse(i["capacity"].ToString());
            string        sprite      = i["sprite"].ToString();

            Item item = new Item(id, name, type, description, capacity, sprite);
            //switch (type)
            //{
            //    case Item.ItemType.Consumable:
            //        break;
            //    case Item.ItemType.Equipment:
            //        break;
            //    case Item.ItemType.Tool:
            //        break;
            //    default:
            //        break;
            //}
            itemList.Add(item);
            Debug.Log(item);
        }
    }
    public void CheckForChallenge(Item.ItemType itemType, Player player)
    {
        bool challengeMatched = false;

        foreach (Player _player in GameManager.Instance.AllPlayers)
        {
            if (_player == player)
            {
                foreach (Challenge challenge in _player.PlayerChallenges)
                {
                    if (challenge.ItemToCraft == itemType)
                    {
                        challenge.AmountCollectedKilledTrapped++;
                        challengeMatched = true;
                        break;
                    }
                }
                break; // Not sure
            }
        }
        if (challengeMatched)
        {
            UpdateShopChallenges(player);
        }
    }
Esempio n. 18
0
    void changeButtonSlotImageAlpha(Item.ItemType weaponType, float alpha)
    {
        Slot  buttonSlot  = FindSlot(weaponType);
        Image buttonImage = buttonSlot.transform.GetChild(1).GetComponent <Image>();

        buttonImage.color = new Color(1, 1, 1, alpha);
    }
Esempio n. 19
0
        /// <summary>
        /// Takes a BibTex file as string as parses it to a Dictionary containing the Bibliography
        /// </summary>
        /// <param name="data">A BibTex file as a string</param>
        /// <returns>A dictionary of the Bibliography</returns>
        public List <Item> Parse(string data)
        {
            // Computing regex matches from the data.
            MatchCollection matchCollection = _entryRegex.Matches(data);

            // Collection to store the BibTex items.
            var items = new List <Item>();

            // Iterate over every BibTex item in the data.
            foreach (Match match in matchCollection)
            {
                try
                {
                    // Get the BibTex item and associated field values.
                    string        key  = match.Groups[2].Value;
                    Item.ItemType type = (Item.ItemType)Enum.Parse(typeof(Item.ItemType), match.Groups[1].Value, true);
                    Dictionary <Item.FieldType, string> fields = ParseItem(match.Groups[3].Value);
                    var item = new Item(type, fields);

                    // Validate the item.
                    if (!_validator.IsItemValid(item))
                    {
                        throw new InvalidDataException($"The item with key {key} is not valid");
                    }

                    items.Add(item);
                }
                catch (ArgumentException e)
                {
                    throw new InvalidDataException($"The item type {match.Groups[1].Value} is not known by the parser", e);
                }
            }

            return(items);
        }
Esempio n. 20
0
    bool AddItem(Item addItem)
    {
        Debug.Log("AddItem : " + addItem.type.ToString());
        playerInstance.GetComponent <Animator>().Play("Armature|eat", -1, 0);
        bool result = false;

        Item.ItemType _itemType = addItem.type;
        if (_itemType == Item.ItemType.food1 || _itemType == Item.ItemType.food2 || _itemType == Item.ItemType.food3)
        {
//			++PlayerItemList[(int)_itemType];
            result = true;
            IncreaseFood(addItem.satiation);
        }
        else
        {
//			if(PlayerItemList[(int)_itemType] == 0)
            if (slimeMode != _itemType)
            {
                result = true;
                if (slimeMode == Item.ItemType.empty)
                {
                    SetSlimeMode(_itemType);
                }
                else
                {
                    Fuse(slimeMode, _itemType);
                }
            }
        }

        return(result);
    }
Esempio n. 21
0
    public void PickupItem(Item.ItemType itemType)
    {
        if (!isLocalPlayer)
        {
            return;
        }

        switch (itemType)
        {
        case Item.ItemType.mushroom:
            Debug.Log("Picking up Mushroom");
            if (playerState == PlayerState.small)
            {
                SwitchState(PlayerState.big);
            }
            break;

        case Item.ItemType.leaf:
            Debug.Log("Picking up Leaf");
            break;

        default:
            Debug.LogError("Item type does not exist");
            break;
        }

        powerUpEffect.Play();
    }
Esempio n. 22
0
    /// <summary>
    /// 解析物品信息
    /// </summary>
    void ParseItemJson()
    {
        itemList = new List <Item>();
        //文本为在Unity里面是 TextAsset类型
        TextAsset  itemText  = Resources.Load <TextAsset>("Items");
        string     itemsJson = itemText.text;//物品信息的Json格式
        JSONObject j         = new JSONObject(itemsJson);

        foreach (JSONObject temp in j.list)
        {
            string        typeStr = temp["type"].str;
            Item.ItemType type    = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), typeStr);

            //下面的事解析这个对象里面的公有属性
            int              id          = (int)(temp["id"].n);
            string           name        = temp["name"].str;
            Item.ItemQuality quality     = (Item.ItemQuality)System.Enum.Parse(typeof(Item.ItemQuality), temp["quality"].str);
            string           description = temp["description"].str;
            int              capacity    = (int)(temp["capacity"].n);
            int              buyPrice    = (int)(temp["buyPrice"].n);
            int              sellPrice   = (int)(temp["sellPrice"].n);
            string           sprite      = temp["sprite"].str;

            Item item = null;
            switch (type)
            {
            case Item.ItemType.Consumable:
                //int hp = (int)(temp["hp"].n);
                //int mp = (int)(temp["mp"].n);
                int exp = (int)(temp["exp"].n);
                item = new Consumable(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, exp);
                break;

            case Item.ItemType.Equipment:
                //
                //int strength = (int)temp["strength"].n;
                //int intellect = (int)temp["intellect"].n;
                //int agility = (int)temp["agility"].n;
                //int stamina = (int)temp["stamina"].n;
                int hp = (int)temp["hp"].n;
                Equipment.EquipmentType equipType = (Equipment.EquipmentType)System.Enum.Parse(typeof(Equipment.EquipmentType), temp["equipType"].str);
                item = new Equipment(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, hp, equipType);
                break;

            case Item.ItemType.Weapon:
                //
                int damage = (int)temp["damage"].n;
                //Weapon.WeaponType wpType = (Weapon.WeaponType)System.Enum.Parse(typeof(Weapon.WeaponType), temp["weaponType"].str);
                item = new Weapon(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, damage);
                break;

            case Item.ItemType.Material:
                //
                item = new Material(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite);
                break;
            }
            itemList.Add(item);
            //Debug.Log(item);
        }
    }
Esempio n. 23
0
 public void Start()
 {
     type         = GetComponent <Slot>().slotItem.itemType;
     playerObject = GameObject.FindGameObjectWithTag("Player");
     player       = playerObject.GetComponent <Player>();
     playerAttack = playerObject.GetComponent <BaseAttack>();
 }
Esempio n. 24
0
    void Updateinventory(Item.ItemType itemType, int val)
    {
        string obj = stringFromItem(itemType);

        inventory[obj]    += val;
        quantity[obj].text = (int.Parse(quantity[obj].text) + val).ToString();
    }
    public CraftingSystem()
    {
        itemArray = new Item[GRID_SIZE, GRID_SIZE];

        recipeDictionary = new Dictionary <Item.ItemType, Item.ItemType[, ]>();

        // Stick
        Item.ItemType[,] recipe = new Item.ItemType[GRID_SIZE, GRID_SIZE];
        recipe[0, 2]            = Item.ItemType.None;     recipe[1, 2] = Item.ItemType.None;     recipe[2, 2] = Item.ItemType.None;
        recipe[0, 1]            = Item.ItemType.None;     recipe[1, 1] = Item.ItemType.Wood;     recipe[2, 1] = Item.ItemType.None;
        recipe[0, 0]            = Item.ItemType.None;     recipe[1, 0] = Item.ItemType.Wood;     recipe[2, 0] = Item.ItemType.None;
        recipeDictionary[Item.ItemType.Stick] = recipe;

        // Wooden Sword
        recipe       = new Item.ItemType[GRID_SIZE, GRID_SIZE];
        recipe[0, 2] = Item.ItemType.None;     recipe[1, 2] = Item.ItemType.Wood;      recipe[2, 2] = Item.ItemType.None;
        recipe[0, 1] = Item.ItemType.None;     recipe[1, 1] = Item.ItemType.Wood;      recipe[2, 1] = Item.ItemType.None;
        recipe[0, 0] = Item.ItemType.None;     recipe[1, 0] = Item.ItemType.Stick;     recipe[2, 0] = Item.ItemType.None;
        recipeDictionary[Item.ItemType.Sword_Wood] = recipe;

        // Diamond Sword
        recipe       = new Item.ItemType[GRID_SIZE, GRID_SIZE];
        recipe[0, 2] = Item.ItemType.None;     recipe[1, 2] = Item.ItemType.Diamond;     recipe[2, 2] = Item.ItemType.None;
        recipe[0, 1] = Item.ItemType.None;     recipe[1, 1] = Item.ItemType.Diamond;     recipe[2, 1] = Item.ItemType.None;
        recipe[0, 0] = Item.ItemType.None;     recipe[1, 0] = Item.ItemType.Stick;       recipe[2, 0] = Item.ItemType.None;
        recipeDictionary[Item.ItemType.Sword_Diamond] = recipe;
    }
Esempio n. 26
0
    public string GetClue(Item.ItemType _itemType, bool _truthness)
    {
        switch (_itemType)
        {
        case Item.ItemType.Top:
            return(m_top.GetClue(_truthness));

            break;

        case Item.ItemType.Bottom:
            return(m_bottom.GetClue(_truthness));

            break;

        case Item.ItemType.Face:
            return(m_face.GetClue(_truthness));

            break;

        case Item.ItemType.FaceAccessory:
            return(m_faceAccessory.GetClue(_truthness));

            break;

        case Item.ItemType.HeadAccessory:
            return(m_headAccessory.GetClue(_truthness));

            break;
        }

        return("");
    }
Esempio n. 27
0
    public void SetEquipment(Item.ItemType itemType)
    {
        // Equip Item
        switch (itemType)
        {
        case Item.ItemType.ArmorNone:   EquipArmorNone();       break;

        case Item.ItemType.Armor_1:     EquipArmor_1();         break;

        case Item.ItemType.Armor_2:     EquipArmor_2();         break;

        case Item.ItemType.HelmetNone:  EquipHelmetNone();      break;

        case Item.ItemType.Helmet:      EquipHelmet();          break;

        case Item.ItemType.SwordNone:   EquipWeapon_Punch();    break;

        case Item.ItemType.Sword_1:     EquipWeapon_Sword();    break;

        case Item.ItemType.Sword_2:     EquipWeapon_Sword2();   break;

        case Item.ItemType.Sword_Wood:      EquipWeapon_SwordWooden();   break;

        case Item.ItemType.Sword_Diamond:   EquipWeapon_SwordDiamond();   break;
        }
        OnEquipChanged?.Invoke(this, EventArgs.Empty);
    }
Esempio n. 28
0
        public void CreateChildrenNodes(List <Item.ItemType> _availableTypes, ItemsDatabase _itemsDatabase)
        {
            int randomTypeIndex = Random.Range(0, _availableTypes.Count);

            Item.ItemType childrenItemType = _availableTypes[randomTypeIndex];
            _availableTypes.RemoveAt(randomTypeIndex);

            List <Item> items     = _itemsDatabase.GetItems(childrenItemType);
            int         itemIndex = Random.Range(0, items.Count - 1);
            int         item0     = 0;
            int         item1     = 0;

            int randomNodeIndex = Random.Range(0, 2);

            if (randomNodeIndex == 0)
            {
                item0 = itemIndex;
                item1 = itemIndex + 1;
            }
            else
            {
                item0 = itemIndex + 1;
                item1 = itemIndex;
            }

            m_node1 = new Node(childrenItemType, items[item0], true, m_depth + 1, _availableTypes, _itemsDatabase);
            m_node2 = new Node(childrenItemType, items[item1], false, m_depth + 1, _availableTypes, _itemsDatabase);
        }
Esempio n. 29
0
 private void InstantiateItemInHand()
 {
     if (_itemOnMapPreshow != null)
     {
         Destroy(_itemOnMapPreshow);
     }
     if (HandEquipment.InvSlotContent.Resource)
     {
         _itemOnMapPreshow = Instantiate(ItemOnMapPreshowPrefab, Player.HandPosition);
         _itemOnMapPreshow.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Sprites/" + HandEquipment.InvSlotContent.IconName);
         return;
     }
     Item.ItemType type = HandEquipment.InvSlotContent.Item.Type;
     if (type == Item.ItemType.Axe || type == Item.ItemType.Pickaxe || type == Item.ItemType.Sword)
     {
         _itemOnMapPreshow = Instantiate(ItemOnMapPreshowPrefab, Player.WeaponToolPosition);
     }
     else
     {
         _itemOnMapPreshow = Instantiate(ItemOnMapPreshowPrefab, Player.HandPosition);
     }
     _itemOnMapPreshow.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Sprites/" + HandEquipment.InvSlotContent.IconName);
     if (HandEquipment.InvSlotContent.Item.Type == Item.ItemType.Campfire || HandEquipment.InvSlotContent.Item.Type == Item.ItemType.BearTrap)
     {
         IsPreshowingItemOnMap = true;
         _itemOnMapPreshow.transform.Find("Radius").gameObject.SetActive(true);
         _itemOnMapPreshow.transform.Find("Radius").gameObject.AddComponent <ItemPreshow>();
     }
     else if (HandEquipment.InvSlotContent.Item.Type == Item.ItemType.Bridge)
     {
         IsPreshowingItemOnMap = true;
         _itemOnMapPreshow.AddComponent <Bridge>();
         _itemOnMapPreshow.GetComponent <BoxCollider2D>().enabled = true;
     }
 }
Esempio n. 30
0
 // Use this for initialization
 void Start()
 {
     shopGlobal      = GameObject.FindGameObjectWithTag("ShopGlobal").GetComponent <ShopGlobalScrip>();
     database        = GameObject.FindGameObjectWithTag("ItemDatabase").GetComponent <ItemDatabase>();
     description     = GameObject.FindGameObjectWithTag("Description");
     descriptionText = description.transform.GetChild(1).transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).GetComponent <Text>();
     buyButton       = description.transform.GetChild(2).GetComponent <Button>();
     buyButton.onClick.AddListener(buyProduct);
     graineButton.onClick.AddListener(graineCategorie);
     mobilierButton.onClick.AddListener(mobilierCategorie);
     quickBar      = GameObject.FindGameObjectWithTag("QuickBar").GetComponent <QuickBar>();
     marchande     = GameObject.FindGameObjectWithTag("ShopGlobal").GetComponent <MarchandeScript>();
     boolMarchande = false;
     categorie     = Item.ItemType.Graine;
     slotamount    = 0;
     for (int i = 0; i < 4; i++)
     {
         for (int j = 0; j < 6; j++)
         {
             GameObject slot = (GameObject)Instantiate(slots);
             slot.GetComponent <SlotShopScript>().slotNumber = slotamount;
             Slots.Add(slot);
             Items.Add(new Item());
             slot.name = "Slot" + i + "." + j;
             slot.transform.SetParent(this.gameObject.transform);
             slotamount++;
         }
     }
     graineCategorie();
 }
Esempio n. 31
0
    public void OnDrag(PointerEventData data)
    {
        // Debug.Log("Drag : " + inventory.Items[slotNumber].itemType);
        if (inventory.Items[slotNumber].itemType == Item.ItemType.Consumable)
        {
            inventory.Items[slotNumber].itemValue++;
        }

        if (inventory.Items[slotNumber].itemName != null)
        {
            Item.ItemType itemType = inventory.Items[slotNumber].itemType;
            inventory.showDraggedItem(inventory.Items[slotNumber], slotNumber);
            itemAmount.enabled = false;
            change = new Item.ItemType();
            change = inventory.Items[slotNumber].itemType;
            inventory.Items[slotNumber] = new Item();
            inventory.Items[slotNumber].itemType = itemType;
        }
    }