private void ReadState(string name, Queue <string> lines) { var dirs = int.Parse(GetValue(lines.Dequeue())); var frames = int.Parse(GetValue(lines.Dequeue())); var delay = new List <float>(); var rewind = 0; var movement = 0; if (lines.Peek().Contains("delay")) { delay = GetIntList(lines.Dequeue()); } if (lines.Peek().Contains("rewind")) { rewind = int.Parse(GetValue(lines.Dequeue())); } if (lines.Peek().Contains("movement")) { movement = int.Parse(GetValue(lines.Dequeue())); } var state = new DMIState(name, dirs, frames, delay, rewind, movement); States.Add(state); }
private void GetFrames(DMIState state, FreeImageBitmap img) { for (int i = 0; i < state.Frames; i++) { int[] dirs = { Directions.SOUTH, Directions.NORTH, Directions.EAST, Directions.WEST, Directions.SOUTHEAST, Directions.SOUTHWEST, Directions.NORTHEAST, Directions.NORTHWEST }; var frame = new DMIFrame(state.GetDelay(i)); for (int j = 0; j < state.Dir; j++) { int dir = dirs[j]; if (_pixelX >= img.Width) { _pixelX = 0; _pixelY += StateHeight; } Bitmap frameBitmap; #if (ASEPRITE_LOAD) // string getString = "./in/FromAse/NabFinalParts/r_nabber" + state.colourStr + " (" + state.Name + ") " + Directions.DirToAse(dir) + ".png"; string getString = "./in/FromAse/NabFinalParts/r_nabber" + state.colourStr + " (" + state.Name + ") " + Directions.DirToAse(dir) + ".png"; FreeImageBitmap inImage = new FreeImageBitmap(getString); frameBitmap = inImage.ToBitmap(); #else frameBitmap = img.Copy(new Rectangle(_pixelX, _pixelY, StateWidth, StateHeight)).ToBitmap(); #endif frame.Add(new DMIImageData(frameBitmap, dir)); _pixelX += StateWidth; } state.Add(frame); } }
private void GetFrames(DMIState state, FreeImageBitmap img) { for (int i = 0; i < state.Frames; i++) { int[] dirs = { Directions.SOUTH, Directions.NORTH, Directions.EAST, Directions.WEST, Directions.SOUTHEAST, Directions.SOUTHWEST, Directions.NORTHEAST, Directions.NORTHWEST }; var frame = new DMIFrame(state.GetDelay(i)); for (int j = 0; j < state.Dir; j++) { int dir = dirs[j]; if (_pixelX >= img.Width) { _pixelX = 0; _pixelY += StateHeight; } Bitmap frameBitmap; frameBitmap = img.Copy(new Rectangle(_pixelX, _pixelY, StateWidth, StateHeight)).ToBitmap(); frame.Add(new DMIImageData(frameBitmap, dir)); _pixelX += StateWidth; } state.Add(frame); } }
private void ReadState(string name, Queue<string> lines) { var dirs = int.Parse(GetValue(lines.Dequeue())); var frames = int.Parse(GetValue(lines.Dequeue())); var delay = new List<float>(); var rewind = 0; if (lines.Peek().Contains("delay")) delay = GetIntList(lines.Dequeue()); if (lines.Peek().Contains("rewind")) rewind = int.Parse(GetValue(lines.Dequeue())); var state = new DMIState(name, dirs, frames, delay, rewind); States.Add(state); }