Beispiel #1
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();
    }
    public void SetText(string text, Item.ItemRarity rarity)
    {
        switch (rarity)
        {
        case Item.ItemRarity.common:

            labelText.color = Color.white;
            light.enabled   = false;
            break;

        case Item.ItemRarity.rare:

            labelText.color = Color.blue;
            light.enabled   = false;
            break;

        case Item.ItemRarity.epic:

            light.color     = Color.magenta;
            labelText.color = Color.magenta;
            light.enabled   = true;
            break;

        case Item.ItemRarity.legendary:

            light.color     = Color.yellow;
            labelText.color = Color.yellow;
            light.enabled   = true;

            legendaryMark.SetActive(true);
            break;
        }

        labelText.text = text;
    }
Beispiel #3
0
    //show item stas
    void ShowItemStats(string itemName, Item.ItemType itemType, Item.ItemRarity itemRare, List <Stat> stats, GameObject layout)
    {
        //all previously created StatInf objects
        List <StatInf> usedStats = new List <StatInf>(layout.GetComponentsInChildren <StatInf>());
        //allStatCount is how much we need StatInf obj ,stats +3 for (name,type,rare)
        int allStatCount = stats.Count + 3;

        #region Create StatInf
        //if we need more StatInf objects , Instantiate
        if (usedStats.Count < allStatCount)
        {
            int neededStat = allStatCount - usedStats.Count;
            for (int i = 0; i < neededStat; i++)
            {
                GameObject newStat = Instantiate(statPrefab);
                usedStats.Add(newStat.GetComponent <StatInf>());
                newStat.transform.SetParent(layout.transform);
                newStat.transform.localScale = Vector3.one;
            }
        }
        #endregion

        #region Disable StatInf
        // if we have more StatInf then we need , Disable
        if (usedStats.Count > allStatCount)
        {
            int moreStat = usedStats.Count - allStatCount;
            for (int i = 0; i < moreStat; i++)
            {
                usedStats[0].gameObject.SetActive(false);
                usedStats.RemoveAt(0);
            }
        }
        #endregion

        #region show
        //set name , type , rare
        usedStats[0].SetItemName(itemName);
        usedStats[1].SetItemType(itemType);
        usedStats[2].SetItemRare(itemRare);

        //set stats
        for (int i = 3; i < allStatCount; i++)
        {
            usedStats[i].SetStatVaribles(stats[i - 3]);
        }
        #endregion
    }
Beispiel #4
0
        /// <summary>
        /// Spawn an item in a random valid spawn position.
        /// </summary>
        /// <param name="validPositions"></param>
        /// <param name="itemRarity"></param>
        /// <param name="zone"></param>
        private void SpawnItem(Vector3[] validPositions, Item.ItemRarity itemRarity, Zone zone)
        {
            if (ValidSpawnPositions.Count > 0)
            {
                List <GameObject> items = _itemRarities[itemRarity].FindAll(x => x.GetComponent <Item>().Rarity == itemRarity);
                if (!items.Any())
                {
                    Debug.LogWarning("Tried to spawn an item of rarity '" + itemRarity + "' but there are none!");
                    return;
                }

                GameObject gameObjectToSpawn = items[Random.Range(0, items.Count)];
                Vector3    position          = validPositions[Random.Range(1, validPositions.Count())];

                Instantiate(gameObjectToSpawn, position, Quaternion.identity, null);
                ValidSpawnPositions.Remove(position);
            }
            else
            {
                Debug.LogWarning("Attempted to spawn an item with no remaining spawn positions in room " + zone.Tile.name + "!");
            }
        }
Beispiel #5
0
 public Ammo(string NameOfItem,
             string DescriptionOfItem,
             int ItemID,
             float WeightOfItem,
             Item.ItemSpawnPoint SpawnPointOfItem,
             Item.ItemRarity RarityOfItem,
             GameObject DragDropPrefabOfItem,
             GameObject PlacedPrefabOfItem,
             GameObject PickupPrefabOfItem,
             Vector2 DragOffsetOfItem)
 {
     ammoName           = NameOfItem;
     ammoDesc           = DescriptionOfItem;
     ammoID             = ItemID;
     ammoWeight         = WeightOfItem;
     weaponSpawnPoint   = SpawnPointOfItem;
     weaponRarity       = RarityOfItem;
     ammoDragDropPrefab = DragDropPrefabOfItem;
     ammoPlacedPrefab   = PlacedPrefabOfItem;
     ammoPickupPrefab   = PickupPrefabOfItem;
     dragOffset         = DragOffsetOfItem;
 }
Beispiel #6
0
 public Weapon(string NameOfItem,
               string DescriptionOfItem,
               int ItemID,
               int ItemAimFieldOfView,
               float WeightOfItem,
               WeaponOfType TypeOfItem,
               Item.ItemSpawnPoint SpawnPointOfItem,
               Item.ItemRarity RarityOfItem,
               GameObject DragDropPrefabOfItem,
               GameObject PickupPrefabOfItem,
               Vector2 DragOffsetOfItem)
 {
     weaponName           = NameOfItem;
     weaponDesc           = DescriptionOfItem;
     weaponID             = ItemID;
     weaponAimFieldOfView = ItemAimFieldOfView;
     weaponWeight         = WeightOfItem;
     weaponType           = TypeOfItem;
     weaponSpawnPoint     = SpawnPointOfItem;
     weaponRarity         = RarityOfItem;
     weaponDragDropPrefab = DragDropPrefabOfItem;
     weaponPickupPrefab   = PickupPrefabOfItem;
     dragOffset           = DragOffsetOfItem;
 }
Beispiel #7
0
    public Color GetSlotColor(Item.ItemRarity rarity)
    {
        switch (rarity)
        {
        case Item.ItemRarity.common:

            return(common);

        case Item.ItemRarity.rare:

            return(rare);

        case Item.ItemRarity.epic:

            return(epic);

        case Item.ItemRarity.legendary:

            return(Legendary);

        default:
            return(defaultColor);
        }
    }
Beispiel #8
0
 //set item rare for inventory items
 public void SetItemRare(Item.ItemRarity rare)
 {
     statName.text  = "ıtem rare";
     statValue.text = rare.ToString();
 }