예제 #1
0
        public MonsterPart UpdateAndGetPart(ulong address, bool isRemovable, float maxHealth, float currentHealth, int timesBrokenCount)
        {
            ObservableCollection <MonsterPart> collection = Parts;

            if (isRemovable)
            {
                collection = RemovableParts;
            }

            MonsterPart part = collection.SingleOrDefault(collectionPart => collectionPart.Address == address);

            if (part != null)
            {
                part.IsRemovable      = isRemovable;
                part.Health.Max       = maxHealth;
                part.Health.Current   = currentHealth;
                part.TimesBrokenCount = timesBrokenCount;
            }
            else
            {
                part = new MonsterPart(this, address, isRemovable, maxHealth, currentHealth, timesBrokenCount);
                collection.Add(part);
            }

            part.IsVisible = CanShowPart(part.InitialTime, part.LastChangedTime);

            return(part);
        }
예제 #2
0
        public MonsterPart UpdateAndGetPart(ulong address, bool isRemovable, float maxHealth, float currentHealth, int timesBrokenCount)
        {
            MonsterPart part = Parts.SingleOrDefault(collectionPart => collectionPart.Address == address);

            if (part != null)
            {
                if (!float.IsNaN(currentHealth / maxHealth))
                {
                    part.IsRemovable      = isRemovable;
                    part.Health.Max       = maxHealth;
                    part.Health.Current   = currentHealth;
                    part.TimesBrokenCount = timesBrokenCount;
                }
            }
            else
            {
                part          = new MonsterPart(this, address, isRemovable, maxHealth, currentHealth, timesBrokenCount);
                part.Changed += PartOrStatusEffect_Changed;

                Parts.Add(part);
            }

            part.NotifyPropertyChanged(nameof(MonsterPart.IsVisible));

            return(part);
        }