// 初始化地图制造者相关变量 public void InitMapMaker() { _instance = this; // 如果不加这一句会获取不到MapMaker的单例 CalcGirdSize(); // 计算相关参数 gridPoints = new GridPoint[row, column]; for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { #if Tool GameObject itemGo = Instantiate(gridGo, transform.position, transform.rotation); #endif // 通过工厂拿到itemGo物体 #if Game GameObject itemGo = GameController.Instance.GetGameObjectResource("Grid"); #endif itemGo.transform.localPosition = new Vector2(-mapWidth / 2 + j * gridWidth + gridWidth / 2, -mapHeight / 2 + i * gridHeight + gridHeight / 2); itemGo.transform.SetParent(transform); gridPoints[i, j] = itemGo.GetComponent <GridPoint>(); gridPoints[i, j].gridIndex.xIndex = i; gridPoints[i, j].gridIndex.yIndex = j; } } bgSR = transform.Find("BG").GetComponent <SpriteRenderer>(); roadSR = transform.Find("Road").GetComponent <SpriteRenderer>(); }
public static void NewGame() { Objects = new List <GameObject> (); Map = new Tile[MAP_WIDTH, MAP_HEIGHT]; Log = new List <Message>(); abilityGUI = new AbilityGUI(); statusGUI = new StatusGUI(); equipmentGUI = new EquipmentGUI(5); inventoryGUI = new InventoryGUI(); Map = MapMaker.MakeTunnelMap(false); miniMap = new MiniMap(30, 20, Map); PlayerObject = new GameObject(StartPosition.x, StartPosition.y, "hero", 120, 200, (int)(0.05 * Game1.WIDTH - 124.21), (int)(0.61 * Game1.HEIGHT - 670)); PlayerObject.Player = new Player(10); PlayerObject.Player.Owner = PlayerObject; PlayerObject.Fighter = new Fighter(2, 5, 0, 0); PlayerObject.Fighter.Owner = PlayerObject; Objects.Add(PlayerObject); DeathScreen.OnStart(); Started = true; ToRemove = new List <GameObject>(); GoToPlaying(); //Console.Out.WriteLine(PlayerObject.x.ToString() + ";" + PlayerObject.y.ToString()); //Console.Out.WriteLine("Position : " + PlayerObject.Position.x.ToString() + ";" + PlayerObject.Position.y.ToString()); //Console.Out.WriteLine("InventoryWidth:" + InventoryWidth.ToString()); }
private Vector3 _playerStartPosition; //start position #endregion #region Unity void Start() { _mapMaker = gameObject.GetComponent <MapMaker>(); //set ref GetMap(); //get map from MapMaker.cs AddMap_0(); //choose map and add InstantiateMap(); //spawn }
private void Awake() { _instance = this; gameTrans = UnityTool.FindChild(gameObject, "Game").transform; lvInfoMgr = LevelInfoMgr.Instance; mapMaker = GetComponent <MapMaker>(); enemyBuilder = new EnemyBuilder(); towerBuilder = new TowerBuilder(); bullectBuilder = new BullectBuilder(); currentLevel = GameRoot.Instance.pickLevel; info = lvInfoMgr.levelInfoList[currentLevel]; //初始化地图 mapMaker.InitAllGrid(); mapMaker.LoadLevelMap(currentLevel); //获得关卡数据和回合数据 SetLevelData(info); level = new Level(info); level.HandleRound(); beginPos = level.roundInfoList[0].pathList[0]; EventCenter.Broadcast(EventType.SetStartPos, beginPos); isPause = true; EventCenter.AddListener <int>(EventType.UseItemInGame, UseItem); }
private void Awake() { #if Tool _instance = this; Init(); #endif }
private string GetImageUrl(AppState appState, int width, int height) { MapMaker mapMaker = new MapMaker(appState, width, height); string key = AppContext.BrowserImageCache.Store(mapMaker.GetImage()); return("Services/MapImage.ashx?key=" + key); }
void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (scene.name == "Game") { if (NetworkServer.active) { map = Instantiate(mapPrefab); mapCode = map.GetComponent <MapMaker>(); mapCode.gm = this; foreach (UnitBasics unit in FindObjectsOfType <UnitBasics>()) { Destroy(unit.gameObject); } foreach (PlayerScript player in FindObjectsOfType <PlayerScript>()) { if (!players.Contains(player.gameObject)) { players.Add(player.gameObject); } player.GetComponent <PlayerScript>().map = mapCode; player.GetComponent <PlayerScript>().num = players.IndexOf(player.gameObject); } NetworkServer.Spawn(map); turnTime = turnTimer + 30f; inGame = true; // Get Light CmdSpawnPlayers(); } } }
private void Awake() { #if Tool Instance = this; InitMapMaker(); #endif }
// Use this for initialization void Start () { instance = this; ConsoleControl.Log("Start called"); float theBeforeTime = Time.realtimeSinceStartup; /*for (int i = 0; i < floors.Length; i++){ floors[i].Id = i+1; //floors[i].make(); }*/ line = this.GetComponent<LineRenderer>();//get a reference to the line seeker = GetComponent<Seeker>(); //astarPath = GetComponent<AstarPath>(); //logs["Getting components"] = Time.realtimeSinceStartup - theBeforeTime; //logs["Set active floor"] = Time.realtimeSinceStartup - theBeforeTime; //add the waypoints to the graph //float thebeforetime = Time.realtimeSinceStartup; PlayerPrefs.SetString("MarkerSave", ""); MapLabel.loadMarkers(); //logs["Initial marker load"] = Time.realtimeSinceStartup - theBeforeTime; if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork){ startMarkerUpdate(); } //logs["Start update of markers"] = Time.realtimeSinceStartup - theBeforeTime; logs["Startup time"] = Time.realtimeSinceStartup - theBeforeTime; setLogs(); }
/// <summary> /// creates a random map with the following parameters /// </summary> /// <param name="x">width</param> /// <param name="y">height</param> /// <param name="prob">close cell probability (0-100)</param> /// <param name="h">cell operation specifier [h=true, if c>n close else open; h=false if c>n open else close]</param> /// <param name="counter">number of iterations</param> /// <param name="n">number of cells neighbors</param> /// <param name="c">number of cells closed neighbors</param> public GameMap createRandomCaveMap(int x, int y, int prob, bool h, int counter, int n, int seed) { Map map = MapMaker.create(x, y); object[] parameters = new object[CaveGen.CAVE_PARAMS_SIZE]; parameters[CaveGen.CAVE_PARAMS_X] = x; parameters[CaveGen.CAVE_PARAMS_Y] = y; parameters[CaveGen.CAVE_PARAMS_PROB] = prob; parameters[CaveGen.CAVE_PARAMS_CELL_OP_SPEC] = h; parameters[CaveGen.CAVE_PARAMS_ITER] = counter; parameters[CaveGen.CAVE_PARAMS_NEIGHBORS] = n; parameters[CaveGen.CAVE_PARAMS_SEED] = seed; MapMaker.Parameters = parameters; MapMaker.generate(map, MapType.CAVE); GameMap gameMap = new GameMap(map); Entity e = ecs_instance.create(); ecs_instance.add_component(e, gameMap); ecs_instance.tag_manager.tag_entity("MAP", e); ecs_instance.resolve(e); return(gameMap); }
public override void OnInspectorGUI() { DrawDefaultInspector(); MapMaker mapMaker = (MapMaker)target; if (GUILayout.Button("Spawn Level")) { mapMaker.CreateMap(mapMaker.GetMapText(SceneManager.GetActiveScene())); } if (GUILayout.Button("Spawn From File")) { mapMaker.CreateMap(mapMaker.mapSpawnFile.text); } if (GUILayout.Button("Destroy Map")) { mapMaker.DestroyMapObject(); } if (GUILayout.Button("Save To File")) { mapMaker.SaveMap(savePath); } GUIContent savePathLabelContent = new GUIContent("Save Path", "Root location is Assets Folder"); GUILayout.Label(savePathLabelContent); savePath = GUILayout.TextField(savePath); }
public GamePlay(MapMaker mapMaker, GameWindow window) { this.MapMaker = mapMaker; this.LevelObjects = new List<GameObject>(); this.Window = window; LevelCreators.Peek()(); }
private void OnEnable() { this.minSize = new Vector2(width, height); myMapMaker = GetWindow <MapMaker>(); myCurrState = myMapMaker.myStateMachine.currentState; mySaves = myMapMaker.myStateMachine.currentState.mySaves; }
void Start() { if (singleton != null) { Debug.LogWarning("Houve uma tentativa de criar 2 MapMakers"); Destroy(this); } singleton = this; hotbar = new List <GameObject>(); blockList = GameObject.Find("DataHandler").GetComponent <BlockData>().blockList; fluidList = GameObject.Find("DataHandler").GetComponent <BlockData>().fluidList; ChangeHotbarContent(VoxelData.VoxelType.Block); // Inicializa ferramenta ativada curTool = Tool.None; // Referencia objetos necessários para o controle dos blocos do mapa highlightBlock = GameObject.Find("BlockHighlight"); highlightBlock?.SetActive(false); lastCoord = new Vector2Int(-1, -1); // Adiciona listeners para os botões das ferramentas for (int i = 0; i < toolButtons.Length; i++) { int pos = i; toolButtons[i].GetComponent <Button>().onClick.AddListener(() => SelectTool((Tool)pos)); toolButtons[i].GetComponentsInChildren <Image>()[1].enabled = false; toolButtons[i].GetComponentsInChildren <Text>()[0].enabled = false; } // Instancia blocos para permitir edição do mapa InitBlockEditorMap(); }
void Start() { gameController = FindObjectOfType <GameController>(); inputController = FindObjectOfType <InputController>(); mapMaker = FindObjectOfType <MapMaker>(); grabbing = GetComponent <Grabbing>(); map = GameObject.Find("Map"); if (map == null) { map = new GameObject("Map"); map.transform.position = Vector3.zero; } spawnLists = new GameObject[4][]; spawnLists[0] = mapMaker.wallList; spawnLists[1] = mapMaker.actorList; spawnLists[2] = mapMaker.hazardList; spawnLists[3] = mapMaker.floorList; iteratorMemory = new int[spawnLists.Length]; for (int i = 0; i < iteratorMemory.Length; i++) { iteratorMemory[i] = 0; } creativeUIController = FindObjectOfType <CreativeUIController>(); if (gameController.creativeMode) { SendUIUpdate(); } }
public GameMap createRandomForestMap(int x, int y, int prob, short baseTerrain, short blockingTerrain, int seed) { Map map = MapMaker.create(x, y); object[] parameters = new object[ForestGen.FOREST_PARAMS_SIZE]; parameters[ForestGen.FOREST_PARAMS_X] = x; parameters[ForestGen.FOREST_PARAMS_Y] = y; parameters[ForestGen.FOREST_PARAMS_PROB] = prob; parameters[ForestGen.FOREST_PARAMS_BASE_TERRAIN] = baseTerrain; parameters[ForestGen.FOREST_PARAMS_BLOCKING_TERRAIN] = blockingTerrain; parameters[ForestGen.FOREST_PARAMS_SEED] = seed; MapMaker.Parameters = parameters; MapMaker.generate(map, MapType.WILDERNESS); GameMap gameMap = new GameMap(map); Entity e = ecs_instance.create(); ecs_instance.add_component(e, gameMap); ecs_instance.tag_manager.tag_entity("MAP", e); ecs_instance.resolve(e); return(gameMap); }
public GameMap createRandomDungeonMap(int x, int y, int features, int seed) { Map map = MapMaker.create(x, y); object[] parameters = new object[DungeonGen.DUNGEON_PARAMS_SIZE]; parameters[DungeonGen.DUNGEON_PARAMS_XSIZE] = x; parameters[DungeonGen.DUNGEON_PARAMS_YSIZE] = y; parameters[DungeonGen.DUNGEON_PARAMS_SEED] = seed; parameters[DungeonGen.DUNGEON_PARAMS_FEATURE_COUNT] = features; MapMaker.Parameters = parameters; MapMaker.generate(map, MapType.DUNGEON); GameMap gameMap = new GameMap(map); Entity e = ecs_instance.create(); ecs_instance.add_component(e, gameMap); ecs_instance.tag_manager.tag_entity("MAP", e); ecs_instance.resolve(e); return(gameMap); }
public GameMap createWorldMap(int x, int y, int dx, int dy, float z, int xSize, int ySize, int seed) { Map map = MapMaker.create(xSize, ySize); object[] parameters = new object[WorldGen.WORL_PARAMS_SIZE]; parameters[WorldGen.WORL_PARAMS_X] = x; parameters[WorldGen.WORL_PARAMS_Y] = y; parameters[WorldGen.WORL_PARAMS_DX] = dx; parameters[WorldGen.WORL_PARAMS_DY] = dy; parameters[WorldGen.WORL_PARAMS_Z] = z; parameters[WorldGen.WORL_PARAMS_XSIZE] = xSize; parameters[WorldGen.WORL_PARAMS_YSIZE] = ySize; parameters[WorldGen.WORL_PARAMS_SEED] = seed; MapMaker.Parameters = parameters; MapMaker.generate(map, MapType.WORLD); GameMap gameMap = new GameMap(map); Entity e = ecs_instance.create(); ecs_instance.add_component(e, gameMap); ecs_instance.tag_manager.tag_entity("MAP", e); ecs_instance.resolve(e); return(gameMap); }
public void MakeMapFromNet() { MapMakerSettings mapMakerSettings = new MapMakerSettings(); mapMakerSettings.MapDataSources.Add( new OsmDataSource(new OsmFileData(@"..\..\..\..\Data\Samples\KosmosProjects\Maribor\Maribor.osm", FileSystem), SerializersRegistry)); mapMakerSettings.StartingMapId = "12345678"; mapMakerSettings.MapNamePrefix = "TestMap"; mapMakerSettings.RenderingRulesSource = @"http://wiki.openstreetmap.org/index.php?title=GroundTruth_Driving_Map&action=edit"; //mapMakerSettings.RenderingRulesSource = @"GroundTruthTests\SampleRules.txt"; mapMakerSettings.StandardGarminTypesSource = @"..\..\..\GroundTruth\Rules\StandardGarminTypes.txt"; mapMakerSettings.CharactersConversionTableSource = @"..\..\..\GroundTruth\Rules\CharacterConversionTable.txt"; mapMakerSettings.CGpsMapperPath = @"..\..\..\..\lib\cgpsmapper"; MapMaker mapMaker = new MapMaker(); mapMaker.MapMakerSettings = mapMakerSettings; mapMaker.AddTask(new GenerateMapPolishFilesTask(mapMakerSettings, SerializersRegistry)); mapMaker.AddTask(new GenerateMapTypesPolishFileTask()); mapMaker.AddTask(new GenerateTypeFileTask()); mapMaker.AddTask(new GenerateMapImgFilesTask()); mapMaker.AddTask(new GeneratePreviewPolishFileTask()); mapMaker.AddTask(new GeneratePreviewAndTdbFilesTask()); mapMaker.AddTask(new GenerateMapListFileTask()); //mapMaker.AddTask (new UploadMapsToGpsTask ()); mapMaker.AddTask(new CopyProductFilesToOutputDirTask()); mapMaker.AddTask(new GenerateMapSourceRegFilesTask()); mapMaker.Run(); }
public GameObject handleTowerCanvasGo;//处理塔的画布 private void Awake() { #if Game _instance = this; mGameManager = GameManager.Instance; mCurrentStage = mGameManager.CurrentStage; //normalModelPanel = mGameManager.uiManager.mUIFacade.currentScenePanelDict[StringManager.NormalModelPanel] as NormalModelPanel; mapMaker = GetComponent <MapMaker>(); mapMaker.InitMapMaker(); //mapMaker.LoadMap(mCurrentStage.mBigLevelID, mCurrentStage.mLevelID); mapMaker.LoadMap(1, 3); GameSpeed = 1; monsterBuilder = new MonsterBuilder(); mLevel = new Level(mapMaker.roundInfoList.Count, mapMaker.roundInfoList); mLevel.HandleRound(); AnimControllers = new RuntimeAnimatorController[12]; for (int i = 0; i < AnimControllers.Length; i++) { AnimControllers[i] = GetRuntimeAnimatorController("Monster/" + mapMaker.bigLevelID.ToString() + "/" + (i + 1).ToString()); } #endif }
public void ConstructorSquareMapTest() { int widthXHeight = 128; string seed = "Angelica"; int fillpercentWalkable = 57; int sites = 5; int relaxIterations = 1; int smoothIterations = 5; int NumberOFSprites = 8; int width = widthXHeight; int height = widthXHeight; MapMaker mapmaker = new MapMaker( width, height, NumberOFSprites, // Map Properites seed, fillpercentWalkable, smoothIterations, // BinaryMap Properities sites, relaxIterations, // Voronoi Properties 7 ); int[,] map = mapmaker.GetMap(); int groundCount = 0; int wallCount = 0; int castleCount = 0; int other = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (map[x, y] < 0) { Assert.Fail("Failed due to illegal map value. Value in map below zero(0)."); } else if (map[x, y] == MapMaker.GROUND) { groundCount++; } else if (map[x, y] == MapMaker.WALL) { wallCount++; } else if (map[x, y] == MapMaker.CASTLE) { castleCount++; } else { other++; } } } // Tester for om hele kartet kun består av en type tile: Assert.AreNotEqual(groundCount, map.GetLength(0) * map.GetLength(1)); Assert.AreNotEqual(wallCount, map.GetLength(0) * map.GetLength(1)); Assert.AreNotEqual(castleCount, map.GetLength(0) * map.GetLength(1)); }
public void MapMaker_Row_Test_3() { var input = ".^^.^.^^^^".ToCharArray(); var result = new string(MapMaker.NextRow(input)); Assert.AreEqual("^^^...^..^", result); }
private void Awake() { UIManager = GameObject.Find("UIManager").GetComponent <UIButtonManager>(); GameManager = GameObject.Find("StartManager").GetComponent <GameStartManager>(); MatrixManager = GameObject.Find("MapMaker").GetComponent <MapMaker>(); MarkManager = GameObject.Find("MarkManager").GetComponent <MarkManager>(); SyncManager = GameObject.Find("SyncManager").GetComponent <SyncManager>(); }
public void SaveToJsonFile(string fname) { var lcld = getLinkCloud(); if (lcld != null) { MapMaker.SaveToFile(lcld, fname); } }
public static void loadMarkers() { //TextAsset txt = Resources.Load("TextAssets/MarkerSave") as TextAsset; //string text = txt.text; ConsoleControl.Log("LoadMarkers Called"); if (!PlayerPrefs.HasKey("MarkerSave")) { PlayerPrefs.SetString("MarkerSave", ""); Debug.LogWarning("If you see this message twice more than once at the beginning " + "and you have internet access, let me know"); } string text = PlayerPrefs.GetString("MarkerSave"); string[] lines = text.Trim().Split(new char[] { '\n', '\r', '\t' }, System.StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines) { try { //suround in a try catch block in case any one is weirdly formatted string[] pieces = line.Trim().Split(new char[] { '|' }); if (pieces.Length >= 6) { int nid = int.Parse(pieces[0].Trim()); string ntext = pieces[1].Trim(); float x = float.Parse(pieces[2].Trim()); float y = float.Parse(pieces[3].Trim()); int pri = int.Parse(pieces[4].Trim()); int flor = int.Parse(pieces[5].Trim()); bool ele = (int.Parse(pieces[6].Trim()) == 1); string[] fls = pieces[7].Trim().Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries); int[] efls = new int[fls.Length]; if (fls.Length == 0 || fls[0] == "undefined") { efls = new int[] {}; } else { for (int i = 0; i < fls.Length; i++) { efls[i] = int.Parse(fls[i]); } } if (pri > 0) { Vector3 oldPos = new Vector3(x, y, -4f); createLabel(MapMaker.mapSpaceToWorldSpaceFull(oldPos), nid, ntext, pri, flor, ele, efls); } } } catch { Debug.LogWarning("Malformed label (request=\"" + line + "\")"); } } //MapMaker.needsToScan = true; }
private void CreatePdfOverviewMap(PdfContentByte content, Configuration.PrintTemplateContentRow row) { AppState appState = new AppState(); appState.Application = _appState.Application; Configuration.ApplicationRow application = AppContext.GetConfiguration().Application.First(o => o.ApplicationID == appState.Application); appState.MapTab = application.OverviewMapID; appState.Extent = application.GetFullExtentEnvelope(); int pixelWidth = Convert.ToInt32(row.Width * PixelsPerInch); int pixelHeight = Convert.ToInt32(row.Height * PixelsPerInch); MapMaker mapMaker = new MapMaker(appState, pixelWidth, pixelHeight, 2); MapImageData mapImageData = mapMaker.GetImage(); System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(new MemoryStream(mapImageData.Image)); Transformation trans = new AffineTransformation(pixelWidth * 2, pixelHeight * 2, appState.Extent); MapGraphics mapGraphics = MapGraphics.FromImage(bitmap, trans); double minSize = (trans.Transform(new Coordinate(1, 0)).X - trans.Transform(new Coordinate(0, 0)).X) * 12; Envelope extent = new Envelope(new Coordinate(_appState.Extent.MinX, _appState.Extent.MinY), new Coordinate(_appState.Extent.MaxX, _appState.Extent.MaxY)); if (extent.Width < minSize) { extent = new Envelope(new Coordinate(extent.Centre.X - minSize * 0.5, extent.MinY), new Coordinate(extent.Centre.X + minSize * 0.5, extent.MaxY)); } if (extent.Height < minSize) { extent = new Envelope(new Coordinate(extent.MinX, extent.Centre.Y - minSize * 0.5), new Coordinate(extent.MaxX, extent.Centre.Y + minSize * 0.5)); } System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(64, System.Drawing.Color.Red)); System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Red, 4); mapGraphics.FillEnvelope(brush, extent); mapGraphics.DrawEnvelope(pen, extent); MemoryStream stream = new MemoryStream(); bitmap.Save(stream, mapImageData.Type == CommonImageType.Png ? System.Drawing.Imaging.ImageFormat.Png : System.Drawing.Imaging.ImageFormat.Jpeg); byte[] mapImage = stream.ToArray(); float originX = Convert.ToSingle(row.OriginX) * PointsPerInch; float originY = Convert.ToSingle(row.OriginY) * PointsPerInch; float width = Convert.ToSingle(row.Width) * PointsPerInch; float height = Convert.ToSingle(row.Height) * PointsPerInch; iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(mapImage); image.SetAbsolutePosition(originX, originY); image.ScaleAbsolute(width, height); content.AddImage(image); CreatePdfBox(content, row, false); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ScaleImage); // Register our sensor listener _sensorManager = (SensorManager)GetSystemService(SensorService); _sensorListener = new CustomListener(_sensorManager); _sensorListener.AccelerationProcessor.OnValueChanged += AccelerationProcessorOnValueChanged; _sensorListener.RotationProcessor.OnValueChanged += RotationProcessorOnValueChanged; // Class that will handle drawing of the map _mapMaker = new MapMaker(); _mapMaker.Initialize(Resources); var graphAsset = Assets.Open("dcsGroundFloor.xml"); var graphInstance = Graph.Load(graphAsset); _mapMaker.PathfindingGraph = graphInstance; _collision = new Collision(graphInstance, new StepDetector()); _collision.SetLocation(707.0f, 677.0f); _collision.PassHeading(90); _collision.PositionChanged += CollisionOnPositionChanged; _collision.StepDetector.OnStep += StepDetectorOnStep; collisionMap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.dcsFloor); _walCol = new WallCollision((x, y) => collisionMap.GetPixel(x, y)); _collision.WallCol = _walCol; pf = new Pathfinding.Pathfinding(new Dictionary <int, Stream>() { { 0, Assets.Open("dcsGroundFloor.xml") }, { 1, Assets.Open("dcsFloor1.xml") } }, Assets.Open("Rooms.xml")); pf.CurrentFloor = 0; while (true) { if (pf.Ready) { break; } Thread.Sleep(500); } var result = pf.FindPath(new GraphLocatable(609, 457, 1), new GraphLocatable(1256, 80, 0)); setUpUITabs(); }
public void Test(bool metric) { // prepare the temp directory MapMaker mapMaker = new MapMaker(); mapMaker.PrepareTempDirectory(); if (false == metric) { mapMaker.MapMakerSettings.ContoursRenderingRulesSource = "Rules/ContoursRulesFeet.txt"; } ContoursDataSource dataSource = new ContoursDataSource(@"..\..\..\..\Data\Samples\IBF\Maribor.ibf"); IPolishMapFileCreator creator = new DefaultPolishMapFileCreator(mapMaker.MapMakerSettings); List <ProductFile> productFiles = new List <ProductFile>(); ITaskRunner runner = MockRepository.GenerateStub <ITaskRunner> (); runner.Expect(r => r.RegisterProductFile(null)).IgnoreArguments() .Do((Action <ProductFile>)(productFiles.Add)).Repeat.Any(); dataSource.AnalyzeData(mapMaker.MapMakerSettings); dataSource.GeneratePolishMapFiles(runner, creator); int polylinesCount = 0; foreach (ProductFile file in productFiles) { string mapContent = File.ReadAllText(file.ProductFileName); polylinesCount += GetCountOf(mapContent, "[POLYLINE]"); if (metric) { Assert.IsTrue(mapContent.Contains("Label=800")); Assert.IsTrue(mapContent.Contains("Label=820")); Assert.IsFalse(mapContent.Contains("Label=790")); } else { Assert.IsTrue(mapContent.Contains("Label=450")); Assert.IsTrue(mapContent.Contains("Label=600")); Assert.IsFalse(mapContent.Contains("Label=1000")); } } if (metric) { Assert.AreEqual(9602, polylinesCount); } else { Assert.AreEqual(1968, polylinesCount); } }
private void OnMouseOver() { Vector2Int coord = gameObject.GetComponent <PathCoord>().coord; MapMaker.PlaceHighlight(coord); if (Input.GetMouseButton(0)) { MapMaker.UpdateVoxel(coord); } }
// Start is called before the first frame update void Awake() { if (GameManager.instance != null && GameManager.instance.getLevel() % 3 == 0) { int chance = Random.Range(1, 20); if (chance >= 5) { bossRoom = true; } } if (bossRoom) { mapThingy = this; grid = new Node[worldSizex, worldSizey]; int id = 1; for (int i = 0; i < worldSizex; i++) { for (int j = 0; j < worldSizey; j++) { grid[i, j] = new Node(); grid[i, j].id = id; id++; } } int room = Random.Range(0, bossRooms.Count - 1); Node bossNode = grid[worldSizex / 2, worldSizey / 2]; bossNode.AddNodalPosition(worldSizex / 2, worldSizey / 2, tileSize); GameObject tmp = Instantiate(bossRooms[room], new Vector2(bossNode.positionX, bossNode.positionY), Quaternion.identity); nodalList.Add(bossNode); } else { if (getPieces) { FillOutRooms(); } mapThingy = this; grid = new Node[worldSizex, worldSizey]; int id = 1; for (int i = 0; i < worldSizex; i++) { for (int j = 0; j < worldSizey; j++) { grid[i, j] = new Node(); grid[i, j].id = id; id++; } } Source.id = 0; grid[worldSizex / 2, worldSizey / 2] = Source; grid[worldSizex / 2, worldSizey / 2].AddNodalPosition(worldSizex, worldSizey, tileSize); path.Push(Source); startWalk(); } }
//绘制操作面板 public override void OnInspectorGUI() { base.OnInspectorGUI(); //程序运行时才绘制 if (Application.isPlaying) { mapMaker = MapMaker.Instance; //第一行 EditorGUILayout.BeginHorizontal(); //获取操作文件名 fileNameList = GetNames(fileList); int currentIndex = EditorGUILayout.Popup(selectIndex, fileNameList); //下拉列表 返回用户选择的索引 if (currentIndex != selectIndex) //选择对象改变 { selectIndex = currentIndex; //实例化地图的方法 mapMaker.InitMap(); //加载当前选择的level文件 mapMaker.LoadLevelInfo(mapMaker.LoadLevelInfoFile(fileNameList[selectIndex])); } if (GUILayout.Button("读取关卡列表")) //当用户单击按钮时返回true { LoadLevelFiles(); } EditorGUILayout.EndHorizontal(); //第二行 EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("回复地图编辑器默认状态")) { mapMaker.RecoverTowerPoint(); } if (GUILayout.Button("清除怪物路径")) { mapMaker.ClearMonsterPath(); } if (GUILayout.Button("更新物品")) { //Debug.Log(mapMaker.bigLevelID + " " + mapMaker.levelID); // Debug.Log(mapMaker.grid.GetComponent<GridPoint>()) ; //mapMaker.grid.GetComponent<GridPoint>().UpdateItem(); //更新物品信息 // mapMaker.InitMapMaker(); //初始化MapMaker mapMaker.UpdateGrid(); } EditorGUILayout.EndHorizontal(); //第三行 if (GUILayout.Button("保存当前关卡数据文件")) { mapMaker.SaveLevelFileByJson(); } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (Application.isPlaying) { // 游戏运行时才去绘制面板 EditorGUILayout.BeginHorizontal(); //在begin和end之间是对应的布局 // 获得文件名 fileNameList = GetNames(); // 获得MapMaker单例 mapMaker = MapMaker.Instance; // 下拉文件列表 int currentIndex = EditorGUILayout.Popup(selectIndex, fileNameList); if (currentIndex != selectIndex) { // 当前选择对象是否改变 selectIndex = currentIndex; // 实例化地图的方法 mapMaker.InitMap(); // 加载当前选择的level文件 LevelInfo levelFile = mapMaker.LoadLevelInfoByJson(fileNameList[selectIndex]); mapMaker.LoadLevelData(levelFile); } if (GUILayout.Button("读取关卡列表")) { LoadLevelFiles(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("恢复地图编辑器默认状态")) { mapMaker.RecoverTowerPoint(); } if (GUILayout.Button("清除怪物路点")) { mapMaker.ClearMonsterPoint(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("更新当前地图背景和道路")) { mapMaker.SetMapBgAndRoad(); mapMaker.RecoverTowerPoint(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("保存当前关卡数据")) { mapMaker.SaveFileByJson(); } } }
private void GetMapImage() { AppState appState = AppState.FromJson(Request.QueryString["state"]); // set the default map layers as visible Configuration.MapTabRow mapTab = Configuration.MapTab.FindByMapTabID(appState.MapTab); appState.VisibleLayers = new System.Collections.Generic.Dictionary<string,StringCollection>() { { appState.MapTab, new StringCollection(mapTab.GetMapTabLayerRows().Where(e => !e.IsCheckInLegendNull() && e.CheckInLegend == 1).Select(e => e.LayerID)) } }; int width = Convert.ToInt32(Request.QueryString["width"]); int height = Convert.ToInt32(Request.QueryString["height"]); MapMaker mapMaker = new MapMaker(appState, width, height); MapImageData mapImageData = mapMaker.GetImage(); Response.ContentType = mapImageData.Type == CommonImageType.Png ? "image/png" : "image/jpeg"; Response.BinaryWrite(mapImageData.Image); }
// Use this for initialization void Start () { //MapCameraControl.main = this; //mainCamera = this.transform.FindChild("PrimaryRotator").FindChild("Main Camera"); centralCube = GameObject.Find("CentralCube").transform;//this.transform.FindChild("CentralCube"); mapMaker = this.gameObject.GetComponent("MapMaker") as MapMaker; elasticConnection = this.gameObject.GetComponent<ElasticConnection>(); //regularRotation = new Vector3(0f, 65f, 270f); /*regularRotation = mainCamera.localRotation.eulerAngles; regularRotationM = transform.localRotation.eulerAngles; birdsRotation = new Vector3(0f, 0f, 0f); birdsRotationM = new Vector3(0f, 0f, 0f); postPos = new Vector3(126,126,-240); postPosM = new Vector3(0,0,0);*/ activeScreen = UIName.Landing; initUI(); MapMaker.ActiveFloor = MapMaker.floors[0]; }
private void GetOverviewImage() { Configuration.ApplicationRow application = Configuration.Application.First(o => o.ApplicationID == Request.Params["application"]); int width = Convert.ToInt32(Request.Params["width"]); int height = Convert.ToInt32(Request.Params["height"]); string[] bbox = Request.Params["bbox[]"].Split(','); AppState appState = new AppState() { Application = application.ApplicationID, MapTab = application.OverviewMapID, Extent = new Envelope(new Coordinate(Convert.ToDouble(bbox[0]), Convert.ToDouble(bbox[1])), new Coordinate(Convert.ToDouble(bbox[2]), Convert.ToDouble(bbox[3]))) }; MapMaker mapMaker = new MapMaker(appState, width, height); MapImageData mapImageData = mapMaker.GetImage(); Response.ContentType = mapImageData.Type == CommonImageType.Png ? "image/png" : "image/jpeg"; Response.BinaryWrite(mapImageData.Image); }
private string GetImageUrl(AppState appState, int width, int height) { MapMaker mapMaker = new MapMaker(appState, width, height); string key = AppContext.BrowserImageCache.Store(mapMaker.GetImage()); return "Services/MapImage.ashx?key=" + key; }
private void SaveMapKml() { AppState appState = AppState.FromJson(Request.Form["state"]); int width = Convert.ToInt32(Math.Round(Convert.ToDouble(Request.Form["width"]))); int height = Convert.ToInt32(Math.Round(Convert.ToDouble(Request.Form["height"]))); MapMaker mapMaker = new MapMaker(appState, width, height); MapImageData mapImageData = mapMaker.GetImage(); Configuration.ApplicationRow application = Configuration.Application.Select(String.Format("ApplicationID = '{0}'", appState.Application))[0] as Configuration.ApplicationRow; string appName = application.DisplayName; DateTime now = DateTime.Now; string timeStamp = now.ToString("yyyyMMddHHmmssff"); string dateNow = now.ToString("MM/dd/yyyy hh:mm tt"); string kmzName = String.Format("Map_{0}.kmz", timeStamp); string kmlName = String.Format("Map_{0}.kml", timeStamp); string imageName = String.Format("Map_{0}.", timeStamp) + (mapImageData.Type == CommonImageType.Png ? "png" : "jpg"); double f = AppSettings.MapUnits == "feet" ? Constants.MetersPerFoot : 1; CoordinateSystem coordSys = AppSettings.CoordinateSystem; double lat; double lon; coordSys.ToGeodetic(appState.Extent.MinX * f, appState.Extent.MinY * f, out lon, out lat); double minLat = lat; double maxLat = lat; double minLon = lon; double maxLon = lon; coordSys.ToGeodetic(appState.Extent.MinX * f, appState.Extent.MaxY * f, out lon, out lat); minLat = Math.Min(minLat, lat); maxLat = Math.Max(maxLat, lat); minLon = Math.Min(minLon, lon); maxLon = Math.Max(maxLon, lon); coordSys.ToGeodetic(appState.Extent.MaxX * f, appState.Extent.MaxY * f, out lon, out lat); minLat = Math.Min(minLat, lat); maxLat = Math.Max(maxLat, lat); minLon = Math.Min(minLon, lon); maxLon = Math.Max(maxLon, lon); coordSys.ToGeodetic(appState.Extent.MaxX * f, appState.Extent.MinY * f, out lon, out lat); minLat = Math.Min(minLat, lat); maxLat = Math.Max(maxLat, lat); minLon = Math.Min(minLon, lon); maxLon = Math.Max(maxLon, lon); Coordinate p = appState.Extent.Centre; double cLat; double cLon; coordSys.ToGeodetic(p.X * f, p.Y * f, out cLon, out cLat); p.X = appState.Extent.MaxX; double eLat; double eLon; coordSys.ToGeodetic(p.X * f, p.Y * f, out eLon, out eLat); double rotation = Math.Atan2(eLat - cLat, eLon - cLon) * 180 / Math.PI; string kml = @"<?xml version=""1.0"" encoding=""UTF-8""?> <kml xmlns=""http://earth.google.com/kml/2.2""> <Folder> <name>{0}</name> <GroundOverlay> <name>Map: created {1}</name> <Icon> <href>{2}</href> </Icon> <LatLonBox> <north>{3}</north> <south>{4}</south> <east>{5}</east> <west>{6}</west> <rotation>{7}</rotation> </LatLonBox> </GroundOverlay> </Folder> </kml>"; kml = String.Format(kml, appName, dateNow, imageName, maxLat, minLat, maxLon, minLon, rotation); Response.ContentType = "application/vnd.google-earth.kmz"; Response.AddHeader("Content-Disposition", "attachment; filename=" + kmzName); ZipOutputStream zipStream = new ZipOutputStream(Response.OutputStream); MemoryStream memoryStream = new MemoryStream(); byte[] buffer = (new UTF8Encoding()).GetBytes(kml); ZipEntry entry = new ZipEntry(kmlName); entry.Size = buffer.Length; zipStream.PutNextEntry(entry); zipStream.Write(buffer, 0, buffer.Length); entry = new ZipEntry(imageName); entry.Size = mapImageData.Image.Length; zipStream.PutNextEntry(entry); zipStream.Write(mapImageData.Image, 0, mapImageData.Image.Length); zipStream.Finish(); }
private void CreatePdfMap(PdfContentByte content, Configuration.PrintTemplateContentRow row) { int pixelWidth = Convert.ToInt32(row.Width * PixelsPerInch); int pixelHeight = Convert.ToInt32(row.Height * PixelsPerInch); MapMaker mapMaker = new MapMaker(_appState, pixelWidth, pixelHeight, 2); byte[] mapImage = mapMaker.GetImage().Image; float originX = Convert.ToSingle(row.OriginX) * PointsPerInch; float originY = Convert.ToSingle(row.OriginY) * PointsPerInch; float width = Convert.ToSingle(row.Width) * PointsPerInch; float height = Convert.ToSingle(row.Height) * PointsPerInch; iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(mapImage); image.SetAbsolutePosition(originX, originY); image.ScaleAbsolute(width, height); content.AddImage(image); CreatePdfBox(content, row, false); }
void OnEnable() { maker = target as MapMaker; drawTimer = 0f; }
void Start() { // Set the properties of the objects we use map = GameObject.FindObjectOfType<MapMaker>() as MapMaker; blocks = new GameObject[(int)map.mapSize.x, (int)map.mapSize.y]; for (int i = 0; i < map.mapSize.x; i++) { for (int j = 0; j < map.mapSize.y; j++) { blocks[i, j] = null; } } // Create a holder for the blocks blockHolder = new GameObject("BlockHolder").transform; blockHolder.parent = GameObject.Find ("BlockController").transform; }
protected override void LoadContent() { SpriteBatch = new SpriteBatch(GraphicsDevice); MapMaker = new MapMaker(this.Content, GetDeathAction()); Background = new Background(this.Content); GamePlay = new GamePlay(MapMaker, Window); ExplosionSound = Content.Load<SoundEffect>("sounds/explosion"); BackgroundMusic = Content.Load<Song>("sounds/groove"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(BackgroundMusic); }
private void SaveMapImage() { AppState appState = AppState.FromJson(Request.Form["state"]); int width = Convert.ToInt32(Math.Round(Convert.ToDouble(Request.Form["width"]))); int height = Convert.ToInt32(Math.Round(Convert.ToDouble(Request.Form["height"]))); MapMaker mapMaker = new MapMaker(appState, width, height); MapImageData mapImageData = mapMaker.GetImage(); Response.ContentType = mapImageData.Type == CommonImageType.Png ? "image/png" : "image/jpeg"; Response.AddHeader("Content-Disposition", "attachment; filename=Map." + (mapImageData.Type == CommonImageType.Png ? "png" : "jpg")); Response.BinaryWrite(mapImageData.Image); }
// Use this for initialization void Start () { stage = GameObject.Find ("MapMaker").GetComponent<MapMaker> (); }