Example #1
0
    private void DisplayItems()
    {   //Load Data of items
        TextAsset dataAsJson = new TextAsset();

        dataAsJson = Resources.Load <TextAsset>("ItemListJson");
        ItemListDatas allItemListData = new ItemListDatas();

        allItemListData = JsonUtility.FromJson <ItemListDatas>(dataAsJson.text);
        ItemListData[] itemListDatas = allItemListData.itemListDatas;

        itemData = new List <ItemListData>();
        foreach (ItemListData itemListData in itemListDatas)
        {
            itemData.Add(itemListData);
        }

        //Debug_ShowItemDatas(itemData);//for debug use only

        foreach (ItemListData thisItemData in itemData)
        {
            GameObject buttonGameObject = GameObjectUtility.CustomInstantiate(itemButton.gameObject, this.transform);
            Button     btn = buttonGameObject.GetComponent <Button>();
            btn.GetComponentInChildren <Text>().text    = thisItemData.strItemName;
            btn.GetComponentInChildren <Image>().sprite = Resources.Load <Sprite>("ItemIcons/" + thisItemData.strItemName);
            ExistingButtons.Add(btn);

            ItemScript itemScript = buttonGameObject.GetComponent <ItemScript>();
            itemScript.Initialize(processor);

            foreach (ItemAttribute itemAttri in thisItemData.itemAttributes)
            {
                itemScript.AddAttribute(itemAttri.key, itemAttri.value);
                foreach (string strExtra in possibleExtras)
                {
                    if (itemAttri.key.Contains(strExtra))
                    {
                        itemScript.AddExtra(itemAttri.key, (int)itemAttri.value);
                    }
                }
            }
            itemScript.item.strName = thisItemData.strItemName;
        }
    }
 private void GenerateSecondaryPathSelections(string primaryPathSelected)
 {   //Secondary Path Selectors are destroyed and regenerated when a new primary path is selected
     secPathSelections = new List <GameObject>();
     if (primaryPathSelected == "")
     {
         Debug.LogError("Error when Generating Secondary path: No primary path selected");
         throw new System.Exception("Error when Generating Secondary path: No primary path selected");
     }
     for (int i = 0; i < 5; i++)
     {
         if (primaryPathSelected.Equals(strPathNames[i]))
         {
             continue;
         }
         GameObject gO = GameObjectUtility.CustomInstantiate(pathSelectionButton, transform);
         secPathSelections.Add(gO);
         RunePathSelection rpS = gO.GetComponent <RunePathSelection>();
         rpS.Initialize(strPathNames[i], this, runePage, isPrimary);
     }
 }
    public void Initialize(List <string> spells, Hero user)
    {
        this.user    = user;
        newSpellBtns = new Dictionary <string, GameObject>();
        foreach (string spell in spells)
        {
            GameObject  splBtnGo = GameObjectUtility.CustomInstantiate(spellButton.gameObject, transform);
            SpellButton splBtn   = splBtnGo.GetComponent <SpellButton>();
            splBtn.Initialize(spell, this);
        }

        displayPanelGameObject = GameObject.Find("DisplayPanel");
        displayPanel           = displayPanelGameObject.GetComponent <DisplayPanel>();

        GameObject BackBtnGO = GameObjectUtility.CustomInstantiate(BackSpaceBtn.gameObject, transform);

        BackBtnGO.GetComponent <Button>().onClick.RemoveAllListeners();
        BackBtnGO.GetComponent <Button>().onClick.AddListener(() => { BackSpace(); });
        GameObject ClearBtnGO = GameObjectUtility.CustomInstantiate(ClearAllBtn.gameObject, transform);

        ClearBtnGO.GetComponent <Button>().onClick.RemoveAllListeners();
        ClearBtnGO.GetComponent <Button>().onClick.AddListener(() => { ClearAll(); });
    }
Example #4
0
    public void Initialize(Item item)
    {
        this.item    = item;
        orignialItem = item.MakeCopy();

        closeBtn.onClick.RemoveAllListeners();
        closeBtn.onClick.AddListener(() => { Close(); });

        okBtn.onClick.RemoveAllListeners();
        okBtn.onClick.AddListener(() => { OK(); });

        itemIcon.sprite = Resources.Load <Sprite>("ItemIcons/" + item.strName);

        foreach (KeyValuePair <string, int> kvP in item.Extras)
        {
            GameObject            go     = GameObjectUtility.CustomInstantiate(advancedSettingEditorPrefab, holderGameObject.transform);
            AdvancedSettingEditor editor = go.GetComponent <AdvancedSettingEditor>();
            editors.Add(editor);
            editor.Initialize(kvP.Key, item);
        }

        isConfirmed = false;
    }
Example #5
0
 public void Start()
 {
     priPS = GameObjectUtility.CustomInstantiate(primaryPathSelector, transform);
     priPS.transform.SetAsFirstSibling();
     priPS.GetComponent <RunePathSelector>().Initialize(true, this);
 }