/// <summary> /// 设置敌机子弹的直线运动参数 /// <para>bullet</para> /// <para>v</para> /// <para>vAngle</para> /// <para>bool isAimToPlayer</para> /// <para>acce</para> /// <para>accAngle</para> /// <para>maxV</para> /// </summary> /// <param name="luaState"></param> /// <returns></returns> public static int EnemyBulletSetStraightParas(ILuaState luaState) { EnemyBulletBase bullet = luaState.ToUserData(-6) as EnemyBulletBase; float v = (float)luaState.ToNumber(-5); float angle = (float)luaState.ToNumber(-4); bool isAimToPlayer = luaState.ToBoolean(-3); float acce = (float)luaState.ToNumber(-2); float accAngle; if (luaState.Type(-1) == LuaType.LUA_TBOOLEAN) { accAngle = angle; } else { accAngle = (float)luaState.ToNumber(-1); } if (isAimToPlayer) { Vector2 playerPos = PlayerInterface.GetInstance().GetCharacter().GetPosition(); float relAngle = MathUtil.GetAngleBetweenXAxis(playerPos - bullet.GetPosition()); angle += relAngle; accAngle += relAngle; } bullet.SetStraightParas(v, angle, acce, accAngle); return(0); }