示例#1
0
    private void ShowEditItem()
    {
        mSelectedItemIndex = EditorGUILayout.Popup("Item: ", mSelectedItemIndex, mItemOptions);
        InventoryItem nextItem = ItemList[mSelectedItemIndex];

        if (nextItem != mSelectedItem)
        {
            // clear the sprite so it will be reloaded
            mSelectedItemSprite = null;
            mSelectedItem       = ItemList[mSelectedItemIndex];
        }

        System.Type currentType = mSelectedItem.GetType();
        #region Consumables
        if (currentType == typeof(HPRecover))
        {
            HPRecover item = (HPRecover)mSelectedItem;

            ShowEditItemBase(item);

            // recovery
            item.Amount = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        }
        //if (currentType == typeof(RecoveryItem))
        //{
        //    RecoveryItem item = (RecoveryItem)mSelectedItem;

        //    ShowEditItemBase(item);

        //    // recovery
        //    item.ConsumableStatType = (Enums.eConsumableStatType)EditorGUILayout.EnumPopup("Stat Type: ", item.ConsumableStatType);
        //    item.Amount = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        //}
        //else if (currentType == typeof(StatUpgradeItem))
        //{
        //    StatUpgradeItem item = (StatUpgradeItem)mSelectedItem;

        //    ShowEditItemBase(item);

        //    // stat upgrade
        //    item.StatType = (Enums.eStatType)EditorGUILayout.EnumPopup("Boost Stat: ", item.StatType);
        //    item.Amount = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        //}
        //else if (currentType == typeof(StatusEffectItem))
        //{
        //    StatusEffectItem item = (StatusEffectItem)mSelectedItem;

        //    ShowEditItemBase(item);

        //    // status effect
        //    item.Effect = (Enums.eStatusEffect)EditorGUILayout.EnumPopup("Effect: ", item.Effect);
        //}
        //else if (currentType == typeof(WeaponUpgradeItem))
        //{
        //    WeaponUpgradeItem item = (WeaponUpgradeItem)mSelectedItem;

        //    ShowEditItemBase(item);

        //    // weapon upgrade
        //    item.Amount = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        //}
        //else if (currentType == typeof(CharacterSupportItem))
        //{
        //    // TODO
        //}
        #endregion

        #region Companions
        else if (currentType == typeof(CompanionItem))
        {
            CompanionItem item = (CompanionItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // companion
        }
        #endregion

        #region Stat Boosts
        else if (currentType == typeof(StatBoostItem))
        {
            StatBoostItem item = (StatBoostItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // stat boost
            item.StatType = (Enums.eStatType)EditorGUILayout.EnumPopup("Stat: ", item.StatType);
            item.Amount   = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        }
        else if (currentType == typeof(LongTermEffectItem))
        {
            LongTermEffectItem item = (LongTermEffectItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // long term effect
            item.EffectType = (Enums.eLongTermEffectType)EditorGUILayout.EnumPopup("Effect: ", item.EffectType);
            item.Delay      = EditorGUILayout.FloatField("Interval: ", Mathf.Clamp(item.Delay, 0, 10));
            item.Amount     = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        }
        else if (currentType == typeof(ResistItem))
        {
            ResistItem item = (ResistItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // resist
            item.Effect  = (Enums.eStatusEffect)EditorGUILayout.EnumPopup("Effect: ", item.Effect);
            item.Percent = EditorGUILayout.FloatField("Percent: ", Mathf.Clamp(item.Percent, 0, 100));
        }
        #endregion

        #region Armours
        else if (currentType == typeof(HeadArmourItem))
        {
            HeadArmourItem item = (HeadArmourItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // head armour
        }
        else if (currentType == typeof(BodyArmourItem))
        {
            BodyArmourItem item = (BodyArmourItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // body armour
            item.Slots = EditorGUILayout.IntField("# Slots: ", Mathf.Clamp(item.Slots, 0, 5));
        }
        else if (currentType == typeof(ArmArmourItem))
        {
            ArmArmourItem item = (ArmArmourItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // arm armour
        }
        #endregion

        #region Weapons
        else if (currentType == typeof(MeleeWeaponItem))
        {
            MeleeWeaponItem item = (MeleeWeaponItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // melee weapon
            item.TwoHanded = EditorGUILayout.Toggle("Two Handed?: ", item.TwoHanded);
        }
        else if (currentType == typeof(RangedWeaponItem))
        {
            RangedWeaponItem item = (RangedWeaponItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // ranged weapon
            item.Range = EditorGUILayout.FloatField("Range: ", Mathf.Clamp(item.Range, 0, 99));
        }
        else if (currentType == typeof(MagicWeaponItem))
        {
            MagicWeaponItem item = (MagicWeaponItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // magic weapon
            item.FocusType   = (Enums.eMagicFocusType)EditorGUILayout.EnumPopup("Focus: ", item.FocusType);
            item.MagicType   = (Enums.eMagicType)EditorGUILayout.EnumPopup("Type: ", item.MagicType);
            item.Radius      = EditorGUILayout.FloatField("Radius: ", Mathf.Clamp(item.Radius, 0, 99));
            item.MagicEffect = (Enums.eStatusEffect)EditorGUILayout.EnumPopup("Effect: ", item.MagicEffect);
            item.MPCost      = EditorGUILayout.IntField("Cost: ", Mathf.Clamp(item.MPCost, 0, 999));
        }
        #endregion

        if (GUILayout.Button("Delete Item"))
        {
            mConfirmPopup = ConfirmPopup.Create();
            mConfirmPopup.OnResultClicked += OnPopupClosed;
            mConfirmPopup.SetMessage("Are you sure you'd like to delete this item?");
        }

        if (GUILayout.Button("Update"))
        {
            Save();
        }
    }
示例#2
0
    private void CreateItem()
    {
        //System.Type currentType = mCurrentItem.GetType();
        System.Type currentType = mCurrentCreateType.GetType();

        // fill in required fields
        #region Consumables
        if (currentType == typeof(HPRecover))
        {
            HPRecover item = new HPRecover(itemID);
            item.Amount = recoveryAmount;

            SetItemBase(item);

            ItemList.Add(item);
        }

        //if (currentType == typeof(RecoveryItem))
        //{
        //    RecoveryItem item = new RecoveryItem(itemID);
        //    item.ConsumableStatType = newRecoveryStatType;
        //    item.Amount = recoveryAmount;

        //    SetItemBase(item);

        //    ItemList.Add(item);
        //}
        //else if (currentType == typeof(StatUpgradeItem))
        //{
        //    StatUpgradeItem item = new StatUpgradeItem(itemID);
        //    item.StatType = newStatType;
        //    item.Amount = statBoostAmount;

        //    SetItemBase(item);

        //    ItemList.Add(item);
        //}
        //else if (currentType == typeof(StatusEffectItem))
        //{
        //    StatusEffectItem item = new StatusEffectItem(itemID);
        //    item.Effect = newEffectType;

        //    SetItemBase(item);

        //    ItemList.Add(item);
        //}
        //else if (currentType == typeof(WeaponUpgradeItem))
        //{
        //    WeaponUpgradeItem item = new WeaponUpgradeItem(itemID);
        //    item.Amount = weaponUpgradeAmount;

        //    SetItemBase(item);

        //    ItemList.Add(item);
        //}
        //else if (currentType == typeof(CharacterSupportItem))
        //{
        //    // TODO
        //}
        #endregion

        #region Companions
        else if (currentType == typeof(CompanionItem))
        {
            CompanionItem item = new CompanionItem(itemID);

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        #endregion

        #region Stat Boosts
        else if (currentType == typeof(StatBoostItem))
        {
            StatBoostItem item = new StatBoostItem(itemID);

            item.Stat   = StatToBoost;
            item.Amount = BoostAmount;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(LongTermEffectItem))
        {
            LongTermEffectItem item = new LongTermEffectItem(itemID);

            item.EffectType = LongTermEffect;
            item.Delay      = LongTermDelay;
            item.Amount     = LongTermAmount;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(ResistItem))
        {
            ResistItem item = new ResistItem(itemID);

            item.Effect  = ResistEffect;
            item.Percent = ResistPercent;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        #endregion

        #region Armours
        else if (currentType == typeof(HeadArmourItem))
        {
            HeadArmourItem item = new HeadArmourItem(itemID);

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(BodyArmourItem))
        {
            BodyArmourItem item = new BodyArmourItem(itemID);

            item.Slots = BodySlots;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(ArmArmourItem))
        {
            ArmArmourItem item = new ArmArmourItem(itemID);

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        #endregion

        #region Weapons
        else if (currentType == typeof(MeleeWeaponItem))
        {
            MeleeWeaponItem item = new MeleeWeaponItem(itemID);

            item.TwoHanded = MeleeTwoHanded;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(RangedWeaponItem))
        {
            RangedWeaponItem item = new RangedWeaponItem(itemID);

            item.Range = Range;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(MagicWeaponItem))
        {
            MagicWeaponItem item = new MagicWeaponItem(itemID);

            item.FocusType   = MagicFocusType;
            item.MagicType   = MagicType;
            item.Radius      = MagicRadius;
            item.MagicEffect = MagicEffect;
            item.MPCost      = MagicCost;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        #endregion

        itemID += 1;
        Reset();
    }