private TileAnimation GetTileAnimation(string Filename) { try { TileAnimation ani = null; if (Path.GetExtension(Filename) != ".bani") { Filename += ".bani"; } ani = (TileAnimation)Load(Filename, delegate(AssetTracker Tracker) { TileAnimation tmpAni = null; byte[] buf = (byte[])Tracker.Asset; using (MemoryStream ms = new MemoryStream(buf)) TileAnimation.Load(ms, out tmpAni); buf = null; return(tmpAni); } ); return(ani); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(null); } }
private void menuEditorImportRpgMaker_Click(object sender, EventArgs e) { using (var frm = new FormImportRpgMaker()) { if (frm.ShowDialog(this) != DialogResult.OK) { return; } var selectedAnim = frm.SelectedAnimation; var newTileAnimation = TileAnimation.LoadFromJson(selectedAnim); mAnimation = newTileAnimation.Clone() as TileAnimation; // FIX: RPG Maker XP effects are based on a larger character /* * foreach (var frame in mAnimation.Frames) { * foreach (var image in frame) { * if (image.Scale > 0.1f) { * image.Scale = image.Scale * 0.5f; * } * } * } */ ReloadAnimation(); } }
public bool HasTileAnimation(TileAnimationKind kind, Point position, bool looping) { TileAnimation animation = new TileAnimation(); animation.Kind = kind; animation.Looping = looping; animation.Position = position; return this.TileAnimations.ContainsKey(animation.GetHashCode()); }
public void RemoveTileAnimation(TileAnimationKind kind, Point position, bool looping) { TileAnimation animation = new TileAnimation(); animation.Kind = kind; animation.Looping = looping; animation.Position = position; this.TileAnimations.Remove(animation.GetHashCode()); }
public static TileAnimation CreateAnimation(int givenX, int givenY, Terrain givenTerrain, Guid givenDomain) { TileAnimation outPut = CreateAnimation(); outPut.SetTransform(new Vector2(givenX, givenY)); outPut.SetTerrain(givenTerrain); return(outPut); }
public void SetCell(int x, int y, TileAnimation Ani) { if (IsValidPoint(x, y) == false) { return; } mLayoutMap[x][y] = Ani.Clone() as TileAnimation; }
public override CompiledTileAnimationData Process(TileAnimationImporterData input, ContentProcessorContext context) { TileAnimation ani; TileLoadResult result; using (MemoryStream ms = new MemoryStream(input.Data)) result = TileAnimation.Load(ms, out ani); return(new CompiledTileAnimationData(ani, result)); }
public TileAnimationLayer(int width, int height) { mLayoutMap = new TileAnimation[width][]; for (int x = 0; x < width; x++) { mLayoutMap[x] = new TileAnimation[height]; for (int y = 0; y < height; y++) { mLayoutMap[x][y] = null; } } }
private void OpenAnimation(string fileName) { mSelectedAnimation = -1; mSelectedFrame = -1; SelectImagePreview(-1); if (TileAnimation.Load(fileName, out mAnimation) != TileLoadResult.Success) { mAnimation = new TileAnimation(); // avoid "null" crashes } ReloadAnimation(); }
public static TileAnimation CreateAnimation() { GameObject m_gameObject = new GameObject(); m_gameObject.transform.localScale = new Vector3(2, 2, 1); m_gameObject.layer = LayerMask.NameToLayer("Tile"); TileAnimation outPutTile = m_gameObject.AddComponent <TileAnimation>(); BoxCollider2D m_collider = m_gameObject.AddComponent <BoxCollider2D>(); m_collider.size = new Vector2(1 / m_gameObject.transform.localScale.x, 1 / m_gameObject.transform.localScale.y); m_collider.offset = new Vector2(0.5f / m_collider.transform.localScale.x, 0.5f / m_collider.transform.localScale.y); outPutTile.Initialise(); return(outPutTile); }
private void MenuEditorNew_Click(object sender, EventArgs e) { mSelectedAnimation = -1; mSelectedFrame = -1; SelectImagePreview(-1); mAnimation = new TileAnimation(); listFrameImages.Items.Clear(); listFrames.Items.Clear(); listFrames.Items.Add("Frame " + 1); cmbTilesets.SelectedIndex = 0; comboFrameCount.SelectedIndex = 0; listFrames.SelectedItem = 0; numFrameTime.Value = (int)(mAnimation.FrameLength * 1000f); }
public TileAnimation AddTileAnimation(TileAnimationKind kind, Point position, bool looping) { TileAnimation animation = new TileAnimation(); animation.Kind = kind; animation.Looping = looping; animation.Position = position; int hashCode = animation.GetHashCode(); if (!this.TileAnimations.ContainsKey(hashCode)) { animation.LinkedAnimation = this.Scenario.GameCommonData.AllTileAnimations.GetAnimation((int) kind); animation.Drawing = true; animation.currentFrameIndex = 0; animation.currentStayIndex = 0; this.TileAnimations.Add(hashCode, animation); return animation; } return null; }
public TileAnimationLayer(TileAnimation[][] existingMap, int newW, int newH) { mLayoutMap = new TileAnimation[newW][]; for (int x = 0; x < newW; x++) { mLayoutMap[x] = new TileAnimation[newH]; for (int y = 0; y < newH; y++) { if (existingMap == null || x >= existingMap.Length || y >= existingMap[x].Length) { mLayoutMap[x][y] = null; } else { mLayoutMap[x][y] = existingMap[x][y]; } } } }
void AddTile(Tile tile) { //Change Color to SelectedColor tile.SetMaterialColor(HighlightCol); //Off Tile Animation TileAnimation tileAnim = tile.GetComponent <TileAnimation>(); if (tileAnim != null) { tileAnim.EnableFloating = false; } if (audioManager) { audioManager.PlaySFX("Tile_Select"); } Tiles.Add(tile); OnAddTile.Invoke(); }
public void Tick() { TileAnimation anim = _anim; int c = (_counter + 1) % anim.Duration; _counter = c; for (int f = 0; f < anim.Frames.Length; f++) { TileAnimation.Frame frame = anim.Frames[f]; Tileset.Tile tile = _tileset.Tiles[frame.TilesetTile]; for (int s = frame.Stops.Length - 1; s >= 0; s--) { TileAnimation.Frame.Stop stop = frame.Stops[s]; if (stop.Time <= c) { tile.AnimBitmap = anim.Sheet[stop.SheetTile]; goto bottom; } } tile.AnimBitmap = null; bottom: ; } }
private IEnumerator CheckDeleteTweenEnded(TileAnimation tileAnim,List<GameObject> tileGOs) { while(!tileAnim.HasFinishedDeleteTween()){ // Debug.Log("wait for finish delete" + tileGOs.Count); yield return null; } //オブジェクトプーリングする場合は下記の処理消してからね foreach(var tileGO in tileGOs){ tileGOList.Remove (tileGO); // pooledTileGOList.Add (tileGO); // Debug.Log("ついか"); GameObject.Destroy (tileGO); } tileGOs.Clear (); boardManager.FindEmptyTileAndSlide(); PlayDropTween(); }
public static Map loadTmx(IModHelper modHelper, string mapName, string path) { var tmap = new TiledMap(Path.Combine(modHelper.DirectoryPath, path)); var xmap = new Map(mapName); addTiledPropertiesToXTile(tmap.Properties, xmap.Properties); var tileMapping = new Dictionary <int, TileMapping>(); var animMapping = new Dictionary <int, TileAnimation>(); foreach (var ttileSheet in tmap.Tilesets) { // xTile wants things like "Mines/mine", not "Mines/mine.png" string image = ttileSheet.Image.Source; if (image.EndsWith(".png")) { string dir = Path.GetDirectoryName(path); string tempKey = Path.Combine(dir, image); string actualKey = modHelper.Content.GetActualAssetKey(tempKey); Log.debug($"{dir} | {image} | {tempKey} | {actualKey} "); image = Path.Combine(Path.GetDirectoryName(path), image); //modHelper.Content.Load<Texture2D>(image); image = modHelper.Content.GetActualAssetKey(image); } var xtileSheet = new TileSheet(xmap, image, new Size(ttileSheet.Columns, ttileSheet.TileCount / ttileSheet.Columns), new Size(tmap.TileWidth, tmap.TileHeight)); addTiledPropertiesToXTile(ttileSheet.Properties, xtileSheet.Properties); xtileSheet.Id = ttileSheet.Name; xtileSheet.Spacing = new Size(ttileSheet.Spacing, ttileSheet.Spacing); xtileSheet.Margin = new Size(ttileSheet.Margin, ttileSheet.Margin); for (int i = 0; i < ttileSheet.TileCount; ++i) { tileMapping.Add(ttileSheet.FirstGlobalId + i, new TileMapping(xtileSheet, i)); } foreach (var ttile in ttileSheet.Tiles) { addTiledPropertiesToXTile(ttile.Properties, xtileSheet.TileIndexProperties[ttile.Id]); if (ttile.Animation != null && ttile.Animation.Count > 0) { List <int> tanimFrames = new List <int>(); foreach (var ttileAnim in ttile.Animation) { tanimFrames.Add(ttileSheet.FirstGlobalId + ttileAnim.TileId); } animMapping.Add(ttileSheet.FirstGlobalId + ttile.Id, new TileAnimation(tanimFrames.ToArray <int>(), ttile.Animation[0].Duration)); } } xmap.AddTileSheet(xtileSheet); } var tobjectGroups = new List <TiledObjectGroup>(); foreach (var tlayer_ in tmap.Layers) { if (tlayer_ is TiledTileLayer) { var tlayer = tlayer_ as TiledTileLayer; // Note that the tile size needs to be * 4. Otherwise, you will break collisions and many other things. // Yes, even if you don't use the loaded map. Creating the layer is enough. // For some reason vanilla has a tilesize of 16 for tilesheets, but 64 for the layers. // I mean, I knew the game was scaled up, but that's kinda odd. // Anyways, whenever you create a layer with a different tile size, it changes the tile size // of EVERY OTHER LAYER IN EXISTANCE to match. And guess what, that breaks things. // I spent hours figuring this out. I don't care about the underlying cause. I just want to mod. var xlayer = new Layer(tlayer.Name, xmap, new Size(tmap.Width, tmap.Height), new Size(tmap.TileWidth * 4, tmap.TileHeight * 4)); addTiledPropertiesToXTile(tlayer.Properties, xlayer.Properties); if (tlayer.Data.Compression != TiledData.CompressionType.NoCompression) { throw new InvalidDataException("Compressed tile data is not supported."); } if (tlayer.Data.Encoding == TiledData.EncodingType.NoEncoding || tlayer.Data.Encoding == TiledData.EncodingType.Xml) { for (int i = 0; i < tlayer.Data.Tiles.Count; ++i) { var ttile = tlayer.Data.Tiles[i]; int ix = i % tmap.Width; int iy = i / tmap.Width; var xtile = new StaticTile(xlayer, tileMapping[ttile.GlobalId].tileSheet, BlendMode.Alpha, tileMapping[ttile.GlobalId].tileId); xlayer.Tiles[ix, iy] = xtile; } } else if (tlayer.Data.Encoding == TiledData.EncodingType.Csv) { string[] ttiles = string.Join("", tlayer.Data.Data).Split(','); for (int i = 0; i < ttiles.Length; ++i) { var ttile = int.Parse(ttiles[i]); if (!tileMapping.ContainsKey(ttile)) { continue; } int ix = i % tmap.Width; int iy = i / tmap.Width; Tile xtile = null; if (animMapping.ContainsKey(ttile)) { TileAnimation tanim = animMapping[ttile]; var xanimTiles = new StaticTile[tanim.tileIds.Length]; for (int ia = 0; ia < xanimTiles.Length; ++ia) { xanimTiles[ia] = new StaticTile(xlayer, tileMapping[tanim.tileIds[ia]].tileSheet, BlendMode.Alpha, tileMapping[tanim.tileIds[ia]].tileId); } xtile = new AnimatedTile(xlayer, xanimTiles, tanim.duration); } else { xtile = new StaticTile(xlayer, tileMapping[ttile].tileSheet, BlendMode.Alpha, tileMapping[ttile].tileId); } xlayer.Tiles[ix, iy] = xtile; } } else { throw new InvalidDataException("Tile data encoding type " + tlayer.Data.Encoding + " not supported."); } xmap.AddLayer(xlayer); } else if (tlayer_ is TiledObjectGroup) { tobjectGroups.Add(tlayer_ as TiledObjectGroup); } } foreach (var tobjectGroup in tobjectGroups) { var xlayer = xmap.GetLayer(tobjectGroup.Name); if (xlayer == null) { continue; } foreach (var tobj in tobjectGroup.Objects) { if (tobj.Name != "TileData" || tobj.Width != tmap.TileWidth || tobj.Height != tmap.TileWidth || tobj.Properties.Count == 0) { continue; } int x = (int)tobj.X / tmap.TileWidth; int y = (int)tobj.Y / tmap.TileWidth; if (xlayer.Tiles[new Location(x, y)] == null) { Log.warn("Tile property for non-existant tile; skipping"); continue; } addTiledPropertiesToXTile(tobj.Properties, xlayer.Tiles[new Location(x, y)].Properties); } } return(xmap); }
private IEnumerator CheckGenerateTweenEnded(TileAnimation tileAnim) { while(!tileAnim.HasFinishedDropTween()){ yield return null; } PlayerState.ViewState = ViewState.NONE; gameParam.SetMission(); missionLabel.text = gameParam.Mission_.CurrentTarget; boardManager.ResetTilesInfo (); }
public static AnimatedTilesCollection Create(List<Point<int>> tilesToUpdate, TileAnimation frames = null) { return new AnimatedTilesCollection(tilesToUpdate, frames); }
private AnimatedTilesCollection(List<Point<int>> tilesToUpdate, TileAnimation frames = null) { this.Tiles = tilesToUpdate; this.Frames = frames; }
public static TileMapInfo fromStream(Level level, Stream stream, TileSet ts) { BinaryReader reader = new BinaryReader(stream); int w = reader.ReadInt32(), h = reader.ReadInt32(); List <Event.EventTile> eventTiles = new List <Event.EventTile>(); TileMap map = new TileMap(w, h, ts); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { int data = reader.ReadInt32(); if ((data & 1 << 31) == 1 << 31) { TileData buffer = new TileData(data); bool flipped = false; data = data ^ 1 << 31; // additional data byte flags = reader.ReadByte(); if ((flags & 1 << 0) == 1 << 0) { flipped = true; buffer = new ExtendedTileData(data, flipped); } if ((flags & 1 << 6) == 1 << 6) { Event.TEvent[] events = null; if ((flags & 1 << 7) == 1 << 7) { int count = reader.ReadInt32(); events = new Event.TEvent[count]; for (int i = 0; i < count; i++) { events[i] = level.TileManager.createEvent(reader.ReadInt32(), level.World, x, y); events[i].getSBCompound().readCompound(reader); } } int idscount = reader.ReadInt32(); List <int> ids = new List <int>(); for (int i = 0; i < idscount; i++) { ids.Add(reader.ReadInt32()); } int interval = reader.ReadInt32(); bool pingpong = reader.ReadBoolean(); TileAnimation anim = new TileAnimation(ids.ToArray(), interval, pingpong, flipped, x, y, events); buffer = anim; eventTiles.Add(anim); } else if ((flags & 1 << 7) == 1 << 7) { int count = reader.ReadInt32(); Event.TEvent[] events = new Event.TEvent[count]; for (int i = 0; i < count; i++) { events[i] = level.TileManager.createEvent(reader.ReadInt32(), level.World, x, y); events[i].getSBCompound().readCompound(reader); } Event.EventTile evT = new Event.EventTile(data, flipped, x, y, events /*events...*/); buffer = evT; eventTiles.Add(evT); } map.setTile(x, y, buffer); } else { map.setTile(x, y, new TileData(data)); } } } if (h == 0 || w == 0) { map = new TileMap(1, 1, ts); } TileMapInfo info = new TileMapInfo(map) { XScrollSpeed = reader.ReadSingle(), YScrollSpeed = reader.ReadSingle(), AutoXSpeed = reader.ReadSingle(), AutoYSpeed = reader.ReadSingle(), WidthWrap = reader.ReadBoolean(), HeightWrap = reader.ReadBoolean(), EventTiles = eventTiles.ToArray() }; return(info); }
public void SetCell(Point point, TileAnimation Ani) { SetCell(point.X, point.Y, Ani); }
public void LoadTile() { m_animation = TileAnimation.CreateAnimation(x, y, terrain, domain); m_animation.gameObject.layer = LayerMask.NameToLayer("Tile"); m_animation.gameObject.name = ToString(); }
public TileAnimationLive(Tileset tileset, TileAnimation anim) { _tileset = tileset; _anim = anim; }
public void LoadMapConfig(string strXmlFile) { XmlDocument mapXml = new XmlDocument(); mapXml.Load(strXmlFile); //read tile set XmlNodeList nodeList = mapXml.GetElementsByTagName("TileSet"); foreach (XmlNode node in nodeList) { TileSet tileSet = new TileSet(); tileSet.m_strFileName = node.Attributes["FileName"].Value; tileSet.m_t2dTexture = m_resourceManager.LoadTexture(@"Resource/Background/" + tileSet.m_strFileName); tileSet.m_iTileWidth = int.Parse(node.Attributes["TileWidth"].Value); tileSet.m_iTileHeight = int.Parse(node.Attributes["TileHeight"].Value); tileSet.m_iVerticalSpacing = int.Parse(node.Attributes["VerticalSpacing"].Value); tileSet.m_iHorizontalSpacing = int.Parse(node.Attributes["HorizontalSpacing"].Value); tileSet.m_iTilesPerRow = tileSet.m_t2dTexture.Width / (tileSet.m_iTileWidth + tileSet.m_iHorizontalSpacing); m_iTileHeightMap = tileSet.m_iTileHeight; m_iTileWidthMap = tileSet.m_iTileWidth; m_iTileCanWalk = int.Parse(node.Attributes["TileCanWalk"].Value); m_TileSets.Add(tileSet); m_iTileBaseStart = int.Parse(node.Attributes["TileBaseStart"].Value); m_iTileBaseEnd = int.Parse(node.Attributes["TileBaseEnd"].Value); m_iTileBaseCurrIndex = m_iTileBaseStart; m_iTileTransStart = int.Parse(node.Attributes["TileTransStart"].Value); m_iTileTransEnd = int.Parse(node.Attributes["TileTransEnd"].Value); m_iTileTransCurrIndex = m_iTileTransStart; m_iTileObjStart = int.Parse(node.Attributes["TileObjStart"].Value); m_iTileObjEnd = int.Parse(node.Attributes["TileObjEnd"].Value); m_iTileObjCurrIndex = m_iTileObjStart; } nodeList = mapXml.GetElementsByTagName("TileAnimation"); foreach (XmlNode node in nodeList) { TileAnimation ta = new TileAnimation(); ta.m_iCurrentFrame = 0; ta.m_iStartFrame = int.Parse(node.Attributes["StartFrame"].Value); ta.m_iFrameCount = int.Parse(node.Attributes["FrameCount"].Value); ta.m_iFrameRate = int.Parse(node.Attributes["FrameRate"].Value); m_taAnimations.Add(ta); } //read total maps nodeList = mapXml.GetElementsByTagName("Data"); m_iTotalMaps = nodeList.Count; }
private IEnumerator CheckDropTweenEnded(TileAnimation tileAnim) { while(tileAnim != null && !tileAnim.HasFinishedDropTween()){ yield return null; } boardManager.FindNewGenerateTile (); PlayNewGenerateTween (); }
public CompiledTileAnimationData(TileAnimation bani, TileLoadResult res) { CompiledData = bani; Result = res; }