Esempio n. 1
0
        /// <summary>
        /// Create a sprite using the database sprite information.  This does not do any checking to make sure
        /// the named sprite already exists.  Usually, what you want to do is to create your SpriteController and
        /// register your SpriteDatabase with the controller.  Then, when you ask the SpriteController for a sprite,
        /// if that sprite does not exist yet, it will create it from the database.
        /// </summary>
        /// <param name="ControllerToUse">The sprite controller that will end up controlling the sprite</param>
        /// <param name="TheDatabaseToUse">The database</param>
        /// <returns></returns>
        internal Sprite CreateSprite(SpriteController ControllerToUse, SpriteDatabase TheDatabaseToUse)
        {
            Sprite DestSprite = null;

            if (ControllerToUse == null)
            {
                return(null);
            }
            for (int index = 0; index < Animations.Count; index++)
            {
                AnimationInfo CurrentAnimation = Animations[index];
                Image         myImage          = TheDatabaseToUse.GetImageFromName(CurrentAnimation.ImageName, true);
                if (myImage == null)
                {
                    return(null);                  //break out if we do not have the image defined for this
                }
                AnimationType AT = CurrentAnimation.FieldsToUse;
                if (index == 0)
                {
                    AT = AnimationType.SpriteDefinition;              //the first one MUST be this.
                }
                switch (AT)
                {
                case AnimationType.SpriteDefinition:
                    if (DestSprite == null)   //Creating the sprite from scratch
                    {
                        DestSprite = new Sprite(CurrentAnimation.StartPoint, ControllerToUse, myImage, CurrentAnimation.Width, CurrentAnimation.Height, CurrentAnimation.AnimSpeed, CurrentAnimation.NumFrames);
                    }
                    else
                    {
                        DestSprite.AddAnimation(CurrentAnimation.StartPoint, myImage, CurrentAnimation.Width, CurrentAnimation.Height, CurrentAnimation.AnimSpeed, CurrentAnimation.NumFrames);
                    }
                    break;

                case AnimationType.Rotation:
                    DestSprite.AddAnimation(CurrentAnimation.AnimationToUse, CurrentAnimation.RotationDegrees);
                    break;

                case AnimationType.Mirror:
                    DestSprite.AddAnimation(CurrentAnimation.AnimationToUse, CurrentAnimation.MirrorHorizontally, CurrentAnimation.MirrorVertically);
                    break;
                }
            }
            int sizepercent = ViewPercent;

            if (sizepercent < 5)
            {
                sizepercent = 100;
            }
            if (sizepercent > 300)
            {
                sizepercent = 100;
            }
            double delta = (double)sizepercent / 100.0; //turn it into a double, and into something we can multiply.

            DestSprite.SetSize(new Size((int)(DestSprite.GetSize.Width * delta), (int)(DestSprite.GetSize.Height * delta)));
            DestSprite.SetName(SpriteName);
            //We have created a new sprite.  Now, return a duplicate of that sprite.
            return(DestSprite);
        }
Esempio n. 2
0
 internal SpriteEntryForm(SpriteDatabase theDatabase, List <SpriteInfo> ListToWorkOn, Size GridSize)
 {
     InitializeComponent();
     myDatabase   = theDatabase;
     myResources  = myDatabase.GetResourceManager();
     SnapGridSize = GridSize;
     LocalSetup();
     SpriteInformation.AddRange(ListToWorkOn);
     if (SpriteInformation.Count > 0)
     {
         SelectNewIndex(0);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// A generic cloning method that works when everything is public
 /// </summary>
 /// <returns>A duplicate of the sprite info.</returns>
 public SpriteInfo Clone()
 {
     return(SpriteDatabase.CloneByXMLSerializing <SpriteInfo>(this));
 }
Esempio n. 4
0
 /// <summary>
 /// A generic cloning method that works when everything is public
 /// </summary>
 /// <returns>A clone of the specified AnimationInfo</returns>
 public AnimationInfo Clone()
 {
     return(SpriteDatabase.CloneByXMLSerializing <AnimationInfo>(this));
 }