static int _CreateBattleSystem_SkillModule_Skill(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                BattleSystem.ObjectModule.UnitBase arg0 = (BattleSystem.ObjectModule.UnitBase)ToLua.CheckObject <BattleSystem.ObjectModule.UnitBase>(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                BattleSystem.SkillModule.Skill obj = new BattleSystem.SkillModule.Skill(arg0, arg1);
                ToLua.PushObject(L, obj);
                return(1);
            }
            else if (count == 3)
            {
                BattleSystem.ObjectModule.UnitBase arg0 = (BattleSystem.ObjectModule.UnitBase)ToLua.CheckObject <BattleSystem.ObjectModule.UnitBase>(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                int arg2 = (int)LuaDLL.luaL_checknumber(L, 3);
                BattleSystem.SkillModule.Skill obj = new BattleSystem.SkillModule.Skill(arg0, arg1, arg2);
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: BattleSystem.SkillModule.Skill.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int _CreateBattleSystem_ObjectModule_UnitBase(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                BattleSystem.ObjectModule.UnitBase obj = new BattleSystem.ObjectModule.UnitBase();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else if (count == 4)
            {
                BattleSystem.SpaceModule.WorldSpace arg0 = (BattleSystem.SpaceModule.WorldSpace)ToLua.CheckObject <BattleSystem.SpaceModule.WorldSpace>(L, 1);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
                int arg2 = (int)LuaDLL.luaL_checknumber(L, 3);
                int arg3 = (int)LuaDLL.luaL_checknumber(L, 4);
                BattleSystem.ObjectModule.UnitBase obj = new BattleSystem.ObjectModule.UnitBase(arg0, arg1, arg2, arg3);
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: BattleSystem.ObjectModule.UnitBase.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 static int InitBehaviorTree(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         BattleSystem.ObjectModule.UnitBase obj = (BattleSystem.ObjectModule.UnitBase)ToLua.CheckObject <BattleSystem.ObjectModule.UnitBase>(L, 1);
         obj.InitBehaviorTree();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int removeExpectedDamage(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         BattleSystem.ObjectModule.UnitBase obj = (BattleSystem.ObjectModule.UnitBase)ToLua.CheckObject <BattleSystem.ObjectModule.UnitBase>(L, 1);
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         obj.removeExpectedDamage(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int Update(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         BattleSystem.ObjectModule.UnitBase obj = (BattleSystem.ObjectModule.UnitBase)ToLua.CheckObject <BattleSystem.ObjectModule.UnitBase>(L, 1);
         float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
         bool  o    = obj.Update(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int AddHP(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         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);
         obj.AddHP(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int InVisualRange(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         BattleSystem.ObjectModule.UnitBase obj  = (BattleSystem.ObjectModule.UnitBase)ToLua.CheckObject <BattleSystem.ObjectModule.UnitBase>(L, 1);
         BattleSystem.ObjectModule.UnitBase arg0 = (BattleSystem.ObjectModule.UnitBase)ToLua.CheckObject <BattleSystem.ObjectModule.UnitBase>(L, 2);
         bool o = obj.InVisualRange(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int get_position(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase obj = (BattleSystem.ObjectModule.UnitBase)o;
            BattleSystem.Vector3 ret = obj.position;
            ToLua.PushValue(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index position on a nil value"));
        }
    }
    static int set_MaxHP(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase obj = (BattleSystem.ObjectModule.UnitBase)o;
            int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
            obj.MaxHP = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index MaxHP on a nil value"));
        }
    }
    static int get_Bullet(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase obj = (BattleSystem.ObjectModule.UnitBase)o;
            int ret = obj.Bullet;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Bullet on a nil value"));
        }
    }
    static int get_BehaviorTree(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase         obj = (BattleSystem.ObjectModule.UnitBase)o;
            BattleSystem.BehaviorTree.BehaviorTreeBase ret = obj.BehaviorTree;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index BehaviorTree on a nil value"));
        }
    }
    static int set_Shield(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase obj  = (BattleSystem.ObjectModule.UnitBase)o;
            BattleSystem.ObjectModule.Shield   arg0 = (BattleSystem.ObjectModule.Shield)ToLua.CheckObject <BattleSystem.ObjectModule.Shield>(L, 2);
            obj.Shield = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Shield on a nil value"));
        }
    }
    static int get_isDying(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase obj = (BattleSystem.ObjectModule.UnitBase)o;
            bool ret = obj.isDying;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index isDying on a nil value"));
        }
    }
    static int get_radius(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase obj = (BattleSystem.ObjectModule.UnitBase)o;
            float ret = obj.radius;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index radius on a nil value"));
        }
    }
    static int get_Owner(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.SkillModule.Skill     obj = (BattleSystem.SkillModule.Skill)o;
            BattleSystem.ObjectModule.UnitBase ret = obj.Owner;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Owner on a nil value"));
        }
    }
    static int get_AttackTarget(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase obj = (BattleSystem.ObjectModule.UnitBase)o;
            BattleSystem.ObjectModule.UnitBase ret = obj.AttackTarget;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index AttackTarget on a nil value"));
        }
    }
    static int get_VisualRange(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase          obj = (BattleSystem.ObjectModule.UnitBase)o;
            BattleSystem.ObjectModule.DistanceAttribute ret = obj.VisualRange;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index VisualRange on a nil value"));
        }
    }
    static int set_AttackRange(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase          obj  = (BattleSystem.ObjectModule.UnitBase)o;
            BattleSystem.ObjectModule.DistanceAttribute arg0 = (BattleSystem.ObjectModule.DistanceAttribute)ToLua.CheckObject <BattleSystem.ObjectModule.DistanceAttribute>(L, 2);
            obj.AttackRange = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index AttackRange on a nil value"));
        }
    }
    static int get_Animator(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase           obj = (BattleSystem.ObjectModule.UnitBase)o;
            BattleSystem.ObjectModule.AnimatorController ret = obj.Animator;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Animator on a nil value"));
        }
    }
    static int set_position(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            BattleSystem.ObjectModule.UnitBase obj = (BattleSystem.ObjectModule.UnitBase)o;
            BattleSystem.Vector3 arg0 = StackTraits <BattleSystem.Vector3> .Check(L, 2);

            obj.position = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index position on a nil value"));
        }
    }
 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));
     }
 }
Exemple #22
0
        /// <summary>
        /// 单位受到治疗
        /// </summary>
        /// <param name="delta">治疗量</param>
        /// <param name="healer">治疗者</param>
        public void AddHP(int delta, UnitBase healer)
        {
            if (IsDead)
            {
                return;
            }
            var offset = BuffManager.OnUnitWillHeal(this, healer, delta);

            delta += offset;
            if (delta > 0)
            {
                var origin = HP;
                HP = HP + delta;
                if (HP > MaxHP)
                {
                    HP = MaxHP;
                }
                BuffManager.OnUnitBeHealed(this, healer, HP - origin);
            }
#if DEBUG
            Debug.LogFormat("unit {0} HP = {1}", ID, HP);
#endif
        }
        internal BehaviorResult SearchEnemy()
        {
#if DEBUG
            Debug.Log(Unit.ID + " SearchEnemy");
#endif
            List <UnitBase> set = new List <UnitBase>();
            if (Unit.Bullet > 0)
            {
                BattleInterface.Instance.world.SelectCircle(Unit.position.x, Unit.position.y, Unit.VisualRange.value, set, (obj) => !obj.isDying && obj.CampID != Unit.CampID);
            }
            else
            {
                BattleInterface.Instance.world.SelectCircle(Unit.position.x, Unit.position.y, Unit.VisualRange.value, set, (obj) => obj.CampID != Unit.CampID);
            }
            float    sqr_dis = 0;
            UnitBase unit    = null;
            for (int i = 0; i < set.Count; ++i)
            {
                float dx       = set[i].position.x - Unit.position.x;
                float dy       = set[i].position.y - Unit.position.y;
                var   _sqr_dis = dx * dx + dy * dy;
                if (unit == null || _sqr_dis < sqr_dis)
                {
                    unit    = set[i];
                    sqr_dis = _sqr_dis;
                }
            }
            if (unit != null)
            {
                this.Unit.AttackTarget = unit;
                return(BehaviorResult.success);
            }
            else
            {
                return(BehaviorResult.failed);
            }
        }
    static int Cast(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                BattleSystem.SkillModule.Skill obj = (BattleSystem.SkillModule.Skill)ToLua.CheckObject <BattleSystem.SkillModule.Skill>(L, 1);
                obj.Cast();
                return(0);
            }
            else if (count == 2)
            {
                BattleSystem.SkillModule.Skill     obj  = (BattleSystem.SkillModule.Skill)ToLua.CheckObject <BattleSystem.SkillModule.Skill>(L, 1);
                BattleSystem.ObjectModule.UnitBase arg0 = (BattleSystem.ObjectModule.UnitBase)ToLua.CheckObject <BattleSystem.ObjectModule.UnitBase>(L, 2);
                obj.Cast(arg0);
                return(0);
            }
            else if (count == 3)
            {
                BattleSystem.SkillModule.Skill obj = (BattleSystem.SkillModule.Skill)ToLua.CheckObject <BattleSystem.SkillModule.Skill>(L, 1);
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
                float arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
                obj.Cast(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: BattleSystem.SkillModule.Skill.Cast"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemple #25
0
 public LineBullet(UnitBase shooter, Vector3 target)
 {
     this.Shooter = shooter;
     Movement     = new NormalMovement(this);
     Movement.Retarget(target);
 }
Exemple #26
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);
        }
 public virtual void GetWithinAttackDistance(UnitBase target)
 {
     this.TargetUnit = target;
     this.mTrackMovement.Retarget(target);
 }
Exemple #28
0
 public CoordBullet(UnitBase shooter, Vector3 target)
 {
     Movement = new NormalMovement(this);
     Movement.Retarget(target);
 }