Ejemplo n.º 1
0
        public void Clear()
        {
            if (this.m_id == 0)
            {
                return;
            }

            if (this.m_fstatus != null)
            {
                this.m_fstatus.PropertyChanged -= this.FStatus_PropertyChanged;
            }

            this.m_id        = 0;
            this.m_visible   = false;
            this.m_fstatus   = FResource.StatusListDic[0];
            this.m_iconIndex = -1;

            this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Visible"));
        }
Ejemplo n.º 2
0
        private static bool ReadStatus(Stream stream)
        {
            FStatus status = new FStatus();

            StatusList.Add(status);
            StatusListDic.Add(0, status);

            try
            {
                using (var reader = new StreamReader(stream, Encoding.UTF8, true, 4096, true))
                {
                    using (var csv = new CsvReader(reader))
                    {
                        csv.Configuration.HasHeaderRecord = true;
                        csv.Configuration.RegisterClassMap(typeof(FStatus.Map));

                        foreach (var r in csv.GetRecords <FStatus>())
                        {
                            if (string.IsNullOrEmpty(r.Name) || string.IsNullOrEmpty(r.Desc))
                            {
                                continue;
                            }

                            StatusList.Add(r);
                            StatusListDic.Add(r.Id, r);
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Sentry.Error(ex);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool Update(int id, int param, float remain, bool own)
        {
            bool result = false;

            bool visibleUpdated = false;
            bool iconUpdated    = false;

            visibleUpdated = this.m_id != id;
            if (visibleUpdated)
            {
                result = true;
                if (!FResource.StatusListDic.ContainsKey(id))
                {
                    this.Clear();
                    return(true);
                }

                if (this.m_fstatus != null)
                {
                    this.m_fstatus.PropertyChanged -= this.FStatus_PropertyChanged;
                }

                this.m_visible   = true;
                this.m_id        = id;
                this.m_fstatus   = FResource.StatusListDic[id];
                this.m_isChecked = this.m_fstatus.IsChecked;
                this.m_isOwn     = own;

                this.m_isCount = remain == 0 && this.FStatus.IconStack == 0 && (!this.m_fstatus.IsNonExpries || (param > 0 && !this.FStatus.IsStance));

                this.m_fstatus.PropertyChanged += this.FStatus_PropertyChanged;

                iconUpdated = true;
            }
            else if (!this.m_isCount)
            {
                iconUpdated = this.m_iconIndex != param;
            }

            if (iconUpdated)
            {
                this.m_iconIndex = param;
                this.m_icon      = this.m_fstatus.Icon;

                if (this.m_fstatus.IconStack > 0 && param <= this.m_fstatus.IconStack)
                {
                    this.m_icon += param - 1;
                }
            }

            bool remainChanged = false;

            if (this.m_isCount)
            {
                this.m_remain = param;
                remainChanged = true;
            }
            else if (!this.m_fstatus.IsFCBuff && !this.m_fstatus.IsNonExpries)
            {
                this.m_remain = remain < 0 ? remain * -1 : remain;
                remainChanged = true;
            }
            else if (this.m_remain != 0)
            {
                this.m_remain = 0;
                remainChanged = true;
            }

            if (this.PropertyChanged != null)
            {
                if (visibleUpdated)
                {
                    this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Visible"));
                    this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsCount"));
                    this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsChecked"));
                    this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsOwn"));
                }

                if (iconUpdated)
                {
                    this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Icon"));
                }

                if (remainChanged)
                {
                    this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Remain"));
                }
            }

            return(result);
        }