/// <summary> /// 做加速运动 /// <para>bullet 敌机子弹</para> /// <para>float acce 加速度</para> /// <para>float angle 速度方向 or bool useVAngle使用速度方向</para> /// <para>bool isAimToPlayer 是否朝向玩家</para> /// </summary> /// <param name="luaState"></param> /// <returns></returns> public static int EnemyBulletDoAcceleration(ILuaState luaState) { EnemyBulletBase bullet = luaState.ToUserData(-4) as EnemyBulletBase; float acce = (float)luaState.ToNumber(-3); float angle; if (luaState.Type(-2) == LuaType.LUA_TBOOLEAN) { bullet.GetBulletPara(BulletParaType.VAngel, out angle); } else { angle = (float)luaState.ToNumber(-2); } bool isAimToPlayer = luaState.ToBoolean(-1); luaState.Pop(4); if (isAimToPlayer) { Vector2 playerPos = PlayerInterface.GetInstance().GetCharacter().GetPosition(); angle += MathUtil.GetAngleBetweenXAxis(playerPos - bullet.GetPosition()); } bullet.DoAcceleration(acce, angle); return(0); }