Ejemplo n.º 1
0
 public Sprite(string spriteName, Project project)
 {
     this.project = project;
     PropertyReader props = project.loader.GetPropertyReader().Select("sprites/" + spriteName + ".xml");
     animation = project.animations[props.GetString("animation")];
     speed = props.GetInt("speed");
     noclip = props.GetBool("noclip");
     foreach (PropertyReader extNode in props.SelectAll("exts/ext")) {
         ext.Add(extNode.GetString("key"), extNode.GetString("value"));
     }
 }
Ejemplo n.º 2
0
        public AnimationDialog(Animation baseAnimation, Project project)
            : this(project)
        {
            this.baseAnimation = baseAnimation;
            nameTextBox.Text = baseAnimation.Name;

            sheetComboBox.SelectedItem = new KeyValuePair<string, SpriteSheet>(baseAnimation.sheet.Name, baseAnimation.sheet);

            foreach (var kvp in baseAnimation.groups) {
                groups.Add(kvp);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a copy of this Animation, but does not add it to the current project.
 /// Do not call the Name property until you added it to the project!
 /// </summary>
 /// <returns>A new Animation instance.</returns>
 public Animation Clone()
 {
     Animation cloned = new Animation(this.sheet, this.project);
     foreach (KeyValuePair<string, Group> oldGroup in this.groups) {
         Group newGroup = new Group();
         foreach (Frame oldFrame in oldGroup.Value.frames) {
             newGroup.frames.Add(new Frame(oldFrame.sheetId, oldFrame.time));
         }
         cloned.groups.Add(oldGroup.Key, newGroup);
     }
     return cloned;
 }
Ejemplo n.º 4
0
        public AnimationSelector(Animation.Group group, SpriteSheet sheet, Project project)
        {
            InitializeComponent();
            spriteSelector.Image = sheet.sheet;
            spriteSelector.SpriteWidth = sheet.spriteWidth;
            spriteSelector.SpriteHeight = sheet.spriteHeight;
            selectedFrames = group.frames.ToArray();

            //Must be set last because their events are already hooked up
            maxFramesNumUpDown.Value = group.frames.Count;
            spriteSelector.SelectedIndex = selectedFrames[0].sheetId;
            timeoutNumericUpDown.Value = selectedFrames[0].time;
        }
Ejemplo n.º 5
0
 public void RemoveAnimation(Animation a)
 {
     var undoComm = new UndoCommandList("Remove animation " + a.Name);
     RemoveAnimation(a, undoComm);
     Undo.DoCommand(undoComm);
 }
Ejemplo n.º 6
0
 public void RemoveAnimation(Animation a, UndoCommandList list)
 {
     foreach (var sprite in sprites.Values) {
         if (sprite.animation == a) {
             throw new CannotRemoveException("Sprite " + sprite.Name);
         }
     }
     string name = a.Name;
     list.Add(new UndoCommand(
                  delegate() {
                      animations.Remove(name);
                  },
                  delegate() {
                      animations.Add(name, a);
                  }
              ));
 }
Ejemplo n.º 7
0
 private void AddAnimationGroup(string name, Animation.Frame[] frames)
 {
     Animation.Group group = new Animation.Group();
     group.frames = new List<Animation.Frame>(frames);
     groups.Add(new KeyValuePair<string,Animation.Group>(name, group));
 }