Пример #1
0
 private void DestroyBuffStateImmediately(BSBase buffState)
 {
     SyncEventHelper.BuffStateRemoved(this.rid, buffState.id);
     buffState.OnDestroy();
     this._buffStates.Remove(buffState);
     BuffStatePool.Push(buffState);
 }
Пример #2
0
        internal override void UpdateState(UpdateContext context)
        {
            this.time += context.deltaTime;

            this._regenTime += context.deltaTime;
            if (this._regenTime >= 5f)
            {
                this._regenTime -= 5f;
                if (!this.isDead)
                {
                    this.property.Add(Attr.Hp, this.property.hpRegen);
                    this.property.Add(Attr.Mana, this.property.manaRegen);
                }
            }

            this.UpdateThink(context);
            this.fsm.Update(context);

            for (int i = 0; i < this._numSkills; i++)
            {
                this.skills[i].Update(context.deltaTime);
            }

            int count = this._buffStates.Count;

            for (int i = 0; i < count; i++)
            {
                this._buffStates[i].Update(context);
            }

            count = this._buffStatesToDestroy.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    BSBase buffState = this._buffStatesToDestroy[i];
                    this.DestroyBuffStateImmediately(buffState);
                }
                this._buffStatesToDestroy.Clear();
            }

            this.UpdateSteering(context);

            this.sensorySystem.Update(context);

            if (this.debugDraw)
            {
                SyncEventHelper.DebugDraw(SyncEvent.DebugDrawType.WireCube, this.property.position + new Vec3(0, this.size.y * 0.5f, 0), this.size, null, 0, Color4.gray);
            }

            if (this.lifeTime > 0 &&
                this.time >= this.lifeTime)
            {
                this.markToDestroy = true;
            }
        }
Пример #3
0
 internal bool DestroyBuffState(BSBase bs)
 {
     if (this._buffStatesToDestroy.Contains(bs))
     {
         LLogger.Warning("BuffState {0} already in destroy list", bs.id);
         return(false);
     }
     this._buffStatesToDestroy.Add(bs);
     return(true);
 }
Пример #4
0
        public BSBase GetBuffState(string id)
        {
            int count = this._buffStates.Count;

            for (int i = 0; i < count; i++)
            {
                BSBase buffState = this._buffStates[i];
                if (buffState.id == id)
                {
                    return(buffState);
                }
            }
            return(null);
        }
Пример #5
0
        public void DestroyAllDisableBuffStates()
        {
            int count = this._buffStates.Count;

            for (int i = 0; i < count; i++)
            {
                BSBase buffState = this._buffStates[i];
                if (buffState.beneficialType == BeneficialType.Debuff)
                {
                    this.DestroyBuffStateImmediately(buffState);
                    --i;
                    --count;
                }
            }
        }
Пример #6
0
        internal void OnExitBuff(Buff buff)
        {
            //跟随buff失效的state需要去掉
            int count = this._buffStates.Count;

            for (int i = 0; i < count; i++)
            {
                BSBase buffState = this._buffStates[i];
                if (!MathUtils.Approximately(buffState.duration, -1f) ||
                    buffState.buff != buff)
                {
                    continue;
                }
                this.DestroyBuffStateImmediately(buffState);
                --i;
                --count;
            }
        }
Пример #7
0
        internal void CreateBuffState(string id, Buff buff)
        {
            BuffStateData buffStateData = ModelFactory.GetBuffStateData(id);

            //有免疫限制技能的属性,并且将要产生的state是限制类型,则不会生效
            if (this.property.immuneDisables > 0 &&
                buffStateData.beneficialType == BeneficialType.Debuff)
            {
                return;
            }

            bool create = true;

            if (buffStateData.overlapType == BuffStateOverlapType.Replace ||
                buffStateData.overlapType == BuffStateOverlapType.Unique)
            {
                BSBase bs = this.GetBuffState(id);
                if (bs != null)
                {
                    switch (buffStateData.overlapType)
                    {
                    case BuffStateOverlapType.Replace:
                        this.DestroyBuffStateImmediately(bs);
                        break;

                    case BuffStateOverlapType.Unique:
                        bs.Unite();
                        create = false;
                        break;
                    }
                }
            }
            if (create)
            {
                SyncEventHelper.BuffStateAdded(this.rid, id, buff.rid);
                BSBase buffState = BSBase.Create(buffStateData.type);
                buffState.Init(id, this, buff);
                this._buffStates.Add(buffState);
            }
        }