void Awake() { if (parent == null) { parent = new GameObject("MapObjects").transform; parent.position = Vector3.zero; } if (mapReader == null) { mapReader = new MapReader(); } if (spawner == null) { spawner = GetComponent <MapSpawner>(); } (map, WaveData) = mapReader.ReadMap(mapToRead); for (int y = 0; y < map.GetLength(1); y++) { for (int x = 0; x < map.GetLength(0); x++) { WalkableTiles = spawner.SpawnTile(x, y, map[x, y], tiles, parent); } } EndTile = spawner.EndTile; StartTile = spawner.StartTile; }
/// Randomizes faction attribution for all players inside a room. private void AssignDefaultPlayerFactions() { Random rng = new Random(); List <int> order = new List <int>(); for (int ix = 0; ix < 4; ix++) { order.Add(ix); } int nx = 4; while (nx > 1) { nx--; int k = rng.Next(nx + 1); int value = order[k]; order[k] = order[nx]; order[nx] = value; } List <Faction> factions = (List <Faction>)MapReader.readFactions(); int i = 0; IEnumerator roomPlayer = this.Players.PlayerList.GetEnumerator(); while (roomPlayer.MoveNext()) { Console.WriteLine(i); RoomPlayer rp = (RoomPlayer)roomPlayer.Current; rp.faction = factions[order[i]].name; RoomPlayer newCopy = (RoomPlayer)roomPlayer.Current; Console.WriteLine(newCopy.playerId + "; " + newCopy.faction); i++; } }
/// <summary> /// Finds a map with the name provided. If the map that was found ends /// up being corrupt or it could not be found, this returns false. /// </summary> /// <param name="name">The map name.</param> /// <param name="map">The found map, or null if none was found.</param> /// <returns>The map, or an empty optional if no map name matches. /// </returns> public static bool TryFindMap(UpperString name, out MapData map) { for (int i = Archives.Count - 1; i >= 0; i--) { foreach (MapComponents mapComponents in Archives[i].GetMaps()) { if (mapComponents.Name != name) { continue; } if (MapReader.TryRead(mapComponents, out map)) { return(true); } // If we find the map but its corrupt, we won't keep // looking for other maps since that will be really // confusing to the caller. map = null; return(false); } } map = null; return(false); }
static LispReader() { _macros['"'] = new StringReader(); _macros[';'] = new CommentReader(); _macros['\''] = new WrappingReader(QUOTE); _macros['@'] = new WrappingReader(DEREF);//new DerefReader(); _macros['^'] = new WrappingReader(META); _macros['`'] = new SyntaxQuoteReader(); _macros['~'] = new UnquoteReader(); _macros['('] = new ListReader(); _macros[')'] = new UnmatchedDelimiterReader(); _macros['['] = new VectorReader(); _macros[']'] = new UnmatchedDelimiterReader(); _macros['{'] = new MapReader(); _macros['}'] = new UnmatchedDelimiterReader(); //// macros['|'] = new ArgVectorReader(); _macros['\\'] = new CharacterReader(); _macros['%'] = new ArgReader(); _macros['#'] = new DispatchReader(); _dispatchMacros['^'] = new MetaReader(); _dispatchMacros['\''] = new VarReader(); _dispatchMacros['"'] = new RegexReader(); _dispatchMacros['('] = new FnReader(); _dispatchMacros['{'] = new SetReader(); _dispatchMacros['='] = new EvalReader(); _dispatchMacros['!'] = new CommentReader(); _dispatchMacros['<'] = new UnreadableReader(); _dispatchMacros['_'] = new DiscardReader(); }
public void TestLaserExample() { List <(int, int)> expectedAsteroids = new List <(int, int)> { (8, 1), (9, 0), (9, 1), (10, 0), (9, 2), (11, 1), (12, 1), (11, 2), (15, 1), (12, 2), (13, 2), (14, 2), (15, 2), (12, 3), (16, 4), (15, 4), (10, 4), (4, 4), (2, 4), (2, 3), (0, 2), (1, 2), (0, 1), (1, 1), (5, 2), (1, 0), (5, 1), (6, 1), (6, 0), (7, 0), (8, 0), (10, 1), (14, 0), (16, 1), (13, 3), (14, 3) }; var map = MapReader.FindAllAsteroids(File.ReadAllText("LaserExample.txt")); BestPlace bestPlace = BestPlaceDetector.Determine(map); Assert.True(bestPlace.Asteroid.X == 8 && bestPlace.Asteroid.Y == 3, $"Best place: X:{bestPlace.Asteroid.X}/Y:{bestPlace.Asteroid.Y}"); var vaporizedAsteroids = GiantLaser.Vaporize(map, bestPlace.Asteroid); Assert.NotEmpty(vaporizedAsteroids); for (int i = 0; i < expectedAsteroids.Count; i++) { Assert.True(vaporizedAsteroids[i].X == expectedAsteroids[i].Item1 && vaporizedAsteroids[i].Y == expectedAsteroids[i].Item2, $"At position {i} expected location: X:{expectedAsteroids[i].Item1}/Y:{expectedAsteroids[i].Item2}, actual: X:{vaporizedAsteroids[i].X}/Y:{vaporizedAsteroids[i].Y}"); } }
private void Start() { gameManager = GetComponent <GameManager>(); mapReaderMono = GetComponent <MapReaderMono>(); mapReader = new MapReader(); enemies = new List <string>(); enemies = mapReader.ReadEnemyWaves(mapReaderMono.TxtFile); path = GetComponent <Pathfinding>(); list = path.WorldPos; if (m_smallEnemyPrefab != null) { smallEnemyPool = new GameObjectPool(10, m_smallEnemyPrefab); } if (m_bigEnemyPrefab != null) { bigEnemyPool = new GameObjectPool(10, m_bigEnemyPrefab); } gameManager.GetMaxWave(enemies.Count); StartCoroutine("ReadInEnemies"); }
public void Should_return_map_object_from_api() { var response = new MapReader(new ApiProcessor(), new LogWriter()); var result = response.GetGeoLocation("London"); result.ShouldBeAssignableTo(typeof(MapModel)); }
void Start() { if (me != null) { Destroy(gameObject); return; } me = this; DontDestroyOnLoad(gameObject); tr = transform; aud = GetComponent <AudioSource>(); fade = tr.Find("fade/fade").GetComponent <Renderer>(); Window.Start(); sceneTempo = 0; AnimateFade(); block = true; currentScene = SceneManager.GetActiveScene().name; SetNewScene(string.Empty, currentScene); MapReader.SetRouteList(); fadeAudio = false; #if UNITY_EDITOR #else Cursor.visible = false; #endif }
private static void LoadMaps() { foreach (var fileName in Directory.GetFiles(UtilitySettings.Default.MapLocation, "*.xml")) { using (var mapFile = File.Open(fileName, FileMode.Open)) { var mapDocument = XDocument.Load(mapFile); switch (MapReader.ReadHandlerType(mapDocument)) { case HandlerType.ModuleRegistration: ModuleRegistrarFactory.LoadMap(MapReader.ReadMap(mapDocument)); break; case HandlerType.TypeResolution: TypeResolverFactory.LoadMap(MapReader.ReadMap(mapDocument)); break; case HandlerType.LibraryReader: LibraryReaderFactory.LoadMap(MapReader.ReadMap(mapDocument)); break; case HandlerType.Verification: NodeVerifierFactory.LoadMap(MapReader.ReadMap(mapDocument)); break; case HandlerType.Translation: ArtifactTranslatorFactory.LoadMap(MapReader.ReadMap(mapDocument)); break; case HandlerType.NodeTranslation: NodeTranslatorFactory.LoadMap(MapReader.ReadMap(mapDocument)); break; case HandlerType.ModelTranslation: ModelTranslatorFactory.LoadMap(MapReader.ReadMap(mapDocument)); break; case HandlerType.Writing: ArtifactWriterFactory.LoadMap(MapReader.ReadMap(mapDocument)); break; } } } }
private void Awake() { var tex = Resources.Load <Texture2D>("Textures/Maps/" + _mapImageFile); var nodes = MapReader.Read(tex); Grid = new Grid(nodes); }
public void LoadGame(int mapIndex) { MapReader reader = new MapReader(Helper.Maps[mapIndex]); reader.Map(info => { switch (info.Type) { case "Block": AddBlock(info.Position); break; case "AI": AddBot(TankFactory.GetInstance().CreateTank(info.TankType, "E_50_Ausf_M", info.Position)); break; case "Player": Tank playerTank = TankFactory.GetInstance().CreateTank(info.TankType, "E_50_Ausf_M", info.Position); if (playerTank != null) { Cursor.GetCursor().Fire = playerTank.Fire; _player = new Player(playerTank); _gui = new DebugPanel(playerTank); } else { SafeExit(); } break; } }); }
public void test_czy_map_reader_wczyta_operaty_obiektu() { var map = new MapaGeoMap(); var reader = new MapReader(map); var fileName = Path.Combine(@"..\..\..\GeoMapSamples", "Nysa.MAP"); reader.Load(fileName); //A1, A2, A3, A4,A5, A6, TX, DT, KR, MP var guid = "EBD94CBD-70F4-4504-9C76-EE6B44B165E3"; var element = map.Szukaj(guid); //*4741 65535 40 0.00000000 Assert.AreEqual(expected: 1361, actual: element.Nagłówek.Kod); Assert.AreEqual(expected: 7, actual: element.Atrybuty.Count()); Assert.AreEqual(expected: 0, actual: element.Opisy.Count()); Assert.AreEqual(expected: 1, actual: element.Punkty.Count()); //:ID[5B16242D-CAC5-454B-B11B-7592376D1681] Assert.AreEqual(expected: guid, actual: element.Id); var operaty = element.Operaty; var operat = operaty.Single(); Assert.AreEqual(expected: "473-414/70/1988", actual: operat.Numer); Assert.AreEqual(expected: null, actual: operat.Data); Assert.AreEqual(expected: null, actual: operat.Operator); //:A5[473-414/70/1988] //:TX[1988-09-15] //:MP[1] //:DT[42473.57348] //P 1 5591312.865 6460507.470 }
public void BuildMap(Transform transform) { if (m_MapData != null) { m_MapTileDictionary = m_MapData.ToDictionary(d => d.Key, d => d.ObjectType); m_MapWalkableDictionary = m_MapData.ToDictionary(d => d.Key, d => d.Walkable); } MapReader mapReader = new MapReader(); Maps = mapReader.ReadMap(SelectedMap); foreach (MapCell item in Maps.GridCells) { float z = item.YPos2D * CellSize; float x = item.XPos2D * CellSize; Vector3 newPos = m_MapstartPoint + new Vector3(x, 0, z); Instantiate(m_MapTileDictionary[item.ObjectType], newPos, Quaternion.identity, transform); if (item.ObjectType == '8') { m_StartPoint = newPos; } if (item.ObjectType == '9') { m_EndPoint = newPos; } } }
public override IEnumerator Start() { Debug.Log("Level Start!"); // Get map resource with currentLevel TextAsset textData = MapReader.GetTextAsset(gameManager.CurrentLevel); // if there isn't next map, victory. otherwise, Split map data if (textData == null) { gameManager.SetState(new Victory(gameManager)); yield break; } else { MapData.SplitTextData(textData); } // GameBoard.Initialize TileManager_Initialize?.Invoke(this); yield return(new WaitForSeconds(gameManager.CoroutineDelay)); gameManager.SetState(new WaveStart(gameManager)); yield break; }
public override void OnInspectorGUI() { // base.DrawDefaultInspector(); MapReader MapReader = (MapReader)target; // 读取地图信息 EditorGUILayout.Space(); var fileName = Path.Combine(Application.dataPath, "Map"); MapReader.GetDirs(fileName, ref MapReader.MapNameList); MapReader.FindCurrentMapIndex(); GUIContent arrayLabel = new GUIContent("Choose the Map"); MapReader.ArrayIndex = EditorGUILayout.Popup(arrayLabel, MapReader.ArrayIndex, MapReader.MapNameList.ToArray()); // 回到地图编辑器 EditorGUILayout.Space(); if (GUILayout.Button("Go Back To MapEditor")) { var filePath = Path.Combine(Application.dataPath, "MapEditor", "MapEditor.unity"); EditorSceneManager.OpenScene(filePath); var editor = GameObject.Find("Editor"); editor.GetComponent <MapCreator>().MapIndex = MapReader.ArrayIndex; Selection.activeGameObject = editor; } }
public void Should_return_ok_response_from_api() { var response = new MapReader(new ApiProcessor(), new LogWriter()); var result = response.GetGeoLocation("London"); result.Status.Code.ShouldBe("200"); }
public override void Initialize() { pad = new HexPad(Content, ExhibeatSettings.WindowWidth / 2, ExhibeatSettings.WindowHeight / 2); pad.Initialize(); pad.CenteredOrigin = true; pad.Scale = 1; grades = new NoteGradeDisplay(Content); lifebar = new LifeBar(Content, 30, 30); mapReader = new MapReader(); mapReader.Initialize(Content); mapReader.RegisterNewReciever(pad); mapReader.Read("test.exi"); mapReader.Play(); mapReader.RegisterNewReciever(this); visualizer = new Visualizer(Content, 0, 0, 0, ExhibeatSettings.WindowHeight / 4, 30); mapReader.RegisterNewReciever(visualizer); //runner = new AnimatedSprite(Content.Load<Texture2D>("running-test"), Content.Load<SpriteSheet>("running-test-sheet"), new Vector2(100, 100), false); //runner.Position = new Vector2(0, 0/* ExhibeatSettings.WindowHeight - Content.Load<Texture2D>("running-test").Height / 2*/); background = Content.Load <Texture2D>("blueWP"); background_dest = new Rectangle(0, 0, ExhibeatSettings.WindowWidth, ExhibeatSettings.WindowHeight); base.Initialize(); }
private void GenerateMap() { string fileName = "./Assets/Maps/map1.txt"; MapTiles mapTiles = MapReader <MapTiles, TileType> .ReadMapFile(fileName, ListToMapTiles, tileDictionary); LevelMaps.Add(mapTiles); }
public async Task <IActionResult> UploadMap(int?id, IFormFile file) { if (id == null) { return(NotFound()); } var race = await _context.Races.SingleOrDefaultAsync(r => r.ID == id); if (race == null) { return(NotFound()); } if (file.Length > 0) { var mapFilePath = Path.GetTempFileName(); using (var stream = System.IO.File.Create(mapFilePath)) { await file.CopyToAsync(stream); } MapReader mapReader = new MapReader(_env.WebRootPath, mapFilePath, Path.GetExtension(file.FileName).ToLowerInvariant()); Map map = mapReader.Read(); if (map != null) { map.Race = race; _context.Maps.Add(map); _context.SaveChanges(); return(RedirectToAction("Setting", "Races", new { id = id }).Success("Mapa byla nahrána.")); } } return(RedirectToAction("Setting", "Races", new { id = id }).Danger("Mapa nebyla nahrána.")); }
public static void createOsmNodes(MapReader mapReader, Dispatcher dispatcher, Connection connection) { List <ulong> createdRoadNodeIds = new List <ulong>(); foreach (OsmWay way in mapReader.ways.Values.ToList()) { if (way.IsRoad) { foreach (ulong nodeId in way.NodeIDs) { OsmNode thisNode; if (mapReader.nodes.TryGetValue(nodeId, out thisNode)) { if (thisNode.Id != nodeId) { Startup.StaticConnection.SendLogMessage(LogLevel.Info, Startup.StaticLogName, "Node ids don't match!"); } if (!createdRoadNodeIds.Contains(nodeId)) { createdRoadNodeIds.Add(nodeId); RequestId <CreateEntityRequest> roadNodeRequestId = CreationRequests.CreateOsmNodeEntity(dispatcher, connection, "Road Node", thisNode.coords); } } else { Startup.StaticConnection.SendLogMessage(LogLevel.Info, Startup.StaticLogName, "Couldn't find road node by id"); } } } if (way.IsBuilding) { } } }
public static void TestAll() { //var name = "小米科技有限责任公司"; //var code = "551385082"; //var area = "1101"; //var name = "深圳前瞻资讯股份有限公司"; //var code = "734185657"; //var area = "4403"; var name = "深圳市腾讯计算机系统有限公司"; var code = "708461136"; var area = "4403"; // 投资族谱 //var invCluster = MapReader.GetInvCluster(name, code, area); //// 股权结构 //var stockStruct = MapReader.GetStockStructs(name, code, area); // 实际控制人 //var actualControl = MapReader.GetActualControllers(name, code, area); //var ac = MapReader.GetStockController(name, code, area); // 企业图谱 var entMap = MapReader.GetEntMap(name, code, area); // 疑似关系 //var relation = MapReader.GetRelations(name, code, area); }
private int Process(IdMappings idMappings, string mapFilePath) { Log.Information("Processing {file}", mapFilePath); using var mapFile = new GZipStream(File.OpenRead(mapFilePath), CompressionMode.Decompress); var reader = new MapReader(idMappings); try { var mapData = reader.Read(new MapDeserializer(new PositionTrackingStream(mapFile))); validator?.Validate(mapData); duplicateFinder.Process(mapData, mapFilePath); } catch (InvalidDataException e) { Log.Error(e, "Failed to process map {file}. File is most likely corrupted.", mapFilePath); return(e.HResult); } catch (ArgumentException e) { Log.Error(e, "Failed to process map {file}. File is most likely corrupted.", mapFilePath); return(e.HResult); } catch (InvalidOperationException e) { Log.Error(e, "Failed to process map {file}. File is most likely corrupted.", mapFilePath); return(e.HResult); } return(0); }
public void FindBestAsteroid(string exampleFileName, int expectedLargestNumberOfOtherAsteroids) { var map = MapReader.FindAllAsteroids(File.ReadAllText(exampleFileName)); BestPlace bestPlace = BestPlaceDetector.Determine(map); Assert.Equal(expectedLargestNumberOfOtherAsteroids, bestPlace.DetectionRatio); }
public Map() { maploader = new MapReader(this); tileBank = new TileBank(); Layers = new List <Layer>(); CollisionObjects = new List <PhysicsObject>(); }
protected virtual void ReadCountFile(string countFile) { Dictionary <string, string> counts = new MapReader(0, 1).ReadFromFile(countFile); foreach (var c in counts) { Counts[c.Key] = int.Parse(c.Value); } }
public Map() { maploader = new MapReader(this); tileBank = new TileBank(); Layers = new List <Layer>(); AStarCollisionObjects = new List <Rectangle>(); CollisionObjects = new List <Rectangle>(); }
//private string URL; // Use this for initialization void Start() { Debug.ClearDeveloperConsole(); map = gameObject.GetComponent <MapReader>(); //map.ReadInput("iu"); currentPhase = Phase.SearhcingGPS; locationPoints = new List <Vector3>(); StartCoroutine(StartLocationService()); }
IEnumerator Start() { map = GetComponent <MapReader>(); while (!map.IsReady) { yield return(null); } // TODO: Proces map data to create buildings }
public static void TestMap() { var name = "金兴资本有限公司"; var code = "MA002C5H1"; var area = ""; var entMap = MapReader.GetEntMap2FmtJson(name, code, area); Console.WriteLine(entMap); Console.ReadLine(); }
private static Dictionary <string, List <MapLine> > ReadDict(Settings set) { Dictionary <string, List <MapLine> > result = new Dictionary <string, List <MapLine> >(); foreach (var sm in set.SpecialMap.Maps) { result.Add(sm.SelectorValue, MapReader.Read(StreamFile(sm.Path))); } return(result); }
public MainWindow() { InitializeComponent(); var basedir = ConfigurationManager.AppSettings["basedir"]; var reader = new MapReader(basedir); Dictionary<int, string> maps = reader.GetMaps(); foreach (KeyValuePair<int, string> map in maps) { MapListBox.Items.Add(map); } MapListBox.DisplayMemberPath = "Value"; }
static EdnReader() { _macros['"'] = new StringReader(); _macros[';'] = new CommentReader(); _macros['^'] = new MetaReader(); _macros['('] = new ListReader(); _macros[')'] = new UnmatchedDelimiterReader(); _macros['['] = new VectorReader(); _macros[']'] = new UnmatchedDelimiterReader(); _macros['{'] = new MapReader(); _macros['}'] = new UnmatchedDelimiterReader(); _macros['\\'] = new CharacterReader(); _macros['#'] = new DispatchReader(); _dispatchMacros['^'] = new MetaReader(); //_dispatchMacros['"'] = new RegexReader(); _dispatchMacros['{'] = new SetReader(); _dispatchMacros['<'] = new UnreadableReader(); _dispatchMacros['_'] = new DiscardReader(); }