static int RemoveEventHander(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); TGNetService obj = (TGNetService)ToLua.CheckObject(L, 1, typeof(TGNetService)); string arg0 = ToLua.CheckString(L, 2); TGNetService.NetEventHanlder arg1 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg1 = (TGNetService.NetEventHanlder)ToLua.CheckObject(L, 3, typeof(TGNetService.NetEventHanlder)); } else { LuaFunction func = ToLua.ToLuaFunction(L, 3); arg1 = DelegateFactory.CreateDelegate(typeof(TGNetService.NetEventHanlder), func) as TGNetService.NetEventHanlder; } obj.RemoveEventHander(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private void Start() { netService = TGNetService.GetInstance(); //StartCoroutine(doJoystick()); //StartCoroutine(doScreenClick()); }
public static TGNetService GetInstance() { if (instance == null) { instance = new TGNetService(); } return(instance); }
private void OnDestroy() { if (lua != null) { lua.Dispose(); lua = null; } TGNetService.GetInstance().Stop(); }
static int GetServerLatency(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); int o = TGNetService.GetServerLatency(); LuaDLL.lua_pushinteger(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetServerTime(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); System.DateTime o = TGNetService.GetServerTime(); ToLua.PushValue(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int Stop(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); TGNetService obj = (TGNetService)ToLua.CheckObject(L, 1, typeof(TGNetService)); obj.Stop(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int NewInstance(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); TGNetService o = TGNetService.NewInstance(); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetServerPassedTime(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); System.DateTime arg0 = (System.DateTime)ToLua.CheckObject(L, 1, typeof(System.DateTime)); float o = TGNetService.GetServerPassedTime(arg0); LuaDLL.lua_pushnumber(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SendRequest(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); TGNetService obj = (TGNetService)ToLua.CheckObject(L, 1, typeof(TGNetService)); TGNetService.NetRequest arg0 = (TGNetService.NetRequest)ToLua.CheckObject(L, 2, typeof(TGNetService.NetRequest)); obj.SendRequest(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int IsRunning(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); TGNetService obj = (TGNetService)ToLua.CheckObject(L, 1, typeof(TGNetService)); bool o = obj.IsRunning(); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int NetEventDispatcher(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); TGNetService obj = (TGNetService)ToLua.CheckObject(L, 1, typeof(TGNetService)); System.Collections.IEnumerator o = obj.NetEventDispatcher(); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int Start(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); TGNetService obj = (TGNetService)ToLua.CheckObject(L, 1, typeof(TGNetService)); string arg0 = ToLua.CheckString(L, 2); int arg1 = (int)LuaDLL.luaL_checknumber(L, 3); obj.Start(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int set_pool(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); TGNetService obj = (TGNetService)o; UTGNetServicePool arg0 = (UTGNetServicePool)ToLua.CheckObject(L, 2, typeof(UTGNetServicePool)); obj.pool = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index pool on a nil value" : e.Message)); } }
static int set_serverPort(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); TGNetService obj = (TGNetService)o; int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); obj.serverPort = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index serverPort on a nil value" : e.Message)); } }
static int set_serverIp(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); TGNetService obj = (TGNetService)o; string arg0 = ToLua.CheckString(L, 2); obj.serverIp = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index serverIp on a nil value" : e.Message)); } }
static int get_pool(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); TGNetService obj = (TGNetService)o; UTGNetServicePool ret = obj.pool; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index pool on a nil value" : e.Message)); } }
static int get_serverPort(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); TGNetService obj = (TGNetService)o; int ret = obj.serverPort; LuaDLL.lua_pushinteger(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index serverPort on a nil value" : e.Message)); } }
public static TGNetService NewInstance() { instance.Stop(); instance = new TGNetService(); return(instance); }
private IEnumerator UpdateUI() { var data = new BattleUpdateData(); data.SkillDatas = new BattleUpdateSkillData[6]; for (int i = 0; i < data.SkillDatas.Length; i++) { data.SkillDatas[i] = new BattleUpdateSkillData(); } data.Ally = new BattleUpdatePlayerData[5]; for (int i = 0; i < data.Ally.Length; i++) { data.Ally[i] = new BattleUpdatePlayerData(); } data.Enemy = new BattleUpdatePlayerData[5]; for (int i = 0; i < data.Enemy.Length; i++) { data.Enemy[i] = new BattleUpdatePlayerData(); } var enemyList = new ArrayList(); var updateFunction = NTGApplicationController.Instance.LuaGetFunction("UIBattleAPI", "BattleUpdate"); while (true) { data.GameDuration = String.Format("{0:00}:{1:00}", (int)((Time.time - mainController.battleStartTime) / 60), (Time.time - mainController.battleStartTime) % 60); data.FPS = ((int)Math.Round(fps)).ToString(); data.TeamKill = mainController.allyScore.ToString(); data.EnemyTeamKill = mainController.enemyScore.ToString(); data.PersonKill = localPlayerController.statistic.kill.ToString(); data.PersonDead = localPlayerController.statistic.death.ToString(); data.PersonAssists = localPlayerController.statistic.assist.ToString(); data.Coin = String.Format("{0}", (int)localPlayerController.coin); if (netService != null && netService.IsRunning()) { data.NetworkLatency = String.Format("{0}ms", TGNetService.GetServerLatency()); } if (localPlayerController.targetUnit == null) { data.TargetActive = false; } else { data.TargetActive = true; data.TargetIcon = localPlayerController.targetUnit.icon; data.TargetHp = localPlayerController.targetUnit.hp; data.TargetHpMax = localPlayerController.targetUnit.hpMax; data.TargetMp = localPlayerController.targetUnit.mp; data.TargetMpMax = localPlayerController.targetUnit.mpMax; data.TargetPAtk = localPlayerController.targetUnit.pAtk; data.TargetMAtk = localPlayerController.targetUnit.mAtk; data.TargetPDef = localPlayerController.targetUnit.pDef; data.TargetMDef = localPlayerController.targetUnit.mDef; if (data.TargetHp < 0) { data.TargetHp = 0; } } data.Player = localPlayerController; for (int i = 1; i <= 6; i++) { if (i < localPlayerController.skills.Length && localPlayerController.skills[i] != null) { data.SkillDatas[i - 1].Valid = true; data.SkillDatas[i - 1].Id = localPlayerController.skills[i].id; data.SkillDatas[i - 1].Level = localPlayerController.skills[i].level; data.SkillDatas[i - 1].MPCost = (int)localPlayerController.skills[i].mpCost; data.SkillDatas[i - 1].CD = localPlayerController.skills[i].inCd; data.SkillDatas[i - 1].MaxCD = (int)localPlayerController.skills[i].cd; data.SkillDatas[i - 1].MpEnough = localPlayerController.mp >= localPlayerController.skills[i].mpCost; if (!mainController.DebugMode && i <= 3) { bool canUpgrade = localPlayerController.skillPoint > 0 && localPlayerController.level >= localPlayerController.skills[i].requireUpgradeLevel && localPlayerController.skills[i].level < localPlayerController.skills[i].levelCap; data.SkillDatas[i - 1].CanUpgrade = canUpgrade; } } else { data.SkillDatas[i - 1].Valid = false; } } for (int i = 0; i < allyPlayerList.Count; i++) { var player = allyPlayerList[i] as NTGBattlePlayerController; data.Ally[i].Valid = true; data.Ally[i].HPRatio = player.hp / player.hpMax; if (player.skills[3] != null && player.skills[3].level > 0) { data.Ally[i].SkillReady = player.skills[3].inCd <= 0; } else { data.Ally[i].SkillReady = false; } data.Ally[i].ReviveCount = (int)player.reviveCountDown; } enemyList.Clear(); for (int i = 0; i < enemyPlayerList.Count; i++) { var player = enemyPlayerList[i] as NTGBattlePlayerController; if (player.reviveCountDown > 0) { int p = enemyList.Count; for (int j = 0; j < enemyList.Count; j++) { var pc = enemyList[j] as NTGBattlePlayerController; if (player.reviveCountDown < pc.reviveCountDown) { p = j; break; } } enemyList.Insert(p, player); } } for (int i = 1; i <= 5; i++) { if (i - 1 < enemyList.Count) { var player = enemyList[i - 1] as NTGBattlePlayerController; data.Enemy[i - 1].Valid = true; data.Enemy[i - 1].Icon = player.icon; data.Enemy[i - 1].ReviveCount = (int)player.reviveCountDown; } else { data.Enemy[i - 1].Valid = false; } } //updateFunction.Call(uiBattleAPI, data); updateFunction.BeginPCall(); updateFunction.Push(uiBattleAPI); updateFunction.Push(data); updateFunction.PCall(); updateFunction.EndPCall(); yield return(new WaitForSeconds(0.1f)); } }