void CallAwake() { LuaFunction fun = table.GetLuaFunction("Awake"); if (fun != null) { fun.Call(table, gameObject); } }
void CallAwake() { LuaFunction fun = luaTable.GetLuaFunction("Awake");//得到表中的方法 if (fun != null) { fun.Call(luaTable, gameObject); } }
public void ConnectLua(LuaTable peerTable) { _peerTable = peerTable; _OnInit = peerTable.GetLuaFunction("OnInit"); _DoHideAnimation = peerTable.GetLuaFunction("DoHideAnimation"); _DoShowAnimation = peerTable.GetLuaFunction("DoShowAnimation"); _OnShown = peerTable.GetLuaFunction("OnShown"); _OnHide = peerTable.GetLuaFunction("OnHide"); }
public void SetSkillInfo(SkillInfo data, int curStar, int starMin, float showDelay = 0) { _skillInfo = data; _curStar = curStar; _starMin = starMin; _showDelay = showDelay; GetLuaSkillDesButton(); _luaTalbe.GetLuaFunction("SetSkillId").Call(_luaTalbe, data.skillData.skillId, _curStar, _starMin, showDelay); _luaTalbe.GetLuaFunction("IsLongPress").Call(_luaTalbe, true); }
public void SetLuaTalbe(LuaTable peerTable) { _peerTable = peerTable; _OnInit = _peerTable.GetLuaFunction("OnInit"); _DoHideAnimation = _peerTable.GetLuaFunction("DoHideAnimation"); _DoShowAnimation = _peerTable.GetLuaFunction("DoShowAnimation"); _OnShown = _peerTable.GetLuaFunction("OnShown"); _OnHide = _peerTable.GetLuaFunction("OnHide"); //callback = peerTable.GetLuaFunction(""); }
void CallAwake() { LuaFunction fun = luaTable.GetLuaFunction("Awake"); if (fun == null) { return; } fun.Call(luaTable); }
void CallAwake() { LuaFunction function = table.GetLuaFunction("Awake"); if (function != null) { function.Call(table, gameObject); Debug.LogWarning("Awake"); } }
//private bool LOBBY2CLIENT_BASE_RESOURCES_SYNC(Observers.Interfaces.INotification note) //{ //BaseResourceSyn baseResourceSyn = note.Body as BaseResourceSyn; //List<BaseResourceInfo> baseResourcesInfos = baseResourceSyn.resourceInfos; //return true; //} private bool LOBBY2CLIENT_ROLE_HEAD_RESP_Handler(Observers.Interfaces.INotification note) { RoleHeadResp resp = note.Body as RoleHeadResp; GameProxy.instance.AccountHeadIcon = UIUtil.ParseHeadIcon(resp.headNo); //GameProxy.instance.UpdateAccountInfo(); LuaTable gameModel = (LuaTable)LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetModel", "game_model")[0]; gameModel.GetLuaFunction("SetAccountHeadNo").Call(resp.headNo); gameModel.GetLuaFunction("UpdateAccountLevelAndExpDelegateByProtocol").Call(); return(true); }
public void CallLuaFunction(string funcName) { try { LuaFunction func = luaInstance.GetLuaFunction(funcName); func.Call <LuaTable>(luaInstance); } catch (Exception e) { Debug.LogError(e); } }
public object[] Calls(string funcName, params object[] args) { if (_luaTable != null) { LuaFunction func = _luaTable.GetLuaFunction(funcName); if (func != null) { //TO DO return(func.Call(args)); } } return(null); }
private LuaIEnumerator(LuaTable table) { table_ = table; current_ = table.GetLuaFunction("getCurrent"); if (current_ == null) { throw new ArgumentNullException(); } moveNext_ = table.GetLuaFunction("MoveNext"); if (moveNext_ == null) { throw new ArgumentNullException(); } }
protected void OnEnable() { if (__lb_Update != null) { var Add = __g_update_beat.GetLuaFunction("Add"); Add.Call(__g_update_beat, __lb_Update, this); } if (__lb_FixedUpdate != null) { var Add = __g_fixed_update_beat.GetLuaFunction("Add"); Add.Call(__g_fixed_update_beat, __lb_FixedUpdate, this); } __call_lua_func_with_objs(__lb_OnEnable); }
private bool LOBBY2CLIENT_PLAYER_ROLE_RESP_Handler(Observers.Interfaces.INotification note) { // Logic.Protocol.Model.PlayerRoleResp resp = note.Body as Logic.Protocol.Model.PlayerRoleResp; // Debugger.Log(resp.ToString()); // UIMgr.instance.CloseAll(); // UIMgr.instance.Open(UI.CreateRole.View.SelectRoleView.PREFAB_PATH); // return true; // new test Logic.Protocol.Model.PlayerRoleResp resp = note.Body as Logic.Protocol.Model.PlayerRoleResp; Debugger.Log(resp.ToString()); UI.UIMgr.instance.Close(EUISortingLayer.MainUI); List <PlayerData> basicPlayerDataList = PlayerData.GetBasicPlayerDataList(); Logic.UI.CreateRole.Controller.CreateRoleController.instance.SelectRole(basicPlayerDataList[0].Id); UIMgr.instance.Open(Logic.UI.CreateRole.View.CreateRoleView.PREFAB_PATH); if (resp.isNeedCDKey) { LuaTable loginCtrlLua = (LuaTable)LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetCtrl", "login_controller")[0]; loginCtrlLua.GetLuaFunction("OpenLoginVerifyCDKeyView").Call(); } return(true); // new test }
// 调用对象内函数 public static void CallOnce(LuaTable self, string funcName) { LuaFunction func = self.GetLuaFunction(funcName); func.Call(); func.Dispose(); }
//添加LUA组件 public static LuaTable Add(GameObject go, LuaTable tableClass) { LuaFunction fun = tableClass.GetLuaFunction("New"); if (fun == null) { return(null); } /*object[] rets = fun.Call(tableClass); * if (rets.Length != 1) * * return null; * * LuaComponent cmp = go.AddComponent(); * * cmp.table = (LuaTable)rets[0]; */ //lua升级后不,Call方法不再返回对象,因此改为Invoke方法实现 object rets = fun.Invoke <LuaTable, object>(tableClass); if (rets == null) { return(null); } LuaComponent cmp = go.AddComponent <LuaComponent>(); cmp.table = (LuaTable)rets; cmp.CallAwake(); return(cmp.table); }
//添加LUA组件 // isAllowOneComponent为true时,表示只添加一次组件,如果已存在,就不再添加 public static LuaTable Add(GameObject go, LuaTable tableClass, bool isAllowOneComponent) { //如果已存在,则不再添加 LuaComponent luaComponent = go.GetComponent <LuaComponent>(); if (luaComponent != null) { return(null); } LuaFunction fun = tableClass.GetLuaFunction("New"); if (fun == null) { return(null); } object rets = fun.Invoke <LuaTable, object>(tableClass); if (rets == null) { return(null); } LuaComponent cmp = go.AddComponent <LuaComponent>(); cmp.table = (LuaTable)rets; cmp.CallAwake(); return(cmp.table); }
private void AddMethod(string luaFunName) { if (!dicLuaFun.ContainsKey(luaFunName)) { dicLuaFun.Add(luaFunName, luaTable.GetLuaFunction(luaFunName)); } }
/// <summary> /// 添加Lua组件,该方法编写后将在Lua脚本中调用 /// </summary> /// <param name="go"></param> /// <param name="luaTable"></param> /// <returns></returns> public static LuaTable Add(GameObject go, LuaTable luaTable) { //调用Lua脚本的New方法 LuaFunction fun = luaTable.GetLuaFunction("New"); if (fun == null) { return(null); } //有参函数的fun.Call(luaTable)这个必须传luaTable进去 //object[] results = fun.Call(luaTable); object[] results = fun.LazyCall(luaTable); if (results.Length != 1) { return(null); } //给对象绑定当前组件 LuaComponent luaCmp = go.AddComponent <LuaComponent>(); //为组件关联相关的Lua表的一个实例 luaCmp.luaTable = results[0] as LuaTable; luaCmp.CallAwake(); return(luaCmp.luaTable); }
private void OnViewReady() { LuaTable audio_model = (LuaTable)LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetModel", "audio_model")[0]; audio_model.GetLuaFunction("PlayRandomAudioInView").Call((int)AudioViewType.taskView, 0); Observers.Facade.Instance.SendNotification(string.Format("{0}::{1}", PREFAB_PATH, "OnViewReady")); }
// public void UpdateMyPvpRewardTime() // { // if (_pvpInfo.nextGetRewardTime > 0) // { // _pvpInfo.UpdateNextGetRewardCountDown(); // if (OnUpdateMyRewardTimeDelegate != null) // { // OnUpdateMyRewardTimeDelegate(); // } // // if(_pvpInfo.nextGetRewardTime <= 0) // // { // // RequestUpdatePvpInfo(); // // } // } // } // private void RequestUpdatePvpInfo() // { // PvpController.instance.CLIENT2LOBBY_GET_RANK_ARENA_REQ(); // } #region update by server public void UpdatePvpArenaInfo(GetRankArenaResp resp) { _pvpInfo.rankNo = resp.rankNo; _pvpInfo.totalWinTimes = resp.totalWinTimes; //challenge _pvpInfo.challengeCoolingOverTime = resp.challengeCoolingOverTime; _pvpInfo.challengeMaxCount = resp.challengeTimesUp; _pvpInfo.remainChallengeTimes = resp.remainChallengeTimes; _pvpInfo.SetChallengeTimesNextRecoverTime(resp.challengeTimesNextRecoverTime); //refresh _pvpInfo.refreshMaxCount = resp.refreshListingTimesUp; _pvpInfo.remainRefreshTimes = resp.remainRefreshTimes; _pvpInfo.SetRefreshTimesCoolingOverTime(resp.refreshTimesCoolingOverTime); //reward _pvpInfo.SetNextGetRewardTime(resp.nextGetRewardTime); //last rank,gain reward use it _pvpInfo.lastRankNo = resp.lastSettleRankNo; //power _pvpInfo.fightingPower = resp.fightingPower; _pvpInfo.canUseWinTimes = resp.canUseWinTimes; //Debug.Log("rankNo:" + resp.rankNo); LuaTable arenaModelLua = (LuaTable)LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetModel", "arena_model")[0]; arenaModelLua.GetLuaFunction("SetCanUseWinTimes").Call(resp.canUseWinTimes); GameProxy.instance.OnPvpActionInfoUpdate(_pvpInfo.remainChallengeTimes, _pvpInfo.challengeMaxCount, _pvpInfo.challengeTimesNextRecoverTime); UpdatePvpArenaFighters(resp.opponents, resp.remainRefreshTimes, resp.refreshTimesCoolingOverTime); if (OnUpdatePvpInfoDelegate != null) { OnUpdatePvpInfoDelegate(); } }
protected void __lua_bind() { if (peer != null) { return; } __initialize_once(); if (luaComponentName == null) { if (LUA_COMPONENT_NAME_TO_ADD == "") { print("ERROR! Lua Component name is Invalid"); } luaComponentName = LUA_COMPONENT_NAME_TO_ADD; LUA_COMPONENT_NAME_TO_ADD = ""; } __bind_script_func.BeginPCall(); __bind_script_func.Push(this); __bind_script_func.Push(luaComponentName); __bind_script_func.PCall(); this.lua_component = __bind_script_func.CheckLuaTable(); this.peer = __bind_script_func.CheckLuaTable(); __bind_script_func.EndPCall(); // try ref all binding function from lua component foreach (var field in __lua_behaviour_bind_fields) { var lua_func = lua_component.GetLuaFunction(field.Name.Substring("__lb_".Length)); field.SetValue(this, lua_func); } }
//添加LUA组件 public static LuaTable Add(GameObject go, LuaTable tableClass) { LuaFunction fun = tableClass.GetLuaFunction("New"); if (fun == null) { return(null); } #region 原来的逻辑 //object[] rets = fun.Call(tableClass); //if (rets.Length != 1) // return null; //LuaComponent cmp = go.AddComponent<LuaComponent>(); //cmp.table = (LuaTable)rets[0]; //cmp.CallAwake(); //return cmp.table; #endregion fun.Call(tableClass); LuaComponent cmp = go.AddComponent <LuaComponent>(); cmp.table = tableClass; cmp.CallAwake(); return(cmp.table); }
public void RefreshByProtocol(int funcId, int subFuncId) { //蛋疼的策划非得不统一客户端、服务端id FunctionOpenType type = (FunctionOpenType)(funcId / 10 * 10); int sub = subFuncId - funcId; switch (type) { case FunctionOpenType.MainView_Mail: MailProxy.instance.hasNewMailComing = true; break; case FunctionOpenType.MainView_Friend: if (sub == 1) { FriendProxy.instance.NewFriendListComing = true; } else if (sub == 3) { FriendProxy.instance.NewFriendRequestComing = true; } break; default: { LuaTable model = (LuaTable)LuaInterface.LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetModel", "red_point_model")[0]; model.GetLuaFunction("UpdateRedPointByProtocol").Call((int)type, sub); } break; } RefreshSpecific((int)type); }
public void SetSignInDataByProtocol(int lastId, bool isSignToday) { this.lastSignInId = lastId; this.isSignInToday = isSignToday; SignInInfo lastInfo = SignInList[SignInList.Count - 1]; if (lastSignInId == lastInfo.id && !isSignInToday) { lastSignInId = 0; } curSignInId = isSignToday ? lastSignInId : lastSignInId + 1; SignInInfo info; for (int i = 0, count = SignInList.Count; i < count; i++) { info = SignInList[i]; info.isSign = info.id <= lastSignInId; } if (RefreshSignDelegate != null) { RefreshSignDelegate(lastId); } // if(isSignToday && UpdateSignedTodayDelegate!= null) // UpdateSignedTodayDelegate(); LuaTable gameModelLua = (LuaTable)LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetModel", "sign_in_model")[0]; gameModelLua.GetLuaFunction("SetIsSign").Call(this.lastSignInId, this.curSignInId, this.isSignInToday); }
public List <EquipmentInfo> GetFreeEquipmentInfoList() { // List<EquipmentInfo> allEquipmentInfoList = GetAllEquipmentInfoList(); // List<EquipmentInfo> allFreeEquipmentInfoList = new List<EquipmentInfo>(); // int allEquipmentCount = allEquipmentInfoList.Count; // for (int i = 0; i < allEquipmentCount; i++) // { // if (!allEquipmentInfoList[i].isInUse) // { // allFreeEquipmentInfoList.Add(allEquipmentInfoList[i]); // } // } // return allFreeEquipmentInfoList; List <EquipmentInfo> freeEquipmentInfoList = new List <EquipmentInfo>(); LuaTable equipModelLuaTable = (LuaTable)LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetModel", "equip_model")[0]; LuaFunction getFreeEquipmentInfoListLuaFunction = equipModelLuaTable.GetLuaFunction("GetFreeEquipmentInfoList"); LuaTable freeEquipmentInfoListLuaTable = (LuaTable)getFreeEquipmentInfoListLuaFunction.Call(null)[0]; foreach (DictionaryEntry kvp in freeEquipmentInfoListLuaTable.ToDictTable()) { EquipmentInfo equipmentInfo = new EquipmentInfo((LuaTable)kvp.Value); freeEquipmentInfoList.Add(equipmentInfo); } return(freeEquipmentInfoList); }
public void RegisterCallBack(LuaTable t, string luaFactionName, GameObject go, EventTriggerType eventType) { if (luaFactionName == "") { return; } LuaFunction luaFunction = t.GetLuaFunction(luaFactionName); if (luaFunction == null) { Debug.LogError("RegisterCallBack is error " + luaFactionName); return; } var eventCom = go.GetComponent <EventTrigger>(); if (eventCom == null) { eventCom = go.AddComponent <EventTrigger>(); } EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = eventType; UnityAction <BaseEventData> unityAction = (BaseEventData sender) => { luaFunction.Call(t, sender); }; entry.callback.AddListener(unityAction); eventCom.triggers.Add(entry); }
///响应添加好友(S->C) private bool LOBBY2CLIENT_FriendAddResp_handler(Observers.Interfaces.INotification note) { // CLIENT2LOBBY_FriendRecommendListReq_REQ(); FriendAddResp resp = note.Body as FriendAddResp; if (resp.newFriend == null) { Logic.UI.Tips.View.CommonAutoDestroyTipsView.Open(Common.Localization.Localization.Get("ui.friendView.friendAddSend")); FriendProxy.instance.RemoveFriend(2, _friendAddResposeId); FriendProxy.instance.RefreshOneByProtocol(_friendAddResposeId); } else { Logic.UI.Tips.View.CommonAutoDestroyTipsView.Open(Common.Localization.Localization.Get("ui.friendView.friendAddSuccess")); FriendProxy.instance.AddFriend(1, resp.newFriend); FriendProxy.instance.RemoveFriend(2, resp.newFriend.id); FriendProxy.instance.RemoveFriend(3, resp.newFriend.id); FriendProxy.instance.RefreshOneByProtocol(resp.newFriend.id); } LuaTable friendTable = (LuaTable)LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetCtrl", "friend_controller")[0]; friendTable.GetLuaFunction("FriendAddRespByCSharp").Call(resp.newFriend == null ? 0 : 1); // FriendProxy.instance.AddFriend(1,resp.newFriend); // FriendProxy.instance.RemoveFriend(2,resp.newFriend.id); // FriendProxy.instance.RemoveFriend(3,resp.newFriend.id); // FriendProxy.instance.RefreshOneByProtocol(resp.newFriend.id); // if(_isAssignAddFriend) // { // _isAssignAddFriend = false; // Logic.UI.Tips.View.CommonAutoDestroyTipsView.Open(Common.Localization.Localization.Get( "ui.friendView.friendAddSuccess")); // } return(true); }
/// <summary> /// 根据指定值触发 /// </summary> /// <param name="cutsceneId">过场动画ID</param> public void Trigger(int cutsceneId) { LuaTable triggerCtrl = LuaManager.mainLua.GetTable("CutsceneTriggerCtrl.inst"); LuaFunction isTrigger = triggerCtrl.GetLuaFunction("isTrigger"); isTrigger.BeginPCall(); isTrigger.Push(triggerCtrl); isTrigger.Push(cutsceneId); isTrigger.PCall(); bool result = isTrigger.CheckBoolean(); isTrigger.EndPCall(); if (!result) { return; } //处理预加载 if (catchCutscenes.ContainsKey(cutsceneId)) { PlayCutscene(catchCutscenes[cutsceneId]); return; } this.StartCoroutine(this.playCutscene(cutsceneId)); }
public void ClickAddGoldButtonHandler() { //FunctionOpenProxy.instance.OpenFunction(FunctionOpenType.Shop_Gold,5); LuaTable goldenTouchCtrl = (LuaTable)LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetCtrl", "golden_touch_controller")[0]; goldenTouchCtrl.GetLuaFunction("OpenGoldenTouchView").Call(); }
// Start is called before the first frame update void Start() { //学会在C#中调用lua中的自定义Table LuaManager.GetInstance().Init(); LuaManager.GetInstance().LuaState.Require("Main"); LuaTable luaTable = LuaManager.GetInstance().LuaState.GetTable("testTable"); //luaTable = LuaManager.GetInstance().LuaState["testTable"] as LuaTable; 这样也行 //访问其中变量 //中括号 变量名 就可以获取 Debug.Log(luaTable["testInt"]); Debug.Log(luaTable["testBool"]); Debug.Log(luaTable["testString"]); Debug.Log(luaTable["testFloat"]); luaTable["testInt"] = 74; LuaTable luaTable1 = LuaManager.GetInstance().LuaState.GetTable("testTable"); Debug.Log(luaTable["testInt"]); //表中函数 LuaFunction luaFunction = luaTable1.GetLuaFunction("testFunction"); luaFunction.Call(); //表中表 }