public void Build(Map map, float cellSz, float wallH) { CellSize = cellSz; MapBuilder mb = new MapBuilder(map, cellSz, wallH); MapMesh mapMesh = mb.Build(); Mesh floor = CreateMesh(mapMesh.Floor); Mesh ceil = CreateMesh(mapMesh.Ceil); Mesh walls = CreateMesh(mapMesh.Walls); transform.Find("Floor").GetComponent <MeshFilter>().sharedMesh = floor; transform.Find("Ceiling").GetComponent <MeshFilter>().sharedMesh = ceil; transform.Find("Walls").GetComponent <MeshFilter>().sharedMesh = walls; //Mesh mesh = new Mesh(); //mesh.vertices = new Vector3[3] //{ // new Vector3(0,0,0), // new Vector3(0,0,1), // new Vector3(1,0,0) //}; //mesh.triangles = new int[3] //{ // 0,1,2 //}; //mesh.RecalculateNormals(); //GetComponent<MeshFilter>().sharedMesh = mesh; }
/// <summary> /// Creates a new instance of <see cref="FluentEntityMapper{TEntity,TModel}"/> /// </summary> public FluentParamMapper(bool autoMap = true, bool ignoreUndefinedOptional = true, Action <MapBuilder <TParams, TEntity> > configEntityToModel = null) { var mapBuilder = new MapBuilder <TParams, TEntity>(); if (autoMap) { foreach (var property in mapBuilder.DynamicSourceType.Properties) { var targetProperty = mapBuilder.DynamicTargetType.GetProperty(property.Name); if (targetProperty == null) { continue; } if (property.ValueType.IsAssignableTo <IOptional>()) { mapBuilder.Map(property.Name, b => OptionalToValue(b, targetProperty.ValueType, ignoreUndefinedOptional)); } else { mapBuilder.Map(property.Name); } } } configEntityToModel?.Invoke(mapBuilder); _paramsToEntity = mapBuilder.Build(); }
private static void DecompileMapBackgroundWork(object sender, DoWorkEventArgs e) { var outputFile = (string)e.Argument; var filesToDecompile = (MapFiles)0; foreach (var checkBox in _filesToDecompileCheckBoxes) { if (checkBox.Checked) { filesToDecompile |= checkBox.MapFile; } } var decompiledMap = MapDecompiler.DecompileMap(_map, filesToDecompile, _worker); if (decompiledMap is null) { return; } var mapBuilder = new MapBuilder(decompiledMap); mapBuilder.AddFiles(_archive); mapBuilder.Build(outputFile); }
public override void Update() { if (Input.CheckButtonPress(BuildCustomMapBuilderButton)) { if (_builder != null) { _builder.Destroy(); _builder = null; } _builder = new SolidMapBuilder(Resources.Maps.Test); _builder.Build(); } if (Input.CheckButtonPress(BuildDefaultMapBuilderButton)) { if (_builder != null) { _builder.Destroy(); _builder = null; } _builder = new MapBuilder(Resources.Maps.Test); _builder.Build(); } if (_builder != null && Input.CheckButtonPress(DestroyMapButton)) { _builder.Destroy(); _builder = null; } }
public Map GetMap() { // map should look something like this // // 01234567890123 // 0 // 1 +-- +-+ +-+ // 2 | | | | | // 3 | | +-+ | // 4 | | | // 5 +----+ | // 6 var map = new MapBuilder(13, 7) .AddPath(1, 1, Directions.East, 3) .AddPath(1, 1, Directions.South, 5) .AddPath(1, 5, Directions.East, 6) .AddPath(6, 5, Directions.North, 5) .AddPath(6, 1, Directions.East, 3) .AddPath(8, 1, Directions.South, 3) .AddPath(8, 3, Directions.East, 3) .AddPath(10, 3, Directions.North, 3) .AddPath(10, 1, Directions.East, 3) .AddPath(12, 1, Directions.South, 5) ; return(map.Build()); }
public void TestCreateNewTemplateMap() { const string OutputMapName = "Template.w3x"; var scriptCompilerOptions = new ScriptCompilerOptions(CSharpLua.CoreSystem.CoreSystemProvider.GetCoreSystemFiles()); scriptCompilerOptions.MapInfo = MapInfo.Default; scriptCompilerOptions.MapEnvironment = MapEnvironment.Default; scriptCompilerOptions.SourceDirectory = @".\TestData\Script\Template"; scriptCompilerOptions.OutputDirectory = @".\TestOutput\Template"; #if DEBUG scriptCompilerOptions.Debug = true; #endif // Build and launch var mapBuilder = new MapBuilder(OutputMapName); if (mapBuilder.Build(scriptCompilerOptions)) { var mapPath = Path.Combine(scriptCompilerOptions.OutputDirectory, OutputMapName); var absoluteMapPath = new FileInfo(mapPath).FullName; Assert.IsNotNull(Warcraft3ExecutableFilePath, "Path to Warcraft III.exe is not set."); Process.Start(Warcraft3ExecutableFilePath, $"-loadfile \"{absoluteMapPath}\""); } else { Assert.Fail(); } }
public void TestGenerateLuaScriptWithUnitData() { const string OutputMapName = "TestOutput.w3x"; const string InputPath = @".\TestData\MapFiles\TestGenerateUnitData"; var mapInfo = MapInfo.Parse(File.OpenRead(Path.Combine(InputPath, MapInfo.FileName))); mapInfo.ScriptLanguage = ScriptLanguage.Lua; var scriptCompilerOptions = new ScriptCompilerOptions(); scriptCompilerOptions.MapInfo = mapInfo; scriptCompilerOptions.ForceCompile = true; scriptCompilerOptions.SourceDirectory = null; scriptCompilerOptions.OutputDirectory = @".\TestOutput\TestGenerateUnitData"; var mapBuilder = new MapBuilder(OutputMapName); if (mapBuilder.Build(scriptCompilerOptions, InputPath)) { var mapPath = Path.Combine(scriptCompilerOptions.OutputDirectory, OutputMapName); var absoluteMapPath = new FileInfo(mapPath).FullName; Assert.IsNotNull(Warcraft3ExecutableFilePath, "Path to Warcraft III.exe is not set."); Process.Start(Warcraft3ExecutableFilePath, $"-loadfile \"{absoluteMapPath}\""); } else { Assert.Fail(); } }
public MapController(Map map, MapBuilder builder) { _views = builder.Build(map); _pathfinder = new Pathfinder(_views); _presenter = new PathPresenter(map); Subsctibe(); }
static SchoolLogic() { _schoolService = ObjectBuilder <SchoolService> .Build(); _gradeService = ObjectBuilder <GradeService> .Build(); _mapper = MapBuilder.Build(); }
public void Init(Vector2[][] obstacles) { stopwatch = new Stopwatch(); stopwatch.Start(); map = MapBuilder.Build(obstacles); stopwatch.Stop(); Console.WriteLine("total init time is " + stopwatch.Elapsed.TotalMilliseconds); pathFinder = new Finder(map); }
public TiledDemo(Layer layer) : base(layer) { // TiledMap which is loaded from Content, is just a data structure // describing the map. We need to make an actual Scene object with entities on it. // You can write your own map builder, or use the default one. // Default map builder can also be expanded. _builder = new SolidMapBuilder(Resources.Maps.Test); _builder.Build(); }
static AccountLogic() { userService = ObjectBuilder <UserService> .Build(); userGradesService = ObjectBuilder <UserGradesService> .Build(); gradeService = ObjectBuilder <GradeService> .Build(); studentInfoService = ObjectBuilder <StudentInfoService> .Build(); mapper = MapBuilder.Build(); }
public static GameContext NewGame(uint?seed = null) { var ctx = new GameContext(seed); var m = MapBuilder.Build(85, 85, "mines", ctx, MapType.DUNGEON); var m2 = MapBuilder.FromFile("testfixed.txt", "text", Color.Gray, Color.LightGray, ctx); var randPos = m.Terrain.RandomPosition((c, t) => t.IsWalkable, ctx.RNG); ctx.Player = Mobile.TestPlayer(randPos); ctx.SetCurMap("mines"); ctx.changeMap(ctx.Player, "mines"); ctx.CurMap.CalculateFOV(randPos, 6); return(ctx); }
public void LevelTest() { var rules = new[] { new Rule { One = "A", Two = "B" }, new Rule { One = "A", Two = "C" }, }; var map = MapBuilder.Build(rules); Assert.AreEqual(map["A"].Level, 1); }
public MapViewModel(ILogger <MapViewModel> logger) { _logger = logger; // create a simple map for use with a start and end var builder = new MapBuilder(30, 15); builder.AddPath(1, 1, Directions.East, 5); builder.AddPath(3, 1, Directions.South, 5); builder.AddPath(3, 5, Directions.East, 5); builder.AddStart(2, 1); builder.AddEnd(5, 5); Map = builder.Build(); }
private static void Main() { // Build and launch var mapBuilder = new MapBuilder(OutputMapName); var options = CompilerOptions.GetCompilerOptions(SourceCodeProjectFolderPath, OutputFolderPath); var buildResult = mapBuilder.Build(options, AssetsFolderPath); if (buildResult.Success) { var mapPath = Path.Combine(OutputFolderPath, OutputMapName); var absoluteMapPath = new FileInfo(mapPath).FullName; #if DEBUG if (Warcraft3ExecutableFilePath != null) { var commandLineArgs = new StringBuilder(); var isReforged = Version.Parse(FileVersionInfo.GetVersionInfo(Warcraft3ExecutableFilePath).FileVersion) >= new Version(1, 32); if (isReforged) { commandLineArgs.Append("-launch "); } else if (GraphicsApi != null) { commandLineArgs.Append($"-graphicsapi {GraphicsApi} "); } if (!PauseGameOnLoseFocus) { commandLineArgs.Append("-nowfpause "); } commandLineArgs.Append($"-loadfile \"{absoluteMapPath}\""); Process.Start(Warcraft3ExecutableFilePath, commandLineArgs.ToString()); } else #endif { Process.Start("explorer.exe", $"/select, \"{absoluteMapPath}\""); } } else { throw new Exception(buildResult.Diagnostics.Where(diagnostic => diagnostic.Severity == Microsoft.CodeAnalysis.DiagnosticSeverity.Error).First().GetMessage()); } }
static void Init() { var map = MapBuilder.Build(MapType.DUNGEON, 100, 100, "test", Color.SlateGray, Color.White); var console = new MapConsole(map); console.IsVisible = true; console.IsFocused = true; var player = new PlayerFactory() .SetName("Player") .Build(); map.AddEntity(player); console.Focus = player; player.Position = (25, 25); //console.FillWithRandomGarbage(); Global.CurrentScreen = console; }
public static (int all, int quietOnly) CountTilesReachedByWater(string[] input) { var mapBuilder = new MapBuilder(); foreach (var scan in input) { mapBuilder.AddClaySegment(scan); } var map = mapBuilder.Build(); Console.WriteLine("Before:\n" + map.Draw()); map.SimulateWaterFlow(); Console.WriteLine("\nAfter:\n" + map.Draw()); return(map.CountTilesReachedByWater()); }
private static void Main() { var stringProvider = new ExampleStringProvider(); var mapInfo = MapInfo.Parse(FileProvider.GetFile(Path.Combine(stringProvider.BaseMapFilePath, MapInfo.FileName))); mapInfo.MapName = stringProvider.MapName; mapInfo.MapDescription = stringProvider.MapDescription; mapInfo.MapAuthor = stringProvider.MapAuthor; mapInfo.RecommendedPlayers = stringProvider.RecommendedPlayers; mapInfo.MapFlags &= ~MapFlags.MeleeMap; mapInfo.ScriptLanguage = ScriptLanguage.Lua; PlayerAndForceProperties.ApplyToMapInfo(mapInfo); var scriptCompilerOptions = new ScriptCompilerOptions(CoreSystemProvider.GetCoreSystemFiles().Append(@".\LuaLibs\PerlinNoise.lua")); scriptCompilerOptions.MapInfo = mapInfo; scriptCompilerOptions.LobbyMusic = stringProvider.LobbyMusic; scriptCompilerOptions.SourceDirectory = stringProvider.SourceProjectPath; scriptCompilerOptions.OutputDirectory = stringProvider.OutputDirectoryPath; // Note: do not use MpqFileFlags.SingleUnit, as it appears to be bugged. scriptCompilerOptions.DefaultFileFlags = MpqFileFlags.Exists | MpqFileFlags.CompressedMulti; scriptCompilerOptions.FileFlags["war3map.wtg"] = 0; scriptCompilerOptions.FileFlags[mapInfo.ScriptLanguage == ScriptLanguage.Jass ? "war3map.lua" : "war3map.j"] = 0; scriptCompilerOptions.FileFlags[ListFile.Key] = MpqFileFlags.Exists | MpqFileFlags.Encrypted | MpqFileFlags.BlockOffsetAdjustedKey; #if DEBUG scriptCompilerOptions.Debug = true; #endif // Build and launch var mapName = stringProvider.MapFileName; var mapBuilder = new MapBuilder(mapName); if (mapBuilder.Build(scriptCompilerOptions, stringProvider.AssetsDirectoryPath, stringProvider.BaseMapFilePath)) { var mapPath = Path.Combine(scriptCompilerOptions.OutputDirectory, mapName); var absoluteMapPath = new FileInfo(mapPath).FullName; Process.Start(stringProvider.Warcraft3ExecutablePath, $"{stringProvider.CommandLineArguments} -loadfile \"{absoluteMapPath}\""); } }
private static void Main() { // Build and launch var mapBuilder = new MapBuilder(OutputMapName); var options = CompilerOptions.GetCompilerOptions(SourceCodeProjectFolderPath, OutputFolderPath); if (mapBuilder.Build(options, AssetsFolderPath, BaseMapPath)) { var mapPath = Path.Combine(OutputFolderPath, OutputMapName); var absoluteMapPath = new FileInfo(mapPath).FullName; #if DEBUG if (Warcraft3ExecutableFilePath != null) { var commandLineArgs = new StringBuilder(); var isReforged = Version.Parse(FileVersionInfo.GetVersionInfo(Warcraft3ExecutableFilePath).FileVersion) >= new Version(1, 32); if (isReforged) { commandLineArgs.Append("-launch "); } else if (GraphicsApi != null) { commandLineArgs.Append($"-graphicsapi {GraphicsApi} "); } if (!PauseGameOnLoseFocus) { commandLineArgs.Append("-nowfpause "); } commandLineArgs.Append($"-loadfile \"{absoluteMapPath}\""); Process.Start(Warcraft3ExecutableFilePath, commandLineArgs.ToString()); } else #endif { Process.Start("explorer.exe", $"/select, \"{absoluteMapPath}\""); } } }
public void TestGenerateJassScriptWithUnitData() { const string OutputMapName = "TestOutput.w3x"; const string InputPath = @".\TestData\MapFiles\TestGenerateUnitData"; var scriptCompilerOptions = new ScriptCompilerOptions(); scriptCompilerOptions.ForceCompile = true; scriptCompilerOptions.SourceDirectory = null; scriptCompilerOptions.OutputDirectory = @".\TestOutput\TestGenerateUnitData"; var mapBuilder = new MapBuilder(OutputMapName); if (mapBuilder.Build(scriptCompilerOptions, InputPath)) { } else { Assert.Fail(); } }
public Map GetMap() { // map should look something like this // // 0123456789 // 0 +---- // 1| | // 2+----+---- // 3| | // 4 +---- var map = new MapBuilder(10, 5) .AddPath(0, 2, Directions.East, 10) .AddPath(5, 0, Directions.South, 5) .AddPath(5, 0, Directions.East, 5) .AddPath(9, 4, Directions.West, 5) .AddPath(0, 3, Directions.North, 3) ; return(map.Build()); }
public static List <Vector2> GetPath(this SceneViewModel scene, Vector2 startPoint, Vector2 endPoint) { var points = new List <Vector2>(); try { var mapBuilder = new MapBuilder(); foreach (var component in scene.Components.Where(c => c.CollisionDetectionEnabled).ToList()) { mapBuilder.AddObstacle(component); } mapBuilder.SetStart(startPoint); mapBuilder.SetEnd(endPoint); mapBuilder.SetDimensions(scene.Size); var mapResult = mapBuilder.Build(); if (mapResult.Success && mapResult.Map != null) { var pathFinder = new PathFinder.Algorithm.PathFinder(mapResult.Map, DefaultNeighbourFinder.Straight(0.5f)); points.AddRange(pathFinder.FindPath()); } else { Console.WriteLine(mapResult.Message.ToString()); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(points); }
public static List <Vector2> GetPath(this DesignerViewModel designer, Vector2 startPoint, Vector2 endPoint, INeighbourFinder neighbourFinder = null) { var points = new List <Vector2>(); try { var mapBuilder = new MapBuilder(); foreach (var item in designer.ConnectedComponents.ToList()) { mapBuilder.AddObstacle(item.Position - Vector2.One, item.Size + (Vector2.One * 2)); } mapBuilder.SetStart(startPoint); mapBuilder.SetEnd(endPoint); mapBuilder.SetDimensions(designer.Width, designer.Height); var mapResult = mapBuilder.Build(); if (!mapResult.Success) { throw new Exception(mapResult.Message); } var pathFinder = new PathFinder.Algorithm.PathFinder(mapResult.Map, neighbourFinder ?? DefaultNeighbourFinder.Straight(0.5f)); points.AddRange(pathFinder.FindPath()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(points); }
private static void Main() { if (ScenarioFilePath is null) { throw new FileNotFoundException("An input .scn file is required."); } // Convert .scn to .w3x var convertedScenarioFilesFolder = Path.Combine(OutputFolderPath, new FileInfo(ScenarioFilePath).Name); ScenarioConverter.MapConverter.Convert(ScenarioFilePath, convertedScenarioFilesFolder); // Generate .w3o files var generatedObjectDataFolder = Path.Combine(OutputFolderPath, "Object Data"); ObjectDataGenerator.Generate(generatedObjectDataFolder); // Generate DISBTN icons var generatedDisbtnFolder = Path.Combine(OutputFolderPath, "DISBTN Icons"); #if !SKIP_GENERATE_DISBTN Directory.CreateDirectory(Path.Combine(generatedDisbtnFolder, "ReplaceableTextures", "CommandButtonsDisabled")); foreach (var button in Directory.EnumerateFiles(Path.Combine(AssetsFolderPath, "ReplaceableTextures", "CommandButtons"))) { var btnName = new FileInfo(button).Name.Substring(3); var expectDisbtnPath = Path.Combine("ReplaceableTextures", "CommandButtonsDisabled", $"DISBTN{btnName}"); if (!File.Exists(Path.Combine(AssetsFolderPath, expectDisbtnPath))) { File.Copy(button, Path.Combine(generatedDisbtnFolder, expectDisbtnPath)); } } #endif // Build and launch var mapBuilder = new MapBuilder(OutputMapName); var options = CompilerOptions.GetCompilerOptions(SourceCodeProjectFolderPath, OutputFolderPath); var buildResult = mapBuilder.Build(options, generatedObjectDataFolder, AssetsFolderPath, convertedScenarioFilesFolder, generatedDisbtnFolder); if (buildResult.Success) { var mapPath = Path.Combine(OutputFolderPath, OutputMapName); var absoluteMapPath = new FileInfo(mapPath).FullName; #if DEBUG if (Warcraft3ExecutableFilePath != null) { var commandLineArgs = new StringBuilder(); var isReforged = Version.Parse(FileVersionInfo.GetVersionInfo(Warcraft3ExecutableFilePath).FileVersion) >= new Version(1, 32); if (isReforged) { commandLineArgs.Append("-launch "); } else if (GraphicsApi != null) { commandLineArgs.Append($"-graphicsapi {GraphicsApi} "); } if (!PauseGameOnLoseFocus) { commandLineArgs.Append("-nowfpause "); } commandLineArgs.Append($"-loadfile \"{absoluteMapPath}\""); Process.Start(Warcraft3ExecutableFilePath, commandLineArgs.ToString()); } else #endif { Process.Start("explorer.exe", $"/select, \"{absoluteMapPath}\""); } } }
public static void Build(bool launch) { // Ensure these folders exist Directory.CreateDirectory(ASSETS_FOLDER_PATH); Directory.CreateDirectory(OUTPUT_FOLDER_PATH); // Load existing map data var map = Map.Open(BASE_MAP_PATH); var builder = new MapBuilder(map); builder.AddFiles(BASE_MAP_PATH, "*", SearchOption.AllDirectories); builder.AddFiles(ASSETS_FOLDER_PATH, "*", SearchOption.AllDirectories); // Set debug options if necessary, configure compiler var csc = DEBUG ? "-debug -define:DEBUG" : null; var csproj = Directory.EnumerateFiles(SOURCE_CODE_PROJECT_FOLDER_PATH, "*.csproj", SearchOption.TopDirectoryOnly).Single(); var compiler = new Compiler(csproj, OUTPUT_FOLDER_PATH, string.Empty, null, "", "", csc, false, null, string.Empty) { IsExportMetadata = true, IsModule = false, IsInlineSimpleProperty = false, IsPreventDebugObject = true, IsCommentsDisabled = !DEBUG }; // Collect required paths and compile var coreSystemFiles = CSharpLua.CoreSystem.CoreSystemProvider.GetCoreSystemFiles(); var blizzardJ = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Warcraft III/JassHelper/Blizzard.j"); var commonJ = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Warcraft III/JassHelper/common.j"); var compileResult = map.CompileScript(compiler, coreSystemFiles, blizzardJ, commonJ); // If compilation failed, output an error if (!compileResult.Success) { throw new Exception(compileResult.Diagnostics.First(x => x.Severity == DiagnosticSeverity.Error).GetMessage()); } // Update war3map.lua so you can inspect the generated Lua code easily File.WriteAllText(Path.Combine(OUTPUT_FOLDER_PATH, OUTPUT_SCRIPT_NAME), map.Script); // Build w3x file var archiveCreateOptions = new MpqArchiveCreateOptions { ListFileCreateMode = MpqFileCreateMode.Overwrite, AttributesCreateMode = MpqFileCreateMode.Prune, BlockSize = 3, }; builder.Build(Path.Combine(OUTPUT_FOLDER_PATH, OUTPUT_MAP_NAME), archiveCreateOptions); // Launch if that option was selected if (launch) { var wc3exe = ConfigurationManager.AppSettings["wc3exe"]; if (File.Exists(wc3exe)) { var commandLineArgs = new StringBuilder(); var isReforged = Version.Parse(FileVersionInfo.GetVersionInfo(wc3exe).FileVersion) >= new Version(1, 32); if (isReforged) { commandLineArgs.Append(" -launch"); } else if (GRAPHICS_API != null) { commandLineArgs.Append($" -graphicsapi {GRAPHICS_API}"); } if (!PAUSE_GAME_ON_LOSE_FOCUS) { commandLineArgs.Append(" -nowfpause"); } var mapPath = Path.Combine(OUTPUT_FOLDER_PATH, OUTPUT_MAP_NAME); var absoluteMapPath = new FileInfo(mapPath).FullName; commandLineArgs.Append($" -loadfile \"{absoluteMapPath}\""); Process.Start(wc3exe, commandLineArgs.ToString()); } else { throw new Exception("Please set wc3exe in Launcher/app.config to the path of your Warcraft III executable."); } } }
static MessengerLogic() { messengerService = ObjectBuilder <MessengerService> .Build(); mapper = MapBuilder.Build(); }
static EmailLogic() { mailTemplateService = ObjectBuilder <MailTemplateService> .Build(); mapper = MapBuilder.Build(); }
private void BuildMap() { MapBuilder builder = new MapBuilder(); _map = builder.Build(); }