Exemplo n.º 1
0
    private void OnItemFocusChangeCallback(object sender, ItemFocusChangeArgs args)
    {
        if (helpText != null)
        {
            UpdateHelpText(args.newItem);
        }

        if (args.newItem == null)
        {
            if (objectTitle != null)
            {
                objectTitle.enabled = false;
            }
            if (objectDescription != null)
            {
                objectDescription.enabled = false;
            }
            if (objectImage != null)
            {
                objectImage.enabled = false;
            }

            return;
        }
        else
        {
            if (objectTitle != null)
            {
                objectTitle.enabled = true;
            }
            if (objectDescription != null)
            {
                objectDescription.enabled = true;
            }
            if (objectImage != null)
            {
                objectImage.enabled = true;
            }
        }

        if (objectTitle != null)
        {
            objectTitle.text = args.newItem.Name;
        }

        if (objectDescription != null)
        {
            objectDescription.text  = args.newItem.Description;
            objectDescription.text += "\nWeight : " + args.newItem.Weigth;
            if (args.newItem is IUsable)
            {
                objectDescription.text += "\nUse : " + (args.newItem as IUsable).GetDescription();
            }
            if (args.newItem is ItemWeapon)
            {
                ItemWeapon weapItem = args.newItem as ItemWeapon;

                IWeapon weapon = weapItem.weaponPrefab.GetComponent <IWeapon>();
                if (weapon != null)
                {
                    if (weapon.GearStats != 0)
                    {
                        objectDescription.text += "<color=green>\nStats : ";
                        if (weapon.GearStats.Strength != 0)
                        {
                            objectDescription.text += weapon.GearStats.Strength + " STR | ";
                        }
                        if (weapon.GearStats.Stamina != 0)
                        {
                            objectDescription.text += weapon.GearStats.Stamina + " STA | ";
                        }
                        if (weapon.GearStats.Defense != 0)
                        {
                            objectDescription.text += weapon.GearStats.Defense + " DEF | ";
                        }
                        if (weapon.GearStats.Energy != 0)
                        {
                            objectDescription.text += weapon.GearStats.Energy + " ENG";
                        }
                        objectDescription.text += "</color>";
                    }

                    objectDescription.text += weapon.GetInventoryDescription();
                }
            }
            else if (args.newItem is ItemArmor)
            {
                ItemArmor item  = args.newItem as ItemArmor;
                Armor     armor = item.ArmorPrefab as Armor;

                objectDescription.text += "\n" + armor.Type.ToString() + " armor.\n";
                if (armor.ArmorValue != 0)
                {
                    objectDescription.text += "Armor : " + armor.ArmorValue + "\n";
                }

                if (armor.Stats != 0)
                {
                    objectDescription.text += "<color=green>Stats : ";
                    if (armor.Stats.Strength != 0)
                    {
                        objectDescription.text += armor.Stats.Strength + " STR | ";
                    }
                    if (armor.Stats.Stamina != 0)
                    {
                        objectDescription.text += armor.Stats.Stamina + " STA | ";
                    }
                    if (armor.Stats.Defense != 0)
                    {
                        objectDescription.text += armor.Stats.Defense + " DEF | ";
                    }
                    if (armor.Stats.Energy != 0)
                    {
                        objectDescription.text += armor.Stats.Energy + " ENG";
                    }
                    objectDescription.text += "</color>";
                }
            }
        }

        if (objectImage != null)
        {
            if (args.newItem.Image != null)
            {
                objectImage.sprite = args.newItem.Image;
            }
            else
            {
                objectImage.sprite = defaultSprite;
            }
        }
    }
Exemplo n.º 2
0
    private void OnItemFocusChangeCallback(object sender, ItemFocusChangeArgs args)
    {
        if (args.newItem == null)
        {
            ChangeButtonState(useButton, false);
            ChangeButtonState(dropButton, false);
            ChangeButtonState(mainHandEquipButton, false);
            ChangeButtonState(offHandEquipButton, false);

            return;
        }
        else
        {
            ChangeButtonState(useButton, true);
            ChangeButtonState(dropButton, true);
            ChangeButtonState(mainHandEquipButton, true);
            ChangeButtonState(offHandEquipButton, true);
        }

        if (args.newItem is ItemWeapon)
        {
            ChangeButtonState(useButton, false);

            WeaponManager wm = null;
            switch ((args.newItem as ItemWeapon).Restriction)
            {
            case WeaponRestriction.Both:
                ChangeButtonState(mainHandEquipButton, true);
                wm = GetComponentInParent <UIInventoryMenu>().target.GetComponentInParent <WeaponManager>();
                if (wm != null && (wm.MainHandWeapon == null || wm.MainHandWeapon.WeaponHand == WeaponHand.OneHanded))
                {
                    ChangeButtonState(offHandEquipButton, true);
                }
                else
                {
                    ChangeButtonState(offHandEquipButton, false);
                }
                break;

            case WeaponRestriction.MainHand:
                ChangeButtonState(mainHandEquipButton, true);
                ChangeButtonState(offHandEquipButton, false);
                break;

            case WeaponRestriction.OffHand:
                ChangeButtonState(mainHandEquipButton, false);
                wm = GetComponentInParent <UIInventoryMenu>().target.GetComponentInParent <WeaponManager>();
                if (wm != null && (wm.MainHandWeapon == null || wm.MainHandWeapon.WeaponHand == WeaponHand.OneHanded))
                {
                    ChangeButtonState(offHandEquipButton, true);
                }
                else
                {
                    ChangeButtonState(offHandEquipButton, false);
                }
                break;
            }
        }
        else
        {
            ChangeButtonState(mainHandEquipButton, false);
            ChangeButtonState(offHandEquipButton, false);

            if (useButton != null)
            {
                if (args.newItem is IUsable)
                {
                    ChangeButtonState(useButton, true);
                }
                else
                {
                    ChangeButtonState(useButton, false);
                }
            }

            if (dropButton != null)
            {
                ChangeButtonState(dropButton, args.newItem.CanDrop);
            }
        }

        lastSelectedItem = args.newItem;
    }