public void CommandExport(object param) { if (!TilePoolExists(param)) { return; } Guid uid = (Guid)param; TilePool tilePool = Editor.Project.TilePoolManager.Pools[uid]; using (System.Drawing.Bitmap export = tilePool.TileSource.CreateBitmap()) { using (SaveFileDialog ofd = new SaveFileDialog()) { ofd.Title = "Export Raw Tileset"; ofd.Filter = "Portable Network Graphics (*.png)|*.png|Windows Bitmap (*.bmp)|*.bmp|All Files|*"; ofd.OverwritePrompt = true; ofd.RestoreDirectory = false; if (ofd.ShowDialog() == DialogResult.OK) { try { export.Save(ofd.FileName); } catch { MessageBox.Show("Could not save image file.", "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }
/// <summary> /// Display GUI for updating the preview shown in the editor /// </summary> public void PreviewUpdate() { EditorGUILayout.Space(); EditorGUILayout.Separator(); EditorGUILayout.Space(); if (GUILayout.Button("Generate")) { if (_config.Generator.GenerationRadius > 4) { int amt = TilePool.GetTilePositionsFromRadius( _config.Generator.GenerationRadius, new Vector2(0, 0), _config.Generator.Length) .Count; string msg = "You are about to generate " + amt + " Tiles synchronously which " + "may take a while. Are you sure you want to continue?"; if (EditorUtility.DisplayDialog("Warning", msg, "Continue")) { _config.GenerateEditor(); } } else { _config.GenerateEditor(); } } if (GUILayout.Button("Clear Tiles")) { if (_config.Generator != null && _config.Generator.Pool != null) { _config.Generator.Pool.RemoveAll(); } } }
private TileGridLayer ProcessTileLayer(TileGridLayer layer, TilePool layerTilePool, Dictionary <Guid, Guid> tileUidMap) { MultiTileGridLayer outLayer = new MultiTileGridLayer(layer.Name, layer.TileWidth, layer.TileHeight, layer.TilesWide, layer.TilesHigh) { IsVisible = layer.IsVisible, Opacity = layer.Opacity, RasterMode = layer.RasterMode, }; foreach (Property prop in layer.PropertyManager.CustomProperties) { outLayer.PropertyManager.CustomProperties.Add(prop); } foreach (LocatedTile tile in layer.Tiles) { Guid tileUid; if (!tileUidMap.TryGetValue(tile.Tile.Uid, out tileUid)) { Tile mappedTile = layerTilePool.Tiles.Add(tile.Tile.Pool.Tiles.GetTileTexture(tile.Tile.Uid)); tileUidMap[tile.Tile.Uid] = mappedTile.Uid; tileUid = mappedTile.Uid; foreach (Property prop in tile.Tile.PropertyManager.CustomProperties) { mappedTile.PropertyManager.CustomProperties.Add(prop); } } outLayer.AddTile(tile.X, tile.Y, layerTilePool.Tiles[tileUid]); } return(outLayer); }
// Use this for initialization void Awake() { if (instance == null) { instance = this; tilePool = GameObject.FindGameObjectWithTag("EventSystem").GetComponent <TilePool>(); GenerationMap = this.gameObject.AddComponent <GameMap>(); GenerationMap.AttachMapGameObject(); forestGenerator = this.gameObject.GetComponent <ForestGenerator>(); GenerationMap.AttachForestGenerator(forestGenerator); GenerationMap.AttachTiles(); CreatePaths.AttachMap(GenerationMap); CreatePaths.AttachTiles(GetCurrentBiomeTileSet().Road, GetCurrentBiomeTileSet().Shallows, GetCurrentBiomeTileSet().Water); displaySelected = canvas.GetComponent <DisplaySelected>(); } else { instance.tilePool = this.gameObject.GetComponent <TilePool>(); instance.canvas = GameObject.FindGameObjectWithTag("Canvas").GetComponent <Canvas>(); Destroy(this); } gamePlayCam = cam1.GetComponent <Camera>(); gamePlayCam.enabled = true; topDownCam = cam2.GetComponent <Camera>(); topDownCam.enabled = false; testingPhaseCanvas.enabled = false; }
protected override void Write(ContentWriter output, TileRegistryContent value) { output.Write(value.Version); Guid id = value.Id; TilePool pool = value.TilePool; output.Write((short)id); output.Write((short)pool.TileWidth); output.Write((short)pool.TileHeight); output.Write(value.TextureAsset); WritePropertyBlock(output, pool.CustomProperties); output.Write((short)pool.Count); foreach (Tile tile in pool) { TileCoord coord = pool.GetTileLocation(tile.Uid); output.Write((short)tile.Uid); output.Write((short)coord.X); output.Write((short)coord.Y); WritePropertyBlock(output, tile.CustomProperties); } }
private void _buttonOK_Click(object sender, EventArgs e) { Pool = LoadFile(); DialogResult = DialogResult.OK; Close(); }
/// <summary> /// Add source of masks for drawing. /// </summary> public void AddSource(ICubismMaskTextureCommandSource source) { // Make sure isstance is valid. TryRevive(); // Initialize container if necessary. if (Sources == null) { Sources = new List <SourcesItem>(); } // Return early if source already exists. else if (Sources.FindIndex(i => i.Source == source) != -1) { return; } // Register source. var item = new SourcesItem { Source = source, Tiles = TilePool.AcquireTiles(source.GetNecessaryTileCount()) }; Sources.Add(item); // Apply tiles to source. source.SetTiles(item.Tiles); }
public void CommandRename(object param) { if (!TilePoolExists(param)) { return; } Guid uid = (Guid)param; TilePool tilePool = Editor.Project.TilePoolManager.Pools[uid]; using (NameChangeForm form = new NameChangeForm(tilePool.Name)) { foreach (TilePool pool in Editor.Project.TilePoolManager.Pools) { if (pool.Name != tilePool.Name) { form.ReservedNames.Add(pool.Name); } } if (form.ShowDialog() == DialogResult.OK) { tilePool.TrySetName(form.Name); } } }
private TilePool LoadFile() { if (_fileStream == null) { return(null); } if (_fileStream.Position != 0) { _fileStream.Position = 0; } _localManager.Reset(); TextureResource resource = TextureResourceBitmapExt.CreateTextureResource(_fileStream); TilePool.TileImportOptions options = new TilePool.TileImportOptions() { TileHeight = (int)_numTileHeight.Value, TileWidth = (int)_numTileWidth.Value, SpaceX = (int)_numXSpacing.Value, SpaceY = (int)_numYSpacing.Value, MarginX = (int)_numXMargin.Value, MarginY = (int)_numYMargin.Value, ImportPolicty = TileImportPolicy.SetUnique, }; _previewPool = _localManager.ImportPool(_textName.Text, resource, options); _originalResource = _previewPool.TileSource.Crop(_previewPool.TileSource.Bounds); if (_useTransColor) { SetTransparentColor(); } // Update preview window if (_previewLayer != null) { _previewLayer.Dispose(); } Model.TileSetLayer layer = new Model.TileSetLayer(_previewPool.Name, _previewPool); _previewLayer = new TileSetLayerPresenter(layer) { LevelGeometry = _layerControl.LevelGeometry, }; _rootLayer.Layers.Clear(); _rootLayer.Layers.Add(_previewLayer); // Update stats _countTilesHigh.Text = ((_height + (int)_numYSpacing.Value) / ((int)_numTileHeight.Value + (int)_numYSpacing.Value + (int)_numYMargin.Value)).ToString(); _countTilesWide.Text = ((_width + (int)_numXSpacing.Value) / ((int)_numTileWidth.Value + (int)_numXSpacing.Value + (int)_numXMargin.Value)).ToString(); _countUniqueTiles.Text = _previewPool.Count.ToString(); return(_previewPool); }
private void CreateInstance() { if (instance != null) { print("multiple instances de TilePool"); } instance = this; }
/** Initialize */ public void Init() { maxSpeed = LevelData.instance.roadSpeed; this.speed = 0f; this.tiles = new List <GameObject>(); this.tilePool = new TilePool(this.tileTypes, MAX_TILES, this.transform); InitTiles(); }
private void AddPoolPresenter(TilePool pool) { TilePoolPresenter presenter = new TilePoolPresenter(pool); presenter.SelectedTileChanged += SelectedTileChanged; _tilePoolPresenters[pool.Uid] = presenter; }
public TileSetLayer(string name, TileSetLayer layer) : base(name, layer) { _pool = layer._pool; _pool.TileAdded += TileAdded; _pool.TileRemoved += TileRemoved; SyncIndex(); }
public TileSetLayer(string name, TilePool pool) : base(name, pool.TileWidth, pool.TileHeight) { _pool = pool; _pool.TileAdded += TileAdded; _pool.TileRemoved += TileRemoved; SyncIndex(); }
// Start is called before the first frame update void Start() { tilePool = GetComponent <TilePool>(); creaturePool = GetComponent <CreaturePool>(); treasureChests = new List <TreasureChest>(); InitializeMap(); }
public ProjectInfrastructure(MonoBehaviourContainer monoBehaviourContainer) { _monoBehaviourContainer = monoBehaviourContainer; _tilePool = new TilePool(monoBehaviourContainer.TileFactory); _roadBuilder = new RoadBuilder(_tilePool); _ballController = new BallController(monoBehaviourContainer.BallView); _tileController = new TileController(_roadBuilder); _UIController = new UIController(monoBehaviourContainer.UIView); _gameplayController = new GameplayController(_ballController, _UIController); }
public override TileRegistryContent Import(string filename, ContentImporterContext context) { //Form form = new Form(); //PresentationParameters presentation = new PresentationParameters(); //presentation.DeviceWindowHandle = form.Handle; //GraphicsAdapter.UseReferenceDevice = true; //GraphicsAdapter.UseNullDevice = true; //GraphicsDevice device = new GraphicsDevice( // GraphicsAdapter.DefaultAdapter, // GraphicsProfile.Reach, // presentation // ); Project project = new Project(); // project.Initialize(device); using (FileStream fs = File.OpenRead(filename)) { XmlReaderSettings settings = new XmlReaderSettings() { CloseInput = true, IgnoreComments = true, IgnoreWhitespace = true, }; using (XmlReader reader = XmlTextReader.Create(fs, settings)) { XmlSerializer serializer = new XmlSerializer(typeof(LibraryX.TilePoolX)); LibraryX.TilePoolX proxy = serializer.Deserialize(reader) as LibraryX.TilePoolX; TilePool.FromXProxy(proxy, (TilePoolManager)project.TilePoolManager); } /*XmlReader reader = XmlTextReader.Create(fs); * * XmlHelper.SwitchAll(reader, (xmlr, s) => * { * switch (s) { * case "tilesets": * * project.ReadXmlTilesets(reader); * break; * } * });*/ } TileRegistryContent content = new TileRegistryContent(project); content.Filename = filename; content.Directory = filename.Remove(filename.LastIndexOf('\\')); return(content); }
public GenerationData() { if (Pool == null) { Pool = new TilePool(); } if (Lod == null) { Lod = new LodData(); } }
public TilePoolPresenter(TilePool tilePool) { _tilePool = tilePool; _tilePool.TileRemoved += TilePoolTileRemoved; _tileSet = new TileSetLayer(tilePool.Name, tilePool); _annotations = new ObservableCollection <Annotation>(); InitializeLayerHierarchy(); }
public void TestSetup() { _eventsFired = EventFlags.None; _registry = new TileRegistry(_service.GraphicsDevice); _pool = new TilePool("pool", _registry, 16, 16); Texture2D tex1 = new Texture2D(_service.GraphicsDevice, 16, 16); Texture2D tex2 = new Texture2D(_service.GraphicsDevice, 16, 16); _tile1 = _pool.GetTile(_pool.AddTile(tex1)); _tile2 = _pool.GetTile(_pool.AddTile(tex2)); }
public MainGameWindow(GameType type) { this.game_type = type; this.player_tracker = new GameKeeper(); this.cpu_tracker = new GameKeeper(); this.AI = new AIEngine(); this.stats = new GameStatistics(); this.game_logic = new WordBuffer(); this.tile_sack = new TilePool(); InitializeComponent(); initStartUp(); }
protected virtual void Dispose(bool disposing) { if (_pool != null) { if (disposing) { _pool.TileAdded -= TileAdded; _pool.TileRemoved -= TileRemoved; } _pool = null; } }
public void TestImport() { using (FileStream fs = File.OpenRead("TestContent/purple_caves.png")) { TilePool pool = TilePool.Import("Test", _registry, fs, 16, 16); Assert.AreEqual(64, pool.Count); Assert.AreEqual(64, pool.Capacity); Assert.AreEqual("Test", pool.Name); Assert.AreEqual(16, pool.TileWidth); Assert.AreEqual(16, pool.TileHeight); } }
protected virtual void Dispose(bool disposing) { if (_tilePool != null) { if (disposing) { _tileSet.Dispose(); } _tilePool.TileRemoved -= TilePoolTileRemoved; _tilePool = null; } }
public void CommandProperties(object param) { if (!TilePoolExists(param)) { return; } Guid uid = (Guid)param; TilePool pool = Editor.Project.TilePoolManager.Pools[uid]; Editor.Presentation.PropertyList.Provider = pool; Editor.ActivatePropertyPanel(); }
public Main( IOpts opts, TilePool pool, ICamera camera, RandomAccessArray <Vector3> directions) { this.opts = opts; this.pool = pool; this.camera = camera; this.directions = directions; this.startDirection = opts.Directions[0]; this.block = new List <ITile>(this.opts.LootBlock); }
public void TestExport() { using (FileStream fs = File.OpenRead("TestContent/purple_caves.png")) { TilePool pool = TilePool.Import("Test", _registry, fs, 16, 16); pool.Export("TestOutput/purple_caves1.png"); } using (FileStream fs = File.OpenRead("TestOutput/purple_caves1.png")) { TilePool pool = TilePool.Import("Test", _registry, fs, 16, 16); Assert.AreEqual(64, pool.Count); Assert.AreEqual(64, pool.Capacity); } }
/// <summary> /// SpawnTiles() tells new tiles to place themselves relative to the previous tile /// </summary> void SpawnTiles() { Tile tile; // Spawn a new tile if the player is sufficiently far if (player.position.z + safeDistance > lastSpawnedTile.transform.position.z + lastSpawnedTile.Length) { Tile choosePrefab = lastSpawnedTile.ConnectsTo[Random.Range(0, lastSpawnedTile.ConnectsTo.Length)]; Tile t = TilePool.GetFromPool(choosePrefab.gameObject); t.SetPositionAfter(lastSpawnedTile); lastSpawnedTile = t; } }
public new void OnEnable() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } if (_spawnTileTypes.Length != _spawnObjs.Length) { Debug.LogWarning("Your TilePool requires arrays SpawnTileTypes and SpawnObjects to be the same length. Different lengths can cause errors!"); } }
public void TestSetup() { _eventsFired = EventFlags.None; _registry = new TileRegistry(_service.GraphicsDevice); _pool = new TilePool("pool", _registry, 16, 16); _pool.Modified += (s, e) => { _eventsFired |= EventFlags.Modified; }; _pool.NameChanged += (s, e) => { _eventsFired |= EventFlags.NameChanged; }; _pool.TileAdded += (s, e) => { _eventsFired |= EventFlags.TileAdded; }; _pool.TileRemoved += (s, e) => { _eventsFired |= EventFlags.TileRemoved; }; _pool.TileModified += (s, e) => { _eventsFired |= EventFlags.TileModified; }; _pool.CustomProperties.PropertyAdded += (s, e) => { _eventsFired |= EventFlags.PropertyAdded; }; _pool.CustomProperties.PropertyRemoved += (s, e) => { _eventsFired |= EventFlags.PropertyRemoved; }; _pool.CustomProperties.PropertyModified += (s, e) => { _eventsFired |= EventFlags.PropertyModified; }; _pool.CustomProperties.PropertyRenamed += (s, e) => { _eventsFired |= EventFlags.PropertyRenamed; }; }
public void CommandImportMerge(object param) { if (!TilePoolExists(param)) { return; } Guid uid = (Guid)param; TilePool tilePool = Editor.Project.TilePoolManager.Pools[uid]; using (ImportTilePool form = new ImportTilePool(tilePool.Name, tilePool.TileWidth, tilePool.TileHeight)) { if (form.ShowDialog() == DialogResult.OK && form.Pool != null) { tilePool.Merge(form.Pool, TileImportPolicy.SetUnique); } } }
private void displayTilePool(TilePool pool) { Dictionary<String, int> tiles = new Dictionary<String, int>(); foreach (Letter l in pool.letters) { if (!(tiles.ContainsKey(l.letter_alpha))) tiles.Add(l.letter_alpha, l.distribution_count); else if (tiles.ContainsKey(l.letter_alpha)) { // // } } foreach (KeyValuePair<String, int> kvp in tiles) { this.ListBox.Items.Add(kvp.Key + " - " + kvp.Value); } }
private static Tile[] CreateTiles(Random rng) { Tile[] tiles = new Tile[19]; TilePool tilePool = new TilePool(); TokenPool tokenPool = new TokenPool(); for (int i = 0; i < 19; ++i) { Tile tile = tilePool.GetRandomTile(rng); if (tile.terrain != TerrainType.Desert) { tile.token = tokenPool.GetRandomToken(rng); } else { tile.token = 0; } tiles[i] = tile; } return tiles; }
public TilePoolPresenter(TilePool tilePool) { _tilePool = tilePool; _tileSet = new TileSetLayer(tilePool.Name, tilePool); _annotations = new ObservableCollection<Annotation>(); InitializeLayerHierarchy(); }
private TilePool LoadFile(ITilePoolManager manager) { if (_fileStream == null) { return null; } if (_fileStream.Position != 0) { _fileStream.Position = 0; } _localManager.Reset(); TextureResource resource = TextureResourceBitmapExt.CreateTextureResource(_fileStream); TilePool.TileImportOptions options = new TilePool.TileImportOptions() { TileHeight = (int)_numTileHeight.Value, TileWidth = (int)_numTileWidth.Value, SpaceX = (int)_numXSpacing.Value, SpaceY = (int)_numYSpacing.Value, MarginX = (int)_numXMargin.Value, MarginY = (int)_numYMargin.Value, ImportPolicty = TileImportPolicy.SetUnique, }; _previewPool = _localManager.ImportPool(_textName.Text, resource, options); _originalResource = _previewPool.TileSource.Crop(_previewPool.TileSource.Bounds); if (_useTransColor) SetTransparentColor(); // Update preview window if (_previewLayer != null) _previewLayer.Dispose(); Model.TileSetLayer layer = new Model.TileSetLayer(_previewPool.Name, _previewPool); _previewLayer = new TileSetLayerPresenter(layer) { LevelGeometry = _layerControl.LevelGeometry, }; _rootLayer.Layers.Clear(); _rootLayer.Layers.Add(_previewLayer); // Update stats _countTilesHigh.Text = ((_height + (int)_numYSpacing.Value) / ((int)_numTileHeight.Value + (int)_numYSpacing.Value + (int)_numYMargin.Value)).ToString(); _countTilesWide.Text = ((_width + (int)_numXSpacing.Value) / ((int)_numTileWidth.Value + (int)_numXSpacing.Value + (int)_numXMargin.Value)).ToString(); _countUniqueTiles.Text = _previewPool.Count.ToString(); return _previewPool; }
/** /* @name: generateTilePool /* @version: 1.0 /* @Descrition: Cria uma fila de tiles que será usado para criar areas de ação. */ private void generateTilePool(int tileSize) { // Cria uma fila de tiles para ser usada pela criação de areas; this.tilePool = new TilePool(tileSize); Vector3 tilePosition; int columNumber = 0; int rowNumber = 0; //Popula a fila com Tiles para que estes sejam usados no jogo. for (int i = 0; i < tileSize; i++) { rowNumber = i % 20; if (rowNumber == 0) { columNumber ++; } tilePosition = wargridCoordDOWN(new ponto2D(rowNumber, columNumber)); tilePosition.y = -500; GroundOverlayReactor tile = ((GameObject)Instantiate(groundOverlayTile, // O que instanciar. tilePosition, // Posição de instanciamento. Quaternion.Euler(new Vector3())) // Rotação inicial. ).GetComponent<GroundOverlayReactor>(); // acessa o script de controle do objeto e armarzena este na variavel; tile.poolPosition = new ponto2D(rowNumber, columNumber); this.tilePool.deposit(tile); } }
public void TestSetup() { _eventsFired = EventFlags.None; _registry = new TileRegistry(_service.GraphicsDevice); _pool = new TilePool("pool", _registry, 16, 16); }
public SyncTilePoolEventArgs(TilePool tilePool) { PreviousTilePool = tilePool; }
protected virtual void Dispose(bool disposing) { if (_tilePool != null) { if (disposing) { _tileSet.Dispose(); } _tilePool = null; } }
public TilePoolEventArgs(TilePool pool) { TilePool = pool; }
public TilePoolViewForm(TilePool pool) { InitializeComponent(); displayTilePool(pool); }