Skip to content

Commit

Permalink
同步cstolua2.0最新版本。
Browse files Browse the repository at this point in the history
  • Loading branch information
jarjin committed Aug 25, 2015
1 parent e6dbdbf commit ed02ad7
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 30 deletions.
25 changes: 19 additions & 6 deletions Assets/Lua/System/Vector2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
-- as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.
--------------------------------------------------------------------------------

local sqrt = math.sqrt
local setmetatable = setmetatable
local rawset = rawset
local rawget = rawget

Vector2 =
{
x = 0,
--[[ x = 0,
y = 0,
class = "Vector2",
class = "Vector2",--]]
}

setmetatable(Vector2, Vector2)
Expand All @@ -33,9 +38,8 @@ Vector2.__index = function(t,k)
end

function Vector2.New(x, y)
local v = {x = 0, y = 0}
setmetatable(v, Vector2)
v:Set(x,y)
local v = {x = x or 0, y = y or 0}
setmetatable(v, Vector2)
return v
end

Expand Down Expand Up @@ -75,8 +79,17 @@ function Vector2:SetNormalize()
return self
end

function Vector2.Dot(lhs, rhs)
return lhs.x * rhs.x + lhs.y * rhs.y
end

function Vector2.Angle(from, to)
return acos(clamp(Vector2.dot(from:Normalize(), to:Normalize()), -1, 1)) * 57.29578
end


function Vector2.Magnitude(v2)
return math.sqrt(v2.x * v2.x + v2.y * v2.y)
return sqrt(v2.x * v2.x + v2.y * v2.y)
end

function Vector2:Div(d)
Expand Down
25 changes: 25 additions & 0 deletions Assets/uLua/Core/LuaAttributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;

public class NoToLuaAttribute : System.Attribute
{
public NoToLuaAttribute()
{

}
}

public class OnlyGCAttribute : System.Attribute
{
public OnlyGCAttribute()
{

}
}

public class UseDefinedAttribute : System.Attribute
{
public UseDefinedAttribute()
{

}
}
12 changes: 12 additions & 0 deletions Assets/uLua/Source/Base/LuaScriptMgr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,10 @@ public static string[] GetArrayString(IntPtr L, int stackPos)
return (string[])ret;
}
}
else if (luatype == LuaTypes.LUA_TNIL)
{
return null;
}

LuaDLL.luaL_error(L, string.Format("invalid arguments to method: {0}, pos {1}", GetErrorFunc(1), stackPos));
return null;
Expand Down Expand Up @@ -2155,6 +2159,10 @@ public static T[] GetArrayNumber<T>(IntPtr L, int stackPos)
return (T[])ret;
}
}
else if (luatype == LuaTypes.LUA_TNIL)
{
return null;
}

LuaDLL.luaL_error(L, string.Format("invalid arguments to method: {0}, pos {1}", GetErrorFunc(1), stackPos));
return null;
Expand Down Expand Up @@ -2200,6 +2208,10 @@ public static bool[] GetArrayBool(IntPtr L, int stackPos)
return (bool[])ret;
}
}
else if (luatype == LuaTypes.LUA_TNIL)
{
return null;
}

LuaDLL.luaL_error(L, string.Format("invalid arguments to method: {0}, pos {1}", GetErrorFunc(1), stackPos));
return null;
Expand Down
24 changes: 0 additions & 24 deletions Assets/uLua/Source/Base/LuaWrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,6 @@ public LuaEnum(string str, System.Enum v)
}
}*/

public class NoToLuaAttribute : System.Attribute
{
public NoToLuaAttribute()
{

}
}

public class OnlyGCAttribute : System.Attribute
{
public OnlyGCAttribute()
{

}
}

public class UseDefinedAttribute : System.Attribute
{
public UseDefinedAttribute()
{

}
}


public interface ILuaWrap
{
Expand Down
3 changes: 3 additions & 0 deletions ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
游戏案例地址 http://www.ulua.org/showcase.html
框架详细介绍 http://bbs.ulua.org/dispbbs.asp?boardid=3&Id=24

//-------------2015-08-25-------------
(1)同步cstolua2.0最新版本。

//-------------2015-08-22-------------
(1)精简PureMVC,留下了消息层,使用方式大大简化。
(2)添加自动Wrap模式,开关在AppConst.AutoWrapMode;
Expand Down

0 comments on commit ed02ad7

Please sign in to comment.