当前位置: 首页>>代码示例>>C#>>正文


C# ILuaState.PushNumber方法代码示例

本文整理汇总了C#中ILuaState.PushNumber方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.PushNumber方法的具体用法?C# ILuaState.PushNumber怎么用?C# ILuaState.PushNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILuaState的用法示例。


在下文中一共展示了ILuaState.PushNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WidgetReadOper

        protected override bool WidgetReadOper(ILuaState lua, string key)
        {
            switch (key)
            {
                case "speed":
                    lua.PushNumber(_speed);
                    return true;
                case "dwMMethod":
                    lua.PushInteger(_dwMMethod);
                    return true;
                case "bMoving":
                    lua.PushBoolean(_bMoving);
                    return true;
                case "fUpdateInterval":
                    lua.PushNumber(_fUpdateInterval);
                    return true;
                case "fAnimSpeed":
                    if (_animator)
                    {
                        lua.PushNumber(_animator.speed);
                    }
                    else
                    {
                        lua.PushNumber(0);
                    }
                    return true;
            }

            return base.WidgetReadOper(lua, key);
        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:30,代码来源:Actor.cs

示例2: WidgetReadOper

        protected override bool WidgetReadOper(ILuaState lua, string key)
        {
            switch (key)
            {
                case "name":
                    lua.PushString(gameObject.name);
                    break;
                case "fDir":
                    lua.PushNumber(transform.localEulerAngles.y);
                    break;
                case "position":
                    Vector3ToStack(lua, transform.position);
                    break;
                case "localPosition":
                    Vector3ToStack(lua, transform.localPosition);
                    break;
                case "localRotate":
                    Vector3ToStack(lua, transform.localEulerAngles);
                    break;
                case "localScale":
                    Vector3ToStack(lua, transform.localScale);
                    break;
                case "ambientLight":
                    ColorToStack(lua, RenderSettings.ambientLight);
                    break;
                case "ambientIntensity":
#if UNITY_4_6
                    lua.PushNumber(1.0);
#else
                    lua.PushNumber(RenderSettings.ambientIntensity);
#endif
                    break;
                case "fog":
                    lua.PushBoolean(RenderSettings.fog);
                    break;
                case "fogColor":
                    ColorToStack(lua, RenderSettings.fogColor);
                    break;
                case "fogDensity":
                    lua.PushNumber(RenderSettings.fogDensity);
                    break;
                case "fogEndDistance":
                    lua.PushNumber(RenderSettings.fogEndDistance);
                    break;
                case "fogMode":
                    lua.PushInteger((int)RenderSettings.fogMode);
                    break;
                case "fogStartDistance":
                    lua.PushNumber(RenderSettings.fogStartDistance);
                    break;
                default:
                    return false;
            }
            return true;
        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:55,代码来源:LuaExport.cs

示例3: OpenLib

		public static int OpenLib( ILuaState lua )
		{
			NameFuncPair[] define = new NameFuncPair[]
			{
				new NameFuncPair( "abs",   		Math_Abs ),
				new NameFuncPair( "acos",  		Math_Acos ),
				new NameFuncPair( "asin",  		Math_Asin ),
				new NameFuncPair( "atan2", 		Math_Atan2 ),
				new NameFuncPair( "atan",  		Math_Atan ),
				new NameFuncPair( "ceil",  		Math_Ceil ),
				new NameFuncPair( "cosh",  		Math_Cosh ),
				new NameFuncPair( "cos",   		Math_Cos ),
				new NameFuncPair( "deg",   		Math_Deg ),
				new NameFuncPair( "exp",   		Math_Exp ),
				new NameFuncPair( "floor", 		Math_Floor ),
				new NameFuncPair( "fmod",  		Math_Fmod ),
				new NameFuncPair( "frexp", 		Math_Frexp ),
				new NameFuncPair( "ldexp", 		Math_Ldexp ),
				new NameFuncPair( "log10", 		Math_Log10 ),
				new NameFuncPair( "log",   		Math_Log ),
				new NameFuncPair( "max",   		Math_Max ),
				new NameFuncPair( "min",   		Math_Min ),
				new NameFuncPair( "modf",  		Math_Modf ),
				new NameFuncPair( "pow",   		Math_Pow ),
				new NameFuncPair( "rad",   		Math_Rad ),
				new NameFuncPair( "random",     Math_Random ),
				new NameFuncPair( "randomseed", Math_RandomSeed ),
				new NameFuncPair( "sinh", 		Math_Sinh ),
				new NameFuncPair( "sin",   		Math_Sin ),
				new NameFuncPair( "sqrt",  		Math_Sqrt ),
				new NameFuncPair( "tanh",   	Math_Tanh ),
				new NameFuncPair( "tan",   		Math_Tan ),
			};

			lua.L_NewLib( define );

			lua.PushNumber( Math.PI );
			lua.SetField( -2, "pi" );

			lua.PushNumber( Double.MaxValue );
			lua.SetField( -2, "huge" );

			RandObj = new Random();

			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:46,代码来源:LuaMathLib.cs

示例4: B_CollectGarbage

        public static int B_CollectGarbage( ILuaState lua )
        {
            // not implement gc
            string opt = lua.L_OptString( 1, "collect" );
            switch( opt )
            {
                case "count":
                    lua.PushNumber( 0 );
                    lua.PushNumber( 0 );
                    return 2;

                case "step":
                case "isrunning":
                    lua.PushBoolean( true );
                    return 1;

                default:
                    lua.PushInteger( 0 );
                    return 1;
            }
        }
开发者ID:matthewyang,项目名称:UniLua,代码行数:21,代码来源:LuaBaseLib.cs

示例5: 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;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:17,代码来源:LuaTableLib.cs

示例6: WidgetReadOper

 protected override bool WidgetReadOper(ILuaState lua, string key)
 {
     switch (key)
     {
         case "onFinish":
             if (m_pfnFinish != 0)
             {
                 //lua.RawGetRegistry(m_pfnFinish);
             }
             return true;
         case "bDestroyOnFinish":
             lua.PushBoolean(m_bDestroyOnFinish);
             return true;
         case "finishTime":
             lua.PushNumber(m_fEffectTime);
             return true;
     }
     return base.WidgetReadOper(lua, key);
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:19,代码来源:LuaEffect.cs

示例7: Math_Rad

		private static int Math_Rad( ILuaState lua )
		{
			lua.PushNumber( lua.L_CheckNumber(1) * RADIANS_PER_DEGREE );
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:5,代码来源:LuaMathLib.cs

示例8: Math_Modf

		private static int Math_Modf( ILuaState lua )
		{
			double d = lua.L_CheckNumber(1);
			double c = Math.Ceiling(d);
			lua.PushNumber( c );
			lua.PushNumber( d-c );
			return 2;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:8,代码来源:LuaMathLib.cs

示例9: Math_Pow

		private static int Math_Pow( ILuaState lua )
		{
			lua.PushNumber( Math.Pow( lua.L_CheckNumber(1),
									  lua.L_CheckNumber(2)));
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:6,代码来源:LuaMathLib.cs

示例10: Math_Log

		private static int Math_Log( ILuaState lua )
		{
			double x = lua.L_CheckNumber(1);
			double res;
			if( lua.IsNoneOrNil(2) )
				res = Math.Log(x);
			else
			{
				double logBase = lua.L_CheckNumber(2);
				if( logBase == 10.0 )
					res = Math.Log10(x);
				else
					res = Math.Log(x, logBase);
			}
			lua.PushNumber(res);
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:17,代码来源:LuaMathLib.cs

示例11: Math_Min

		private static int Math_Min( ILuaState lua )
		{
			int n = lua.GetTop();
			double dmin = lua.L_CheckNumber(1);
			for( int i=2; i<=n; ++i )
			{
				double d = lua.L_CheckNumber(i);
				if( d < dmin )
					dmin = d;
			}
			lua.PushNumber(dmin);
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:13,代码来源:LuaMathLib.cs

示例12: Math_Tanh

		private static int Math_Tanh( ILuaState lua )
		{
			lua.PushNumber( Math.Tanh( lua.L_CheckNumber(1) ) );
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:5,代码来源:LuaMathLib.cs

示例13: ImportProperty

 public void ImportProperty(ILuaState lua, int dwIndex)
 {
     _listCtrl.Clear();
     lua.PushValue(dwIndex);
     int len = lua.L_Len(-1);
     for (int i = 1; i <= len; i++)
     {
         lua.PushNumber(i);
         lua.GetTable(-2);
         lua.PushString("event");
         lua.GetTable(-2);
         string eventName = lua.L_CheckString(-1);
         lua.Pop(1);
         StoryBaseCtrl objCtrl = InstanceEventCtrl(eventName);
         if (objCtrl != null)
         {
             objCtrl.ImportProperty(lua, -1);
             objCtrl.ModInfo();
         }
         else
         {
             Debug.LogWarning("InstanceEventCtrl objCtrl is null " + eventName);
         }
         lua.Pop(1);
         Add(objCtrl);
     }
     lua.Pop(1);
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:28,代码来源:StoryShotCtrl.cs

示例14: Math_Frexp

		private static int Math_Frexp( ILuaState lua )
		{
			double d = lua.L_CheckNumber(1);

			// Translate the double into sign, exponent and mantissa.
			long bits = BitConverter.DoubleToInt64Bits(d);
			// Note that the shift is sign-extended, hence the test against -1 not 1
			bool negative = (bits < 0);
			int exponent = (int) ((bits >> 52) & 0x7ffL);
			long mantissa = bits & 0xfffffffffffffL;

			// Subnormal numbers; exponent is effectively one higher,
			// but there's no extra normalisation bit in the mantissa
			if (exponent==0)
			{
				exponent++;
			}
			// Normal numbers; leave exponent as it is but add extra
			// bit to the front of the mantissa
			else
			{
				mantissa = mantissa | (1L<<52);
			}

			// Bias the exponent. It's actually biased by 1023, but we're
			// treating the mantissa as m.0 rather than 0.m, so we need
			// to subtract another 52 from it.
			exponent -= 1075;

			if (mantissa == 0) 
			{
				lua.PushNumber( 0.0 );
				lua.PushNumber( 0.0 );
				return 2;
			}

			/* Normalize */
			while((mantissa & 1) == 0) 
			{    /*  i.e., Mantissa is even */
				mantissa >>= 1;
				exponent++;
			}

			double m = (double)mantissa;
			double e = (double)exponent;
			while( m >= 1 )
			{
				m /= 2.0;
				e += 1.0;
			}

			if( negative ) m = -m;
			lua.PushNumber( m );
			lua.PushNumber( e );
			return 2;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:56,代码来源:LuaMathLib.cs

示例15: Math_Ceil

		private static int Math_Ceil( ILuaState lua )
		{
			lua.PushNumber( Math.Ceiling( lua.L_CheckNumber(1) ) );
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:5,代码来源:LuaMathLib.cs


注:本文中的ILuaState.PushNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。