Inheritance: MonoBehaviour, IPointerDownHandler, IDragHandler
Example #1
0
 public void AddCharacterSlot(CharacterSlot slot)
 {
     lock ("CharacterSlot")
     {
         CharacterSlots.Add(slot);
     }
 }
Example #2
0
 public void battleStart(CharacterSlot slot)
 {
     if (onBattleStart != null)
     {
         onBattleStart(slot);
     }
 }
Example #3
0
 public void DeleteCharacterSlot(CharacterSlot slot)
 {
     lock ("CharacterSlot")
     {
         CharacterSlots.Remove(slot);
     }
 }
Example #4
0
 public void turnEnd(CharacterSlot slot)
 {
     if (onTurnEnd != null)
     {
         onTurnEnd(slot);
     }
 }
Example #5
0
    public void FillWithStats(bool snap = false)
    {
        if (playerParty == null)
        {
            playerParty = Game.Instance.PlayerParty;
        }

        for (int i = 0; i < slots.Count; i++)
        {
            if (i >= playerParty.characters.Count)
            {
                slots[i].slotGroup.alpha   = 0;
                slots[i].AssignedCharacter = null;
                continue;
            }

            slots[i].slotGroup.alpha = 1;

            CharacterSlot slot      = slots[i];
            CharacterBase character = playerParty.characters[i];

            slot.AssignedCharacter  = character;
            slot.characterName.text = character.stats.characterName;
            UpdateHealth(slot, snap);
            UpdateMana(slot, snap);
        }

        level.text = playerParty.Level.ToString();
    }
Example #6
0
 public void battleEnd(CharacterSlot slot)
 {
     if (onBattleEnd != null)
     {
         onBattleEnd(slot);
     }
 }
    private void RefreshMenu()
    {
        characters = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <CharacterManager>().GetCharacters();

        int i = 0;

        foreach (GameObject character in characters)
        {
            CharacterSlot characterSlot = characterSlots[i].GetComponent <CharacterSlot>();

            characterSlot.isUnlocked     = character.GetComponent <CharacterSpecifics>().isUnlocked;
            characterSlot.characterIndex = i;

            characterSlots[i].GetComponentInChildren <TextMeshProUGUI>().text = character.GetComponent <CharacterSpecifics>().characterName;

            if (characterSlot.isUnlocked)
            {
                characterSlot.avatar.sprite             = character.GetComponent <Image>().sprite;
                characterSlot.switchButton.interactable = true;
            }
            else
            {
                characterSlot.avatar.sprite             = defaultCharacterSlotAvatar;
                characterSlot.switchButton.interactable = false;
            }

            i++;
        }
    }
 public void RegisterSlot(CharacterSlot slot)
 {
     if (!m_Slots.Contains(slot))
     {
         m_Slots.Add(slot);
     }
 }
Example #9
0
        public void AddAllyToParty(Player newAlly)
        {
            if (partyMembers.Count > MAX_PARTY_MEMBERS)
            {
                // If party member count > MAX_PARTY_MEMBERS, move those members to the reserves
                for (int i = partyMembers.Count - 1; i >= MAX_PARTY_MEMBERS; i--)
                {
                    partyMembers.RemoveAt(i);
                }
                characters.Add(newAlly);
                return;
            }
            if (partyMembers.Count == MAX_PARTY_MEMBERS)
            {
                // If party count == MAX_PARTY_MEMBERS, add new ally to reserves
                characters.Add(newAlly);
                return;
            }
            newAlly.SetInParty(true);
            CharacterSlot slot = (CharacterSlot)partyMembers.Count;              // character slot is based off last index + 1

            newAlly.slot = slot;
            partyMemberLocations.Add(slot, newAlly);
            partyMembers.Add(newAlly);
            BattleEventManager.bem.AddAllyIncapacitatedListener(slot, newAlly.gameObject, IncIncapacitatedCount);
            newAlly.SetPartySlot(partyMembers.Count - 1);
            characters.Add(newAlly);
        }
    //穿上装备
    public void PutOn(Item item)
    {
        Item exitItem = null;

        foreach (Slot slot in m_slotArr)
        {
            CharacterSlot characterSlot = (CharacterSlot)slot;
            if (characterSlot.IsRightItem(item))
            {
                //物品槽有item  替换或者增加数量
                if (characterSlot.transform.childCount > 0)
                {
                    ItemUI currentItemUI = characterSlot.transform.GetChild(0).GetComponent <ItemUI>();
                    exitItem = currentItemUI.m_item;
                    currentItemUI.SetItem(item, 1);

                    Knapsack.Instance.StoreItem(exitItem);
                }
                //物品槽为空  存储
                else
                {
                    characterSlot.StoreItem(item);
                }
            }
        }
        UpdateProperty();
    }
Example #11
0
 public void turnStart(CharacterSlot slot)
 {
     if (onTurnStart != null)
     {
         onTurnStart(slot);
     }
 }
Example #12
0
    public void ShowCharacter(string nickname, int avartarindex, int accountlevel, int slot)
    {
        GameObject    obj        = Instantiate(_prefabCharacterSlot, _slotObjArr[slot].gameObject.transform);
        CharacterSlot characSlot = obj.GetComponent <CharacterSlot>();

        characSlot.InitSlot(nickname, avartarindex, accountlevel);
    }
Example #13
0
        public void Show(Character character, ItemInstance item, CharacterSlot equipSlot, ItemInstance[] characterItems, bool allowDelete)
        {
            if (character == null)
            {
                return;
            }
            Character = character;
            bool loaded = !string.IsNullOrEmpty(character.Name);

            _item                             = item;
            _characterItems                   = characterItems;
            _menuItemEquipAll.Visible         = _menuItemRemoveFromUpgradeList.Visible = (_characterItems != null);
            _equipSlot                        = equipSlot;
            _menuItemEquip.Enabled            = (Character[equipSlot] != item);
            _menuItemEquip.Visible            = _menuItemEvaluateUpgrade.Visible = _menuItemEquipCustomizedItem.Visible = equipSlot != CharacterSlot.None;
            _menuItemDelete.Enabled           = allowDelete && _menuItemEquip.Enabled && Character.CustomItemInstances.Contains(item);
            _menuItemDeleteDuplicates.Enabled = allowDelete;
            _menuItemName.Text                = item.Item.Name;

            // upgrade is only shown for character already loaded
            _menuSlotUpgradeWowhead.Visible =
                _menuSlotUpgrade.Visible    = loaded;

            this.Show(Control.MousePosition);
        }
    public void Upgrade()
    {
        CharacterSlot characterSlot = characterSlotList.getCurrentSlot();

        if (characterSlot != null)
        {
            if (CharacterInfomationUI.instance != null)
            {
                if (characterSlot.CHARACTER.AddLevel(1))
                {
                    CharacterInfomationUI.instance.UpdateHeroUI(characterSlot.CHARACTER);
                    characterSlotList.SetupData();
                    ICharacterManager ICharacter = DIContainer.GetModule <ICharacterManager>();
                    ICharacter.SaveCharacterIntoPlayerPrefX();
                }
                else
                {
                    if (PopupFactory.instance != null)
                    {
                        PopupFactory.instance.ShowPopup(BasePopup.TypeOfPopup.PO_Character);
                    }
                }
            }
        }
    }
Example #15
0
 public virtual void cast(CharacterSlot caster, CharacterSlot target, StatusEffectSlot slot)
 {
     if (isCastValid(caster, target))
     {
         skillEffects.cast(caster, target, slot);
     }
 }
Example #16
0
    public virtual bool isCastValid(CharacterSlot caster, CharacterSlot target)
    {
        for (int i = restrictions.Count - 1; i > -1; i--)
        {
            if (caster.tags.Contains(restrictions[i]))
            {
                Debug.Log("Skill could not be cast due to restriction(s).");
                return(false);
            }
        }
        for (int i = requirements.Count - 1; i > -1; i--)
        {
            if (!caster.tags.Contains(requirements[i]))
            {
                Debug
                .Log("Skill could not be cast due to missing requirement(s)");
                return(false);
            }
        }
        if (!scope.isTargetValid(caster, target))
        {
            return(false);
        }

        return(true);
    }
Example #17
0
        void ItemCache_ItemsChanged(object sender, EventArgs e)
        {
            CharacterSlot characterSlot = _characterSlot;

            _characterSlot = CharacterSlot.None;
            LoadItemsBySlot(characterSlot);
        }
Example #18
0
    public override void Drop(Draggable newDraggable, bool ignoreEnabled = false)
    {
        if (!isEnabled && !ignoreEnabled)
        {
            return;
        }

        CharacterSlot otherSlot = newDraggable.slot;

        if (otherSlot != null)
        {
            otherSlot.draggable = draggable;
        }

        if (draggable != null)
        {
            draggable.AssignSlot(otherSlot);
        }

        draggable = newDraggable;
        newDraggable.AssignSlot(this);

        UpdateCharacter();
        if (otherSlot != null)
        {
            otherSlot.UpdateCharacter();
        }
    }
Example #19
0
 public void cast(
     CharacterSlot caster,
     CharacterSlot target,
     List <float> values
     )
 {
 }
Example #20
0
        public void LoadCurrentGearEnchantsBuffs(CharacterCalculationsBase currentCalculations)
        {
            List <ComparisonCalculationBase> itemCalculations = new List <ComparisonCalculationBase>();

            if (Character != null)
            {
                foreach (CharacterSlot slot in Enum.GetValues(typeof(CharacterSlot)))
                {
                    if (Character[slot] != null)
                    {
                        itemCalculations.Add(Calculations.GetItemCalculations(Character[slot], Character, slot));
                    }
                }

                foreach (ComparisonCalculationBase calc in Calculations.GetEnchantCalculations(ItemSlot.None, Character, currentCalculations, true))
                {
                    itemCalculations.Add(calc);
                }

                foreach (ComparisonCalculationBase calc in Calculations.GetBuffCalculations(Character, currentCalculations, "Current"))
                {
                    itemCalculations.Add(calc);
                }
            }

            comparisonGraph1.RoundValues      = true;
            comparisonGraph1.CustomRendered   = false;
            comparisonGraph1.ItemCalculations = itemCalculations.ToArray();
            comparisonGraph1.EquipSlot        = CharacterSlot.None;
            _characterSlot = CharacterSlot.None;
        }
Example #21
0
        public void OnCreateCharacter(IncomingPacket packet)
        {
            CreateCharacter request = new CreateCharacter(packet);

            Account account = ClusterServer.LoginDatabase.Accounts[this.Username];

            Character character = new Character();

            character.CharacterId   = SharpFly_Utility_Library.Database.ClusterDatabase.Queries.Character.Instance.GetNewCharacterId();
            character.Name          = request.CharacterName;
            character.ClusterId     = (uint)ClusterServer.Config.GetSetting("ClusterId");
            character.Skinset       = request.Skinset;
            character.HairStyle     = request.HairStyle;
            character.HairColor     = request.HairColor;
            character.HeadMesh      = request.HeadMesh;
            character.Face          = request.Face;
            character.Gender        = request.Gender;
            character.Strength      = 15;
            character.Stamina       = 15;
            character.Dexterity     = 15;
            character.Intelligence  = 15;
            character.SkillPoints   = 0;
            character.StatPoints    = 0;
            character.Level         = 1;
            character.Experience    = 0;
            character.Map           = 1;
            character.Position      = new SharpFly_Utility_Library.Math.Vector4 <float>(0, 0, 0, 0); // temp
            character.Penya         = 0;
            character.FlyingLevel   = 0;
            character.FlyingExp     = 0;
            character.HP            = 1; // temp
            character.MP            = 1; // temp
            character.Size          = 1;
            character.PvPPoints     = 0;
            character.PKPoints      = 0;
            character.GuildId       = 0;
            character.Bag1TimeLeft  = 0;
            character.Bag2TimeLeft  = 0;
            character.MsgState      = 0;
            character.MotionFlags   = 0;
            character.MovementFlags = 0;
            character.PlayerFlags   = 0;

            CharacterSlot charSlot = new CharacterSlot();

            charSlot.AccountId   = account.Id;
            charSlot.CharacterId = character.CharacterId;
            charSlot.SlotId      = request.Slot;

            // Add character to database
            SharpFly_Utility_Library.Database.ClusterDatabase.Queries.Character.Instance.AddCharacter(character);
            ClusterServer.ClusterDatabase.AddCharacter(character);

            // Add characterslot to database
            SharpFly_Utility_Library.Database.ClusterDatabase.Queries.CharacterSlot.Instance.AddCharacterSlot(charSlot);
            ClusterServer.ClusterDatabase.AddCharacterSlot(charSlot);

            SendCharacterList(0);
        }
Example #22
0
 public override bool ItemFitsInSlot(Item item, Character character, CharacterSlot slot, bool ignoreUnique)
 {
     if (slot == CharacterSlot.OffHand && item.Slot == ItemSlot.OneHand)
     {
         return(false);
     }
     return(base.ItemFitsInSlot(item, character, slot, ignoreUnique));
 }
Example #23
0
 public override bool ItemFitsInSlot(Item item, Character character, CharacterSlot slot, bool ignoreUnique)
 {
     if (slot == CharacterSlot.OffHand && !(item.Type == ItemType.Shield || item.Type == ItemType.None))
     {
         return(false);
     }
     return(base.ItemFitsInSlot(item, character, slot, ignoreUnique));
 }
Example #24
0
 public void AddAllyIncapacitatedListener(CharacterSlot slot, GameObject ally, UnityAction <GameObject> call)
 {
     if (allyIncapacitatedEvents.Count == 0)
     {
         InitPlayerEvents(allyIncapacitatedEvents);
     }
     allyIncapacitatedEvents[slot].AddListener(() => call(ally));
 }
Example #25
0
    public void Flash(PlayerCharacter player, Color color, float time)
    {
        List <CharacterSlot> characterSlots = characterWindow.characterSlots;
        CharacterSlot        characterSlot  = characterSlots.First(x => x.playerCharacter == player);
        Flash flash = characterSlot.GetComponent <Flash>();

        flash.FlashStart(color, time);
    }
Example #26
0
 public void LoadRelativeStatValues()
 {
     comparisonGraph1.RoundValues      = true;
     comparisonGraph1.CustomRendered   = false;
     comparisonGraph1.ItemCalculations = CalculationsBase.GetRelativeStatValues(Character);
     comparisonGraph1.EquipSlot        = CharacterSlot.None;
     _characterSlot = CharacterSlot.None;
 }
Example #27
0
 public void LoadCustomChart(string chartName)
 {
     comparisonGraph1.RoundValues      = true;
     comparisonGraph1.CustomRendered   = false;
     comparisonGraph1.ItemCalculations = Calculations.GetCustomChartData(Character, chartName);
     comparisonGraph1.EquipSlot        = CharacterSlot.None;
     _characterSlot = CharacterSlot.None;
 }
    //캐릭터 슬롯 생성 (초기에 4개 생성 이후 부터는 계산을 통한 업데이트)
    public void CreateCharacterSlot(E_PREPAREBATTLE_CHARCTERTYPE _typeIndex, RectTransform listRectTransform)
    {
        //가지고 있는 캐릭터의 개수에 따라 전체 리스트 크기를 설정
        for (int iList = 0; iList < GameManager.Instance.lDbBasicCharacter.Count; iList++)
        {
            //Contents Adjust
            //전체 크기
            listRectTransform.sizeDelta = new Vector2(listRectTransform.sizeDelta.x, listRectTransform.sizeDelta.y + fCSlotY_Value + fPlusSpacing_Value);
        }
        //Contents의 위치
        listRectTransform.anchoredPosition = new Vector2(listRectTransform.anchoredPosition.x, -(listRectTransform.sizeDelta.y / 2));

        //50개일때 7개
        //해당 타입에 따라 캐릭터 슬롯을 만든다
        //전체 캐릭에 따라 개수를 다르게 생성 하도록 한다
        for (int i = 0; i < 7; i++)
        {
            GameObject cSlot_Obj = characterSlotPool.GetObject();

            cSlot_Obj.name = "CharacterSlot" + i.ToString();
            CharacterSlot cSlot = cSlot_Obj.GetComponent <CharacterSlot> ();
            cSlot.cSlotRect = cSlot_Obj.GetComponent <RectTransform> ();


            //CharacterSlot Init
            cSlot.characterBox_Image.sprite = GameManager.Instance.CharacterBoxImage_List [i];
            cSlot.mDispatchPanel            = mDispatchPanel;
            cSlot.characterHealth_Text.text = GameManager.Instance.GetPlayer().LIST_CHARACTER [i].Health.ToString();
            cSlot.characterLevel_Text.text  = GameManager.Instance.GetPlayer().LIST_CHARACTER [i].Levels.ToString();
            cSlot.characterName_Text.text   = GameManager.Instance.GetPlayer().LIST_CHARACTER [i].C_JobNames;
            cSlot.characterInfo             = GameManager.Instance.GetPlayer().LIST_CHARACTER [i];
            cSlot.cInfoPanel = this;

            //전체 크기
            //listRectTransform.sizeDelta = new Vector2 (listRectTransform.sizeDelta.x, listRectTransform.sizeDelta.y + fCSlotY_Value + fPlusSpacing_Value);
            //Contents의 위치
            //listRectTransform.anchoredPosition = new Vector2 (listRectTransform.anchoredPosition.x, -(listRectTransform.sizeDelta.y / 2));


            //CharacterSlot 추가
            cSlot_Obj.transform.SetParent(togglePanel [(int)_typeIndex].transform.GetChild(1)
                                          .transform.GetChild(0), false);
            RectTransform cSlotObj_Rect = cSlot_Obj.GetComponent <RectTransform> ();

            //캐릭터 각각의 슬롯 위치(Vertical layout  없을 때)

            if (i == 0)
            {
                cSlotObj_Rect.anchoredPosition = new Vector2(0f, (fCSlotY_Pos * (i + 1)) - 10f);
            }
            else
            {
                RectTransform nextElementTrans = listRectTransform.transform.GetChild(i - 1).gameObject.GetComponent <RectTransform> ();
                cSlotObj_Rect.anchoredPosition = new Vector2(0f, ((nextElementTrans.anchoredPosition.y + (fCSlotY_Pos * 2)) - 10f));
            }
        }
        childTotalCount = 7;
    }
Example #29
0
    public void OnSlotSelected(CharacterSlot _slot)
    {
        if (resetMode)
        {
            bool cancel = false;
            if (PlayerData.Instance.characters[resetJoinCharacter - 1] == _slot.cha)
            {
                cancel = true;
            }

            Character exchange      = null;
            int       exchangeIndex = 0;
            for (int i = 0; i < 5; ++i)
            {
                if (i == resetJoinCharacter - 1)
                {
                    continue;
                }
                Character cha = PlayerData.Instance.characters[i];
                if (cha == _slot.cha)
                {
                    exchange      = cha;
                    exchangeIndex = i;
                }
            }

            resetMode           = false;
            topBackground.color = Color.white;
            botBackground.color = Color.white;
            for (int i = 0; i < 5; ++i)
            {
                joinChaBtn[i].interactable = true;
            }

            if (cancel)
            {
                return;
            }

            if (exchange != null)
            {
                Character ori = PlayerData.Instance.characters[resetJoinCharacter - 1];
                PlayerData.Instance.characters[exchangeIndex] = ori;
                joinChaBtn[exchangeIndex].image.sprite        = ori.portrait;
            }
            PlayerData.Instance.characters[resetJoinCharacter - 1] = _slot.cha;
            PlayerData.Instance.SaveData();
            joinChaBtn[resetJoinCharacter - 1].image.sprite = _slot.cha.portrait;
        }
        else
        {
            int lv = PlayerData.Instance.chaLevel[_slot.cha.id - 1];
            purchase.ActiveTrue();
            purchase.slot = _slot;
            purchase.SetContents(_slot.cha.CalculateLevel(lv));
            purchase.Open();
        }
    }
Example #30
0
 public StatusEffectSlot(CharacterSlot _caster, StatusEffect _effect, int _duration, bool _unremovable, bool _lasting, bool _persistance)
 {
     caster       = _caster;
     statusEffect = _effect;
     duration     = _duration;
     unremovable  = _unremovable;
     lasting      = _lasting;
     persistance  = _persistance;
 }
Example #31
0
 public ItemInstance this[CharacterSlot slot]
 {
     get
     {
         int i = (int)slot;
         if (i < 0 || i >= SlotCount) return null;
         return _item[i];
     }
     set
     {
         int i = (int)slot;
         if (i < 0 || i >= SlotCount) return;
         // should we track id changes? for now assume assume we don't have to
         _item[i] = value;
         OnCalculationsInvalidated();
         //if (value == null || _item[i] != value.GemmedId) 
         //{
         //    _item[i] = value != null ? value.GemmedId : null;
         //    if (_itemCached[i] != null && _trackEquippedItemChanges) _itemCached[i].IdsChanged -= new EventHandler(_itemCached_IdsChanged);
         //    _itemCached[i] = value;
         //    if (_itemCached[i] != null && _trackEquippedItemChanges) _itemCached[i].IdsChanged += new EventHandler(_itemCached_IdsChanged);
         //    OnCalculationsInvalidated();
         //}
     }
 }
Example #32
0
        public virtual ComparisonCalculationBase GetItemCalculations(Item additionalItem, Character character, CharacterSlot slot)
        {
            bool useCache = character == _cachedCharacter && slot == _cachedSlot;
            Character characterWithSlotEmpty = null;

            if (!useCache)
                characterWithSlotEmpty = character.Clone();
            Character characterWithNewItem = character.Clone();

            CharacterCalculationsBase characterStatsWithSlotEmpty;
            if (useCache)
                characterStatsWithSlotEmpty = _cachedCharacterStatsWithSlotEmpty;
            else
            {
                characterStatsWithSlotEmpty = GetCharacterCalculations(characterWithSlotEmpty, null, false, false, false);
                _cachedCharacter = character;
                _cachedSlot = slot;
                _cachedCharacterStatsWithSlotEmpty = characterStatsWithSlotEmpty;
            }

            CharacterCalculationsBase characterStatsWithNewItem = GetCharacterCalculations(characterWithNewItem, additionalItem, false, false, false);

            ComparisonCalculationBase itemCalc = CreateNewComparisonCalculation();
            itemCalc.Item = additionalItem;
            itemCalc.Name = additionalItem.Name;
            itemCalc.Equipped = false;
            itemCalc.ImageSource = additionalItem.IconPath;
            itemCalc.OverallPoints = characterStatsWithNewItem.OverallPoints - characterStatsWithSlotEmpty.OverallPoints;
            float[] subPoints = new float[characterStatsWithNewItem.SubPoints.Length];
            for (int i = 0; i < characterStatsWithNewItem.SubPoints.Length; i++)
            {
                subPoints[i] = characterStatsWithNewItem.SubPoints[i] - characterStatsWithSlotEmpty.SubPoints[i];
            }
            itemCalc.SubPoints = subPoints;

            characterStatsWithNewItem.ToString();

            return itemCalc;
        }
Example #33
0
 public static ComparisonCalculationBase GetItemGemCalculations(Item gem, Character character, CharacterSlot slot, int gemIndex)
 {
     return Instance.GetItemGemCalculations(gem, character, slot, gemIndex);
 }
 public override bool ItemFitsInSlot(Item item, Character character, CharacterSlot slot, bool ignoreUnique) {
     if (slot == CharacterSlot.OffHand && item.Type != ItemType.Shield) return false;
     return base.ItemFitsInSlot(item, character, slot, ignoreUnique);
 }
Example #35
0
 public static List<ComparisonCalculationBase> GetReforgeCalculations(CharacterSlot slot, Character character, CharacterCalculationsBase currentCalcs, bool equippedOnly)
 {
     return Instance.GetReforgeCalculations(slot, character, currentCalcs, equippedOnly);
 }
Example #36
0
 public virtual void ClearCache()
 {
     _cachedCharacterStatsWithSlotEmpty = null;
     _cachedCharacterStatsWithGemSlotEmpty = null;
     _cachedCharacterStatsWithAllSlotsEmpty = null;
     _cachedCharacter = null;
     _cachedSlot = CharacterSlot.Shirt;
     _cachedGemIndex = 0;
 }
Example #37
0
 public Tinkering GetTinkeringBySlot(CharacterSlot slot)
 {
     ItemInstance item = this[slot];
     if ((object)item == null) return null;
     return item.Tinkering;
 }
Example #38
0
 public bool IsEquipped(Item itemToBeChecked, CharacterSlot slot)
 {
     return (object)this[slot] != null && itemToBeChecked.Id == this[slot].Id;
 }
Example #39
0
 public Enchant GetEnchantBySlot(CharacterSlot slot)
 {
     ItemInstance item = this[slot];
     if ((object)item == null) return null;
     return item.Enchant;
 }
Example #40
0
 public bool IsEquipped(ItemInstance itemToBeChecked, CharacterSlot slot)
 {
     return itemToBeChecked == this[slot];
 }
Example #41
0
 public List<Item> GetRelevantItems(CharacterSlot slot, ItemSlot gemColour)
 {
     List<Item> items;
     if (!_relevantItems.TryGetValue(slot, out items))
     {
         items = new List<Item>();
         foreach (Item item in ItemCache.RelevantItems)
         {
             if (item.FitsInSlot(slot, this))
             {
                 if(!item.IsJewelersGem || !Rawr.Properties.GeneralSettings.Default.HideProfEnchants ||
                    (item.IsJewelersGem && this.HasProfession(Profession.Jewelcrafting)))
                 {
                     if ((gemColour == ItemSlot.None) ||
                         (gemColour == ItemSlot.Red && item.IsRedGem) ||
                         (gemColour == ItemSlot.Yellow && item.IsYellowGem) ||
                         (gemColour == ItemSlot.Blue && item.IsBlueGem) ||
                         (gemColour == ItemSlot.Cogwheel && item.IsCogwheel) ||
                         (gemColour == ItemSlot.Hydraulic && item.IsHydraulic))
                     {
                         items.Add(item);
                     }
                 }
             }
         }
         _relevantItems[slot] = items;
     }
     return items;
 }
Example #42
0
        public virtual ComparisonCalculationBase GetItemGemCalculations(Item gem, Character character, CharacterSlot slot, int gemIndex)
        {
            if (gemIndex == 0)
            {
                return GetItemCalculations(gem, character, CharacterSlot.Gems);
            }
            bool useCache = character == _cachedCharacter && slot == _cachedSlot && gemIndex == _cachedGemIndex;
            Character characterWithGemSlotEmpty = null;

            if (!useCache)
                characterWithGemSlotEmpty = character.Clone();
            Character characterWithNewGem = character.Clone();

            if (!useCache)
            {
                ItemInstance emptyItemInstance = characterWithGemSlotEmpty[slot];
                if (emptyItemInstance != null)
                {
                    emptyItemInstance = emptyItemInstance.Clone();
                    emptyItemInstance.SetGem(gemIndex, null);
                    characterWithGemSlotEmpty[slot] = emptyItemInstance;
                }
            }
            ItemInstance newItemInstance = characterWithNewGem[slot];
            if (newItemInstance != null)
            {
                newItemInstance = newItemInstance.Clone();
                newItemInstance.SetGem(gemIndex, gem);
                characterWithNewGem[slot] = newItemInstance;
            }

            CharacterCalculationsBase characterStatsWithGemSlotEmpty;
            if (useCache && _cachedCharacterStatsWithGemSlotEmpty != null)
                characterStatsWithGemSlotEmpty = _cachedCharacterStatsWithGemSlotEmpty;
            else
            {
                characterStatsWithGemSlotEmpty = GetCharacterCalculations(characterWithGemSlotEmpty, null, false, false, false);
                _cachedCharacter = character;
                _cachedSlot = slot;
                _cachedGemIndex = gemIndex;
                _cachedCharacterStatsWithGemSlotEmpty = characterStatsWithGemSlotEmpty;
            }

            CharacterCalculationsBase characterStatsWithNewGem = GetCharacterCalculations(characterWithNewGem,
                (Properties.GeneralSettings.Default.ShowRelativeToEquipped ? character[slot].Item : null),
                false, false, false);

            ComparisonCalculationBase itemCalc = CreateNewComparisonCalculation();
            itemCalc.Item = gem;
            itemCalc.Name = gem != null ? gem.Name : string.Empty;
            itemCalc.Equipped = (character[slot] != null && character[slot].GetGem(gemIndex) == gem);
            itemCalc.OverallPoints = characterStatsWithNewGem.OverallPoints - characterStatsWithGemSlotEmpty.OverallPoints;
            float[] subPoints = new float[characterStatsWithNewGem.SubPoints.Length];
            for (int i = 0; i < characterStatsWithNewGem.SubPoints.Length; i++)
            {
                subPoints[i] = characterStatsWithNewGem.SubPoints[i] - characterStatsWithGemSlotEmpty.SubPoints[i];
            }
            itemCalc.SubPoints = subPoints;

            characterStatsWithNewGem.ToString();

            return itemCalc;
        }
Example #43
0
 /// <summary>
 /// A Function to convert the item from a specific slot into it's string form with gemming info.
 /// If the specified slot is empty this function will return an empty string.
 /// </summary>
 /// <param name="slot">The Slot to pull from.</param>
 /// <returns>ItemId.RandomSuffixId.Gem1.Gem2.Gem3.EnchantId.ReforgeId.TinkeringId
 /// <br />56278.0.52291.52219.0.4208.89.0</returns>
 private string GetGemmedId(CharacterSlot slot)
 {
     ItemInstance item = this[slot];
     if ((object)item == null) return null;
     return item.GemmedId;
 }
Example #44
0
 public Reforging GetReforgingBySlot(CharacterSlot slot)
 {
     ItemInstance item = this[slot];
     if ((object)item == null) return null;
     return item.Reforging;
 }
Example #45
0
 /// <summary>
 /// A Function to take an item in it's Gemmed string form and set character's slot to that.
 /// </summary>
 /// <param name="slot">The Slot to set</param>
 /// <param name="gemmedId">The string gemmed id to put into the slot</param>
 private void SetGemmedId(CharacterSlot slot, string gemmedId)
 {
     if (string.IsNullOrEmpty(gemmedId)) _item[(int)slot] = null;
     else _item[(int)slot] = new ItemInstance(gemmedId); // don't call invalidations all the time while loading character
 }
Example #46
0
 public bool IsEnchantable(CharacterSlot slot)
 {
     switch (slot)
     {
         case CharacterSlot.Head:
         case CharacterSlot.Shoulders:
         case CharacterSlot.Back:
         case CharacterSlot.Chest:
         case CharacterSlot.Wrist:
         case CharacterSlot.Hands:
         case CharacterSlot.Legs:
         case CharacterSlot.Feet:
         case CharacterSlot.Finger1:
         case CharacterSlot.Finger2:
         case CharacterSlot.MainHand:
         case CharacterSlot.OffHand:
         case CharacterSlot.Ranged:
             return true;
         default:
             return false;
     }
 }
Example #47
0
        public virtual ComparisonCalculationBase GetItemCalculations(ItemInstance item, Character character, CharacterSlot slot)
        {
            // Check if the last iteration has the same character and is in the same slot.
            // If it is, we'll use the same characterWithSlotEmpty to save processing time
            bool useCache = character == _cachedCharacter && slot == _cachedSlot;
            Character characterWithSlotEmpty = null;

            if (!useCache)
                characterWithSlotEmpty = character.Clone();
            Character characterWithNewItem = character.Clone();

            if (slot != CharacterSlot.Metas && slot != CharacterSlot.Gems
                && slot != CharacterSlot.Cogwheels && slot != CharacterSlot.Hydraulics)
            {
                // Show Relative to Equipped makes the Base version character with the original item value 0
                // and every other calc relative to that
                if (!useCache) characterWithSlotEmpty[slot] = (Properties.GeneralSettings.Default.ShowRelativeToEquipped && character[slot] != null ? character[slot].Clone() : null);
                characterWithNewItem[slot] = item;
            }

            CharacterCalculationsBase characterStatsWithSlotEmpty;
            if (useCache && _cachedCharacterStatsWithSlotEmpty != null)
                characterStatsWithSlotEmpty = _cachedCharacterStatsWithSlotEmpty;
            else
            {
                characterStatsWithSlotEmpty = GetCharacterCalculations(characterWithSlotEmpty,
                    null,
                    false, false, false);
                _cachedCharacter = character;
                _cachedSlot = slot;
                _cachedCharacterStatsWithSlotEmpty = characterStatsWithSlotEmpty;
            }

            CharacterCalculationsBase characterStatsWithNewItem = GetCharacterCalculations(characterWithNewItem, null, false, false, false);

            ComparisonCalculationBase itemCalc = CreateNewComparisonCalculation();
            itemCalc.ItemInstance = item;
            itemCalc.Item = item.Item;
            itemCalc.Name = item.Name;
            itemCalc.Equipped = character[slot] == item;
            itemCalc.OverallPoints = characterStatsWithNewItem.OverallPoints - characterStatsWithSlotEmpty.OverallPoints;
            float[] subPoints = new float[characterStatsWithNewItem.SubPoints.Length];
            for (int i = 0; i < characterStatsWithNewItem.SubPoints.Length; i++)
            {
                subPoints[i] = characterStatsWithNewItem.SubPoints[i] - characterStatsWithSlotEmpty.SubPoints[i];
            }
            itemCalc.SubPoints = subPoints;

            characterStatsWithNewItem.ToString();

            return itemCalc;
        }
Example #48
0
 public bool IsTinkeringable(CharacterSlot slot)
 {
     switch (slot)
     {
         case CharacterSlot.Back:
         case CharacterSlot.Hands:
         case CharacterSlot.Waist:
             return true;
         default:
             return false;
     }
 }
Example #49
0
 public static bool ItemFitsInSlot(Item item, Character character, CharacterSlot slot, bool ignoreUnique)
 {
     if (Instance != null)
         return Instance.ItemFitsInSlot(item, character, slot, ignoreUnique);
     return false;
 }
Example #50
0
 public void SetReforgingBySlot(CharacterSlot slot, Reforging reforge)
 {
     int i = (int)slot;
     if (i < 0 || i >= SlotCount) return;
     ItemInstance item = this[slot];
     if ((object)item != null) item.Reforging = reforge;
     OnCalculationsInvalidated();
 }
Example #51
0
 public virtual bool ItemFitsInSlot(Item item, Character character, CharacterSlot slot, bool ignoreUnique)
 {
     if (item != null && item.Unique && !ignoreUnique)
     {
         CharacterSlot otherSlot;
         switch (slot)
         {
             case CharacterSlot.Finger1:
                 otherSlot = CharacterSlot.Finger2;
                 break;
             case CharacterSlot.Finger2:
                 otherSlot = CharacterSlot.Finger1;
                 break;
             case CharacterSlot.Trinket1:
                 otherSlot = CharacterSlot.Trinket2;
                 break;
             case CharacterSlot.Trinket2:
                 otherSlot = CharacterSlot.Trinket1;
                 break;
             case CharacterSlot.MainHand:
                 otherSlot = CharacterSlot.OffHand;
                 break;
             case CharacterSlot.OffHand:
                 otherSlot = CharacterSlot.MainHand;
                 break;
             default:
                 otherSlot = CharacterSlot.None;
                 break;
         }
         if (otherSlot != CharacterSlot.None)
         {
             if (character[otherSlot] != null && (item.Id == character[otherSlot].Item.Id || (item.UniqueId != null && item.UniqueId.Contains(character[otherSlot].Id)))) return false;
         }
     }
     return item.FitsInSlot(slot);
 }
Example #52
0
 public void SetEnchantBySlot(CharacterSlot slot, Enchant enchant)
 {
     int i = (int)slot;
     if (i < 0 || i >= SlotCount) return;
     ItemInstance item = this[slot];
     if ((object)item != null) item.Enchant = enchant;
     OnCalculationsInvalidated();
 }
Example #53
0
 public static ComparisonCalculationBase GetItemCalculations(Item item, Character character, CharacterSlot slot)
 {
     return Instance.GetItemCalculations(item, character, slot);
 }
Example #54
0
 public void SetTinkeringBySlot(CharacterSlot slot, Tinkering tinkering)
 {
     int i = (int)slot;
     if (i < 0 || i >= SlotCount) return;
     ItemInstance item = this[slot];
     if ((object)item != null) item.Tinkering = tinkering;
     OnCalculationsInvalidated();
 }
Example #55
0
 public List<Item> GetRelevantItems(CharacterSlot slot) { return GetRelevantItems(slot, ItemSlot.None); }
Example #56
0
        private void UpdateGraphAvailable(string subgraph)
        {
            SetGraphControl(ComparisonGraph);
            CGL_Legend.LegendItems = Calculations.SubPointNameColors;
            ComparisonGraph.LegendItems = Calculations.SubPointNameColors;
            ComparisonGraph.Mode = ComparisonGraph.DisplayMode.Subpoints;
            List<ComparisonCalculationBase> itemCalculations = new List<ComparisonCalculationBase>();

            List<ItemInstance> availableGear = new List<ItemInstance>();
            List<Item> availableEnchants = new List<Item>();
            List<Item> availableTinkerings = new List<Item>();

            foreach (string availableItem in Character.AvailableItems)
            {
                ItemInstance ii = null;
                if ((ii = new ItemInstance(availableItem)) != null) {
                    if (ii.Id > 0 && (subgraph == "Gear" || subgraph == "All")) {
                        availableGear.Add(ii);
                    } else if (ii.Id < -1000000 && (subgraph == "Tinkerings" || subgraph == "All")) {
                        ii.Id *= -1;
                        int slot = int.Parse(ii.Id.ToString().Substring(0, 2));
                        if (slot > (int)ItemSlot.Ranged) slot /= 10;
                        ii.Id -= slot * (int)AvailableItemIDModifiers.Tinkerings;
                        Tinkering temp = Tinkering.FindTinkering(ii.Id, (ItemSlot)slot, Character);

                        Item tink = new Item(string.Format("{0} ({1})", temp.Name, (ItemSlot)slot), ItemQuality.Temp, ItemType.None,
                            -1 * (temp.Id + ((int)AvailableItemIDModifiers.Tinkerings * (int)temp.Slot)), null, ItemSlot.None, null,
                            false, temp.Stats, null, ItemSlot.None, ItemSlot.None, ItemSlot.None,
                            0, 0, ItemDamageType.Physical, 0, null);

                        availableTinkerings.Add(tink);
                    } else if (ii.Id < 0 && (subgraph == "Enchants" || subgraph == "All")) {
                        ii.Id *= -1;
                        int slot = int.Parse(ii.Id.ToString().Substring(0, 2));
                        if (slot > (int)ItemSlot.Ranged) slot /= 10;
                        ii.Id -= slot * (int)AvailableItemIDModifiers.Enchants;
                        Enchant temp = Enchant.FindEnchant(ii.Id, (ItemSlot)slot, Character);

                        Item ench = new Item(string.Format("{0} ({1})", temp.Name, (ItemSlot)slot), ItemQuality.Temp, ItemType.None,
                            -1 * (temp.Id + ((int)AvailableItemIDModifiers.Enchants * (int)temp.Slot)), null, ItemSlot.None, null,
                            false, temp.Stats, null, ItemSlot.None, ItemSlot.None, ItemSlot.None,
                            0, 0, ItemDamageType.Physical, 0, null);

                        availableEnchants.Add(ench);
                    }
                }
            }

            if (subgraph == "Gear" || subgraph == "All")
            {
                CharacterSlot[] slots = new CharacterSlot[]
                {
                     CharacterSlot.Back, CharacterSlot.Chest, CharacterSlot.Feet, CharacterSlot.Finger1,
                     CharacterSlot.Finger2, CharacterSlot.Hands, CharacterSlot.Head, CharacterSlot.Legs,
                     CharacterSlot.MainHand, CharacterSlot.Neck, CharacterSlot.OffHand, /*CharacterSlot.Projectile,
                     CharacterSlot.ProjectileBag,*/ CharacterSlot.Ranged, CharacterSlot.Shoulders,
                     CharacterSlot.Trinket1, CharacterSlot.Trinket2, CharacterSlot.Waist, CharacterSlot.Wrist
                };
                foreach (ItemInstance item in availableGear)
                {
                    if (item != null)
                    {
                        itemCalculations.Add(Calculations.GetItemCalculations(item, Character, Character.GetCharacterSlotByItemSlot(item.Slot)));

                        ItemSlot islot = item.Slot;
                        CharacterSlot PriSlot = Character.GetCharacterSlotByItemSlot(islot), AltSlot;
                        if (islot == ItemSlot.Finger ) { AltSlot = CharacterSlot.Finger2; }
                        else if (islot == ItemSlot.Trinket) { AltSlot = CharacterSlot.Trinket2; }
                        else if (islot == ItemSlot.TwoHand) { AltSlot = CharacterSlot.OffHand; }
                        else if (islot == ItemSlot.OneHand) { AltSlot = CharacterSlot.OffHand; }
                        else { AltSlot = PriSlot; }

                        if      (                      Character[PriSlot] != null && Character[PriSlot].Id == item.Id) { itemCalculations[itemCalculations.Count - 1].PartEquipped = true; }
                        else if (AltSlot != PriSlot && Character[AltSlot] != null && Character[AltSlot].Id == item.Id) { itemCalculations[itemCalculations.Count - 1].PartEquipped = true; }
                    }
                }
            }
            if (subgraph == "Enchants" || subgraph == "All")
            {
                ItemSlot[] slots = new ItemSlot[]
                {
                     ItemSlot.Back, ItemSlot.Chest, ItemSlot.Feet, ItemSlot.Finger,
                     ItemSlot.Hands, ItemSlot.Head, ItemSlot.Legs,
                     ItemSlot.MainHand, ItemSlot.OffHand, ItemSlot.Ranged, ItemSlot.Shoulders,
                     ItemSlot.Waist, ItemSlot.Wrist
                };
                foreach (ItemSlot slot in slots)
                {
                    foreach (ComparisonCalculationBase calc in Calculations.GetEnchantCalculations(slot, Character, Calculations.GetCharacterCalculations(Character), false, true))
                    {
                        foreach(Item item in availableEnchants) {
                            if (calc.Item.Id == item.Id) {
                                itemCalculations.Add(calc);
                                break;
                            }
                        }
                    }
                }
            }
            if (subgraph == "Tinkerings" || subgraph == "All")
            {
                ItemSlot[] slots = new ItemSlot[]
                {
                     ItemSlot.Back, ItemSlot.Hands, ItemSlot.Waist,
                };
                foreach (ItemSlot slot in slots)
                {
                    foreach (ComparisonCalculationBase calc in Calculations.GetTinkeringCalculations(slot, Character, Calculations.GetCharacterCalculations(Character), false, true))
                    {
                        foreach (Item item in availableTinkerings)
                        {
                            if (calc.Item.Id == item.Id)
                            {
                                itemCalculations.Add(calc);
                                break;
                            }
                        }
                    }
                }
            }
            // Now Push the results to the screen
            ComparisonGraph.DisplayCalcs(_itemCalculations = itemCalculations.ToArray());
        }
Example #57
0
        private void UpdateGraphEquipped(string subgraph)
        {
            SetGraphControl(ComparisonGraph);
            CGL_Legend.LegendItems = Calculations.SubPointNameColors;
            ComparisonGraph.LegendItems = Calculations.SubPointNameColors;
            ComparisonGraph.Mode = ComparisonGraph.DisplayMode.Subpoints;
            List<ComparisonCalculationBase> itemCalculations = new List<ComparisonCalculationBase>();

            if (subgraph == "Gear" || subgraph == "All")
            {
                CharacterSlot[] slots = new CharacterSlot[]
                {
                     CharacterSlot.Back, CharacterSlot.Chest, CharacterSlot.Feet, CharacterSlot.Finger1,
                     CharacterSlot.Finger2, CharacterSlot.Hands, CharacterSlot.Head, CharacterSlot.Legs,
                     CharacterSlot.MainHand, CharacterSlot.Neck, CharacterSlot.OffHand, /*CharacterSlot.Projectile,
                     CharacterSlot.ProjectileBag,*/ CharacterSlot.Ranged, CharacterSlot.Shoulders,
                     CharacterSlot.Trinket1, CharacterSlot.Trinket2, CharacterSlot.Waist, CharacterSlot.Wrist
                };
                foreach (CharacterSlot slot in slots)
                {
                    ItemInstance item = Character[slot];
                    if (item != null)
                    {
                        itemCalculations.Add(Calculations.GetItemCalculations(item, Character, slot));
                    }
                }
            }
            if (subgraph == "Enchants" || subgraph == "All")
            {
                ItemSlot[] slots = new ItemSlot[]
                {
                     ItemSlot.Back, ItemSlot.Chest, ItemSlot.Feet, ItemSlot.Finger,
                     ItemSlot.Hands, ItemSlot.Head, ItemSlot.Legs,
                     ItemSlot.MainHand, ItemSlot.OffHand, ItemSlot.Ranged, ItemSlot.Shoulders,
                     ItemSlot.Waist, ItemSlot.Wrist
                };
                
                foreach (ItemSlot slot in slots)
                    foreach (ComparisonCalculationBase calc in Calculations.GetEnchantCalculations(slot, Character, Calculations.GetCharacterCalculations(Character), true))
                        itemCalculations.Add(calc);
            }
            if (subgraph == "Tinkerings" || subgraph == "All")
            {
                ItemSlot[] slots = new ItemSlot[]
                {
                     ItemSlot.Back, ItemSlot.Hands, ItemSlot.Waist,
                };
                foreach (ItemSlot slot in slots)
                    foreach (ComparisonCalculationBase calc in Calculations.GetTinkeringCalculations(slot, Character, Calculations.GetCharacterCalculations(Character), true))
                        itemCalculations.Add(calc);
            }
            if (subgraph == "Buffs" || subgraph == "All")
            {
                itemCalculations.AddRange(Calculations.GetBuffCalculations(Character, Calculations.GetCharacterCalculations(Character), ConvertBuffSelector("Current")));
                ComparisonGraph.DisplayCalcs(itemCalculations.ToArray());
            }
            // Now Push the results to the screen
            ComparisonGraph.DisplayCalcs(_itemCalculations = itemCalculations.ToArray());
        }
Example #58
0
 public void InvalidateItemInstances(CharacterSlot slot)
 {
     _relevantItemInstances.Remove(slot);
 }
Example #59
0
        private void UpdateGraphGear(string subgraph)
        {
            SetGraphControl(ComparisonGraph);
            List<ComparisonCalculationBase> itemCalculations = new List<ComparisonCalculationBase>();
#if DEBUG
            DateTime start;
#endif
            Dictionary<CharacterSlot, bool> slots;

            // Determine which chart we are looking for. All will have the whole list, specific will just have that slot in the list
            if (subgraph == "All (This is Slow to Calc)") {
                // Run All Slots
                slots = new Dictionary<CharacterSlot, bool>() {
                     {CharacterSlot.Back, Character[CharacterSlot.Back] == null},
                     {CharacterSlot.Chest, Character[CharacterSlot.Chest] == null},
                     {CharacterSlot.Feet, Character[CharacterSlot.Feet] == null},
                     {CharacterSlot.Finger1, Character[CharacterSlot.Finger1] == null},
                     {CharacterSlot.Finger2, Character[CharacterSlot.Finger2] == null},
                     {CharacterSlot.Hands, Character[CharacterSlot.Hands] == null},
                     {CharacterSlot.Head, Character[CharacterSlot.Head] == null},
                     {CharacterSlot.Legs, Character[CharacterSlot.Legs] == null},
                     {CharacterSlot.MainHand, Character[CharacterSlot.MainHand] == null},
                     {CharacterSlot.Neck, Character[CharacterSlot.Neck] == null},
                     {CharacterSlot.OffHand, Character[CharacterSlot.OffHand] == null},
                     {CharacterSlot.Ranged, Character[CharacterSlot.Ranged] == null},
                     {CharacterSlot.Shoulders, Character[CharacterSlot.Shoulders] == null},
                     {CharacterSlot.Trinket1, Character[CharacterSlot.Trinket1] == null},
                     {CharacterSlot.Trinket2, Character[CharacterSlot.Trinket2] == null},
                     {CharacterSlot.Waist, Character[CharacterSlot.Waist] == null},
                     {CharacterSlot.Wrist, Character[CharacterSlot.Wrist] == null},
                     //{CharacterSlot.Projectile, Character[CharacterSlot.Projectile] == null},
                     //{CharacterSlot.ProjectileBag, Character[CharacterSlot.ProjectileBag] == null},
                };
            } else {
                _characterSlot = (CharacterSlot)Enum.Parse(typeof(CharacterSlot), subgraph.Replace(" ", ""), true);
                ComparisonGraph.Slot = _characterSlot;
                slots = new Dictionary<CharacterSlot, bool>() {
                    {_characterSlot, Character[_characterSlot] == null},
                };
            }

            // Set up Calculation list with everything we are going to put in it
            Calculations.ClearCache();
            List<ItemInstance> relevantItemInstances = new List<ItemInstance>();
            try {
                foreach(CharacterSlot s in slots.Keys) {
                    relevantItemInstances.AddRange(Character.GetRelevantItemInstances(s));
                }
            } catch (Exception) { relevantItemInstances = new List<ItemInstance>(); }
            // Give us fresh values for the thread safety checks
            _itemCalculations = new ComparisonCalculationBase[relevantItemInstances.Count];
            _calculationCount = 0;
            _autoResetEvent = new AutoResetEvent(false);

#if DEBUG
            System.Diagnostics.Debug.WriteLine("Starting Comparison Calculations");
            start = DateTime.Now;
#endif
            if (relevantItemInstances.Count > 0) {
                foreach (ItemInstance item in relevantItemInstances) {
                    ItemSlot islot = item.Slot;
                    CharacterSlot PriSlot = Character.GetCharacterSlotByItemSlot(islot), AltSlot;
                    if (islot == ItemSlot.Finger ) { AltSlot = CharacterSlot.Finger2; }
                    else if (islot == ItemSlot.Trinket) { AltSlot = CharacterSlot.Trinket2; }
                    else if (islot == ItemSlot.TwoHand) { AltSlot = CharacterSlot.OffHand; }
                    else if (islot == ItemSlot.OneHand) { AltSlot = CharacterSlot.OffHand; }
                    else { AltSlot = PriSlot; }
                    if      (                      slots.Keys.Contains(PriSlot) && !slots[PriSlot] && Character[PriSlot].Equals(item)) { slots[PriSlot] = true; }
                    else if (AltSlot != PriSlot && slots.Keys.Contains(AltSlot) && !slots[AltSlot] && Character[AltSlot].Equals(item)) { slots[AltSlot] = true; }
                    ThreadPool.QueueUserWorkItem(GetItemInstanceCalculations, item);
                }
                _autoResetEvent.WaitOne();
            }
#if DEBUG
            System.Diagnostics.Debug.WriteLine("Finished Comparison Calculations: Total " + DateTime.Now.Subtract(start).TotalMilliseconds.ToString() + "ms");
#endif

            List<ComparisonCalculationBase> listItemCalculations = new List<ComparisonCalculationBase>(_itemCalculations);
            foreach(CharacterSlot s in slots.Keys) {
                if (!slots[s]) {
                    listItemCalculations.Add(Calculations.GetItemCalculations(Character[s], Character, _characterSlot));
                }
            }
            _itemCalculations = FilterTopXGemmings(listItemCalculations);

            CGL_Legend.LegendItems = Calculations.SubPointNameColors;
            ComparisonGraph.LegendItems = Calculations.SubPointNameColors;
            ComparisonGraph.Mode = ComparisonGraph.DisplayMode.Subpoints;
            ComparisonGraph.DisplayCalcs(_itemCalculations);
        }
Example #60
0
 public List<ItemInstance> GetRelevantItemInstances(CharacterSlot slot, bool forceAll=false)
 {
     bool blacksmithingSocket = false;
     if ((slot == CharacterSlot.Waist && WaistBlacksmithingSocketEnabled)
         || (slot == CharacterSlot.Hands && HandsBlacksmithingSocketEnabled)
         || (slot == CharacterSlot.Wrist && WristBlacksmithingSocketEnabled))
     {
         blacksmithingSocket = true;
     }
     List<ItemInstance> items;
     if (!_relevantItemInstances.TryGetValue(slot, out items))
     {
         Dictionary<int, bool> itemChecked = new Dictionary<int, bool>();
         items = new List<ItemInstance>();
         foreach (Item item in (forceAll ? ItemCache.AllItems : ItemCache.RelevantItems))
         {
             if (item.FitsInSlot(slot, this) && item.FitsFaction(Race))
             {
                 itemChecked[item.Id] = true;
                 List<int> suffixList;
                 if (item.AllowedRandomSuffixes == null || item.AllowedRandomSuffixes.Count == 0) {
                     suffixList = zeroSuffixList;
                 } else {
                     suffixList = item.AllowedRandomSuffixes;
                 }
                 foreach (int randomSuffix in suffixList)
                 {
                     foreach (Reforging reforging in CurrentCalculations.GetReforgingOptions(item, randomSuffix))
                     {
                         List<Tinkering> t = CurrentCalculations.GetTinkeringOptions(item, this);
                         foreach (Tinkering tinkering in t)
                         {
                             List<Enchant> e = CurrentCalculations.GetEnchantingOptions(item, this);
                             foreach (Enchant enchant in e)
                             {
                                 List<ItemInstance> itemInstances = new List<ItemInstance>();
                                 // Built in Gemming Templates
                                 foreach (GemmingTemplate template in CurrentGemmingTemplates)
                                 {
                                     if (template.Enabled)
                                     {
                                         ItemInstance instance = template.GetItemInstance(item, randomSuffix, enchant/*GetEnchantBySlot(slot)*/, reforging, tinkering/*GetTinkeringBySlot(slot)*/, blacksmithingSocket);
                                         if (!itemInstances.Contains(instance)) itemInstances.Add(instance);
                                     }
                                 }
                                 // Gemming Templates the User added
                                 foreach (GemmingTemplate template in CustomGemmingTemplates)
                                 {
                                     if (template.Enabled && template.Model == CurrentModel)
                                     {
                                         ItemInstance instance = template.GetItemInstance(item, randomSuffix, enchant/*GetEnchantBySlot(slot)*/, reforging, tinkering/*GetTinkeringBySlot(slot)*/, blacksmithingSocket);
                                         if (!itemInstances.Contains(instance)) itemInstances.Add(instance);
                                     }
                                 }
                                 items.AddRange(itemInstances);
                             }
                         }
                     }
                 }
             }
         }
         // add custom instances
         foreach (ItemInstance item in CustomItemInstances)
         {
             if (item.Item != null && item.Item.FitsInSlot(slot, this)) // item.Item can be null if you're loading character with custom items that are not present on this install
             {
                 // if it's already in make sure to set force visible to true
                 int index = items.IndexOf(item);
                 if (index >= 0)
                 {
                     items[index] = item;
                 }
                 else
                 {
                     items.Add(item);
                 }
             }
         }
         // add available instances (green diamonds)
         foreach (string availableItem in AvailableItems)
         {
             string[] ids = availableItem.Split('.');
             if (ids.Length <= 2)
             {
                 // we have an available item that might be filtered out
                 Item item = ItemCache.FindItemById(int.Parse(ids[0], System.Globalization.CultureInfo.InvariantCulture));
                 if (item != null)
                 {
                     if (item.FitsInSlot(slot, this))
                     {
                         if (itemChecked.ContainsKey(item.Id))
                         {
                             // we've already processed this one
                             continue;
                         }
                         Enchant enchant = GetEnchantBySlot(slot);
                         Tinkering tinkering = GetTinkeringBySlot(slot);
                         List<ItemInstance> itemInstances = new List<ItemInstance>();
                         int randomSuffix = ids.Length < 2 ? 0 : int.Parse(ids[1], System.Globalization.CultureInfo.InvariantCulture);
                         foreach (Reforging reforging in CurrentCalculations.GetReforgingOptions(item, randomSuffix))
                         {
                             foreach (GemmingTemplate template in CurrentGemmingTemplates)
                             {
                                 if (template.Enabled)
                                 {
                                     ItemInstance instance = template.GetItemInstance(item, randomSuffix, GetEnchantBySlot(slot), reforging, GetTinkeringBySlot(slot), blacksmithingSocket);
                                     if (!itemInstances.Contains(instance)) itemInstances.Add(instance);
                                 }
                             }
                             foreach (GemmingTemplate template in CustomGemmingTemplates)
                             {
                                 if (template.Enabled && template.Model == CurrentModel)
                                 {
                                     ItemInstance instance = template.GetItemInstance(item, randomSuffix, GetEnchantBySlot(slot), reforging, GetTinkeringBySlot(slot), blacksmithingSocket);
                                     if (!itemInstances.Contains(instance)) itemInstances.Add(instance);
                                 }
                             }
                         }
                         items.AddRange(itemInstances);
                     }
                     itemChecked[item.Id] = true;
                 }
             }
         }
         // add available instances (blue diamonds)
         foreach (string availableItem in AvailableItems)
         {
             string[] ids = availableItem.Split('.');
             if (ids.Length == 8) // only support new format with random suffixes
             {
                 Item item = ItemCache.FindItemById(int.Parse(ids[0], System.Globalization.CultureInfo.InvariantCulture));
                 if (item.FitsInSlot(slot, this))
                 {
                     ItemInstance instance = new ItemInstance(availableItem);
                     instance.ForceDisplay = true;
                     // we want to force display even if it's already present (might be lower than top N)
                     int index = items.IndexOf(instance);
                     if (index < 0)
                     {
                         items.Add(instance);
                     }
                     else
                     {
                         items[index] = instance;
                     }
                 }
             }
         } 
         _relevantItemInstances[slot] = items;
     }
     return items;
 }