Ejemplo n.º 1
0
 public override bool Update(float dt)
 {
     if (Movement.Update(dt))
     {
         //AOE
         if (aoeRadius > 0)
         {
             AoeRegion region = new CircleRegion(BattleInterface.Instance.world, position.x, position.y, aoeRadius);
             AoeField  aoe    = new AoeField(Shooter, region, duration, interval, emitters);
             BattleInterface.Instance.AddAoeField(aoe);
         }
         return(true);
     }
     return(false);
 }
Ejemplo n.º 2
0
        public override bool Update(float dt)
        {
            float x = position.x;
            float y = position.y;

            if (Movement.Update(dt))
            {
                if (!this.arrive)
                {
                    Movement.Retarget(Shooter.position);
                    this.arrive = true;
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                var shift = speed * dt;

                List <UnitBase> res = new List <UnitBase>();
                BattleInterface.Instance.world.SelectRect(x, y, Movement.shift.x, Movement.shift.y, this.radius * 2, shift, res, (obj) => obj.CampID != Shooter.CampID);

                if (res.Count > 0)
                {
                    if (this.decayScale > 0)
                    {
                        res.Sort((a, b) =>
                        {
                            float da_x = a.position.x - x;
                            float da_y = a.position.y - y;
                            float db_x = b.position.x - x;
                            float db_y = b.position.y - y;
                            float da   = da_x * da_x + da_y * da_y;
                            float db   = db_x * db_x + db_y * db_y;
                            return(da.CompareTo(db));
                        });
                        for (int i = 0; i < res.Count; ++i)
                        {
                            //普攻伤害
                            var rd = (int)(damage * this.damageScale);
                            if (rd > 0)
                            {
                                res[i].LostHP(rd, Shooter, damageType, isAttack);
                            }
                            //给目标上buff
                            if (buffs != null)
                            {
                                for (int n = 0; n < buffs.Length; ++n)
                                {
                                    res[i].AddBuff(buffs[n], Shooter);
                                }
                            }
                            this.damageScale *= (1 - this.decayScale);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < res.Count; ++i)
                        {
                            //普攻伤害
                            if (damage > 0)
                            {
                                res[i].LostHP(damage, Shooter, damageType, isAttack);
                            }
                            //给目标上buff
                            if (buffs != null)
                            {
                                for (int n = 0; n < buffs.Length; ++n)
                                {
                                    res[i].AddBuff(buffs[n], Shooter);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        public override bool Update(float dt)
        {
            float x = position.x;
            float y = position.y;

            if (Movement.Update(dt))
            {
                //AOE
                if (aoeRadius > 0)
                {
                    AoeRegion region = new CircleRegion(BattleInterface.Instance.world, position.x, position.y, aoeRadius);
                    AoeField  aoe    = new AoeField(Shooter, region, duration, interval, emitters);
                    BattleInterface.Instance.AddAoeField(aoe);
                }
                return(true);
            }
            else
            {
                var shift = speed * dt;

                BattleInterface.Instance.world.SelectRect(x, y, Movement.shift.x, Movement.shift.y, this.radius * 2, shift, res, (obj) => obj.CampID != Shooter.CampID);

                if (res.Count > 0)
                {
                    UnitBase unit    = null;
                    float    sqr_dis = 0;
                    for (int i = 0; i < res.Count; ++i)
                    {
                        float dx       = res[i].position.x - x;
                        float dy       = res[i].position.y - y;
                        var   _sqr_dis = dx * dx + dy * dy;
                        if (unit == null || _sqr_dis < sqr_dis)
                        {
                            unit    = res[i];
                            sqr_dis = _sqr_dis;
                        }
                    }
                    //普攻伤害
                    if (damage > 0)
                    {
                        unit.LostHP(damage, Shooter, damageType, isAttack);
                    }
                    //给目标上buff
                    if (buffs != null)
                    {
                        for (int i = 0; i < buffs.Length; ++i)
                        {
                            unit.AddBuff(buffs[i], Shooter);
                        }
                    }
                    //AOE
                    if (aoeRadius > 0)
                    {
                        AoeRegion region = new CircleRegion(BattleInterface.Instance.world, position.x, position.y, aoeRadius);
                        AoeField  aoe    = new AoeField(Shooter, region, duration, interval, emitters);
                        BattleInterface.Instance.AddAoeField(aoe);
                    }
                    return(true);
                }
            }
            return(false);
        }