Exemple #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"));
     }
 }
        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);
            }
        }
Exemple #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;
 }
        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;
        }
Exemple #5
0
 public void RemoveAnimation(Animation a)
 {
     var undoComm = new UndoCommandList("Remove animation " + a.Name);
     RemoveAnimation(a, undoComm);
     Undo.DoCommand(undoComm);
 }
Exemple #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);
                  }
              ));
 }
 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));
 }