IEnumerator BeginReturningIDS()
    {
        yield return new WaitForSeconds(.3f);

        foreach(int id in actor.data.ids)
        {
            ids.Add(id);
            Debug.Log("Got an id");
        }
        for (int i = 0; i < ids.Count; i++)
        {
            InventoryItemDisplay display = (InventoryItemDisplay)Instantiate(inventoryItemDisplayPrefab);
            display.transform.SetParent(targetTransform, false);

            InventoryItem returnInventoryItem = display.gameObject.AddComponent<InventoryItem>();

            display.GetComponent<InventoryItem>().itemId = actor.data.ids[i];
            display.GetComponent<InventoryItem>().ReturnItems();

            display.item = returnInventoryItem;

            if(display.textName.text != returnInventoryItem.itemName)
            {
                Debug.Log("Failed to log in item properly, check inventory item on inventoryitemdisplay object in scene");
            }

        }
    }
    IEnumerator BeginReturningIDS()
    {
        yield return(new WaitForSeconds(.3f));

        foreach (string id in actor.data.ids)
        {
            ids.Add(id);
        }
        foreach (EEquipmentType equipmentType in actor.data.itemTypes)
        {
            types.Add(equipmentType);
        }

        for (int i = 0; i < ids.Count; i++)
        {
            Item item = ItemGenerator.IDToItem(ids[i]);
            InventoryItemDisplay display = (InventoryItemDisplay)Instantiate(inventoryItemDisplayPrefab);
            display.transform.SetParent(targetTransform, false);
            Debug.Log("Item " + i + " Name " + item.Name + " id " + item.ID + " level " + item.Level + "stats" + item.Stats);

            display.textName.text   = item.Name;
            display.flavorText.text = item.FlavorText;
            display.strength.text   = "STR: " + (int)item.Stats.Strength;
            display.dexterity.text  = "Dex: " + (int)item.Stats.Dexterity;
            display.intellect.text  = "Int: " + (int)item.Stats.Intelect;
            display.gold.text       = "Gold: " + (int)item.Stats.GoldValue;
            display.scrap.text      = "Scrap: " + (int)item.Stats.ScrapValue;
            display.health.text     = "Health " + (int)item.Stats.Health;
            display.sprite.sprite   = item.GetSprite();
        }
    }
Beispiel #3
0
 /// <summary>
 /// Inserts the new item. Dazu werden übergeben: QuellItem, auf das geklickt wurde, QuellPanel, abzuziehende LPs sowie das Zielpanel
 /// </summary>
 /// <param name="itemDisplay">Item display.</param>
 /// <param name="contextItemDisplay">Context item display.</param>
 /// <param name="lernpunkteDelta">Lernpunkte delta.</param>
 /// <param name="lpHelper">Lp helper.</param>
 /// <param name="rightPanelDisplay">Right panel display.</param>
 void InsertNewItem(InventoryItemDisplay itemDisplay, string contextItemDisplay, int lernpunkteDelta, LernPlanHelper lpHelper, Transform rightPanelDisplay)
 {
     itemDisplay.item.activated = true;
     //erzeuge neues item
     CreateInventoryItem(itemDisplay, rightPanelDisplay);
     SetLearningPoints(contextItemDisplay, lernpunkteDelta, lpHelper);
 }
 /// <summary>
 /// Des the activate item.
 /// </summary>
 private void DeActivateItem(InventoryItemDisplay itemDisplay)
 {
     itemDisplay.item.activated = false;
     itemDisplay.gameObject.SetActive(false);
     AddLearningPoints(itemDisplay.item);
     maskenType.DeleteFertigkeitFromCharacter(itemDisplay.item);
 }
Beispiel #5
0
    /// <summary>
    /// Creates the inventory item aus dem Prefab, setzt parent und values ein
    /// </summary>
    /// <param name="itemDisplay">Item display.</param>
    /// <param name="rightPanelDisplay">Right panel display.</param>
    void CreateInventoryItem(InventoryItemDisplay itemDisplay, Transform rightPanelDisplay)
    {
        InventoryItemDisplay itemToDisplay = (InventoryItemDisplay)Instantiate(itemDisplayPrefab);

        itemToDisplay.transform.SetParent(rightPanelDisplay, false);
        itemToDisplay.SetDisplayValuesCost(itemDisplay.item);
    }
Beispiel #6
0
    /// <summary>
    /// 아이템 카드 리스트에 장비 아이템 데이터들을 삽입한다.
    /// </summary>
    private void InsertEquipmentItemDataToItemCardsList()
    {
        while (itemCardsList.Count > 0)
        {
            GameObject itemCard = itemCardsList[0];
            itemCardsList.RemoveAt(0);
            Destroy(itemCard);
        }

        // 플레이어 아이템 리스트의 정보를 가져와 아이템 카드 생성
        for (int i = 0; i < PlayerInformation.inventory.equipmentItemDataList.Count; i++)
        {
            GameObject itemCard = Instantiate(inventoryItemCard, transform.position, transform.rotation, scrollViewContent.transform) as GameObject;
            if (itemCard) // 아이템 카드를 생성했으면
            {
                InventoryItemDisplay item = itemCard.GetComponent <InventoryItemDisplay>();
                if (item) // 아이템이 존재한다면
                {
                    item.card.CopyData(PlayerInformation.inventory.equipmentItemDataList[i]);
                    item.UpdateUI();
                }
                else
                {
                    Debug.LogError("아이템이 존재하지 않는다!");
                }
                itemCardsList.Add(itemCard); // 리스트에 집어넣는다.
            }
            else
            {
                Debug.LogError("아이템 카드를 생성하지 못했습니다.");
            }
        }
    }
Beispiel #7
0
    //need to add in all sprites correlated to appropriate item
    #endregion

    void Start()
    {
        itemSpriteColorSwitch = GetComponent <Image>();
        player = FindObjectOfType <Player>();
        inventoryItemDisplay = GetComponentInParent <InventoryItemDisplay>();
        items = FindObjectsOfType <Equip>();
    }
    /// <summary>
    /// Creates the inventory item aus dem Prefab, setzt parent und values ein
    /// </summary>
    /// <param name="itemDisplay">Item display.</param>
    /// <param name="rightPanelDisplay">Right panel display.</param>
    void CreateInventoryItemDisplay(InventoryItem item, Transform berufPanelDisplay)
    {
        InventoryItemDisplay itemToDisplay = (InventoryItemDisplay)Instantiate(itemDisplayPrefab);

        itemToDisplay.transform.SetParent(berufPanelDisplay, false);
        itemToDisplay.SetDisplayValuesWert(item);
    }
Beispiel #9
0
    public void Add <T>(T it, int amount, Action <T> onClick) where T : Item
    {
        GameObject           go  = GameObject.Instantiate(ItemDisplayPrefab, Content.transform);
        InventoryItemDisplay iid = go.GetComponent <InventoryItemDisplay>();

        iid.SetData(it, amount, (it2) => onClick?.Invoke((T)it2.Item));
        items.Add(iid.gameObject);
    }
    /// <summary>
    /// Creates the inventory item aus dem Prefab, setzt parent und values ein
    /// </summary>
    /// <param name="item">Item .</param>
    void CreateInventoryItem(InventoryItem item)
    {
        Transform            rightPanelDisplay = maskenType.GetRightPanel();
        InventoryItemDisplay itemToDisplay     = (InventoryItemDisplay)Instantiate(itemDisplayPrefab);

        itemToDisplay.transform.SetParent(rightPanelDisplay, false);
        itemToDisplay.SetDisplayValuesCost(item);
    }
 public void PrimeInventoryItemList(List <InventoryItem> items)
 {
     foreach (InventoryItem item in items)
     {
         InventoryItemDisplay display = (InventoryItemDisplay)Instantiate(itemDisplayPrefab);
         display.transform.SetParent(targetTransform, false);
         display.Prime(item);
     }
 }
Beispiel #12
0
    public void PrimeItem(WorldObject item)
    {
        InventoryItemDisplay display = (InventoryItemDisplay)Instantiate(itemDisplayPrefab);

        display.transform.SetParent(targetTransform, false);
        display.Prime(item);
        worldObject = item;
        listOfItems.Add(display);
    }
Beispiel #13
0
    void HandleItemAddingData(Player player, InventoryItemDisplay inventoryItemDisplay)
    {
        player.CurrentHealth += inventoryItemDisplay.item.lifeValue;
        player.CurrentAttack += (inventoryItemDisplay.item.rage +
                                 inventoryItemDisplay.item.arcane + inventoryItemDisplay.item.speed);

        player.CurrentDefense += (inventoryItemDisplay.item.lifeValue / 2);

        itemSpriteColorSwitch.color = Color.red;
    }
Beispiel #14
0
    void HandleItemSubtractingData(Player player, InventoryItemDisplay inventoryItemDisplay)
    {
        player.CurrentHealth -= inventoryItemDisplay.item.lifeValue;
        player.CurrentAttack -= (inventoryItemDisplay.item.rage +
                                 inventoryItemDisplay.item.arcane + inventoryItemDisplay.item.speed);

        player.CurrentDefense -= (inventoryItemDisplay.item.lifeValue / 2);

        itemSpriteColorSwitch.color = Color.white;
    }
Beispiel #15
0
    public void SetInventoryItemDisplay(InventoryItemDisplay inventoryItemDisplay)
    {
        if (inventoryItemDisplaysManager == null)
        {
            print("Error on EquipItemButton SetInventoryItemDIsplay 32\n");
            return;
        }

        this.inventoryItemDisplay = inventoryItemDisplay;
    }
Beispiel #16
0
    public void ShowItems(IEnumerable <Item> itemsToAdd, Action <Item> onClick)
    {
        Open();

        foreach (var item in itemsToAdd)
        {
            GameObject           go  = GameObject.Instantiate(ItemDisplayPrefab, Content.transform);
            InventoryItemDisplay iid = go.GetComponent <InventoryItemDisplay>();
            iid.SetData(item, 0, (it2) => onClick?.Invoke(it2.Item));
            items.Add(iid.gameObject);
        }
    }
Beispiel #17
0
 public void Prime(List <InventoryItem> items)
 {
     foreach (InventoryItem item in items)
     {
         // Debug.Log(item);
         InventoryItemDisplay display = (InventoryItemDisplay)Instantiate(itemDisplayPrefab);
         display.transform.SetParent(targetTransform, false);
         display.Prime(item);
         counter++;
         puzzelsdone.text = counter.ToString();
     }
 }
Beispiel #18
0
    //Mostly called from Raycaster after interact button clicked
    public void AddItem(ShopItem _item, InteractableObj _script)
    {
        GameObject newObj = GameObject.Instantiate(itemPrefab, _inventoryGrid.transform);

        StartCoroutine(WaitForHold(newObj));
        _currentInv.Add(new InventoryItem(newObj, _item, _script.GetGameObj()));
        InventoryItemDisplay objDisplay = newObj.GetComponent <InventoryItemDisplay>();

        objDisplay._master = this;
        objDisplay._data   = _item;
        objDisplay.SetDisplay(_script);
    }
Beispiel #19
0
 /// <summary>
 /// Fills the item display: loads inventory items in panel
 /// </summary>
 /// <param name="items">Items.</param>
 public override void FillItemDisplay(List <InventoryItem> items)
 {
     foreach (InventoryItem item in items)
     {
         if (item != null)
         {
             InventoryItemDisplay itemToDisplay = (InventoryItemDisplay)Instantiate(itemDisplayPrefab);
             itemToDisplay.transform.SetParent(displayPanel, false);
             itemToDisplay.SetDisplayValuesWert(item);
         }
     }
 }
Beispiel #20
0
    public void ItemClicked(InventoryItemDisplay it)
    {
        ItemDisplay.SetData(it.Item, 1, null);
        string text = "";

        text += $"Name: {it.Item.GetName()}\n";
        text += $"Type: {it.Item.GetType().Name}\n";
        text += $"Value: {it.Item.GetValue()}\n";
        text += $"'{it.Item.Description}'";
        ItemText.SetText(text);

        EquipItemProcessor.Instance.ProcessItem(it.Item, Refresh);
    }
Beispiel #21
0
    public void Prime(List <ItemClass> items)
    {
        foreach (ItemClass item in items)
        {
            InventoryItemDisplay display = (InventoryItemDisplay)Instantiate(ItemDispalyprefab);
            display.transform.SetParent(targetTransform, false);
            display.Prime(item);

            int LocationInList = ItemManagerTransform.GetComponent <ItemSelectionManager>().AddToList(display.gameObject);
            display.LocationInList = LocationInList;
        }
        //targetTransform.GetComponent<RectTransform>().sizeDelta.Set(targetTransform.GetComponent<RectTransform>().sizeDelta.x,59* (float)items.Count);
    }
Beispiel #22
0
        public void Construct(Inventory inventory)
        {
            Inventory = inventory;
            List <InventoryItem> items = inventory.Items;

            Clear();

            foreach (var item in items)
            {
                InventoryItemDisplay display = Instantiate(ItemDisplayPrefab);
                display.transform.SetParent(TargetTransform, false);
                display.Construct(item);
            }
            Constructed = true;
        }
    /// <summary>
    /// Handles the on item click. Controls whole process of adding and removing items.
    /// </summary>
    /// <param name="itemDisplay">Item display.</param>
    public void HandleOnItemClick(InventoryItemDisplay itemDisplay)
    {
        ConfigContextAndItem(itemDisplay);
        GetItemDependencies();

        //Geklicktes Item schon aktiviert -> löschen, sonst auf rechts panel pushen
        if (itemDisplay.item.activated)
        {
            RemoveItem();
        }
        else
        {
            PushItem();
        }
    }
    /// <summary>
    /// Handles the on item click.
    /// </summary>
    /// <param name="itemDisplay">Item display.</param>
    public void HandleOnItemClick(InventoryItemDisplay itemDisplay)
    {
        //Display aus dem der Click stammt
        string contextItemDisplay = itemDisplay.transform.parent.name;

        lpHelper = Toolbox.Instance.lernHelper;

        //Hier sind die Arten der Panels zu speicher, die vom Click betroffen sein können
        Transform allgemeinPanelDisplay = null;

        string     righPanelShort = "Gewählt";
        GameObject fachAllgemein  = GameObject.Find("FachGewählt");

        allgemeinPanelDisplay = fachAllgemein.transform;
        int aktKategorieClicked = itemDisplay.item.cost;

        //Geklicktes Item schon aktiviert -> deaktivieren
        if (itemDisplay.item.activated)
        {
            if (contextItemDisplay.Contains(righPanelShort))
            {
                itemDisplay.item.activated = false;
                itemDisplay.gameObject.SetActive(false);
                lpHelper.FachBerufClicked -= 1;
                lpHelper.KategorieClicked -= aktKategorieClicked;
                DeleteFertigkeitFromCharacter(itemDisplay.item);
            }
        }
        else             //Neues Item einfügen, falls nicht aktiv-> verschiedene Zielpanels
        {
            bool addMore = CheckBerufFachOk(itemDisplay);
            if (addMore)
            {
                lastKatClicked             = aktKategorieClicked;
                lpHelper.FachBerufClicked += 1;
                lpHelper.KategorieClicked += aktKategorieClicked;
                InsertNewItem(itemDisplay, contextItemDisplay, lpHelper, allgemeinPanelDisplay);
                AddFertigkeitToCharacter(itemDisplay.item);
                lpHelper.lernPunkteResetUngewFertigkeiten = false;                 //jetzt kann das Panel mit Inhalt bleiben
            }
        }
    }
Beispiel #25
0
    //Special function for creating game items from prefabs that bought from shop
    private void AddFromShop(ShopItem _item)
    {
        GameObject      newObj   = GameObject.Instantiate(itemPrefab, _inventoryGrid.transform);
        GameObject      _newItem = GameObject.Instantiate(_item.itemPrefab, RayCaster.instance.itemGuide.transform);
        LiftableObjects _script  = _newItem.GetComponent <LiftableObjects>();

        _script.GetObjScripts();
        _script.itemRigid.useGravity        = false;
        _script.itemRigid.isKinematic       = true;
        _newItem.transform.localPosition    = _script.handPosition;
        _newItem.transform.localEulerAngles = _script.handRotation;
        _newItem.transform.localScale       = _item.handScale;
        _currentInv.Add(new InventoryItem(newObj, _item, _newItem));
        InventoryItemDisplay objDisplay = newObj.GetComponent <InventoryItemDisplay>();

        objDisplay._master = this;
        objDisplay._data   = _item;
        objDisplay.SetDisplay(_script);
        _newItem.SetActive(false);
    }
    /// <summary>
    /// Checks the beruf fach ok.
    ///
    /// </summary>
    private bool CheckBerufFachOk(InventoryItemDisplay itemClicked)
    {
        int beruf100   = lpHelper.BerufswahlW100;
        int katAktuell = itemClicked.item.cost;

        if (beruf100 <= 95)
        {
            if (lpHelper.FachBerufClicked == 0)
            {
                return(true);
            }
        }
        else
        {
            if (lpHelper.FachBerufClicked == 0 || (lpHelper.FachBerufClicked == 1 && lpHelper.KategorieClicked < 3 && katAktuell < 3))
            {
                return(true);
            }
        }
        return(false);
    }
Beispiel #27
0
    public void ShowItems(string title, IEnumerable <InventoryEntry> itemsToAdd, Action <Item> onClick, bool showAmount, bool showNull = false)
    {
        Open();

        Title.text = title;

        foreach (var entry in itemsToAdd)
        {
            GameObject           go  = GameObject.Instantiate(ItemDisplayPrefab, Content.transform);
            InventoryItemDisplay iid = go.GetComponent <InventoryItemDisplay>();
            iid.SetData(entry.Item, showAmount ? entry.Amount : 0, (it2) => onClick?.Invoke(it2.Item));
            items.Add(iid.gameObject);
        }

        if (showNull)
        {
            GameObject           go  = GameObject.Instantiate(ItemDisplayPrefab, Content.transform);
            InventoryItemDisplay iid = go.GetComponent <InventoryItemDisplay>();
            iid.SetData(null, 0, (it2) => onClick?.Invoke(it2.Item));
            items.Add(iid.gameObject);
        }
    }
Beispiel #28
0
    /// <summary>
    /// Handles the on item click.
    /// </summary>
    /// <param name="itemDisplay">Item display.</param>
    public void HandleOnItemClick(InventoryItemDisplay itemDisplay)
    {
        //Display aus dem der Click stammt
        string         contextItemDisplay = itemDisplay.transform.parent.name;
        int            lernpunkteDelta    = itemDisplay.item.cost;
        LernPlanHelper lpHelper           = Toolbox.Instance.lernHelper;

        //Hier sind die Arten der Panels zu speicher, die vom Click betroffen sein können
        Transform allgemeinPanelDisplay = null;

        string     righPanelShort = "Gewählt";
        GameObject fachAllgemein  = GameObject.Find("GewähltUngewFertigkeiten");

        allgemeinPanelDisplay = fachAllgemein.transform;

        //Geklicktes Item schon aktiviert -> deaktivieren
        if (itemDisplay.item.activated)
        {
            if (contextItemDisplay.Contains(righPanelShort))
            {
                itemDisplay.item.activated = false;
                itemDisplay.gameObject.SetActive(false);
                ReSetLearningPoints(itemDisplay.item.type, lernpunkteDelta, lpHelper);
                DeleteFertigkeitFromCharacter(itemDisplay.item);
            }
        }
        else             //Neues Item einfügen, falls nicht aktiv-> verschiedene Zielpanels
        {
            bool addMore = ((lpHelper.LernPunkteUngewFertigkeiten - lernpunkteDelta) >= 0) ? true : false;
            if (addMore)
            {
                InsertNewItem(itemDisplay, contextItemDisplay, lernpunkteDelta, lpHelper, allgemeinPanelDisplay);
                AddFertigkeitToCharacter(itemDisplay.item);

                lpHelper.lernPunkteResetUngewFertigkeiten = false;                 //jetzt kann das Panel mit Inhalt bleiben
            }
        }
    }
 /// <summary>
 /// Inserts the new item. Dazu werden übergeben: QuellItem, auf das geklickt wurde, QuellPanel, abzuziehende LPs sowie das Zielpanel
 /// </summary>
 /// <param name="itemDisplay">Item display.</param>
 /// <param name="contextItemDisplay">Context item display.</param>
 /// <param name="lernpunkteDelta">Lernpunkte delta.</param>
 /// <param name="lpHelper">Lp helper.</param>
 /// <param name="rightPanelDisplay">Right panel display.</param>
 void InsertNewItem(InventoryItemDisplay itemDisplay, string contextItemDisplay, LernPlanHelper lpHelper, Transform rightPanelDisplay)
 {
     itemDisplay.item.activated = true;
     //erzeuge neues item
     CreateInventoryItem(itemDisplay, rightPanelDisplay);
 }
 /// <summary>
 /// Configs the context and item, i.e. an item can be clicked from the panel on the left and the panel on the right. Der are three different categories of left and right panels
 /// Fachkenntnisse, Waffen und Zauber. These contexts are retrieved and stored
 /// </summary>
 /// <param name="itemDisplay">Item display.</param>
 private void ConfigContextAndItem(InventoryItemDisplay itemDisplay)
 {
     this.clickedItemDisplay  = itemDisplay;
     this.contextPanelDisplay = this.clickedItemDisplay.transform.parent;
     maskenType = HandleMaskTypeFactory.GetMaskType(this.contextPanelDisplay.name);
 }