Exemple #1
0
        private void SetupList(UIList list, DealingCharacterItems dealingItems, List <UICharacterItem> uiList)
        {
            CacheItemSelectionManager.DeselectSelectedUI();
            List <CharacterItem> filterItems = new List <CharacterItem>();

            foreach (DealingCharacterItem dealingItem in dealingItems)
            {
                CharacterItem characterItem = dealingItem.characterItem;
                filterItems.Add(characterItem);
            }
            uiList.Clear();
            list.Generate(filterItems, (index, characterItem, ui) =>
            {
                UICharacterItem uiCharacterItem = ui.GetComponent <UICharacterItem>();
                uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, InventoryType.NonEquipItems), null, -1);
                uiCharacterItem.Show();
                uiList.Add(uiCharacterItem);
            });
            CacheItemSelectionManager.Clear();
            foreach (UICharacterItem tempDealingItemUI in tempDealingItemUIs)
            {
                CacheItemSelectionManager.Add(tempDealingItemUI);
            }
            foreach (UICharacterItem tempAnotherDealingItemUI in tempAnotherDealingItemUIs)
            {
                CacheItemSelectionManager.Add(tempAnotherDealingItemUI);
            }
        }
Exemple #2
0
 private void Start()
 {
     if (uiCharacterItem == null)
     {
         uiCharacterItem = GetComponent <UICharacterItem>();
     }
 }
Exemple #3
0
 protected void OnDeselectCharacterItem(UICharacterItem ui)
 {
     if (uiItemDialog != null)
     {
         uiItemDialog.Hide();
     }
 }
Exemple #4
0
 protected void OnSelectCharacterItem(UICharacterItem ui)
 {
     if (uiItemDialog != null && ui.Data.characterItem.NotEmptySlot())
     {
         uiItemDialog.selectionManager = CacheItemSelectionManager;
         uiItemDialog.Setup(ui.Data, null, -1);
         uiItemDialog.Show();
     }
 }
 protected void OnDeselectCharacterItem(UICharacterItem ui)
 {
     if (uiItemDialog != null)
     {
         uiItemDialog.onHide.RemoveListener(OnItemDialogHide);
         uiItemDialog.Hide();
         uiItemDialog.onHide.AddListener(OnItemDialogHide);
     }
 }
Exemple #6
0
 protected void OnSelectCharacterItem(UICharacterItem ui)
 {
     if (uiItemDialog != null && ui.Data.characterItem.IsValid())
     {
         uiItemDialog.selectionManager = ItemSelectionManager;
         uiItemDialog.Setup(ui.Data, null, -1);
         uiItemDialog.Show();
     }
 }
        public void UpdateData(ICharacterData character)
        {
            this.character = character;
            int selectedIdx = CacheItemSelectionManager.SelectedUI != null?CacheItemSelectionManager.IndexOf(CacheItemSelectionManager.SelectedUI) : -1;

            CacheItemSelectionManager.DeselectSelectedUI();
            CacheItemSelectionManager.Clear();

            if (character == null)
            {
                CacheItemList.HideAll();
                return;
            }

            IList <CharacterItem> nonEquipItems = character.NonEquipItems;
            IList <CharacterItem> filteredItems = new List <CharacterItem>();
            List <int>            filterIndexes = new List <int>();
            // Filter items to show by specific item types
            int counter = 0;

            foreach (CharacterItem nonEquipItem in nonEquipItems)
            {
                if (nonEquipItem.GetItem() == null)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(nonEquipItem.GetItem().category) ||
                    filterCategories == null || filterCategories.Count == 0 ||
                    filterCategories.Contains(nonEquipItem.GetItem().category))
                {
                    if (filterItemTypes == null || filterItemTypes.Count == 0 ||
                        filterItemTypes.Contains(nonEquipItem.GetItem().itemType))
                    {
                        filteredItems.Add(nonEquipItem);
                        filterIndexes.Add(counter);
                    }
                }
                ++counter;
            }
            CacheItemList.Generate(filteredItems, (index, characterItem, ui) =>
            {
                UICharacterItem uiCharacterItem = ui.GetComponent <UICharacterItem>();
                uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, InventoryType.NonEquipItems), this.character, filterIndexes[index]);
                uiCharacterItem.Show();
                UICharacterItemDragHandler dragHandler = uiCharacterItem.GetComponentInChildren <UICharacterItemDragHandler>();
                if (dragHandler != null)
                {
                    dragHandler.SetupForNonEquipItems(uiCharacterItem);
                }
                CacheItemSelectionManager.Add(uiCharacterItem);
                if (selectedIdx == index)
                {
                    uiCharacterItem.OnClickSelect();
                }
            });
        }
Exemple #8
0
        protected void OnSelectCharacterItem(UICharacterItem ui)
        {
            var owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (owningCharacter != null)
            {
                owningCharacter.RequestAssignHotkey(hotkeyId, HotkeyType.Item, ui.Data.characterItem.dataId);
            }
            Hide();
        }
 protected void OnSelectCharacterItem(UICharacterItem ui)
 {
     if (!ui.Data.characterItem.NotEmptySlot())
     {
         CacheItemSelectionManager.DeselectSelectedUI();
         return;
     }
     if (uiItemDialog != null)
     {
         uiItemDialog.selectionManager = CacheItemSelectionManager;
         uiItemDialog.Setup(ui.Data, character, ui.IndexOfData);
         uiItemDialog.Show();
     }
 }
Exemple #10
0
        private void Start()
        {
            UICharacterItem ui = GetComponent <UICharacterItem>();

            ui.onSetEquippedData.AddListener(OnSetEquippedData);
            ui.onSetUnEquippedData.AddListener(OnSetUnEquippedData);
            ui.onSetUnEquippableData.AddListener(OnSetUnEquippableData);
            ui.onSetStorageItemData.AddListener(OnSetStorageItemData);
            ui.onNpcSellItemDialogAppear.AddListener(OnNpcSellItemDialogAppear);
            ui.onNpcSellItemDialogDisappear.AddListener(OnNpcSellItemDialogDisappear);
            ui.onStorageDialogAppear.AddListener(OnStorageDialogAppear);
            ui.onStorageDialogDisappear.AddListener(OnStorageDialogDisappear);
            ui.onEnterDealingState.AddListener(OnEnterDealingState);
            ui.onExitDealingState.AddListener(OnExitDealingState);
            // Refresh UI data to applies events
            ui.ForceUpdate();
        }
        public void UpdateData()
        {
            if (storageType == StorageType.None)
            {
                return;
            }

            int selectedIdx = CacheCharacterItemSelectionManager.SelectedUI != null?CacheCharacterItemSelectionManager.IndexOf(CacheCharacterItemSelectionManager.SelectedUI) : -1;

            CacheCharacterItemSelectionManager.DeselectSelectedUI();
            CacheCharacterItemSelectionManager.Clear();
            totalWeight = 0;
            usedSlots   = 0;
            IList <CharacterItem> characterItems = BasePlayerCharacterController.OwningCharacter.StorageItems;

            CacheCharacterItemList.Generate(characterItems, (index, characterItem, ui) =>
            {
                UICharacterItem uiCharacterItem = ui.GetComponent <UICharacterItem>();
                uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, InventoryType.StorageItems), BasePlayerCharacterController.OwningCharacter, index);
                uiCharacterItem.Show();
                if (characterItem.NotEmptySlot())
                {
                    totalWeight += characterItem.GetItem().weight *characterItem.amount;
                    usedSlots++;
                }
                UICharacterItemDragHandler dragHandler = uiCharacterItem.GetComponentInChildren <UICharacterItemDragHandler>();
                if (dragHandler != null)
                {
                    dragHandler.SetupForStorageItems(uiCharacterItem);
                }
                CacheCharacterItemSelectionManager.Add(uiCharacterItem);
                if (selectedIdx == index)
                {
                    uiCharacterItem.OnClickSelect();
                }
            });
        }
Exemple #12
0
        protected override void UpdateData()
        {
            CharacterHotkey characterHotkey = Data;
            Skill           skill           = characterHotkey.GetSkill();
            Item            item            = characterHotkey.GetItem();

            BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (uiCharacterSkill == null && uiCharacterHotkeys != null && uiCharacterHotkeys.uiCharacterSkillPrefab != null)
            {
                uiCharacterSkill = Instantiate(uiCharacterHotkeys.uiCharacterSkillPrefab, transform);
                GenericUtils.SetAndStretchToParentSize(uiCharacterSkill.transform as RectTransform, transform as RectTransform);
                uiCharacterSkill.transform.SetAsFirstSibling();
            }

            if (uiCharacterItem == null && uiCharacterHotkeys != null && uiCharacterHotkeys.uiCharacterItemPrefab != null)
            {
                uiCharacterItem = Instantiate(uiCharacterHotkeys.uiCharacterItemPrefab, transform);
                GenericUtils.SetAndStretchToParentSize(uiCharacterItem.transform as RectTransform, transform as RectTransform);
                uiCharacterItem.transform.SetAsFirstSibling();
            }

            if (uiCharacterSkill != null)
            {
                if (skill == null)
                {
                    uiCharacterSkill.Hide();
                }
                else
                {
                    Dictionary <Skill, short> allSkills = owningCharacter.GetSkills();
                    short skillLevel = 0;
                    if (allSkills.TryGetValue(characterHotkey.GetSkill(), out skillLevel))
                    {
                        int            index          = owningCharacter.IndexOfSkill(characterHotkey.dataId);
                        CharacterSkill characterSkill = index >= 0 ? owningCharacter.Skills[index] : CharacterSkill.Create(characterHotkey.GetSkill(), skillLevel);
                        uiCharacterSkill.Setup(new CharacterSkillTuple(characterSkill, skillLevel), owningCharacter, index);
                        uiCharacterSkill.Show();
                        UICharacterSkillDragHandler dragHandler = uiCharacterSkill.GetComponentInChildren <UICharacterSkillDragHandler>();
                        if (dragHandler != null)
                        {
                            dragHandler.SetupForHotkey(this);
                        }
                    }
                    else
                    {
                        uiCharacterSkill.Hide();
                    }
                }
            }

            if (uiCharacterItem != null)
            {
                if (item == null)
                {
                    uiCharacterItem.Hide();
                }
                else
                {
                    int index = owningCharacter.IndexOfNonEquipItem(characterHotkey.dataId);
                    if (index >= 0 && index < owningCharacter.NonEquipItems.Count)
                    {
                        CharacterItem characterItem = owningCharacter.NonEquipItems[index];
                        uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, InventoryType.NonEquipItems), owningCharacter, index);
                        uiCharacterItem.Show();
                        UICharacterItemDragHandler dragHandler = uiCharacterItem.GetComponentInChildren <UICharacterItemDragHandler>();
                        if (dragHandler != null)
                        {
                            dragHandler.SetupForHotkey(this);
                        }
                    }
                    else
                    {
                        uiCharacterItem.Hide();
                    }
                }
            }
        }
Exemple #13
0
        protected override void UpdateData()
        {
            bool isComplete     = CharacterQuest.isComplete;
            bool isAllTasksDone = CharacterQuest.IsAllTasksDone(Character);

            string titleFormat = isComplete ?
                                 LanguageManager.GetText(formatKeyTitleComplete) :
                                 (isAllTasksDone ?
                                  LanguageManager.GetText(formatKeyTitleTasksComplete) :
                                  LanguageManager.GetText(formatKeyTitleOnGoing));

            if (uiTextTitle != null)
            {
                uiTextTitle.text = string.Format(titleFormat, Quest == null ? LanguageManager.GetUnknowTitle() : Quest.Title);
            }

            if (uiTextDescription != null)
            {
                uiTextDescription.text = string.Format(
                    LanguageManager.GetText(formatKeyDescription),
                    Quest == null ? LanguageManager.GetUnknowDescription() : Quest.Description);
            }

            if (uiTextRewardExp != null)
            {
                uiTextRewardExp.text = string.Format(
                    LanguageManager.GetText(formatKeyRewardExp),
                    Quest == null ? "0" : Quest.rewardExp.ToString("N0"));
            }

            if (uiTextRewardGold != null)
            {
                uiTextRewardGold.text = string.Format(
                    LanguageManager.GetText(formatKeyRewardGold),
                    Quest == null ? "0" : Quest.rewardGold.ToString("N0"));
            }

            if (Quest != null && showRewardItemList)
            {
                CacheRewardItemList.Generate(Quest.rewardItems, (index, rewardItem, ui) =>
                {
                    CharacterItem characterItem     = CharacterItem.Create(rewardItem.item);
                    characterItem.amount            = rewardItem.amount;
                    UICharacterItem uiCharacterItem = ui.GetComponent <UICharacterItem>();
                    uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, InventoryType.NonEquipItems), null, -1);
                    uiCharacterItem.Show();
                });
            }

            if (uiRewardItemRoot != null)
            {
                uiRewardItemRoot.SetActive(showRewardItemList && Quest.rewardItems.Length > 0);
            }

            if (uiQuestTaskRoot != null)
            {
                uiQuestTaskRoot.SetActive(showQuestTaskList && Quest.tasks.Length > 0);
            }

            if (questCompleteStatusObject != null)
            {
                questCompleteStatusObject.SetActive(isComplete);
            }

            if (questTasksCompleteStatusObject != null)
            {
                questTasksCompleteStatusObject.SetActive(!isComplete && isAllTasksDone);
            }

            if (questOnGoingStatusObject != null)
            {
                questOnGoingStatusObject.SetActive(!isComplete && !isAllTasksDone);
            }
        }
        public override void Show()
        {
            CacheSkillSelectionManager.eventOnSelect.RemoveListener(OnSelectCharacterSkill);
            CacheSkillSelectionManager.eventOnSelect.AddListener(OnSelectCharacterSkill);
            CacheItemSelectionManager.eventOnSelect.RemoveListener(OnSelectCharacterItem);
            CacheItemSelectionManager.eventOnSelect.AddListener(OnSelectCharacterItem);
            BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (owningCharacter == null)
            {
                CacheSkillList.HideAll();
                CacheItemList.HideAll();
                return;
            }

            // Skills
            List <CharacterSkill> filterSkills        = new List <CharacterSkill>();
            List <int>            filterSkillsIndexes = new List <int>();
            // Items
            List <CharacterItem> filterItems        = new List <CharacterItem>();
            List <int>           filterItemsIndexes = new List <int>();

            CharacterSkill tempCharacterSkill;

            foreach (KeyValuePair <Skill, short> characterSkill in owningCharacter.CacheSkills)
            {
                tempCharacterSkill = CharacterSkill.Create(characterSkill.Key, characterSkill.Value);
                if (uiCharacterHotkey.CanAssignCharacterSkill(tempCharacterSkill))
                {
                    filterSkills.Add(tempCharacterSkill);
                    filterSkillsIndexes.Add(owningCharacter.IndexOfSkill(tempCharacterSkill.dataId));
                }
            }

            int counter = 0;

            foreach (CharacterItem characterItem in owningCharacter.NonEquipItems)
            {
                if (uiCharacterHotkey.CanAssignCharacterItem(characterItem))
                {
                    filterItems.Add(characterItem);
                    filterItemsIndexes.Add(counter);
                }
                ++counter;
            }

            CacheSkillList.Generate(filterSkills, (index, characterSkill, ui) =>
            {
                UICharacterSkill uiCharacterSkill = ui.GetComponent <UICharacterSkill>();
                uiCharacterSkill.Setup(new CharacterSkillTuple(characterSkill, characterSkill.level), null, filterSkillsIndexes[index]);
                uiCharacterSkill.Show();
                CacheSkillSelectionManager.Add(uiCharacterSkill);
            });

            CacheItemList.Generate(filterItems, (index, characterItem, ui) =>
            {
                UICharacterItem uiCharacterItem = ui.GetComponent <UICharacterItem>();
                uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, InventoryType.NonEquipItems), null, filterItemsIndexes[index]);
                uiCharacterItem.Show();
                CacheItemSelectionManager.Add(uiCharacterItem);
            });
            base.Show();
        }
 public void SetupForStorageItems(UICharacterItem uiCharacterItem)
 {
     sourceLocation       = SourceLocation.StorageItems;
     this.uiCharacterItem = uiCharacterItem;
 }
 public void SetupForNonEquipItems(UICharacterItem uiCharacterItem)
 {
     sourceLocation       = SourceLocation.NonEquipItems;
     this.uiCharacterItem = uiCharacterItem;
 }