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


C# ILuaState.ToInteger方法代码示例

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


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

示例1: applyTranslate

 public static int applyTranslate(ILuaState luaState)
 {
     if (luaState.IsTable(-1))
     {
         TranslateResult transRes = new TranslateResult();
         // 位移目标
         luaState.GetField(-1, "target");
         transRes.target = (Unit)luaState.ToUserData(-1);
         luaState.Pop(1);
         // 行偏移量
         luaState.GetField(-1, "offsetRow");
         transRes.offsetRow = luaState.ToInteger(-1);
         luaState.Pop(1);
         // 列偏移量
         luaState.GetField(-1, "offsetCol");
         transRes.offsetCol = luaState.ToInteger(-1);
         luaState.Pop(1);
         //// 位移原因
         //luaState.GetField(-1, "translateReason");
         //transRes. = luaState.ToInteger(-1);
         //luaState.Pop(1);
         ProcessManager.getInstance().addResult(transRes);
     }
     return 0;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:25,代码来源:EffectLib.cs

示例2: applyDamage

 public static int applyDamage(ILuaState luaState)
 {
     if (luaState.IsTable(-1))
     {
         DamageResult dmgRes = new DamageResult();
         // 攻击者
         luaState.GetField(-1, "attacker");
         dmgRes.attacker = (Unit)luaState.ToUserData(-1);
         luaState.Pop(1);
         // 受害者
         luaState.GetField(-1, "victim");
         dmgRes.victim = (Unit)luaState.ToUserData(-1);
         luaState.Pop(1);
         // 伤害
         luaState.GetField(-1, "physicalDamage");
         dmgRes.physicalDamage = luaState.ToInteger(-1);
         luaState.Pop(1);
         luaState.GetField(-1, "spellDamage");
         dmgRes.spellDamage = luaState.ToInteger(-1);
         luaState.Pop(1);
         luaState.GetField(-1, "hpRemoval");
         dmgRes.hpRemoval = luaState.ToInteger(-1);
         luaState.Pop(1);
         // 伤害原因
         luaState.GetField(-1, "damageReason");
         dmgRes.damageReason = (BattleConsts.DamageReason)luaState.ToInteger(-1);
         luaState.Pop(1);
         ProcessManager.getInstance().addResult(dmgRes);
     }
     return 0;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:31,代码来源:EffectLib.cs

示例3: testLuaCall

 public static int testLuaCall(ILuaState luaState)
 {
     bool arg2 = luaState.ToBoolean(-1);
     luaState.GetField(1, "n");
     int len = luaState.ToInteger(-1);
     luaState.Pop(1);
     int sum = 0;
     for (int i=0;i<len;i++)
     {
         luaState.PushInteger(i + 1);
         luaState.GetTable(1);
         sum += luaState.ToInteger(-1);
         luaState.Pop(1);
     }
     Thread.Sleep(5000);
     luaState.PushInteger(sum);
     Debug.Log(sum);
     return 1;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:19,代码来源:TestLuaLib.cs

示例4: IpairsAux

 private static int IpairsAux( ILuaState lua )
 {
     int i = lua.ToInteger( 2 );
     i++; // next value
     lua.PushInteger( i );
     lua.RawGetI( 1, i );
     return lua.IsNil( -1 ) ? 1 : 2;
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:8,代码来源:LuaBaseLib.cs

示例5: GmatchAux

		private static int GmatchAux( ILuaState lua )
		{
			MatchState ms = new MatchState();
			string src = lua.ToString( lua.UpvalueIndex(1) );
			string pattern = lua.ToString( lua.UpvalueIndex(2) );
			ms.Lua = lua;
			ms.Src = src;
			ms.SrcInit = 0;
			ms.SrcEnd = src.Length;
			ms.Pattern = pattern;
			ms.PatternEnd = pattern.Length;
			for( int s = lua.ToInteger( lua.UpvalueIndex(3) )
			   ; s <= ms.SrcEnd
			   ; s++ )
			{
				ms.Level = 0;
				int e = Match( ms, s, 0 );
				if( e != -1 )
				{
					int newStart = (e == 0) ? e+1: e;
					lua.PushInteger( newStart );
					lua.Replace( lua.UpvalueIndex(3) );
					return PushCaptures(lua, ms, s, e);
				}
			}
			return 0; // not found
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:27,代码来源:LuaStrLib.cs

示例6: WidgetWriteOper

        protected override bool WidgetWriteOper(ILuaState lua, string key)
        {
            switch (key)
            {
                case "target":
                    LuaObject obj = LuaObject.GetLuaObject(lua, 3);
                    if (obj != null)
                        target = obj.transform;
                    else
                        target = null;
                    break;
                case "type":
                    type = (CameraCastType)lua.ToInteger(3);
                    return true;
                case "depth":
                    _camera.depth = lua.ToInteger(3);
                    return true;
                case "distance":
                    m_normalInfo.distance = lua.ToInteger(3);
                    return true;
                case "LRAngle":
                    SetLRAngle((float)lua.L_CheckNumber(3));
                    return true;
                case "UDAngle":
                    SetUDAngle((float)lua.L_CheckNumber(3));
                    return true;
                case "offsetX":
                    m_normalInfo.offSet.x = (float)lua.L_CheckNumber(3);
                    return true;
                case "offsetY":
                    m_normalInfo.offSet.y = (float)lua.L_CheckNumber(3);
                    return true;
                case "offsetZ":
                    m_normalInfo.offSet.z = (float)lua.L_CheckNumber(3);
                    return true;
                case "offset":
                    {
                        if (lua.Type(3) != LuaType.LUA_TTABLE)
                        {
                            Debug.LogWarning("LuaGameCamera set offset attribute parm table excepted.");
                            return true;
                        }
                        Vector3 ve = m_normalInfo.offSet;

                        lua.GetField(3, "x");
                        ve.x = (float)lua.L_CheckNumber(-1);
                        lua.Pop(1);

                        lua.GetField(3, "y");
                        ve.y = (float)lua.L_CheckNumber(-1);
                        lua.Pop(1);

                        lua.GetField(3, "z");
                        ve.z = (float)lua.L_CheckNumber(-1);
                        lua.Pop(1);

                        m_normalInfo.offSet= ve;
                    }
                    return true;
            }
            //return false;
            return base.WidgetWriteOper(lua, key);
        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:63,代码来源:LuaGameCamera.cs

示例7: getEventVOProperty

 public static int getEventVOProperty(ILuaState luaState)
 {
     BattleEventBase evt = (BattleEventBase)luaState.ToUserData(-2);
     if (evt == null)
     {
         luaState.PushNil();
     }
     else
     {
         BattleConsts.Property propId = (BattleConsts.Property)luaState.ToInteger(-1);
         object prop = evt.getEventVOProperty(propId);
         if ( prop == null )
         {
             luaState.PushNil();
         }
         else
         {
             luaState.PushLightUserData(prop);
         }
     }
     return 1;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:22,代码来源:PropertyLib.cs

示例8: setEffectCode

 public static int setEffectCode(ILuaState luaState)
 {
     SkillEffect effect = (SkillEffect)luaState.ToUserData(-2);
     if ( effect == null )
     {
         throw new ArgumentException("effect is null!");
     }
     BattleConsts.Code code = (BattleConsts.Code)luaState.ToInteger(-1);
     effect.setCode(code);
     return 0;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:11,代码来源:PropertyLib.cs

示例9: getVOProperty

 /// <summary>
 /// 获取IBattleVO接口中的属性
 /// </summary>
 /// <param name="luaState"></param>
 /// <returns></returns>
 public static int getVOProperty(ILuaState luaState)
 {
     IBattleVO vo = (IBattleVO)luaState.ToUserData(-2);
     if (vo == null)
     {
         luaState.PushNil();
     }
     else
     {
         BattleConsts.Property propId = (BattleConsts.Property)luaState.ToInteger(-1);
         object prop = vo.getProperty(propId);
         if (prop == null)
         {
             luaState.PushNil();
         }
         else
         {
             // todo 暂时使用is来判断
             // 以后可能会加入全局hash
             if ( prop is int )
             {
                 luaState.PushInteger((int)prop);
             }
             else if ( prop is bool )
             {
                 luaState.PushBoolean((bool)prop);
             }
             else if ( prop is string )
             {
                 luaState.PushString((string)prop);
             }
             else
             {
                 luaState.PushLightUserData(prop);
             }
         }
     }
     return 1;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:44,代码来源:PropertyLib.cs

示例10: 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;
        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:15,代码来源:Entity.cs

示例11: 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);
//.........这里部分代码省略.........
开发者ID:cedar-x,项目名称:unilua_story,代码行数:101,代码来源:LuaPathCamera.cs

示例12: 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;
        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:59,代码来源:LuaExport.cs

示例13: pmain

 /// <summary>
 /// Main body of stand-alone interpreter (to be called in protected mode).
 /// Reads the options and handles them all.
 /// </summary>
 static int pmain(ILuaState L)
 {
     int argc = L.ToInteger(1);
     var argv = L.ToUserData<String[]>(2);
     int script = 0;
     int args = collectargs(argv, ref script);
     L.CheckVersion();   /* check that interpreter has correct version */
     if (argc > 0 && !String.IsNullOrWhiteSpace(argv[0])) progname = argv[0];
     if (args == has_error)
     {  /* bad arg? */
         print_usage(L, argv[script]);  /* 'script' has index of bad arg. */
         return 0;
     }
     if ((args & has_v) != 0)  /* option '-v'? */
         print_version(L);
     if ((args & has_E) != 0)
     {  /* option '-E'? */
         L.PushBoolean(true);  /* signal for libraries to ignore env. vars. */
         L.SetField(L.RegistryIndex, "LUA_NOENV");
     }
     //  luaL_openlibs(L);  /* open standard libraries */
     L.OpenLibs();
     createargtable(L, argv, argc, script);  /* create table 'arg' */
     if (0 == (args & has_E))
     {  /* no option '-E'? */
         if (handle_luainit(L) != LuaStatus.OK)  /* run LUA_INIT */
             return 0;  /* error running LUA_INIT */
     }
     if (runargs(L, argv, script) == 0)  /* execute arguments -e and -l */
         return 0;  /* something failed */
     if (script < argc &&  /* execute main script (if there is one) */
         handle_script(L, argv, script) != LuaStatus.OK)
         return 0;
     if ((args & has_i) != 0)  /* -i option? */
         doREPL(L);  /* do read-eval-print loop */
     else if (script == argc && 0 == (args & (has_e | has_v)))
     {  /* no arguments? */
         if (lua_stdin_is_tty())
         {  /* running in interactive mode? */
             print_version(L);
             doREPL(L);  /* do read-eval-print loop */
         }
         else dofile(L, null);  /* executes stdin as a file */
     }
     L.PushBoolean(true);  /* signal no errors */
     return 1;
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:51,代码来源:Program.cs


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