本文整理汇总了C#中ILuaState.ToNumber方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.ToNumber方法的具体用法?C# ILuaState.ToNumber怎么用?C# ILuaState.ToNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.ToNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WidgetWriteOper
protected override bool WidgetWriteOper(ILuaState lua, string key)
{
switch (key)
{
case "onFinish":
{
//lua.L_UnrefRegistry(ref m_pfnFinish);
if (lua.Type(3) != LuaType.LUA_TFUNCTION)
{
return true;
}
lua.PushValue(3);
m_pfnFinish = lua.L_Ref(LuaDef.LUA_REGISTRYINDEX);
}
return true;
case "bDestroyOnFinish":
m_bDestroyOnFinish = lua.ToBoolean(3);
return true;
case "finishTime":
m_fEffectTime = (float)lua.ToNumber(3);
return true;
}
return base.WidgetWriteOper(lua, key);
}
示例2: TBL_MaxN
private static int TBL_MaxN( ILuaState lua )
{
double max = 0.0;
lua.L_CheckType( 1, LuaType.LUA_TTABLE );
lua.PushNil(); // first key
while( lua.Next(1) )
{
lua.Pop( 1 ); // remove value
if( lua.Type( -1 ) == LuaType.LUA_TNUMBER ) {
double v = lua.ToNumber( -1 );
if( v > max ) max = v;
}
}
lua.PushNumber( max );
return 1;
}
示例3: GetValue
public static dynamic GetValue(this LuaType self, ILuaState luaState, int index)
{
switch (self)
{
case LuaType.Boolean:
return luaState.ToBoolean(index);
case LuaType.Number:
return luaState.ToNumber(index);
case LuaType.String:
return luaState.ToString(index);
case LuaType.Table:
return new LuaTable(luaState, index);
case LuaType.Nil:
return null;
default:
throw new NotImplementedException(string.Format("Try get {0} of type {1}", index, self));
}
}
示例4: ToRawValue
public static object ToRawValue( ILuaState lua, int index, Type t )
{
switch( t.FullName )
{
case "System.Boolean":
return lua.ToBoolean( index );
case "System.Char": {
var s = lua.ToString( index );
if( string.IsNullOrEmpty( s ) )
return null;
return s[0];
}
case "System.Byte":
return (byte)lua.ToNumber( index );
case "System.SByte":
return (sbyte)lua.ToNumber( index );
case "System.Int16":
return (short)lua.ToNumber( index );
case "System.UInt16":
return (ushort)lua.ToNumber( index );
case "System.Int32":
return (int)lua.ToNumber( index );
case "System.UInt32":
return (uint)lua.ToNumber( index );
case "System.Int64":
return (Int64)lua.ToUserData( index );
case "System.UInt64":
return (UInt64)lua.ToUserData( index );
case "System.Single":
return (float)lua.ToNumber( index );
case "System.Double":
return (double)lua.ToNumber( index );
case "System.Decimal":
return (decimal)lua.ToUserData( index );
case "System.String":
return lua.ToString( index );
case "System.Object":
return (object)lua.ToUserData( index );
default: {
var u = lua.ToUserData(index);
if( u == null )
{
// UnityEngine.Debug.Log( "==========" +
// " Name:" + t.Name +
// " FullName:" + t.FullName );
return null;
}
else return u;
}
}
}
示例5: Lua_DoShake
int Lua_DoShake(ILuaState lua)
{
float intensity = (float)lua.ToNumber(2);
float durtime = (float)lua.ToNumber(3);
m_shakeParam.intensity = intensity;
m_shakeParam.durTime = durtime;
if (m_shakeParam.bShake == false)
{
m_shakeParam.originalPos = m_normalInfo.offSet;
}
m_shakeParam.fStart = Time.time;
m_shakeParam.bShake = true;
return 0;
}
示例6: Lua_PlayEffect
int Lua_PlayEffect(ILuaState lua)
{
string effect = lua.ToString(2);
float fDelay = (float)lua.ToNumber(3);
bool bWorldPos = lua.ToBoolean(4);
float fExistTime = (float)lua.ToNumber(5);
int dwEffectType = (int)EffectType.Once;
if(lua.Type(6) == LuaType.LUA_TNUMBER)
{
dwEffectType = lua.ToInteger(6);
}
this.PlayEffect(effect, fDelay,bWorldPos,fExistTime,(EffectType)dwEffectType);
return 0;
}
示例7: WidgetWriteOper
protected override bool WidgetWriteOper(ILuaState lua, string key)
{
switch (key)
{
case "isLoop":
_cameraPath.loop = (bool)lua.ToBoolean(3);
break;
case "interpolation":
_cameraPath.interpolation = (CameraPath.Interpolation)lua.ToInteger(3);
break;
case "animtarget":
LuaObject obj = LuaObject.GetLuaObject(lua, 3);
SetAnimTarget(obj.transform);
break;
case "animMode":
_cameraAnimator.animationMode = (CameraPathAnimator.animationModes)lua.ToInteger(3);
break;
case "speed":
_cameraAnimator.pathSpeed = (float)lua.ToNumber(3);
break;
case "controlpoints":
lua.PushValue(3);
int count = lua.L_Len(-1);
_cameraPath.Clear();
for (int i = 1; i <= count; i++)
{
lua.PushNumber(i);
lua.GetTable(-2);
lua.PushString("controlpoint");
lua.GetTable(-2);
Vector3 controlPoint = GetVector3(lua, -1);
lua.Pop(1);
lua.PushString("forwardControlPoint");
lua.GetTable(-2);
Vector3 forwardControlPoint = GetVector3(lua, -1);
lua.Pop(1);
lua.PushString("backwardControlPoint");
lua.GetTable(-2);
Vector3 backwardControlPoint = GetVector3(lua, -1);
lua.Pop(1);
lua.Pop(1);
_cameraPath.AddPoint(controlPoint);
_cameraPath[i-1].forwardControlPoint = forwardControlPoint;
_cameraPath[i-1].backwardControlPoint = backwardControlPoint;
}
lua.Pop(1);
break;
case "speedArr": //lsy add
//Debug.Log("-----------SPEED-------WRITE----------");
lua.PushValue(3);
int count2 = lua.L_Len(-1);
_cameraPath.speedList.Clear();
for (int i = 1; i <= count2; i++) {
lua.PushNumber(i);
lua.GetTable(-2);
Quaternion pointRotation = GetQuaternion(lua, -1);
//------------------------------------------
int point = -1, cpointA = -1, cpointB = -1;
float curvePercentage = 0f;
int speed = 0;
//free or fixedToPoint
lua.PushString("positionModes");
lua.GetTable(-2);
CameraPathPoint.PositionModes positionModes = (CameraPathPoint.PositionModes)lua.ToInteger(-1);
lua.Pop(1);
lua.PushString("percent");
lua.GetTable(-2);
float percent = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("point");
lua.GetTable(-2);
if (lua.Type(-1) != LuaType.LUA_TNIL)
point = lua.ToInteger(-1);
lua.Pop(1);
lua.PushString("cpointA");
lua.GetTable(-2);
if (lua.Type(-1) != LuaType.LUA_TNIL)
cpointA = lua.ToInteger(-1);
lua.Pop(1);
lua.PushString("cpointB");
lua.GetTable(-2);
if (lua.Type(-1) != LuaType.LUA_TNIL)
cpointB = lua.ToInteger(-1);
lua.Pop(1);
lua.PushString("curvePercentage");
lua.GetTable(-2);
if (lua.Type(-1) != LuaType.LUA_TNIL)
curvePercentage = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("speed");
lua.GetTable(-2);
//.........这里部分代码省略.........
示例8: GetKeyframe
public static Keyframe GetKeyframe(ILuaState lua, int index)
{
Keyframe key = new Keyframe();
lua.PushValue(index);
lua.PushString("time");
lua.GetTable(-2);
key.time = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("value");
lua.GetTable(-2);
key.value = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("inTangent");
lua.GetTable(-2);
key.inTangent = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("outTangent");
lua.GetTable(-2);
key.outTangent = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.Pop(1);
return key;
}
示例9: Lua_Play
private int Lua_Play(ILuaState lua)
{
float fDelay = (float)lua.ToNumber(2);
float fPlayTime = (float)lua.ToNumber(3);
bool bDestroyOnFinish = lua.ToBoolean(4);
Play(fDelay,fPlayTime,bDestroyOnFinish);
return 0;
}
示例10: GetColor
public static Color GetColor(ILuaState lua, int dwIndex)
{
Color v = Color.black;
lua.PushValue(dwIndex);
lua.PushString("r");
lua.GetTable(-2);
v.r = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("g");
lua.GetTable(-2);
v.g = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("b");
lua.GetTable(-2);
v.b = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("a");
lua.GetTable(-2);
v.a = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.Pop(1);
return v;
}
示例11: GetNormalInfo
public static normalInfo GetNormalInfo(ILuaState lua, int dwIndex)
{
normalInfo nInfo = new normalInfo();
lua.PushValue(dwIndex);
lua.PushString("LRAngle");
lua.GetTable(-2);
nInfo.rotationLR = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("UDAngle");
lua.GetTable(-2);
nInfo.rotationUD = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("distance");
lua.GetTable(-2);
nInfo.distance = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("offset");
lua.GetTable(-2);
nInfo.offSet = GetVector3(lua, -1);
lua.Pop(1);
lua.Pop(1);
return nInfo;
}
示例12: GetQuaternion
public static Quaternion GetQuaternion(ILuaState lua, int dwIndex)
{
Quaternion v = new Quaternion();
lua.PushValue(dwIndex);
lua.PushString("x");
lua.GetTable(-2);
v.x = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("y");
lua.GetTable(-2);
v.y = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("z");
lua.GetTable(-2);
v.z = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("w");
lua.GetTable(-2);
v.w = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.Pop(1);
return v;
}
示例13: GetVector2
/// <summary>
///
/// </summary>
public static Vector3 GetVector2(ILuaState lua, int dwIndex)
{
Vector2 v = Vector2.zero;
lua.PushValue(dwIndex);
lua.PushString("x");
lua.GetTable(-2);
v.x = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.PushString("y");
lua.GetTable(-2);
v.y = (float)lua.ToNumber(-1);
lua.Pop(1);
lua.Pop(1);
return v;
}
示例14: WidgetWriteOper
protected override bool WidgetWriteOper(ILuaState lua, string key)
{
//Debug.Log("LuaExport:StramImportOper:"+key);
int dwStackIndex = lua.GetTop();
switch (key)
{
case "name":
gameObject.name = lua.L_CheckString(3);
break;
case "fDir":
transform.localEulerAngles = new Vector3(0, (float)lua.L_CheckNumber(3), 0);
break;
case "position":
transform.position = GetVector3(lua, 3);
break;
case "localPosition":
transform.localPosition = GetVector3(lua, 3);
break;
case "localRotate":
transform.localEulerAngles = GetVector3(lua, 3);
break;
case "localScale":
transform.localScale = GetVector3(lua, 3);
break;
case "ambientLight":
RenderSettings.ambientLight = GetColor(lua, 3);
break;
case "ambientIntensity":
#if UNITY_4_6
#else
RenderSettings.ambientIntensity = (float)lua.ToNumber(3);
#endif
break;
case "fog":
RenderSettings.fog = lua.ToBoolean(3);
break;
case "fogColor":
RenderSettings.fogColor = GetColor(lua, 3);
break;
case "fogDensity":
RenderSettings.fogDensity = (float)lua.ToNumber(3);
break;
case "fogEndDistance":
RenderSettings.fogEndDistance = (float)lua.ToNumber(3);
break;
case "fogMode":
RenderSettings.fogMode = (FogMode)lua.ToInteger(3);;
break;
case "fogStartDistance":
RenderSettings.fogStartDistance = (float)lua.ToNumber(3);
break;
default:
return false;
}
if (dwStackIndex != lua.GetTop())
Debug.LogWarning("LuaExport:WidgetWriteOper stack Exception:start=" + key + ":" + dwStackIndex + " end=" + lua.GetTop());
return true;
}
示例15: Lua_Play3DSound
private static int Lua_Play3DSound(ILuaState lua)
{
string name = lua.L_CheckString(2);
float fDelay = 0;
if (lua.Type(3) == LuaType.LUA_TNUMBER)
{
fDelay = (float)lua.ToNumber(3);
}
PlaySound(name, 0, 0, 0, fDelay);
return 0;
}