void Start()
 {
     itemGUI          = GameObject.FindObjectOfType <ItemGUI>();
     commandProcessor = GameObject.FindObjectOfType <CommandProcessor>();
     manager          = this.GetComponent <CombatManager>();
     manager.Attach(this);
 }
 public void useItemInNPC()
 {
     if (!isBusy && currentItemGUI != null)
     {
         if (currentItemGUI.item.filter < 1 || currentItemGUI.item.antoxidant > 0 || currentItemGUI.item.damage > 0)
         {
             manager.hpSlider.value -= currentItemGUI.item.damage;
             manager.antoxidant     += currentItemGUI.item.antoxidant;
             manager.filter          = (currentItemGUI.item.filter == 1)? manager.filter : currentItemGUI.item.filter;
             if (currentItemGUI.life != 0)
             {
                 currentItemGUI.life--;
                 currentItemGUI.text.text = LocalizationManager.Instance.getLocalizatedValue(currentItemGUI.item.key);
                 if (currentItemGUI.life > 0)
                 {
                     currentItemGUI.text.text += " x" + currentItemGUI.life;
                 }
                 else
                 {
                     RemoveItemGUI(currentItemGUI.item);
                     currentItemGUI = null;
                 }
             }
         }
         else
         {
             StartCoroutine(displayText());
         }
     }
 }
Example #3
0
    public void ClickHandler(ItemGUI from)
    {
        //_textToShow = string.Format("(objId {0}) [mouse click]", from.ObjectId);
        //Console.WriteLine(_textToShow);

        if (_countersByButtonId.ContainsKey(from.ObjectId))
        {
            _countersByButtonId[from.ObjectId]++;
        }
    }
    IEnumerator displayText()
    {
        dialogText.enabled = true;
        isBusy             = true;
        yield return(new WaitForSeconds(1f));

        currentItemGUI.backImage.enabled = false;
        currentItemGUI     = null;
        dialogText.enabled = false;
        isBusy             = false;
    }
Example #5
0
    void Start()
    {
        player = this.gameObject;

        stat = player.GetComponent <StatCollectionClass>();

        skill = player.GetComponent <SkillTree>();

        quest = player.GetComponent <All_Quests> ();

        item = player.GetComponent <ItemGUI>();
    }
Example #6
0
    void Start()
    {
        player = this.gameObject;

        stat = player.GetComponent<StatCollectionClass >();

        skill = player.GetComponent<SkillTree >();

        quest = player.GetComponent<All_Quests> ();

        item = player.GetComponent<ItemGUI>();
    }
Example #7
0
 public void EnablerHandler(ItemGUI from)
 {
     if (_toEnableRef.CurrentState == ItemGUI.State.DISABLED)
     {
         _toEnableRef.SetText("Enabled");
         _toEnableRef.Enable();
     }
     else
     {
         _toEnableRef.SetText("Disabled");
         _toEnableRef.Disable();
     }
 }
 private void Start()
 {
     m_path            = new NavMeshPath();
     m_client          = (LidClient)UnityEngine.Object.FindObjectOfType(typeof(LidClient));
     m_inventory       = (InventoryGUI)UnityEngine.Object.FindObjectOfType(typeof(InventoryGUI));
     m_communicator    = (QmunicatorGUI)UnityEngine.Object.FindObjectOfType(typeof(QmunicatorGUI));
     m_itemGui         = (ItemGUI)UnityEngine.Object.FindObjectOfType(typeof(ItemGUI));
     m_popupGui        = (PopupGUI)UnityEngine.Object.FindObjectOfType(typeof(PopupGUI));
     m_repairNpcs      = (RepairingNpc[])UnityEngine.Object.FindObjectsOfType(typeof(RepairingNpc));
     m_tooltipText     = m_tooltip.GetComponentInChildren <TextMesh>();
     m_tooltipHudRText = m_tooltipHudR.GetComponentInChildren <TextMesh>();
     m_tooltipHudLText = m_tooltipHudL.GetComponentInChildren <TextMesh>();
     ResetTarget();
     m_buySellPos = m_invalidPos;
 }
    public void AddItemGUI(Item item)
    {
        GameObject newSlot = (GameObject)Instantiate(itemSlot, itemSlot.transform.position, itemSlot.transform.rotation);
        //set item, text and image
        ItemGUI gui = newSlot.GetComponent <ItemGUI>();

        gui.item      = item;
        gui.text.text = LocalizationManager.Instance.getLocalizatedValue(item.key);
        gui.life      = item.life;
        if (gui.life > 0)
        {
            gui.text.text += " x" + gui.life;
        }
        gui.image.sprite = item.sprite;
        //set parent
        newSlot.transform.SetParent(parent.transform, false);
        //add to list
        itemsGUI.Add(gui);
    }
Example #10
0
    public void FillShop()
    {
        for (int i = 0; i < contentItems.childCount; i++)
        {
            contentItems.GetChild(i).gameObject.SetActive(false);
        }

        for (int i = 0; i < ShopInstance.instance.playerShopManager.PlayerItems.Count; i++)
        {
            _currentItem = contentItems.GetChild(i).GetComponent <ItemGUI>();
            _currentItem.gameObject.SetActive(true);

            _currentItem.SetItem(p_id: i,
                                 p_name: ShopInstance.instance.playerShopManager.PlayerItems[i].itemName,
                                 p_description: ShopInstance.instance.playerShopManager.PlayerItems[i].description,
                                 p_cost: ShopInstance.instance.playerShopManager.PlayerItems[i].cost,
                                 p_bought: ShopInstance.instance.playerShopManager.PlayerItems[i].bought,
                                 p_image: ShopInstance.instance.playerShopManager.PlayerItems[i].image);
        }
    }
Example #11
0
 public void AddElement(ItemGUI itemToAdd)
 {
     _guiItems.Add(itemToAdd);
 }
Example #12
0
 public void ExitApp(ItemGUI from)
 {
     _shouldExit = true;
 }
Example #13
0
 private void Awake()
 {
     itemGUI = GameObject.FindGameObjectWithTag("ItemGUI").GetComponent <ItemGUI>();
 }
Example #14
0
    /*
     * Update the gui according to the player inventory
     */
    private void UpdateGUI()
    {
        Dictionary <char, ItemLine> playerInventory = player.Inventory;
        List <char> keys = new List <char> (this.playerGUI.Keys);

        foreach (char key in keys)
        {
            // The move action is not displayed
            if (key == 'M')
            {
                continue;
            }

            ItemGUI itemGui = this.playerGUI[key];
            // if the inventory don't contains the key
            if (!playerInventory.ContainsKey(key))
            {
                // if item no longer present in the inventory
                if (itemGui.Item != null)
                {
                    itemGui.Item     = null;
                    itemGui.Quantity = 0;
                    itemGui.GUI.GetComponentInChildren <Image>().color = Color.black;
                }
                continue;
            }

            ItemLine itemline = playerInventory[key];

            // Update sprite
            if (!itemline.item.Equals(itemGui.Item))
            {
                Debug.Log("ItemGui : " + itemline.item.name);
                itemGui.Item     = itemline.item;
                itemGui.Quantity = 0;
                itemGui.GUI.GetComponentInChildren <Image>().sprite = itemline.item.Sprite;
                itemGui.GUI.GetComponentInChildren <Image>().color  = Color.white;
            }

            // Update quantity
            if (itemGui.Quantity != itemline.quantity)
            {
                itemGui.Quantity = itemline.quantity;
                if (itemGui.Quantity > 1)
                {
                    itemGui.GUI.Find("Quantity").GetComponentInChildren <Text> ().text = itemGui.Quantity.ToString();
                }
                else
                {
                    itemGui.GUI.Find("Quantity").GetComponentInChildren <Text> ().text = "";
                }
            }

            // Action selected
            itemGui.GUI.GetComponentInChildren <Image>().color = Color.white;
            if (itemGui.Item.ActionBound.Equals(player.CurrentAction))
            {
                itemGui.GUI.GetComponentInChildren <Image>().color = Color.green;
            }
            // update dictionary
            this.playerGUI[key] = itemGui;
        }
    }
Example #15
0
    // Use this for initialization
    void Start()
    {
        CreateQuests ();

        //find out all GUI we need to handle
        player = GameObject.FindWithTag ("Player");

        psg = player.GetComponent<PlayerStateGUI> ();

        skill = player.GetComponent<SkillTree> ();

        item = player.GetComponent<ItemGUI> ();

        Q1Script = this.gameObject.GetComponent<Quest1>();
        Q2Script = this.gameObject.GetComponent<Quest2>();
        Q3Script = this.gameObject.GetComponent<Quest3>();
        Q4Script = this.gameObject.GetComponent<Quest4>();

        R = GameObject.Find ("Arrow").GetComponent<RotateTo>();
    }