public void ReadAllSkills() { object[] obj = Util.CallMethod("TableSkillCtrl", "Get_All_Skills"); LuaTable skills = obj[0] as LuaTable; Debug.Log("skills.Length: " + skills.Length); for (int i = 1; i <= skills.Length; i++) { LuaTable skill = skills[i] as LuaTable; if (skill != null) { Debug.Log(skill.GetStringField("id")); Debug.Log(skill.GetStringField("name")); Debug.Log(skill.GetStringField("desc")); Debug.Log(skill.GetStringField("skill_icon")); Debug.Log("------------------------"); } } }
public void SetData() { object[] data = Util.CallMethod("UIMainModule", "GetStages"); LuaTable stages = data[0] as LuaTable; _opponentOriTotalHp = 0; _myOriTotalHp = 0; DicOpponentBoss.Clear(); DicMyBossHp.Clear(); DicOriOpponentBoss.Clear(); for (int i = 1; i <= stages.Length; i++) { LuaTable MyStage = stages[i] as LuaTable; if (MyStage != null) { int LevelID = int.Parse(MyStage.GetStringField("id")); int ID = int.Parse(MyStage.GetStringField("boss_id")); int HP = int.Parse(MyStage.GetStringField("boss_hp")); OpponentBossId[i - 1] = ID; LevelId[i - 1] = LevelID; DicOpponentBoss.Add(ID, HP); DicOriOpponentBoss.Add(ID, HP); MyBossId[i - 1] = i; int mybossHp = 0; if (i == 1) { mybossHp = UIFight.MyBoss1Hp; } else if (i == 2) { mybossHp = UIFight.MyBoss2Hp; } else if (i == 3) { mybossHp = UIFight.MyBoss3Hp; } DicMyBossHp.Add(MyBossId[i - 1], mybossHp); _myOriTotalHp += mybossHp; _opponentOriTotalHp += HP; } } if (stages.Length < 3) { DebugUtil.Error("不足三个场景"); } moduleFight.SetData(); }
public void ReadSkillInLua() { object[] obj = Util.CallMethod("TableSkillCtrl", "Get_1_Skill", 1002); LuaTable skill = obj[0] as LuaTable; Debug.Log("skill length: " + skill.Length); string ski_name = skill.GetStringField("name"); string ski_desc = skill.GetStringField("desc"); Debug.Log(ski_name + " " + ski_desc); }
/// <summary> /// 异步加载场景 /// </summary> /// <param name="newStage">场景Lua状态</param> /// <param name="activeImmediate">场景加载完成后是否立即切换</param> public void LoadSceneViaPreloading(LuaTable newStage, bool activeImmediate) { LuaTable lastStage = curStage; curStage = newStage; //下个场景名 string sceneName = newStage.GetStringField("stageName"); nextSceneName = sceneName; //过滤场景名 string transitScene = newStage.GetStringField("transitScene"); stageLoader = new LoadStageAsync(sceneName, activeImmediate); CallFunction(lastStage, "onExit"); SceneManager.LoadScene(transitScene); }
/// <summary> /// 加载切块的场景 /// </summary> /// <param name="newStage">场景Lua状态</param> public void LoadChunkScene(LuaTable newStage) { LuaTable lastStage = curStage; curStage = newStage; //下个场景名 string sceneName = newStage.GetStringField("stageName"); nextSceneName = sceneName; //过渡场景名 string transitScene = newStage.GetStringField("transitScene"); stageLoader = new StageLoader(); CallFunction(lastStage, "onExit"); UnityEngine.SceneManagement.SceneManager.LoadScene(transitScene); }
/// <summary> /// 异步加载场景 /// </summary> /// <param name="newStage">场景Lua状态</param> /// <param name="activeImmediate">场景加载完成后是否立即切换</param> public void LoadSceneChunk(LuaTable newStage, bool activeImmediate) { LuaTable lastStage = curStage; curStage = newStage; //下个场景名 string sceneName = newStage.GetStringField("stageName"); nextSceneName = sceneName; stageLoader = new LoadStageAsync(); CallFunction(lastStage, "onExit"); SceneManager.LoadScene(sceneName + "_Base"); }
private void OnFightResultDataCBK(object data) { if (data != null) { LuaTable msg = data as LuaTable; int result = int.Parse(msg.GetStringField("result")); object[] dataVal = Util.CallMethod("FightModule", "GetAwardTrophy"); // DebugUtil.Info("too large:" + dataVal[0].ToString()); int jiangBei = int.Parse(dataVal[0].ToString()); dataVal = Util.CallMethod("FightModule", "GetAwardG_money"); // DebugUtil.Info("too large:" + dataVal[0].ToString()); int money = int.Parse(dataVal[0].ToString()); Util.CallMethod("UIMainCtrl", "Recalculate_Gold_Trophy_After_Fight"); EventDispatcher.TriggerEvent <int>(UIFight.BossKillEvent, 2); StartCoroutine(ShowUI(result == (int)Result.FIGHT_WIN, jiangBei, money)); } }
public void LoadTutorialTable() { #if USE_TUTORIAL _guides = new Dictionary <string, TutorialExector>(); _dataMap = new Dictionary <int, TutorialData>(); object[] element = Util.CallMethod("TableTutorialCtrl", "GetDataCount"); int count = int.Parse(element[0].ToString()); for (int i = 1; i <= count; i++) { element = Util.CallMethod("TableTutorialCtrl", "GetDataByIndex", i); LuaTable MyData = element[0] as LuaTable; if (MyData != null) { TutorialData CData = new TutorialData(); CData.ID = int.Parse(MyData.GetStringField("id")); CData.Name = MyData.GetStringField("name"); CData.Scene = int.Parse(MyData.GetStringField("scene_index")); CData.Level = int.Parse(MyData.GetStringField("level_id")); CData.Condition = int.Parse(MyData.GetStringField("condition")); CData.Operator = int.Parse(MyData.GetStringField("condition_operator")); CData.ConditionValue = int.Parse(MyData.GetStringField("condition_value")); CData.ExeTimes = int.Parse(MyData.GetStringField("execute_times")); CData.bAfterExeSub = int.Parse(MyData.GetStringField("after_execute")) == 1 ? true : false; CData.NextStepID = int.Parse(MyData.GetStringField("next_step")); CData.StartSound = MyData.GetStringField("sound"); CData.Script = MyData.GetStringField("script"); _dataMap.Add(CData.ID, CData); } } #endif }
public void LoadScene(LuaTable newStage) { string sceneName = newStage.GetStringField("stageName"); luaMgr.StartCoroutine(loadScene(sceneName, newStage)); }
public void AddTestData() { #if !FightTest object[] obj = Util.CallMethod("TableSkillCtrl", "Get_All_Skills"); LuaTable skills = obj[0] as LuaTable; DebugUtil.Info("skills.Length: " + skills.Length); SkillModule skill = null; for (int i = 1; i <= skills.Length; i++) { skill = new SkillModule(); LuaTable _skill = skills[i] as LuaTable; skill.Id = int.Parse(_skill.GetStringField("id")); skill.Name = _skill.GetStringField("name"); skill.Desc = _skill.GetStringField("desc"); skill.SkillTypeMain = (E_SkillTypeMain)int.Parse(_skill.GetStringField("skill_type_main")); skill.SkillTypeDetail = (E_SkillTypeDetail)int.Parse(_skill.GetStringField("skill_type_detail")); skill.EffectNum = _skill.GetStringField("effect_num"); skill.NeedEnergy = int.Parse(_skill.GetStringField("need_energy")); skill.HarmPara = float.Parse(_skill.GetStringField("harm_para")); skill.CoolDown = int.Parse(_skill.GetStringField("cooldown")); skill.SkillIcon = _skill.GetStringField("skill_icon"); skill.AnimationName = _skill.GetStringField("animation_name"); skill.AttackFashion = int.Parse(_skill.GetStringField("attack_fashion")); skill.Effect = _skill.GetStringField("effect"); skill.AttackPrefabName = _skill.GetStringField("attack_prefab_name"); skill.AudioName = _skill.GetStringField("audio_name"); if (_minNeedEnergy > skill.NeedEnergy) { _minSkillId = skill.Id; _minNeedEnergy = skill.NeedEnergy; } AddSkill(skill); } #else //1001 造成大额伤害 SkillModule skill = new SkillModule(); skill.Id = 1001; skill.SkillTypeMain = E_SkillTypeMain.Active; skill.SkillTypeDetail = E_SkillTypeDetail.DoHarm; skill.EffectNum = ""; skill.SkillIcon = "icon-9"; skill.NeedEnergy = 0; skill.HarmPara = 2; skill.AnimationName = string.Empty; skill.AudioName = string.Empty; skill.CoolDown = 0; skill.AttackFashion = 1; skill.Effect = string.Empty; AddSkill(skill); //1007 增加5步(可以突破上限) skill = new SkillModule(); skill.Id = 1002; skill.SkillTypeMain = E_SkillTypeMain.Active; skill.SkillTypeDetail = E_SkillTypeDetail.AddMoves; skill.EffectNum = "5"; skill.SkillIcon = "icon-7"; skill.NeedEnergy = 0; skill.HarmPara = 2; skill.AnimationName = string.Empty; skill.AudioName = string.Empty; skill.CoolDown = 0; skill.AttackFashion = 1; skill.Effect = string.Empty; AddSkill(skill); //1003 放置障碍 skill = new SkillModule(); skill.Id = 1003; skill.SkillTypeMain = E_SkillTypeMain.Active; skill.SkillTypeDetail = E_SkillTypeDetail.AddBlocks; skill.EffectNum = "4"; skill.SkillIcon = "icon-8"; skill.NeedEnergy = 0; skill.HarmPara = 2; skill.AnimationName = string.Empty; skill.AudioName = string.Empty; skill.CoolDown = 0; skill.AttackFashion = 1; skill.Effect = string.Empty; AddSkill(skill); //1004 冰封对手 skill = new SkillModule(); skill.Id = 1004; skill.SkillTypeMain = E_SkillTypeMain.Active; skill.SkillTypeDetail = E_SkillTypeDetail.ForbidAttack; skill.EffectNum = "2.5"; skill.SkillIcon = "icon-10"; skill.NeedEnergy = 0; skill.HarmPara = 2; skill.AnimationName = string.Empty; skill.AudioName = string.Empty; skill.CoolDown = 0; skill.AttackFashion = 1; skill.Effect = string.Empty; AddSkill(skill); #endif }