Beispiel #1
0
    /// <summary>
    /// Update information panel when item is selected
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void InventoryScript_ItemSelected(object sender, InventoryEventsArgs e)
    {
        var image        = transform.GetChild(1).GetComponent <Image>();
        var description  = transform.GetChild(2).GetComponent <Text>();
        var buttonUse    = transform.GetChild(3).GetComponent <Button>();
        var buttonRemove = transform.GetChild(4).GetComponent <Button>();
        var buttonEquip  = transform.GetChild(5).GetComponent <Button>();

        if (e.Item != null)
        {
            description.text = e.Item.Description;
            image.sprite     = Resources.Load <Sprite>(e.Item.Name + "Icon");
            buttonUse.gameObject.SetActive(!(e.Item is InventoryItem_Equipment));
            buttonEquip.gameObject.SetActive(e.Item is InventoryItem_Equipment);
            buttonRemove.gameObject.SetActive(true);
        }
        else
        {
            description.text = "";
            image.sprite     = null;
            buttonUse.gameObject.SetActive(false);
            buttonRemove.gameObject.SetActive(false);
            buttonEquip.gameObject.SetActive(false);
        }
    }
Beispiel #2
0
    /// <summary>
    /// Update the color of the slot border if selected
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public void Event_ItemSelected(object sender, InventoryEventsArgs e)
    {
        SetBorderColor(lastSelectedId, Color.white);

        if (e.Item != null && e.Item.Slot != null)
        {
            SetBorderColor(e.Item.Slot.Id, Color.blue);
            lastSelectedId = e.Item.Slot.Id;
        }
    }
Beispiel #3
0
    /// <summary>
    /// Executed when item is used
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void InventoryInstance_ItemUsed(object sender, InventoryEventsArgs e)
    {
        var ps = new PlayerStats();

        ps.Health       = (e.Item is InventoryItem_Health) ? (e.Item as InventoryItem_Health).HealthPoints : 0;
        ps.Hunger       = (e.Item is InventoryItem_Food) ? (e.Item as InventoryItem_Food).FoodPoints : 0;
        ps.Thirst       = (e.Item is InventoryItem_Drink) ? (e.Item as InventoryItem_Drink).DrinkPoints : 0;
        ps.ActionPoints = 0;
        Playerstats.UpdatePlayerStats(ps);

        OnPlayerStatsChanged();
    }
Beispiel #4
0
    /// <summary>
    /// Update Information panel when item is removed from Inventory, if(removed == selected)
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void InventoryScript_ItemRemoved(object sender, InventoryEventsArgs e)
    {
        if (Inventory.Instance.CurrentSelectedSlot == e.Item.Slot.Id && e.Item.Slot.Count == 0)
        {
            var image        = transform.GetChild(1).GetComponent <Image>();
            var description  = transform.GetChild(2).GetComponent <Text>();
            var buttonUse    = transform.GetChild(3).GetComponent <Button>();
            var buttonRemove = transform.GetChild(4).GetComponent <Button>();
            var buttonEquip  = transform.GetChild(5).GetComponent <Button>();


            description.text = "";
            image.sprite     = null;

            buttonUse.gameObject.SetActive(false);
            buttonRemove.gameObject.SetActive(false);
            buttonEquip.gameObject.SetActive(false);
        }
    }
Beispiel #5
0
 /// <summary>
 /// If a Item is removed or added the UI must be updated
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void Event_ItemChanged(object sender, InventoryEventsArgs e)
 {
     SetSlot(e.Item);
 }