/// <summary> /// 做直线运动 /// <para>bullet 敌机子弹</para> /// <para>float v 速度</para> /// <para>float angle 速度方向</para> /// <para>bool isAimToPlayer 是否朝向玩家</para> /// </summary> /// <param name="luaState"></param> /// <returns></returns> public static int EnemyBulletDoStraightMove(ILuaState luaState) { EnemyBulletBase bullet = luaState.ToUserData(-4) as EnemyBulletBase; float v = (float)luaState.ToNumber(-3); float 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.DoStraightMove(v, angle); return(0); }