new void Awake() { Debug.Log("LuaScriptManager.Awake1"); base.Awake(); Instance = this; Debug.Log("LuaScriptManager.Awake2"); }
//发送新的lua代码 public static void SendLuaSciprtSource(string fileName, bool isFilePath) { if (HttpPushHostingService.GetAsyncSocket().isConnected) { string luaFullPath = fileName; if (!isFilePath) { luaFullPath = (G6HotFixConst.LUA_SOURCES_PATH + fileName).Replace('.', '/'); } if (File.Exists(luaFullPath)) { string luaName = LuaScriptManager.ConvertProjectPathToScriptPath(luaFullPath); var sendMsg = $"#LuaPush#luaName={luaName}#luaSrc={File.ReadAllText(luaFullPath)}"; HttpPushHostingService.GetAsyncSocket().Send(sendMsg); } else { G6Debugger.LogError("lua file does't exist!"); } } else { G6Debugger.LogErrorFormat("PushServer is't connected!"); } }
public async Task ProcessAction(Account account, LuaScriptManager LuaManger) { var path = PathFinder.Instance.GetPath(account.Character.Map, account.Character.Cell.CellId, cellId, false); account.Character.Cell = Map.Maps[account.Character.Map.MapId].Cells[cellId]; var pathString = PathFinderUtils.Instance.GetPathfindingString(path); account.Send($"GA001{pathString}"); await Task.Delay(PathFinderUtils.Instance.GetDeplacementTime(account.Character.Map, path)); }
private void HandleFilesHashesMessage(FilesHashesMessage message) { Application.Current.Dispatcher.Invoke(async() => { // Updater if (await this.ShowUpdatesAsync(message.FilesHashes)) { Environment.Exit(0); return; } // Loading try { var controller = await this.ShowProgressAsync(LanguageManager.Translate("483"), Randomize.GetRandomLoadingText()); await Task.Run(async() => { Protocol.Messages.MessagesBuilder.Initialize(); controller.SetProgress(0.14); await Task.Delay(200); TypesBuilder.Initialize(); controller.SetProgress(0.28); await Task.Delay(200); DataManager.Initialize(DTConstants.AssetsVersion, GlobalConfiguration.Instance.Lang); controller.SetProgress(0.42); await Task.Delay(200); MapsManager.Initialize(DTConstants.AssetsVersion); controller.SetProgress(0.56); await Task.Delay(200); FramesManager.Initialize(); controller.SetProgress(0.70); await Task.Delay(200); CommandsHandler.Initialize(); BreedsUtility.Initialize(); controller.SetProgress(1); await Task.Delay(200); LuaScriptManager.Initialize(); }); await controller.CloseAsync(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }); }
public override ScriptComponent GetComponentFromDefinition(Entity entity) { LuaScript script = LuaScriptManager.LoadScript(entity, File); script.OnInit(); return(new ScriptComponent { LuaScript = script }); }
static int set_Instance(IntPtr L) { try { LuaScriptManager arg0 = (LuaScriptManager)ToLua.CheckObject <LuaScriptManager>(L, 2); LuaScriptManager.Instance = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int ReconnectionLuaDebug(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); LuaScriptManager obj = (LuaScriptManager)ToLua.CheckObject <LuaScriptManager>(L, 1); obj.ReconnectionLuaDebug(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public override void InitializeComponents() { var location = Assembly.GetExecutingAssembly().Location; var shadersPath = Path.GetDirectoryName(location) + "\\Shaders\\ShadowMapLightingShaders.hlsl"; grid = new GridComponentTextured(GameDevice); var texturePath = Path.GetDirectoryName(location) + "\\Textures\\marble_texture2.jpg"; grid.InitializeResources(texturePath, new BlackPlastic(), shadersPath, shadersPath, InputElements.VertexPosNormTex); grid.Translation = new Vector3(-grid.Lenght / 2f, 0f, -grid.Lenght / 2f); cow = new ObjModelComponent(GameDevice); texturePath = Path.GetDirectoryName(location) + "\\Textures\\cow_texture.jpg"; var filePath = Path.GetDirectoryName(location) + "\\Meshes\\cow.obj"; cow.InitializeResources(texturePath, new Silver(), shadersPath, shadersPath, InputElements.VertexPosNormTex, filePath); cow.Scaling = new Vector3(0.01f, 0.01f, 0.01f); texturePath = Path.GetDirectoryName(location) + "\\Textures\\marble_texture2.jpg"; string[] cubetexturesPath = new string[] { Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_ft.bmp", Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_bk.bmp", Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_dn.bmp", Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_up.bmp", Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_lf.bmp", Path.GetDirectoryName(location) + "\\Textures\\SkyText\\miramar_rt.bmp", }; skySphere = new FBXComponent(GameDevice); filePath = Path.GetDirectoryName(location) + "\\Meshes\\skySphere2.fbx"; skySphere.InitializeResources(cubetexturesPath, shadersPath, shadersPath, InputElements.VertexPosNormTex, filePath); skySphere.isLighten = false; // skySphere.InitializeResources(texturePath, new Silver(), shadersPath, shadersPath, InputElements.VertexPosNormTex, filePath); skySphere.Scaling = new Vector3(0.1f, 0.1f, 0.1f); plane = new PlaneComponent(GameDevice); PlaneTexture = worldPositionMap; plane.InitializeResources(shadowMapResourseView, new Silver(), shadersPath, shadersPath, InputElements.VertexPosNormTex); plane.Rotation = Matrix.RotationYawPitchRoll(MathUtil.DegreesToRadians(0f), MathUtil.DegreesToRadians(-90f), MathUtil.DegreesToRadians(0f)); plane.Translation = new Vector3(10f, 10f, 0f); consoleComponent = new ConsoleComponent(); consoleComponent.Initialize(this); LuaManager = new LuaScriptManager(this); }
public async Task ProcessAction(Account account, LuaScriptManager luaScriptManager) { int monsters_max = luaScriptManager.Get("MONSTERS_MAX", MoonSharp.Interpreter.DataType.Number, 8); int monsters_min = luaScriptManager.Get("MONSTERS_MIN", MoonSharp.Interpreter.DataType.Number, 1); int monsters_level_min = luaScriptManager.Get("MONSTERS_LEVEL_MIN", MoonSharp.Interpreter.DataType.Number, 1); int monsters_level_max = luaScriptManager.Get("MONSTERS_LEVEL_MAX", MoonSharp.Interpreter.DataType.Number, 31); var groups = account.Character.GetGroupsMonster(monsters_level_min, monsters_level_max); foreach (var group in groups) { var path = PathFinder.Instance.GetPath(account.Character.Map, account.Character.Cell.CellId, group.Cell.CellId, true); var pathString = PathFinderUtils.Instance.GetPathfindingString(path); account.Send($"GA001{pathString}"); await Task.Delay(PathFinderUtils.Instance.GetDeplacementTime(account.Character.Map, path)); } }
public async Task ProcessAction(Account account, LuaScriptManager LuaManger) { var path = PathFinder.Instance.GetPath(account.Character.Map, account.Character.Cell.CellId, CellId, true, account.Character.Map.Cells.Where(c => !c.IsWalkable).Select(c => (int)c.CellId).ToList()); account.Character.Cell = Map.Maps[account.Character.Map.MapId].Cells[CellId]; if (account.Character.Map.Interactives.TryGetValue(CellId, out DeepBot.Model.Account.Game.Maps.Interactives.InteractivObject obj) && obj.IsUsable) { var interactive = InteractivObject.InteractivesObjects[obj.Id]; if (path != null) { await Task.Run(async() => { var skill = account.Character.Skills.Find(c => interactive.IdSkill.Contains(c.Id)); var pathString = PathFinderUtils.Instance.GetPathfindingString(path); account.Send($"GA001{pathString}"); account.State = AivyData.Enums.AccountState.WALKING; await Task.Delay(PathFinderUtils.Instance.GetDeplacementTime(account.Character.Map, path)); account.Send("GA500" + CellId + ";" + interactive.IdSkill); account.State = AivyData.Enums.AccountState.GATHERING; await Task.Delay((int)skill.GatheringTime + 500); account.State = AivyData.Enums.AccountState.IDLE; }); } else { path = PathFinder.Instance.GetPath(account.Character.Map, account.Character.Cell.CellId, CellId, true); if (path != null) { var skill = account.Character.Skills.Find(c => interactive.IdSkill.Contains(c.Id)); var pathString = PathFinderUtils.Instance.GetPathfindingString(path); account.Send($"GA001{pathString}"); account.State = AivyData.Enums.AccountState.WALKING; await Task.Delay(PathFinderUtils.Instance.GetDeplacementTime(account.Character.Map, path)); account.Send("GA500" + CellId + ";" + interactive.IdSkill); account.State = AivyData.Enums.AccountState.GATHERING; await Task.Delay((int)skill.GatheringTime); account.State = AivyData.Enums.AccountState.IDLE; } } } }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Task.Run(() => { GlobalConfig.Load_All_Accounts(); LuaScriptManager.inicializar_Funciones(); XElement.Parse(Properties.Resources.interactivos).Descendants("SKILL").ToList().ForEach(i => new ObjetoInteractivoModelo(i.Element("nombre").Value, i.Element("gfx").Value, bool.Parse(i.Element("caminable").Value), i.Element("habilidades").Value, bool.Parse(i.Element("recolectable").Value))); PaqueteRecibido.Inicializar(); }).ContinueWith(t => { XElement.Parse(Properties.Resources.hechizos).Descendants("HECHIZO").ToList().ForEach(mapa => { Spell hechizo = new Spell(short.Parse(mapa.Attribute("ID").Value), mapa.Element("NOMBRE").Value); mapa.Descendants("NIVEL").ToList().ForEach(stats => { SpellStats hechizo_stats = new SpellStats(); hechizo_stats.coste_pa = byte.Parse(stats.Attribute("COSTE_PA").Value); hechizo_stats.alcanze_minimo = byte.Parse(stats.Attribute("RANGO_MINIMO").Value); hechizo_stats.alcanze_maximo = byte.Parse(stats.Attribute("RANGO_MAXIMO").Value); hechizo_stats.es_lanzado_linea = bool.Parse(stats.Attribute("LANZ_EN_LINEA").Value); hechizo_stats.es_lanzado_con_vision = bool.Parse(stats.Attribute("NECESITA_VISION").Value); hechizo_stats.es_celda_vacia = bool.Parse(stats.Attribute("NECESITA_CELDA_LIBRE").Value); hechizo_stats.es_alcanze_modificable = bool.Parse(stats.Attribute("RANGO_MODIFICABLE").Value); hechizo_stats.lanzamientos_por_turno = byte.Parse(stats.Attribute("MAX_LANZ_POR_TURNO").Value); hechizo_stats.lanzamientos_por_objetivo = byte.Parse(stats.Attribute("MAX_LANZ_POR_OBJETIVO").Value); hechizo_stats.intervalo = byte.Parse(stats.Attribute("COOLDOWN").Value); stats.Descendants("EFECTO").ToList().ForEach(efecto => hechizo_stats.agregar_efecto(new SpellEffect(int.Parse(efecto.Attribute("TIPO").Value), Zones.Parse(efecto.Attribute("ZONA").Value)), bool.Parse(efecto.Attribute("ES_CRITICO").Value))); hechizo.get_Agregar_Hechizo_Stats(byte.Parse(stats.Attribute("NIVEL").Value), hechizo_stats); }); }); }).Wait(); Application.Run(new Principal()); }
public static LuaScript GetLuaScript(GameEntity entity, string file) { LuaScript result = LuaScriptManager.LoadScript(entity, file); result.BindParent(); result.CallFunction(result.OnInitFunc); entity.OnDestroyEntity += (IEntity e) => { if (e is GameEntity gameE) { if (gameE.hasScript) { LuaScript script = gameE.script.LuaScript; script.CallFunction(script.OnDisposeFunc); } } }; entity.OnComponentReplaced += (IEntity e, int index, IComponent previousComponent, IComponent component) => { if (previousComponent is ScriptComponent script) { script.LuaScript.CallFunction(script.LuaScript.OnDisposeFunc); } }; entity.OnComponentRemoved += (IEntity e, int index, IComponent component) => { if (component is ScriptComponent script) { script.LuaScript.CallFunction(script.LuaScript.OnDisposeFunc); } }; return(result); }
public ScriptManager(Account account) { Account = account; lua_manager = new LuaScriptManager(); Tags = new List <ITag>(); }