void Start() { InventoryList = new List <Item>(); basemovespeed = MoveSpeed; Application.targetFrameRate = 60; guib = GetComponent <GameUIBehavior>(); selfanim = GetComponent <Animator>(); looks = GetComponent <SpriteRenderer>(); Spawner = GameObject.Find("GameManager"); itemList = Spawner.GetComponent <ItemScript>(); itemList.Initialize(); src = GetComponent <AudioSource>(); cameramain = GameObject.FindGameObjectWithTag("MainCamera"); camAnim = cameramain.GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); primary = itemList.Weapons[1]; secondary = null; EquippedWeapon = primary; activeusable = null; legsanimator = legs.GetComponent <Animator>(); if (activeusable != null) { currentTimeActiveitem = activeusable.regentime; } srctwo = Spawner.GetComponent <AudioSource>(); visitedRooms = new List <GameObject>(); }
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 Start() { iscript = GameObject.Find("GameManager").GetComponent <ItemScript>(); iscript.Initialize(); switch (itemtype) { case types.Passive: GetComponent <DropBehavior>().thisitem = iscript.Passives[ID]; break; case types.Usable: GetComponent <DropBehavior>().thisitem = iscript.Usables[ID]; break; case types.Weapon: GetComponent <DropBehavior>().thisitem = iscript.Weapons[ID]; break; } this.gameObject.GetComponent <DropBehavior>().InitializeItem(); }