예제 #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 ShowWindow(int id)
    {
        bool newIsExpanded = GUILayout.Toggle(isExpanded, "  Show/Hide");

        if (newIsExpanded != isExpanded)
        {
            isExpanded = newIsExpanded;
            PlayerPrefs.SetInt("expandSaveMenu", isExpanded ? 1 : 0);
        }

        if (!isExpanded)
        {
            return;
        }

        GUILayout.BeginVertical();
        GUILayout.Label("Save games");
        bool savegamesFound = (saveGameNames[0] != NoSavegamesFoundText);

        GUI.enabled = savegamesFound && !isLoading;

        GUILayout.BeginHorizontal();
        selectedNameIndex = GUILayout.SelectionGrid(selectedNameIndex, saveGameNames, 1, GUILayout.Width(150));
        if (selectedNameIndex != oldSelectedNameIndex)
        {
            saveName             = saveGameNames[selectedNameIndex];
            oldSelectedNameIndex = selectedNameIndex;
        }
        GUILayout.FlexibleSpace();
        GUILayout.BeginVertical();
        for (int i = 0; i < saveGameNames.Length; i++)
        {
            if (GUILayout.Button(deleteButtonContent, GUILayout.Width(21), GUILayout.Height(21)))
            {
                deleteSavegameIndex = i;
                ConfirmPopup popup = ConfirmPopup.Create("Deleting savegame", "You are about to DELETE the savegame '" + saveGameNames[i] + "', are you sure?");
                popup.OnConfirmed += DeleteConfirmed;
                popup.OnCanceled  += PopupClosed;
                enabled            = false;
            }
        }
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        GUI.enabled = true;
        GUILayout.FlexibleSpace();
        saveName = GUILayout.TextField(saveName);
        GUILayout.Label("Status: " + statusText);
        GUILayout.BeginHorizontal();

        GUI.enabled = (saveName != "");
        if (GUILayout.Button("Save"))
        {
            int saveId = GetSaveId(saveName);
            if (saveId != -1)
            {
                ConfirmPopup popup = ConfirmPopup.Create("Overwriting savegame", "You are about to overwrite the savegame '" + saveName + "', are you sure?");
                popup.OnConfirmed += OverwriteConfirmed;
                popup.OnCanceled  += PopupClosed;
                enabled            = false;
            }
            else if (saveGameNames.Length == 5)
            {
                ConfirmPopup popup = ConfirmPopup.Create("Savegame limit reached", "You have reached the limit(5) of savegames. Please overwrite an existing savegame.", true);
                popup.OnCanceled  += PopupClosed;
                popup.OnConfirmed += PopupClosed;
                enabled            = false;
            }
            else
            {
                DoSave();
            }
        }

        GUI.enabled = savegamesFound && selectedNameIndex != -1;
        if (GUILayout.Button("Load"))
        {
            statusText = LoadingGameText;
            if (OnLoadButtonPressed != null)
            {
                OnLoadButtonPressed(saveGames[selectedNameIndex].File);
            }
        }
        GUI.enabled = true;

        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
    }