public Form1() { InitializeComponent(); map = new Map(MaxMapWidth, MaxMapHeight, MapPanel); collisionMap = new int[MaxMapWidth, MaxMapHeight]; InitCollisionTiles(); }
public void save(string filename) { Map newMap = new Map(); // create map dimentions MapMapDimentions dimentions = new MapMapDimentions(); dimentions.Height = 1; dimentions.Width = 1; newMap.MapDimentions = dimentions; // create surfaces MapSurfaces surfaces = new MapSurfaces(); // create background MapSurfacesBackgoundPicture backgroundPic = new MapSurfacesBackgoundPicture(); MapSurfacesBackgoundPictureAsset backgroundAsset = new MapSurfacesBackgoundPictureAsset(); MapSurfacesBackgoundPictureAssetScale backScale = new MapSurfacesBackgoundPictureAssetScale(); MapSurfacesBackgoundPictureAssetPosition backgroundPos = new MapSurfacesBackgoundPictureAssetPosition(); backgroundAsset.name = "smudgystars"; backScale.X = "1"; backScale.Y = "1"; backgroundPos.X = "0"; backgroundPos.Y = "0"; backgroundPic.Asset = backgroundAsset; surfaces.BackgoundPicture = backgroundPic; backgroundAsset.Scale = backScale; backgroundAsset.Position = backgroundPos; // create some walls MapSurfacesWall[] walls = new MapSurfacesWall[4]; createWall(ref walls, 0, "left", editor.leftWallPosition, editor.leftWall); createWall(ref walls, 1, "right", editor.rightWallPosition, editor.rightWall); createWall(ref walls, 2, "bottom", editor.bottomWallPosition, editor.bottomWall); createWall(ref walls, 3, "top", editor.topWallPosition, editor.topWall); MapSurfacesAsset[] obsticals = new MapSurfacesAsset[0]; surfaces.Obsticals = obsticals; surfaces.MapWalls = walls; newMap.Surfaces = surfaces; // create spawns MapSpawnPoint spawns = new MapSpawnPoint(); MapSpawnPointPlayer1 p1Spawn = new MapSpawnPointPlayer1(); p1Spawn.X = "0"; p1Spawn.Y = "100"; spawns.Player1 = p1Spawn; newMap.SpawnPoint = spawns; XmlSerializer serialiser = new XmlSerializer(typeof(Map)); serialiser.Serialize(new StreamWriter(filename), newMap); }
public static Map Get() { if (_instance == null) _instance = new Map(); return _instance; }
public Map( ushort p_tileIdx1, ushort p_tileIdx2, Map.MapBlockAtom[ , ] p_blocks, ushort[ , ] p_border ) { m_tileIdx1 = p_tileIdx1; m_tileIdx2 = p_tileIdx2; m_blocks = p_blocks; m_border = p_border; }
public void SetMap(Map map) { this.map = map; cam.SetPos(Vector2.Zero); if (selecter != null) selecter.LoadTileSet(map.TileSet); }
public void Render(MapObject mapObject) { MapPoint cellPoint = new MapPoint(0, 0, 0); Map map = new Map(1, MapSize.One); map[cellPoint] = new MapCell(new MapPlace(), null); if (mapObject is MapPlace) { map[cellPoint].Place = mapObject as MapPlace; } if (mapObject is MapWall) { map[cellPoint].SetWall(MapDirection.North, mapObject as MapWall); map[cellPoint].SetWall(MapDirection.East, mapObject as MapWall); map[cellPoint].SetWall(MapDirection.West, mapObject as MapWall); map[cellPoint].SetWall(MapDirection.South, mapObject as MapWall); } MapState mapState = new MapState(map); if (mapObject is MapActiveObject) { mapState.AddActiveObject(mapObject as MapActiveObject, cellPoint); } GameMap gameMap = new GameMap(mapState); Renderer.SetMap(gameMap, new MapCellRange(cellPoint, cellPoint)); Renderer.Render(); }
public MapEditorPage() { InitializeComponent(); baseMap = new Map(); RebuildMap(); }
public NewEvents(Project sProject, Map selectedMap, int x, int y) { this.InitializeComponent(); this.Loaded += new RoutedEventHandler(NewEvents_Loaded); this.X = x; this.Y = y; this.SelectedProject = sProject; this.SelectedMap = selectedMap; }
public override void Load(string[] line, Map map) { if (line.Length < 2) ThrowLoadException(); for (int i = 0; i < line.Length; i++ ) { int textid = Convert.ToInt32(line[i]); CreateField(textid,i,map); } }
public void destroy() { if (_isDestroyed) return; _isDestroyed = true; foreach (Chunk chunk in _chunks.Values) chunk._data = null; _chunks.Clear(); _instance = null; }
public void destroy() { Debug.Log("Destroying " + mStaticWalls.Count + " objects"); foreach (PlaceableStaticWall staticWall in mStaticWalls.Values) GameObject.Destroy(staticWall.gameObject); mStaticWalls.Clear(); mStaticWalls = null; _map.destroy(); _map = null; mInstance = null; }
public void LoadTriggers(string mapfolder,Map map) { try { string path = Path.Combine(mapfolder, triggersFile); using (StreamReader sr = new StreamReader(path)) { while (!sr.EndOfStream) { string[] par = sr.ReadLine().Split(' '); Field f = map.GetField(Convert.ToInt32(par[1]), Convert.ToInt32(par[2])); if (f.triggers == null) f.triggers = new List<Trigger>(); switch ((TriggerType)(Convert.ToInt32(par[0]))) { case TriggerType.CHANGE_MAP: f.triggers.Add(new MoveToNextMapTrigger(new Point(Convert.ToInt32(par[3])/Field.SIZE, Convert.ToInt32(par[4])/Field.SIZE),par[5])); break; case TriggerType.SPAWN_MOB: f.triggers.Add(new SpawnMobTrigger( Convert.ToInt32(par[3]), Convert.ToInt32(par[4]), par[5], new Point(Convert.ToInt32(par[6]) / Field.SIZE, Convert.ToInt32(par[7]) / Field.SIZE))); break; } } } } catch (FileNotFoundException) { throw new MapLoadException("Cannot find triggers file"); } catch (Exception ex) { throw new MapLoadException("Exception during loading triggers", ex); } }
public DefaultList(Map.ObjectTable tabl) { table = tabl; InitializeComponent(); foreach (ThingDb.Thing tng in ThingDb.Things.Values) { listDefault.Items.Add(tng.Name.ToLower()); } foreach (string str in Directory.GetFiles(Application.StartupPath + "\\scripts\\objects\\defaultmods\\")) { if (str == "Update.txt") { } else { string[] strs = str.Split("\\".ToCharArray()); string str2 = strs[strs.GetLength(0) - 1]; str2 = str2.Remove(str2.Length - 4); if (listDefault.Items.Contains(str2.ToLower())) { listDefault.Items.Remove(str2.ToLower()); } } } }
private void FillAllConnectedCells( int x, int y, ushort newValue, ListView listView, Map map ) { if( x >= map.Width || y >= map.Height ) return; if( x < 0 || y < 0 ) return; var target = map.m_blocks[ x, y ].m_blockidx; if( target == newValue ) return; FillCell( x, y, newValue, true, listView, map ); var dirs = new[ ] { new[ ] { 0, 1 }, new[ ] { 1, 0 }, new[ ] { 0, -1 }, new[ ] { -1, 0 } }; Queue<Tuple<int,int>> q = new Queue<Tuple<int, int>>( ); q.Enqueue( new Tuple<int, int>( x, y ) ); while( q.Count > 0 ) { var ac = q.Dequeue( ); foreach( var d in dirs ) { int nx = d[ 0 ] + ac.Item1; int ny = d[ 1 ] + ac.Item2; if( nx < 0 || ny < 0 || nx >= map.Width || ny >= map.Height ) continue; if( map.m_blocks[ nx, ny ].m_blockidx != target ) continue; FillCell( nx, ny, newValue, true, listView, map ); q.Enqueue( new Tuple<int, int>( nx, ny ) ); } } }
private StaticWallManager() { mStaticWalls = new SortedList<Vec2Int, PlaceableStaticWall>(Vec2IntComparer.Get()); _map = Map.Get(); }
public bool CloseEditor() { if (!Saved) { MessageBoxResult result = MessageBox.Show("Do you want to save changes to " + TitleName + " before closing?", TitleName, MessageBoxButton.YesNoCancel, MessageBoxImage.None, MessageBoxResult.Cancel); if (result == MessageBoxResult.Cancel) return false; else if (result == MessageBoxResult.Yes) { bool saveResult = SaveEditor(); if (!saveResult) return false; } } foreach (TabItem tab in TileSets.Items) { (tab.Content as TileSetEditor).CloseEditor(); } TileSets.Items.Clear(); baseMap = new Map(); RebuildMap(); baseMap = null; SaveFilePath = null; return true; }
public void OpenEditor(string file) { CloseEditor(); using (FileStream openFile = new FileStream(file, FileMode.Open, FileAccess.Read)) { baseMap = Map.FromStream(openFile, getTileSetFromFileName); } foreach (TileSet tset in baseMap.tileSets) { TileSetEditor ed = new TileSetEditor(); ed.Editable = false; ed.OpenFromTileSet(tset); ed.TileSelected += OnTileSelected; TabItem tab = new TabItem(); tab.Header = ed.Title; tab.Content = ed; TileSets.SelectedIndex = TileSets.Items.Add(tab); } RebuildMap(); ZClip.Value = ZClip.Maximum; SaveFilePath = file; Saved = true; }
private void bLoad_Click(object sender, System.EventArgs e) { string c = System.IO.Directory.GetCurrentDirectory(); DialogResult r = openBox.ShowDialog(); if(r==DialogResult.OK) { System.IO.Directory.SetCurrentDirectory(c); // Parser p = new Parser(openBox.FileName); map = new Map(openBox.FileName); Map.getTileSet().fillListView(lTileSet); Map.getTileSet().fillListView(lManualTS,1); updateSize(); } pMapView.Refresh(); }
public void LoadFromMap(Map map) { if (map.Tiles == null) { GridWidth = map.Width; GridHeight = map.Height; map.Tiles = Tiles; } }
private void FillCell( int x, int y, ushort newValue, bool updateImage, ListView listView, Map map ) { if( x >= map.Width || y >= map.Height ) return; if( x < 0 || y < 0 ) return; if( !m_movementOnly ) map.m_blocks[ x, y ].m_blockidx = newValue; if( comboBox2.SelectedIndex != -1 ) map.m_blocks[ x, y ].m_movedata = (byte)comboBox2.SelectedIndex; if( updateImage && !m_movementOnly ) listView.Items[ y * map.Width + x ].ImageIndex = newValue; }
private void bNew_Click(object sender, System.EventArgs e) { mapProp.nTileX.Enabled = true; mapProp.nTileY.Enabled = true; mapProp.tPath.Enabled = true; DialogResult r = mapProp.ShowDialog(); if(r != DialogResult.OK) return; map = new Map(mapProp.tPath.Text,(int)mapProp.nTileX.Value,(int)mapProp.nTileY.Value); map.desc = mapProp.tDesc.Text; map.numPlayers = (int)mapProp.nNumPlayers.Value; mapProp.nTileX.Enabled = false; mapProp.nTileY.Enabled = false; mapProp.tPath.Enabled = false; nOwner.Maximum = map.numPlayers; Map.getTileSet().fillListView(lTileSet); Map.getTileSet().fillListView(lManualTS,1); updateSize(); pMapView.Refresh(); }
private void InsertRange( Map range, int x, int y, ListView listView, Map destination ) { for( int i = x; i < x + range.Width; ++i ) for( int j = y; j < y + range.Height; ++j ) if( range.m_blocks[ i - x, j - y ].m_blockidx != 0 || range.m_blocks[ i - x, j - y ].m_movedata != 0 ) { if( !m_movementOnly ) FillCell( i, j, range.m_blocks[ i - x, j - y ].m_blockidx, true, listView, destination ); if( x < destination.Width || y < destination.Height ) destination.m_blocks[ i, j ].m_movedata = range.m_blocks[ i - x, j - y ].m_movedata; } }
public void NewEditor() { CloseEditor(); baseMap = new Map(5,5); RebuildMap(); }
private void newMapToolStripMenuItem_Click( object sender, EventArgs e ) { if( numericUpDown8.Value == 0 || numericUpDown7.Value == 0 ) { MessageBox.Show( "Can't create a map with this size.\n(Change the size in the “Map Header” tab.)", "Creating a new map failed." ); return; } CacheMap = new Map( (ushort)numericUpDown6.Value, (ushort)numericUpDown5.Value, new Map.MapBlockAtom[ (int)numericUpDown7.Value, (int)numericUpDown8.Value ], new ushort[ 0, 0 ] ); CacheMap.Border = textBox2.Text; }
/*private bool CanInsertTile(Map.TileStack col, int index, Map.TileReference t) { return index <= col.Count; }*/ /*private void InsertTile(Map.TileStack col, int index, Map.TileReference t) // requires rebuild of map after { col.Insert(index, t); }*/ private void InsertTile(int x, int y, int z, Map.TileReference t) { Map.TileStack col = baseMap.tiles[y][x]; int zindex = baseMap.GetTileIndexByHeight(x, y, z); Tile tile = baseMap.GetTile(t); if (tile.IsSlope && zindex != col.Count) return; if (zindex > 0 && baseMap.GetTile(col[zindex - 1]).IsSlope) return; if (!tile.passable && zindex != col.Count && baseMap.GetTile(col[zindex]).passable) return; if (zindex > 0 && !baseMap.GetTile(col[zindex - 1]).passable && tile.passable) return; col.Insert(zindex, t); OnModify(); RebuildMap(); }
private void Select( int x, int y, Map map ) { if( x >= map.Width || y >= map.Height ) return; if( x < 0 || y < 0 ) return; m_selectedBlock = map.m_blocks[ x, y ].m_blockidx; comboBox1.SelectedIndex = m_selectedBlock; comboBox2.SelectedIndex = map.m_blocks[ x, y ].m_movedata; if( m_selectedBlock >= 512 ) { if( BlockSet2 != null ) pictureBox1.Image = listView2.LargeImageList.Images[ m_selectedBlock % 512 ]; else pictureBox1.Image = new Bitmap( 16, 16 ); } else { if( BlockSet1 != null ) pictureBox1.Image = listView1.LargeImageList.Images[ m_selectedBlock % 512 ]; else pictureBox1.Image = new Bitmap( 16, 16 ); } }
// requires rebuild of map after /*private bool CanReplaceTile(Map.TileStack col, int index, Map.TileReference t) { return index < col.Count; }*/ private void ReplaceTile(Map.TileStack col, int index, Map.TileReference t) { col[index] = t; OnModify(); }
private void toolStripMenuItem10_Click( object sender, EventArgs e ) { if( numericUpDown1.Value == 0 || numericUpDown2.Value == 0 ) { MessageBox.Show( "Can't create a map with this size.\n(Change the size in the “Map Header” tab.)", "Creating a new map failed." ); return; } Map = new Map( (ushort)numericUpDown4.Value, (ushort)numericUpDown3.Value, new Map.MapBlockAtom[ (int)numericUpDown1.Value, (int)numericUpDown2.Value ], new ushort[ 0, 0 ] ); Map.Border = textBox1.Text; toolStripStatusLabel1.Text = "MAP: (New Map)"; }
private void NewMap_Click(object sender, EventArgs e) { Map map = new Map(); map.AssetName = "NewMap"; int SizeX = (int)this.SizeX.Value; int SizeY = (int)this.SizeY.Value; map.Name = "NewMap"; map.MapDimensions = new Microsoft.Xna.Framework.Point(SizeX, SizeY); map.TileSize = new Microsoft.Xna.Framework.Point(64, 64); map.SpawnMapPosition = new Microsoft.Xna.Framework.Point(0, 0); map.TextureName = TileSet.Text; map.Texture = Globals.Instance.Content.Load<Texture2D>(TileSet.Text); map.TilesPerRow = map.Texture.Width / map.TileSize.X; map.BaseLayer = new int[SizeX * SizeY]; map.FringeLayer = new int[SizeX * SizeY]; map.ObjectLayer = new int[SizeX * SizeY]; map.CollisionLayer = new int[SizeX * SizeY]; for (int i = 0; i < SizeX * SizeY; i++) { map.BaseLayer[i] = map.FringeLayer[i] = map.ObjectLayer[i] = -1; map.CollisionLayer[i] = 0; } map.RandomFightPossibility = 0; Globals.Instance.TileEngine.SetMap(map, -1); img = Texture2Image(map.Texture); pictureBox1.Image = img; pictureBox1.Width = img.Width; pictureBox1.Height = img.Height; g = pictureBox1.CreateGraphics(); vScrollBar1.Maximum = map.Texture.Height / Globals.Instance.TileEngine.Map.TileSize.Y + 5; hScrollBar1.Maximum = Globals.Instance.TileEngine.Map.TilesPerRow; vScrollBar1.Value = 0; hScrollBar1.Value = 0; pictureBox1.Left = 0; pictureBox1.Top = 0; Globals.Instance.SelectedTile = 0; }
protected virtual void Start() { _sr = GetComponent<SpriteRenderer>(); mSelection = selectionHighlighter.GetComponent<SpriteRenderer>(); mSelection.gameObject.SetActive(false); _map = Map.Get(); _im = InputManager.Get(); _started = true; if (_prefab != null) _prefab = prefab(); if (onStart != null) onStart(this); }