public override void DecreaseCurrenciesWhenCraftItem(IPlayerCharacterData character, ItemCraft itemCraft)
 {
     character.Gold -= itemCraft.RequireGold;
 }
 public override bool CurrenciesEnoughToCraftItem(IPlayerCharacterData character, ItemCraft itemCraft)
 {
     return(character.Gold >= itemCraft.RequireGold);
 }
예제 #3
0
 public abstract void DecreaseCurrenciesWhenCraftItem(IPlayerCharacterData character, ItemCraft itemCraft);
예제 #4
0
        protected override void UpdateData()
        {
            var owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (uiTextTitle != null)
            {
                uiTextTitle.text = string.Format(titleFormat, Data == null ? "Unknow" : Data.title);
            }

            if (uiTextDescription != null)
            {
                uiTextDescription.text = string.Format(descriptionFormat, Data == null ? "N/A" : Data.description);
            }

            Quest                        quest       = null;
            ItemCraft                    itemCraft   = null;
            List <NpcSellItem>           sellItems   = new List <NpcSellItem>();
            List <UINpcDialogMenuAction> menuActions = new List <UINpcDialogMenuAction>();

            switch (Data.type)
            {
            case NpcDialogType.Normal:
            case NpcDialogType.SaveRespawnPoint:
                if (onSwitchToNormalDialog == null)
                {
                    onSwitchToNormalDialog.Invoke();
                }
                var menus = Data.menus;
                for (var i = 0; i < menus.Length; ++i)
                {
                    var menu = menus[i];
                    if (menu.IsPassConditions(owningCharacter))
                    {
                        var menuAction = new UINpcDialogMenuAction();
                        menuAction.title     = menu.title;
                        menuAction.menuIndex = i;
                        menuActions.Add(menuAction);
                    }
                }
                break;

            case NpcDialogType.Quest:
                if (onSwitchToQuestDialog == null)
                {
                    onSwitchToQuestDialog.Invoke();
                }
                if (uiCharacterQuest != null)
                {
                    quest = Data.quest;
                    if (quest != null)
                    {
                        var acceptMenuAction   = new UINpcDialogMenuAction();
                        var declineMenuAction  = new UINpcDialogMenuAction();
                        var abandonMenuAction  = new UINpcDialogMenuAction();
                        var completeMenuAction = new UINpcDialogMenuAction();
                        acceptMenuAction.title       = messageQuestAccept;
                        acceptMenuAction.menuIndex   = NpcDialog.QUEST_ACCEPT_MENU_INDEX;
                        declineMenuAction.title      = messageQuestDecline;
                        declineMenuAction.menuIndex  = NpcDialog.QUEST_DECLINE_MENU_INDEX;
                        abandonMenuAction.title      = messageQuestAbandon;
                        abandonMenuAction.menuIndex  = NpcDialog.QUEST_ABANDON_MENU_INDEX;
                        completeMenuAction.title     = messageQuestComplete;
                        completeMenuAction.menuIndex = NpcDialog.QUEST_COMPLETE_MENU_INDEX;

                        CharacterQuest characterQuest;
                        var            index = owningCharacter.IndexOfQuest(quest.DataId);
                        if (index >= 0)
                        {
                            characterQuest = owningCharacter.Quests[index];
                            if (!characterQuest.IsAllTasksDone(owningCharacter))
                            {
                                menuActions.Add(abandonMenuAction);
                            }
                            else
                            {
                                menuActions.Add(completeMenuAction);
                            }
                        }
                        else
                        {
                            characterQuest = CharacterQuest.Create(quest);
                            menuActions.Add(acceptMenuAction);
                            menuActions.Add(declineMenuAction);
                        }
                        uiCharacterQuest.Setup(characterQuest, owningCharacter, index);
                    }
                }
                break;

            case NpcDialogType.Shop:
                if (onSwitchToSellItemDialog == null)
                {
                    onSwitchToSellItemDialog.Invoke();
                }
                sellItems.AddRange(Data.sellItems);
                break;

            case NpcDialogType.CraftItem:
                if (onSwitchToCraftItemDialog == null)
                {
                    onSwitchToCraftItemDialog.Invoke();
                }
                if (uiCraftItem != null)
                {
                    itemCraft = Data.itemCraft;
                    if (itemCraft != null)
                    {
                        var startMenuAction  = new UINpcDialogMenuAction();
                        var cancelMenuAction = new UINpcDialogMenuAction();
                        startMenuAction.title      = messageCraftItemStart;
                        startMenuAction.menuIndex  = NpcDialog.CRAFT_ITEM_START_MENU_INDEX;
                        cancelMenuAction.title     = messageCraftItemCancel;
                        cancelMenuAction.menuIndex = NpcDialog.CRAFT_ITEM_CANCEL_MENU_INDEX;
                        uiCraftItem.Data           = Data.itemCraft;
                        menuActions.Add(startMenuAction);
                        menuActions.Add(cancelMenuAction);
                    }
                }
                break;
            }
            // Menu
            if (uiMenuRoot != null)
            {
                uiMenuRoot.SetActive(menuActions.Count > 0);
            }
            CacheMenuList.Generate(menuActions, (index, menuAction, ui) =>
            {
                var uiNpcDialogMenu         = ui.GetComponent <UINpcDialogMenu>();
                uiNpcDialogMenu.Data        = menuAction;
                uiNpcDialogMenu.uiNpcDialog = this;
                uiNpcDialogMenu.Show();
            });
            // Quest
            if (uiCharacterQuest != null)
            {
                if (quest == null)
                {
                    uiCharacterQuest.Hide();
                }
                else
                {
                    uiCharacterQuest.Show();
                }
            }
            // Shop
            if (uiSellItemRoot != null)
            {
                uiSellItemRoot.SetActive(sellItems.Count > 0);
            }
            CacheSellItemList.Generate(sellItems, (index, sellItem, ui) =>
            {
                var uiNpcSellItem = ui.GetComponent <UINpcSellItem>();
                uiNpcSellItem.Setup(sellItem, index);
            });
            // Craft Item
            if (uiCraftItem != null)
            {
                if (itemCraft == null)
                {
                    uiCraftItem.Hide();
                }
                else
                {
                    uiCraftItem.Show();
                }
            }
        }
예제 #5
0
 public abstract bool CurrenciesEnoughToCraftItem(IPlayerCharacterData character, ItemCraft itemCraft);