示例#1
0
        protected virtual float CalcDamageInternal(Bio caster, Bio target, int index)
        {
            BuffData.Trigger trigger        = this._buff.trigger;
            EntityProperty   casterProperty = caster.property;
            EntityProperty   targetProperty = target.property;
            float            cad            = casterProperty.ad;
            float            cap            = casterProperty.ap;
            float            std            = trigger.td?[index] ?? 0f;
            float            sad            = trigger.ad?[index] ?? 0f;
            float            sap            = trigger.ap?[index] ?? 0f;
            float            tpadp          = trigger.tpadp?[index] ?? 0f;
            float            tpapp          = trigger.tpapp?[index] ?? 0f;
            float            padp           = trigger.padp?[index] ?? 0f;
            float            papp           = trigger.papp?[index] ?? 0f;

            float armorResist = MathUtils.Max(0, targetProperty.armor * (1 - casterProperty.armorPen) - casterProperty.armorPenFlat);
            float tad         = sad + cad * padp;
            float pdamage     = tad * (100 / (100 + armorResist));

            float magicResist = MathUtils.Max(0, targetProperty.magicResist * (1 - casterProperty.magicPen) - casterProperty.magicPenFlat);
            float tap         = sap + cap * papp;
            float mdamage     = tap * (100 / (100 + magicResist));

            float trueDamage = std + cad * tpadp + cap * tpapp;

            return(pdamage + mdamage + trueDamage);
        }
示例#2
0
        private void CalcDamage(Bio caster, Bio target, int triggerIndex)
        {
            BuffData.Trigger trigger = this._buff.trigger;
            if (trigger.damaged == null)
            {
                return;
            }

            int index = trigger.damaged.Length - 1;

            index = triggerIndex <= index ? triggerIndex : index;

            if (!trigger.damaged[index])
            {
                return;
            }

            float damage = this.CalcDamageInternal(caster, target, index);

            target.property.Add(Attr.Hp, -damage);

            if (target.property.hp <= 0)
            {
                target.sensorySystem.killer = caster;
            }

            SyncEventHelper.Damage(this._buff.rid, damage, caster.rid, target.rid);
            this.OnDamage(damage, caster, target, triggerIndex);
            caster.OnDamage(this._buff, target, damage);
            target.OnHurt(this._buff, caster, damage);
        }
示例#3
0
        protected override float CalcDamageInternal(Bio caster, Bio target, int index)
        {
            BuffData.Trigger trigger = this._buff.trigger;
            float            cad     = caster.property.ad;
            float            cap     = caster.property.ap;

            if (!this._reverted)
            {
                float sad  = trigger.ad?[index] ?? 0f;
                float sap  = trigger.ap?[index] ?? 0f;
                float padp = trigger.padp?[index] ?? 0f;
                float papp = trigger.papp?[index] ?? 0f;

                float armorResist = MathUtils.Max(0, target.property.armor * (1 - caster.property.armorPen) - caster.property.armorPenFlat);
                float tad         = sad + cad * padp;
                float pdamage     = tad * (100 / (100 + armorResist));

                float magicResist = MathUtils.Max(0, target.property.magicResist * (1 - caster.property.magicPen) - caster.property.magicPenFlat);
                float tap         = sap + cap * papp;
                float mdamage     = tap * (100 / (100 + magicResist));

                return(pdamage + mdamage);
            }
            float std   = trigger.td?[index] ?? 0f;
            float tpadp = trigger.tpadp?[index] ?? 0f;
            float tpapp = trigger.tpapp?[index] ?? 0f;

            return(std + cad * tpadp + cap * tpapp);
        }
示例#4
0
 protected virtual void DoTriggerOrbit(int triggerIndex, float dt)
 {
     switch (this._buff.orbit)
     {
     case Orbit.CustomPosition:
         BuffData.Trigger trigger  = this._buff.trigger;
         float            distance = trigger.distances[triggerIndex];
         Vec3             position = this._buff.property.position;
         position += this._buff.property.direction * distance;
         this._buff.property.Equal(Attr.Position, position);
         break;
     }
 }
示例#5
0
        public void HandleTriggered(int triggerIndex)
        {
            BuffData.Trigger trigger = this.trigger;
            if (trigger.tfxs == null)
            {
                return;
            }
            int index = trigger.tfxs.Length - 1;

            index = triggerIndex <= index ? triggerIndex : index;

            if (!string.IsNullOrEmpty(trigger.tfxs[index]))
            {
                Effect fx = this.battle.CreateEffect(trigger.tfxs[index]);
                fx.position  = this.position;
                fx.direction = this.direction;
            }
        }
示例#6
0
        private static void PreloadBuffs(LoadBatch loader, string[] buffs)
        {
            if (buffs == null)
            {
                return;
            }

            int c2 = buffs.Length;

            for (int i = 0; i < c2; i++)
            {
                BuffData buffData = ModelFactory.GetBuffData(buffs[i]);
                //enter state
                if (buffData.enterStates != null)
                {
                    int c3 = buffData.enterStates.Length;
                    for (int j = 0; j < c3; j++)
                    {
                        string        stateId       = buffData.enterStates[j];
                        BuffStateData buffStateData = ModelFactory.GetBuffStateData(stateId);
                        int           c4            = buffStateData.levels.Length;
                        for (int k = 0; k < c4; k++)
                        {
                            BuffStateData.Level level = buffStateData.levels[k];
                            if (level.fxs == null)
                            {
                                continue;
                            }

                            int c6 = level.fxs.Length;
                            for (int l = 0; l < c6; l++)
                            {
                                EntityData effectData = ModelFactory.GetEntityData(level.fxs[l]);
                                loader.Add(new AssetsLoader("model/" + effectData.model));
                            }

                            if (level.trigger != null &&
                                level.trigger.fxs != null)
                            {
                                int c5 = level.trigger.fxs.Length;
                                for (int l = 0; l < c5; l++)
                                {
                                    string fxId = level.trigger.fxs[l];
                                    if (string.IsNullOrEmpty(fxId))
                                    {
                                        continue;
                                    }
                                    EntityData effectData = ModelFactory.GetEntityData(fxId);
                                    loader.Add(new AssetsLoader("model/" + effectData.model));
                                }
                            }
                        }
                    }
                }

                //trigger state
                if (buffData.triggerStates != null)
                {
                    int c3 = buffData.triggerStates.Length;
                    for (int j = 0; j < c3; j++)
                    {
                        string        stateId       = buffData.triggerStates[j];
                        BuffStateData buffStateData = ModelFactory.GetBuffStateData(stateId);
                        int           c4            = buffStateData.levels.Length;
                        for (int k = 0; k < c4; k++)
                        {
                            BuffStateData.Level level = buffStateData.levels[k];
                            if (level.fxs == null)
                            {
                                continue;
                            }

                            int c6 = level.fxs.Length;
                            for (int l = 0; l < c6; l++)
                            {
                                EntityData effectData = ModelFactory.GetEntityData(level.fxs[l]);
                                loader.Add(new AssetsLoader("model/" + effectData.model));
                            }

                            if (level.trigger != null &&
                                level.trigger.fxs != null)
                            {
                                int c5 = level.trigger.fxs.Length;
                                for (int l = 0; l < c5; l++)
                                {
                                    string fxId = level.trigger.fxs[l];
                                    if (string.IsNullOrEmpty(fxId))
                                    {
                                        continue;
                                    }
                                    EntityData effectData = ModelFactory.GetEntityData(fxId);
                                    loader.Add(new AssetsLoader("model/" + effectData.model));
                                }
                            }
                        }
                    }
                }

                if (buffData.levels != null)
                {
                    int c3 = buffData.levels.Length;
                    for (int k = 0; k < c3; k++)
                    {
                        BuffData.Level buffLevel = buffData.levels[k];

                        if (!string.IsNullOrEmpty(buffLevel.fx))
                        {
                            EntityData effectData = ModelFactory.GetEntityData(buffLevel.fx);
                            loader.Add(new AssetsLoader("model/" + effectData.model));
                        }

                        if (!string.IsNullOrEmpty(buffLevel.areaFx))
                        {
                            EntityData effectData = ModelFactory.GetEntityData(buffLevel.areaFx);
                            loader.Add(new AssetsLoader("model/" + effectData.model));
                        }

                        //trigger
                        BuffData.Trigger trigger = buffLevel.trigger;
                        if (trigger != null)
                        {
                            if (trigger.fxs != null)
                            {
                                int c4 = trigger.fxs.Length;
                                for (int l = 0; l < c4; l++)
                                {
                                    if (!string.IsNullOrEmpty(trigger.fxs[l]))
                                    {
                                        EntityData effectData = ModelFactory.GetEntityData(trigger.fxs[l]);
                                        loader.Add(new AssetsLoader("model/" + effectData.model));
                                    }
                                }
                            }

                            if (trigger.tfxs != null)
                            {
                                int c4 = trigger.tfxs.Length;
                                for (int l = 0; l < c4; l++)
                                {
                                    if (!string.IsNullOrEmpty(trigger.tfxs[l]))
                                    {
                                        EntityData effectData = ModelFactory.GetEntityData(trigger.tfxs[l]);
                                        loader.Add(new AssetsLoader("model/" + effectData.model));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#7
0
        internal void Update(UpdateContext context)
        {
            float dt = context.deltaTime;

            this.DoUpdateOrbit(dt);

            bool selected = false;

            if (this._buff.enterStates != null)
            {
                selected = true;
                this.SelectTargets(this._buff.target, true, ref this._tempInOut);
            }

            BuffData.Trigger trigger = this._buff.trigger;
            if (trigger != null && (trigger.times == null || this._triggerIndex <= trigger.times.Length - 1))
            {
                this._triggerDt += dt;
                float interval = trigger.times?[this._triggerIndex] ?? MathUtils.Max(dt, trigger.interval);

                if (this._triggerDt >= interval)
                {
                    SyncEventHelper.BuffTriggered(this._buff.rid, this._triggerIndex);

                    this.DoTriggerOrbit(this._triggerIndex, this._triggerDt);

                    if (!selected)
                    {
                        this.SelectTargets(this._buff.target, false, ref this._tempTargets);
                    }
                    else
                    {
                        this._tempTargets.AddRange(this._tempInOut);
                    }

                    int count = this._tempTargets.Count;
                    for (int i = 0; i < count; i++)
                    {
                        this.OnTargetTrigger(this._tempTargets[i], this._triggerIndex);
                    }

                    this.CreateSummons(this._triggerIndex);

                    this._tempTargets.Clear();

                    ++this._triggerIndex;

                    this._triggerDt -= interval;
                }
            }

            this._time += dt;

            this.UpdateInternal(context);

            if (this._buff.canInterrupt &&
                this._buff.caster.fsm.currState.type != FSMStateType.Attack)
            {
                this._buff.markToDestroy = true;
                return;
            }

            if (this._buff.deadType == DeadType.WithCaster &&
                this._buff.caster.isDead)
            {
                this._buff.markToDestroy = true;
                return;
            }

            if (this._buff.deadType == DeadType.WithMainTarget &&
                this._buff.target.isDead)
            {
                this._buff.markToDestroy = true;
                return;
            }

            if (this._buff.deadType == DeadType.WithTriggerTarget &&
                this._totalTriggerCount >= this._buff.maxTriggerCount)
            {
                this._buff.markToDestroy = true;
                return;
            }

            if (this._buff.duration >= 0 &&
                this._time >= this._buff.duration)
            {
                this._buff.markToDestroy = true;
            }
        }