コード例 #1
0
 public override bool Update(float dt)
 {
     if (Movement.Update(dt))
     {
         //普攻伤害
         if (damage > 0)
         {
             if (isAttack)
             {
                 Target.removeExpectedDamage(damage);
             }
             Target.LostHP(damage, Shooter, damageType, isAttack);
         }
         //给目标上buff
         if (buffs != null)
         {
             for (int i = 0; i < buffs.Length; ++i)
             {
                 Target.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);
 }
コード例 #2
0
 static int LostHP(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 5);
         BattleSystem.ObjectModule.UnitBase obj = (BattleSystem.ObjectModule.UnitBase)ToLua.CheckObject <BattleSystem.ObjectModule.UnitBase>(L, 1);
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         BattleSystem.ObjectModule.UnitBase arg1 = (BattleSystem.ObjectModule.UnitBase)ToLua.CheckObject <BattleSystem.ObjectModule.UnitBase>(L, 3);
         BattleSystem.DamageType            arg2 = (BattleSystem.DamageType)ToLua.CheckObject(L, 4, typeof(BattleSystem.DamageType));
         bool arg3 = LuaDLL.luaL_checkboolean(L, 5);
         obj.LostHP(arg0, arg1, arg2, arg3);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #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);
        }