Beispiel #1
0
        private void ListFramesContextCopy_Click(object sender, EventArgs e)
        {
            if (mSelectedFrame == -1)
            {
                return;
            }

            mCopiedFrame = mAnimation.Frames[mSelectedFrame].Clone() as TileAnimationFrame;
        }
Beispiel #2
0
        public static Animator CreateDeathStartAnimation()
        {
            Animator animator = new Animator();

            AnimationFrame[] frames = new AnimationFrame[3];
            var tileSheet           = AssetStore.Tiles;

            var map = new Map();

            map.Create("Star1", 2, 2, tileSheet, MapTileDescriptor.HiddenTile);
            map.SetTiles(78, 79, 88, 89);
            frames[0] = new MapAnimationFrame(map, 1);

            map = new Map();
            map.Create("Star2", 2, 2, tileSheet, MapTileDescriptor.HiddenTile);
            map.SetTiles(198, 199, 208, 209);
            frames[1] = new MapAnimationFrame(map, 1);

            frames[2] = new TileAnimationFrame(tileSheet, 207, 1, false, false, 4, 4);

            animator.Initialize(frames);

            return(animator);
        }
Beispiel #3
0
		public TileAnimation(TileAnimationFrame[] frames) {
			Frames = new List<TileAnimationFrame>();
			Frames.AddRange(frames.Clone() as TileAnimationFrame[]);
		}
Beispiel #4
0
		public static TileAnimation LoadFromJson(JToken json, Point2D basePos) {
			var ani = new TileAnimation();

			// RPG Maker XP animations are based on one tileset
			var tilesetSource = new TileCellSource(json["graphic"].ToString(), 0, 0, Constants.AnimationTilesetWidth, Constants.AnimationTilesetHeight);
			var tileset = EngineCore.ContentLoader.GetAnimationTileset(tilesetSource.TextureIndex);
			var tilesPerRow = tileset.Width / tilesetSource.Width;

			var frames = (JArray)json["frames"];
			foreach (var frame in frames) {
				var frameImages = (JArray)frame;
				var tileFrame = new TileAnimationFrame();
				foreach (var frameImage in frameImages) {
					/*
					 * pattern: 1,		// 1-based tile index
					 * x: 0,			// center-based x-offset
					 * y: 16,			// center-based y-offset
					 * zoom: 30,		// 100-based scale
					 * rotation: 0,		// 360-degree
					 * opacity: 100		// 255 = full visible, 0 = full trans
					 */
					// Make index 0-based!
					var patIndex = (int)(frameImage["pattern"]) - 1;
					var patX = (int)(frameImage["x"]);
					var patY = (int)(frameImage["y"]);
					var patZoom = (int)(frameImage["zoom"]);
					var patRotation = (int)(frameImage["rotation"]);
					var patOpacity = (int)(frameImage["opacity"]);

					if (patIndex > 0) {
						tilesetSource.X = (patIndex % tilesPerRow) * tilesetSource.Width;
						tilesetSource.Y = (patIndex / tilesPerRow) * tilesetSource.Width;
					} else {
						tilesetSource.X = 0;
						tilesetSource.Y = 0;
					}
					var scale = patZoom / 100f;
					var pos = new Point2D(patX + basePos.X, patY + basePos.Y);
					var mirror = SpriteEffects.None;
					var col = new Color(Color.White.R, Color.White.G, Color.White.B, patOpacity);
					var isBackground = false; // TODO: How does RPG Maker handle this?
					var rot = (float)patRotation;
					var pattern = new TileAnimationFrameImage(tilesetSource.Clone() as TileCellSource, scale, pos, mirror, col, rot, isBackground);
					tileFrame.Add(pattern);
				}

				ani.Frames.Add(tileFrame);
			}

			return ani;
		}
Beispiel #5
0
		private void ListFramesContextCopy_Click(object sender, EventArgs e) {
			if (mSelectedFrame == -1)
				return;

			mCopiedFrame = mAnimation.Frames[mSelectedFrame].Clone() as TileAnimationFrame;
		}