protected override void OnInit() { base.OnInit(); luaEnv = LuaManager.luaEnv;//从LuaManager上获取 全局只有一个 if (luaEnv == null) { return; } scriptEnv = luaEnv.NewTable(); LuaTable meta = luaEnv.NewTable(); meta.Set("__index", luaEnv.Global); scriptEnv.SetMetaTable(meta); meta.Dispose(); string name = "UI_TaskView"; onInit = scriptEnv.GetInPath <OnInitHandler>(name + ".OnInit"); onOpen = scriptEnv.GetInPath <OnOpenHandler>(name + ".OnOpen"); onClose = scriptEnv.GetInPath <OnCloseHandler>(name + ".OnClose"); onBefore = scriptEnv.GetInPath <OnBeforeHandler>(name + ".OnBefore"); scriptEnv.Set("self", this); onInit?.Invoke(UIFormTransform, Close); }
private void Awake() { //得到lua的环境 luaEnv = LuaHelper.GetInstance().GetLuaEnv(); /* 设置luaTable 的元方法 (“__index”) */ luaTable = luaEnv.NewTable(); LuaTable tmpTab = luaEnv.NewTable();//临时表 tmpTab.Set("__index", luaEnv.Global); luaTable.SetMetaTable(tmpTab); tmpTab.Dispose(); /* 得到当前脚本所在对象的预设名称,且去除后缀(["(Clone)"]) */ string prefabName = this.name; //当前脚本所挂载的游戏对象的名称 if (prefabName.Contains("(Clone)")) { prefabName = prefabName.Split(new string[] { "(Clone)" }, StringSplitOptions.RemoveEmptyEntries)[0]; } /* 查找指定路径下lua文件中的方法,映射为委托 */ luaAwake = luaTable.GetInPath<BaseLuaUIForm.delLuaAwake>(prefabName + ".Awake"); luaStart = luaTable.GetInPath<BaseLuaUIForm.delLuaStart>(prefabName + ".Start"); luaUpdate = luaTable.GetInPath<BaseLuaUIForm.delLuaUpdate>(prefabName + ".Update"); luaDestroy = luaTable.GetInPath<BaseLuaUIForm.delLuaDestroy>(prefabName + ".OnDestroy"); //调用委托 if (luaAwake != null) { luaAwake(gameObject); } }
public void initSerializeFunc() { LuaEnv serializelua = null; if (serializeInMainThread) { serializelua = lua.lua; } else { serializelua = new LuaEnv(); } CLUtlLua.addLuaLoader(serializelua); object[] ret = CLUtlLua.doLua(serializelua, serializeluaPath); if (ret != null && ret.Length > 0) { luaTable = (LuaTable)(ret [0]); packMsgFunc = luaTable.GetInPath <TcpPackMessageAndSendFunc>("packMsg"); unPackMsgFunc = luaTable.GetInPath <TcpUnpackMessageFunc>("unpackMsg"); } else { Debug.LogError("SetLua no luatable returned !! ==" + serializeluaPath); } }
/// <summary> /// 开启这个debug断点功能 /// 在mono里边调用,这个mono最好是传说中的LuaManager /// </summary> public static void StartUp(MonoBehaviour luaManagerScript, LuaEnv usingEnv, string ip = "127.0.0.1", int port = 7003) { debugLuaFilePath = string.Concat(Application.dataPath, "/XLua-Debug-VSCode/LuaDebug.lua").Replace("/", "\\"); debugLuaJITFilePath = string.Concat(Application.dataPath, "/XLua-Debug-VSCode/LuaDebugjit.lua").Replace("/", "\\"); debugLuaEnvFilePath = string.Concat(Application.dataPath, "/XLua-Debug-VSCode/XLua_Debug_VSCode_Env.lua").Replace("/", "\\"); usingEnv.AddLoader(LoaderExtension); LuaTable meta = usingEnv.NewTable(); scriptTable = usingEnv.NewTable(); meta.Set("__index", usingEnv.Global); scriptTable.SetMetaTable(meta); meta.Dispose(); usingEnv.DoString(System.IO.File.ReadAllText(debugLuaEnvFilePath), "XLua_Debug_VSCode_Env", scriptTable); StartUpCaller startUpCaller = scriptTable.GetInPath <StartUpCaller>("XLua_Debug_VSCode_Env.StartUp"); loopCallCaller = scriptTable.GetInPath <LoopCallCaller>("XLua_Debug_VSCode_Env.LoopCall"); startUpCaller.Invoke(scriptTable, ip, port); if (luaManagerScript != null) { luaManagerScript.StartCoroutine(LoopCall()); } }
/// <summary> /// 初始化lua部分 /// </summary> void InitLua() { LuaEnv.CustomLoader method = CustomLoaderMethod; GameManager.GetLuaEnv().AddLoader(method); scriptEnv = GameManager.GetLuaEnv().NewTable(); // 为每个脚本设置一个独立的环境,可一定程度上防止脚本间全局变量、函数冲突 LuaTable meta = GameManager.GetLuaEnv().NewTable(); meta.Set("__index", GameManager.GetLuaEnv().Global); scriptEnv.SetMetaTable(meta); meta.Dispose(); luaPath = cardNo + ".C" + cardNo; GameManager.GetLuaEnv().DoString(@"C" + cardNo + " = require('" + luaPath + "')", "LuaMagicCard", scriptEnv); scriptEnv.Set("self", this); initInfoAction = scriptEnv.GetInPath <Action <CardBase> >("C" + cardNo + ".InitInfo"); canLaunchEffectAction = scriptEnv.GetInPath <ActionJudge>("C" + cardNo + ".CanLaunchEffect"); costAction = scriptEnv.GetInPath <Action <CardBase> >("C" + cardNo + ".Cost"); launchEffectAction = scriptEnv.GetInPath <Action <CardBase> >("C" + cardNo + ".LaunchEffect"); changeCardGameState = scriptEnv.GetInPath <ActionChangeCardGameState>("C" + cardNo + ".ChangeCardGameState"); if (initInfoAction != null) { initInfoAction(this); } else { Debug.LogError("卡牌:" + cardNo + "缺少SetInfo方法!"); } }
private LuaEnv luaEnv; // 全局唯一的lua虚拟机 void Awake() { luaEnv = LuaMgr.luaEnv; scriptEnv = luaEnv.NewTable(); LuaTable meta = luaEnv.NewTable(); // 元表 meta.Set("__index", luaEnv.Global); scriptEnv.SetMetaTable(meta); meta.Dispose(); string prefabName = name; if (prefabName.Contains("(Clone)")) { prefabName = prefabName.Split('(')[0]; } prefabName = prefabName.Replace("pan_", ""); luaAwake = scriptEnv.GetInPath <LuaViewBehaviour.delLuaAwake>(prefabName + ".awake"); luaStart = scriptEnv.GetInPath <LuaViewBehaviour.delLuaStart>(prefabName + ".start"); luaUpdate = scriptEnv.GetInPath <LuaViewBehaviour.delLuaUpdate>(prefabName + ".update"); luaOnDestroy = scriptEnv.GetInPath <LuaViewBehaviour.delLuaOnDestroy>(prefabName + ".ondestroy"); scriptEnv.Set("self", this); if (luaAwake != null) { luaAwake(gameObject); } }
protected override void OnInit(object userData) { base.OnInit(userData); luaEnv = LuaManager.luaEnv; //此处要从LuaManager上获取 全局只有一个 scriptEnv = luaEnv.NewTable(); LuaTable meta = luaEnv.NewTable(); meta.Set("__index", luaEnv.Global); scriptEnv.SetMetaTable(meta); meta.Dispose(); string prefabName = name; if (prefabName.Contains("(Clone)")) { prefabName = prefabName.Split(new string[] { "(Clone)" }, StringSplitOptions.RemoveEmptyEntries)[0] + "View"; } onInit = scriptEnv.GetInPath <OnInitHandler>(prefabName + ".OnInit"); onOpen = scriptEnv.GetInPath <OnOpenHandler>(prefabName + ".OnOpen"); onClose = scriptEnv.GetInPath <OnCloseHandler>(prefabName + ".OnClose"); onBeforDestroy = scriptEnv.GetInPath <OnBeforDestroyHandler>(prefabName + ".OnBeforDestroy"); scriptEnv.Set("self", this); if (onInit != null) { onInit(userData); } }
public void Init(string name) { prefabName = name; try { LuaTable meta = LuaManager.NewTable(); LuaTable scriptEnv = LuaManager.NewTable(); scriptEnv.SetMetaTable(meta); meta.Set("__index", LuaManager.Global); LuaManager.DoString(string.Format("require '{0}'", name), prefabName, scriptEnv); luaAwake = scriptEnv.GetInPath <delLuaAwake>(prefabName + ".awake"); luaStart = scriptEnv.GetInPath <delLuaStart>(prefabName + ".start"); luaUpdate = scriptEnv.GetInPath <delLuaUpdate>(prefabName + ".update"); luaOnDestroy = scriptEnv.GetInPath <delLuaOnDestroy>(prefabName + ".ondestroy"); if (luaAwake != null) { luaAwake(gameObject); } } catch (Exception ex) { Debug.LogErrorFormat(ex.ToString()); } }
void Awake() { luaEnv = LuaManager.luaEnv; //此处要从LuaManager上获取 全局只有一个 scriptEnv = luaEnv.NewTable(); LuaTable meta = luaEnv.NewTable(); meta.Set("__index", luaEnv.Global); scriptEnv.SetMetaTable(meta); meta.Dispose(); string prefabName = name; if (prefabName.Contains("(Clone)")) { prefabName = prefabName.Split(new string[] { "(Clone)" }, StringSplitOptions.RemoveEmptyEntries)[0]; } prefabName = prefabName.Replace("pan_", ""); luaAwake = scriptEnv.GetInPath <LuaBehaviour.delLuaAwake>(prefabName + ".awake"); luaStart = scriptEnv.GetInPath <LuaBehaviour.delLuaStart>(prefabName + ".start"); luaUpdate = scriptEnv.GetInPath <LuaBehaviour.delLuaUpdate>(prefabName + ".update"); luaOnDestroy = scriptEnv.GetInPath <LuaBehaviour.delLuaOnDestroy>(prefabName + ".ondestroy"); scriptEnv.Set("self", this); if (luaAwake != null) { luaAwake(gameObject); } }
private void Awake() { luaEnv = LuaManager.LuaEnv; scriptEnv = luaEnv.NewTable(); var meta = luaEnv.NewTable(); meta.Set("__index", luaEnv.Global); scriptEnv.SetMetaTable(meta); meta.Dispose(); scriptEnv.Set("self", this); foreach (var injection in injections) { scriptEnv.Set(injection.name, injection.value); } var prefabName = name; if (prefabName.Contains("(Clone)")) { prefabName = prefabName.Split(new[] { "(Clone)" }, StringSplitOptions.RemoveEmptyEntries)[0]; } prefabName = prefabName.Replace("Panel", ""); luaAwake = scriptEnv.GetInPath <delLuaAwake>(prefabName + ".awake"); luaStart = scriptEnv.GetInPath <delLuaStart>(prefabName + ".start"); luaUpdate = scriptEnv.GetInPath <delLuaUpdate>(prefabName + ".update"); luaOnDestroy = scriptEnv.GetInPath <delLuaOnDestroy>(prefabName + ".ondestroy"); _myClass = luaEnv.Global.Get <MyClass>("MyClass"); Debug.Log(_myClass == null); luaAwake?.Invoke(gameObject); }
public void SetInfo(LuaTable t) { string targetIcon = t.Get <string>("icon"); int targetLevel = t.Get <int>("level"); bool targetIsLock = t.Get <bool>("isLock"); int targetSSR = t.Get <int>("ssrType"); int targetType = t.Get <int>("type"); int targetEquipPos = t.GetInPath <int>("cfg.type");//t.Get<int>("pos");//装备的穿戴位置 var _strType = t.GetInPath <int>("cfg.id").ToString(); int targetAdv = System.Convert.ToInt32(_strType.Substring(_strType.Length - 3, 1)); if (m_icon == targetIcon && m_level == targetLevel && m_lock == targetIsLock && m_ssr == targetSSR && EquipType == targetType && Pos == targetEquipPos && m_advLevel == targetAdv) { return; } icon = targetIcon; level = targetLevel; isLock = targetIsLock; ssr = targetSSR; EquipType = targetType; Pos = targetEquipPos; m_advActive = targetType == 0 ? true : false; advLevel = targetAdv; }
public void Init(string scriptName) { scriptEnv = LuaMVC.Program.luaEnv.NewTable(); LuaTable meta = Program.luaEnv.NewTable(); meta.Set("__index", Program.luaEnv.Global); scriptEnv.SetMetaTable(meta); meta.Dispose(); // 加载lua script LuaMVC.Program.luaEnv.DoString("require " + "'" + scriptName + "'", scriptName, scriptEnv); string[] array = scriptName.Split('/'); //此处是因为加载的lua地址是全路径 而lua脚本名只有第一个 scriptName = array[array.Length - 1]; scriptEnv.SetInPath <MonoBehaviour>(scriptName + ".self", this); //把自身脚本注册进lua脚本中 示例 scriptName.self = this if (null != this.transform.Find("Panel")) { scriptEnv.SetInPath <GameObject>(scriptName + ".panel", this.transform.Find("Panel").gameObject); } luaStart = scriptEnv.GetInPath <Action>(scriptName + ".start"); luaUpdate = scriptEnv.GetInPath <Action>(scriptName + ".update"); luaOnDestroy = scriptEnv.GetInPath <Action>(scriptName + ".ondestroy"); Action luaAwake = scriptEnv.GetInPath <Action>(scriptName + ".awake"); if (null != luaAwake) { luaAwake(); } }
public override void PreShow(UIBase _pre_ui, params object[] _args) { LuaFunction func = m_lua_self.GetInPath <LuaFunction>("PreShow"); if (func != null) { func.Call(_args); } }
private void Parse(string atlasName, LuaTable animationCfg) { List <Sprite> spriteList = ResourceManager.Instance.LoadSpriteAtlas(atlasName); Dictionary <string, SpriteAnimationClip> clipMap = new Dictionary <string, SpriteAnimationClip>(); for (int i = 0; i < spriteList.Count; i++) { if (spriteList[i] == null) { continue; } string[] names = spriteList[i].name.Split('_'); string action = names[0]; string dir = names[1]; string index = names[2]; string clipName = GetClipName(action, dir); SpriteAnimationClip clip = null; if (!clipMap.TryGetValue(clipName, out clip)) { clip = new SpriteAnimationClip(); clipMap[clipName] = clip; clip.Name = clipName; if (animationCfg != null && animationCfg.ContainsKey <string>(action)) { clip.Length = animationCfg.GetInPath <float>(string.Format("{0}.clip_length", action)); if (animationCfg.GetInPath <string>(string.Format("{0}.loop", action)) == "once") { clip.WrapMode = SpriteAnimation.AnimationWrapMode.eOnce; } else { clip.WrapMode = SpriteAnimation.AnimationWrapMode.eLoop; } } else { Debuger.LogError("common", "ArmySpriteAnimation parse animationCfg have problem!"); clip.Length = 1; clip.WrapMode = SpriteAnimation.AnimationWrapMode.eLoop; } clip.SpriteList = new List <Sprite>(); } clip.SpriteList.Add(spriteList[i]); } List <SpriteAnimationClip> clipList = new List <SpriteAnimationClip>(); foreach (var item in clipMap) { clipList.Add(item.Value); } Animation = gameObject.AddComponent <SpriteAnimation>(); Animation.Init(clipList); }
public LuaBaseUI(LuaTable LuaEntity) : base(UIDepthMode.Normal, 0) { Entity_ = LuaEntity; Entity_.SetInPath("_CSEntity_", this); OnOpen_ = LuaEntity.GetInPath <Action <LuaTable> >("OnOpen"); OnClose_ = LuaEntity.GetInPath <Action <LuaTable> >("OnClose"); OnShow_ = LuaEntity.GetInPath <Action <LuaTable> >("OnShow"); OnHide_ = LuaEntity.GetInPath <Action <LuaTable> >("OnHide"); OnTick_ = LuaEntity.GetInPath <Action <LuaTable, float> >("OnTick"); if (LuaEntity.Exists <string>("Name")) { Name = LuaEntity.GetInPath <string>("Name"); } if (LuaEntity.Exists <UIDepthMode>("DepthMode")) { DepthMode = LuaEntity.GetInPath <UIDepthMode>("DepthMode"); } if (LuaEntity.Exists <int>("DepthIndex")) { DepthIndex = LuaEntity.GetInPath <int>("DepthIndex"); } if (LuaEntity.Exists <bool>("Cached")) { Cached = LuaEntity.GetInPath <bool>("Cached"); } }
/// <summary> /// 卸载资源 /// </summary> /// <param name="group"></param> public void UnLoadGroup(string group) { if (groups.ContainsKey(group)) { for (int i = 0; i < groups[group].Count; i++) { string resName = groups[group][i]; LuaTable tab = resTab.GetInPath <LuaTable>(resName); string id = tab.GetInPath <string>("id"); string path = tab.GetInPath <string>("path"); bool isLocal = tab.GetInPath <bool>("isLocal"); if (isLocal) { //UnityEngine.Object obj = Resources.Load(path); //if (obj.GetType() == typeof(GameObject)) //{ // isUnload = true; //} //else //{ // Resources.UnloadAsset(obj); //} } else { //删除ab资源 if (abs.ContainsKey(path)) { string[] depends = manifest.GetAllDependencies(path); for (int j = 0; j < depends.Length; j++) { if (abs.ContainsKey(depends[j])) { abNum[depends[j]]--; if (abNum[depends[j]] <= 0) { abs[depends[j]].Unload(true); abs.Remove(depends[j]); abNum.Remove(depends[j]); } } } abNum[path]--; if (abNum[path] <= 0) { abs[path].Unload(true); abs.Remove(path); abNum.Remove(path); } } } } groups.Remove(group); } }
public static void OpenLuaUI(LuaTable Desc, LuaTable LuaEntity) { var UIDesc = new UIDescriptor( new AssetUri(Desc.GetInPath <string>("PrefabName")), Desc.GetInPath <bool>("OpenMore"), Desc.GetInPath <bool>("Cached")); var UI = new LuaBaseUI(LuaEntity); UIManager.OpenUI <LuaBaseUI>(UI, UIDesc, null); }
public void UpdateCamera() { #if UNITY_EDITOR || UNITY_STANDALONE_WIN if (Input.GetKeyDown(KeyCode.Insert)) { if (IsShow("TipShowUI")) { bInsertStatus = false; Close("TipShowUI"); } else { bInsertStatus = true; Open("TipShowUI"); } } if (Input.GetKeyDown(KeyCode.B)) { LogMgr.UnityError("########### 主动关闭链接 ##########"); CoreEntry.netMgr.Reconnect.needShowNotice = false; CoreEntry.netMgr.disconnect(); } if (Input.GetKeyDown(KeyCode.C)) { LuaTable G = LuaMgr.Instance.GetLuaEnv().Global; string platform = G.GetInPath <string>("ModelManager.LoginModel.CurPlatform"); LogMgr.UnityLog("platform: " + platform); Dictionary <int, LuaTable> m_levelFuncOpen = G.GetInPath <Dictionary <int, LuaTable> >("ConfigData.CommonConfig.LevelFuncOpen"); Dictionary <int, LuaTable> m_resconfig = G.GetInPath <Dictionary <int, LuaTable> >("ConfigData.ResourcepackageConfig.Resourcepackage"); Dictionary <int, LuaTable> .Enumerator iter = m_resconfig.GetEnumerator(); foreach (var item in m_resconfig) { LuaTable tbl = item.Value; int levelDown = tbl.Get <int>("leveldown"); int levelUp = tbl.Get <int>("levelup"); } } UpdateMainPlayerPos(); //UI摄像机处于飞激活状态 if (uiCamera != null && !uiCamera.enabled) { UpdateCameraControl(); } #endif }
static void parseLuafunc(LuaTable luatable, out LuaFunction func, out LuaTable instance) { if (luatable != null) { func = luatable.GetInPath <LuaFunction>("func"); instance = luatable.GetInPath <LuaTable>("instance"); } else { func = null; instance = null; } }
public void Initialize(string luaString, string initFunctionName, string updateFunctionName, string shutdownFunctionName) { DoString(luaString); m_ScriptEnv = NewTable(); OnLuaInit = m_ScriptEnv.GetInPath <LuaInitAction>(initFunctionName); OnLuaUpdate = m_ScriptEnv.GetInPath <LuaUpdateAction>(updateFunctionName); OnLuaShutdown = m_ScriptEnv.GetInPath <LuaShutdownAction>(shutdownFunctionName); if (OnLuaInit != null) { OnLuaInit(); } }
void Start() { //启动lua LuaEnv env = new LuaEnv(); env.AddLoader(myLuaLoader); mainLuaTable = env.DoString("return require 'main'")[0] as LuaTable; LuaFunction startFunc = mainLuaTable.GetInPath <LuaFunction>("start") as LuaFunction; updateFunc = mainLuaTable.GetInPath <LuaFunction>("update") as LuaFunction; fixedUpdateFunc = mainLuaTable.GetInPath <LuaFunction>("fixedUpdate") as LuaFunction; lateUpdateFunc = mainLuaTable.GetInPath <LuaFunction>("lateUpdate") as LuaFunction; startFunc.Call(); }
static string _getString(LuaTable map, object key) { try { if (map == null) { return(""); } object val = map.GetInPath <object> (key.ToString()); if (val == null) { return(""); } if (val is string) { return((string)val); } else { return(Convert.ToString(val)); } } catch { return(""); } }
// Start is called before the first frame update void Start() { LuaManager.GetInstance().Init(); LuaManager.GetInstance().DoLuaFile("Main"); //不建议使用LuaTable和LuaFunction 效率低 垃圾多 //都是引用类型 LuaTable luaTable = LuaManager.GetInstance().Global.GetInPath <LuaTable>("testTable"); Debug.Log("testInt:" + luaTable.GetInPath <int>("testInt")); Debug.Log("testBool:" + luaTable.GetInPath <bool>("testBool")); Debug.Log("testString:" + luaTable.GetInPath <string>("testString")); Debug.Log("testFloat:" + luaTable.GetInPath <float>("testFloat")); luaTable.GetInPath <LuaFunction>("testFun").Call(); //改 是引用拷贝 luaTable.Set("testInt", 55); Debug.Log(luaTable.GetInPath <int>("testInt")); LuaTable luaTable2 = LuaManager.GetInstance().Global.GetInPath <LuaTable>("testTable"); Debug.Log(luaTable2.GetInPath <int>("testInt")); //table不用了 一定要销毁 //luaTable.Dispose(); //LuaManager.GetInstance().Dispose(); }
public override void OnEnter(object userData) { base.OnEnter(userData); if (onEnter == null) { onEnter = m_ScriptEnv.GetInPath <StateEnterAction>(StateName + ".OnEnter"); } if (onUpdate == null) { onUpdate = m_ScriptEnv.GetInPath <StateUpdateAction>(StateName + ".OnUpdate"); } if (onEnter != null) { onEnter(Fsm, userData); } }
void Awake() { // 为每个脚本设置一个独立的环境,可一定程度上防止脚本间全局变量、函数冲突 object[] obj = luaEnv.DoString(FileUtils.ReadFileContent(luaScript), luaScript); if (obj != null && obj.Length > 0) { scriptEnv = obj[0] as LuaTable; } if (scriptEnv == null) { return; } print(obj.Length); var data = scriptEnv.GetInPath <LuaTable>("data"); var result = LuaConvert.ConvertToObject(data); var ret = MessagePackSerializer.ToJson(result); print(ret); var body = MessagePackSerializer.FromJson(ret); LogTool.Instance.ToStringAll(body); // Action luaAwake = scriptEnv.Get<Action>("awake"); scriptEnv.Get("start", out luaStart); scriptEnv.Get("update", out luaUpdate); scriptEnv.Get("ondestroy", out luaOnDestroy); }
void OnTongJiLvlRefreshResult(GameEvent ge, EventParameter parameter) { MsgData_sTongJiLvlRefreshResult resp = parameter.msgParameter as MsgData_sTongJiLvlRefreshResult; string textTip = ""; if (resp.result == 0) { if (info.id != resp.id) { textTip = "刷新成功"; } else { textTip = "未提品成功,请再次尝试提品!"; } info.id = resp.id; info.Group = resp.Group; SendMsg(TongJiEnum.diffRefresh, info); } else { textTip = "刷新失败"; } LuaTable G = LuaMgr.Instance.GetLuaEnv().Global; ShowTips fun = G.GetInPath <ShowTips>("Common.ShowTips"); if (fun != null && !string.IsNullOrEmpty(textTip) && "TongJiPanel" == MainPanelMgr.Instance.CurPanelName) { fun(textTip); } }
void OnTongJiRefreshState(GameEvent ge, EventParameter parameter) { string textTip = ""; MsgData_sTongJiRefreshState resp = parameter.msgParameter as MsgData_sTongJiRefreshState; //Debug.LogError("resp.result"+resp.result); if (resp.result == 0) { info.coolTime = 0; NowTime = DateTime.Now; leftTime = info.coolTime; SendMsg(TongJiEnum.timeReset, info); textTip = "刷新成功"; } else { return; //textTip = "刷新失败"; } LuaTable G = LuaMgr.Instance.GetLuaEnv().Global; ShowTips fun = G.GetInPath <ShowTips>("Common.ShowTips"); if (fun != null && !string.IsNullOrEmpty(textTip)) { fun(textTip); } }
void Start() { if (ActionSwitchTime == 0) { LuaTable G = LuaMgr.Instance.GetLuaEnv().Global; ActionSwitchTime = G.GetInPath <int>("ConfigData.ConstsConfig.NameToValue.standbyCd.val1"); } lastUpdateTime = Time.time; if (Master != null) { Vector3 position = Master.transform.position; position.y = CommonTools.GetTerrainHeight(transform.position) + fTerrainHight; transform.position = position; } if (Master != null) { EventParameter ep = EventParameter.Get(); ep.objParameter = Master; CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_MAGICKEY_INFO_CREATE, ep); } mAnimator = (Animation)this.GetComponent("Animation"); if (mAnimator) { PlayIdle(); } DelayFollow(); }
static int _getInt(LuaTable map, object key) { try { if (map == null || key == null) { return(0); } object val = map.GetInPath <object> (key.ToString()); // [key]; if (val == null) { return(0); } if (val is int) { return((int)val); } else if (val is byte[]) { return(getBytes2Int(map, key)); } else { return(Convert.ToInt32(val)); } } catch { return(0); } }
/// <summary> /// 方法四 : 映射到luaTable /// </summary> private void ReflectionToLuaTable() { LuaTable luaTable = luaEnv.Global.Get <LuaTable>("Person"); print(luaTable.Get <string>("name")); print(luaTable.Get <int>("age")); luaTable.GetInPath <string>("name"); }