Esempio n. 1
0
 public IList <Packet> Add(Packet packet)
 {
     dictKey = new DictKey(packet.Ethernet.IpV4.Source, packet.Ethernet.IpV4.Identification);
     if (ElementList.TryGetValue(dictKey, out dictValue))
     {
         if (dictValue.AddPacket(packet))
         {
             fragments = dictValue.fragments;
             ElementList.Remove(dictKey);
             return(fragments);
         }
         else
         {
             fragments = null;
             return(fragments);
         }
     }
     else
     {
         dictValue = new DictValue();
         dictValue.AddPacket(packet);
         ElementList.Add(dictKey, dictValue);
         fragments = null;
         return(fragments);
     }
 }
Esempio n. 2
0
        public void SetIsEnabled(Gem gem, int skillIndex, bool isEnabled)
        {
            var key = new DictKey(gem, skillIndex);

            if (_enabledDict.TryGetValue(key, out var value) && value == isEnabled)
            {
                return;
            }
            _enabledDict[key] = isEnabled;
            EnabledChangedForSlots?.Invoke(this, new[] { key.Tuple.itemSlot });
        }
        private void EnsureIsObserved(Skill skill, DictKey key)
        {
            if (!_levelSubscriptions.ContainsKey(key))
            {
                ObserveLevel(skill, key);
            }

            if (!_qualitySubscriptions.ContainsKey(key))
            {
                ObserveQuality(skill, key);
            }
        }
Esempio n. 4
0
    public static Sprite GetPortrait(Hero.HeroSex sex, Hero.HeroRace race, Hero.HeroProfession profession)
    {
        Sprite  TemporarySprite;
        DictKey TemporaryDictKey;

        if (PortraitHolder == null)
        {
            PortraitHolder = new Dictionary <DictKey, Sprite>();
        }
        TemporaryDictKey = new DictKey(sex, race, profession);
        if (!PortraitHolder.ContainsKey(TemporaryDictKey))
        {
            TemporarySprite = Resources.Load <Sprite>("Portraits/" + sex.ToString() + race.ToString() + profession.ToString());
            PortraitHolder.Add(TemporaryDictKey, TemporarySprite);
        }
        return(PortraitHolder[TemporaryDictKey]);
    }
        private void ObserveQuality(Skill skill, DictKey key)
        {
            var qualityStat = _gemStatBuilders.AdditionalQuality(skill).BuildToStats(Entity.Character).Single();

            _qualitySubscriptions[key] = _calculator.ObserveNode(qualityStat)
                                         .ObserveOnDispatcher()
                                         .Subscribe(v =>
            {
                var quality = (int)(v.SingleOrNull() ?? 0);
                if (_qualities.TryGetValue(key, out var oldLevel) && oldLevel == quality)
                {
                    return;
                }
                _qualities[key] = quality;
                StatChangedForSlot?.Invoke(this, skill.ItemSlot);
            }, e => Log.Error(e, $"ObserveQuality({skill}, {key}) failed"));
        }
        public Skill Apply(Skill skill)
        {
            if (skill.Gem is null)
            {
                return(skill);
            }

            var key = new DictKey(skill);

            EnsureIsObserved(skill, key);

            if (_levels.TryGetValue(key, out var additionalLevels))
            {
                skill = skill.WithLevel(skill.Gem.Level + additionalLevels);
            }

            if (_qualities.TryGetValue(key, out var additionalQuality))
            {
                skill = skill.WithQuality(skill.Gem !.Quality + additionalQuality);
            }

            return(skill);
        }
Esempio n. 7
0
 public IList<Packet> Add(Packet packet)
 {
     dictKey = new DictKey(packet.Ethernet.IpV4.Source, packet.Ethernet.IpV4.Identification);
     if (ElementList.TryGetValue(dictKey, out dictValue))
     {
         if (dictValue.AddPacket(packet))
         {
             fragments = dictValue.fragments;
             ElementList.Remove(dictKey);
             return fragments;
         }
         else
         {
             fragments = null;
             return fragments;
         }
     }
     else
     {
         dictValue = new DictValue();
         dictValue.AddPacket(packet);
         ElementList.Add(dictKey, dictValue);
         fragments = null;
         return fragments;
     }
 }