/// <summary> /// Clone this sprite manager and all its sprites. /// </summary> /// <returns>A clone of this sprite manager.</returns> public SpriteManager Clone() { //Create the clone. SpriteManager manager = new SpriteManager(); //Clone the properties. manager.ContentManager = _ContentManager; //Clone the sprites. foreach (Sprite sprite in _Sprites) { //Create the cloned sprite. Sprite sClone = new Sprite(manager, sprite.Name); //Clone the properties. sClone.Position = sprite.Position; sClone.TimePerFrame = sprite.TimePerFrame; sClone.Scale = sprite.Scale; sClone.Depth = sprite.Depth; sClone.Rotation = sprite.Rotation; sClone.PositionOffset = sprite.PositionOffset; sClone.OrbitOffset = sprite.OrbitOffset; sClone.RotationOffset = sprite.RotationOffset; sClone.Tag = sprite.Tag; sClone.Transparence = sprite.Transparence; sClone.Visibility = sprite.Visibility; sClone.Orientation = sprite.Orientation; //Clone the frames. foreach (Frame frame in sprite.Frames) { //Create the cloned frame. Frame fClone = new Frame(frame.Path, frame.Width, frame.Height); //Clone the properties. fClone.Path = frame.Path; fClone.Width = frame.Width; fClone.Height = frame.Height; fClone.Origin = frame.Origin; fClone.Texture = frame.Texture; //Add the cloned frame to the cloned sprite. sClone.AddFrame(fClone); } //Add the cloned sprite to the cloned manager. manager.Add(sClone); } //Make sure that all sprites have been properly activated. manager.ManageSprites(); //Return the clone. return manager; }
/// <summary> /// Initialize the entity. /// </summary> /// <param name="level">The level that this item belongs to.</param> /// <param name="name">The name of the item.</param> /// <param name="position">The position of the item.</param> /// <param name="rotation">The rotation of the item.</param> /// <param name="scale">The scale of the item.</param> /// <param name="width">The width of the item.</param> /// <param name="height">The height of the item.</param> protected override void Initialize(Level level, string name, Vector2 position, float rotation, Vector2 scale, float width, float height) { //Call the base method. base.Initialize(level, name, position, rotation, scale, width, height); //Initialize a few variables. _Limbs = new List<Limb>(); _Sprites = new SpriteManager(); _Type = Enums.ItemType.Entity; }
/// <summary> /// Initialize the skeleton. /// </summary> /// <param name="graphicsDevice">The graphics device to be used.</param> public void Initialize(GraphicsDevice graphicsDevice) { //Initialize variables. _Bones = new List<Bone>(); _BoneUpdateOrder = _Bones; _Animations = new List<Animation>(); _Sprites = new SpriteManager(); _BoneBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Black); _SelectedBoneBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Green); _JointBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Red); try { _BoneBrush.Load(graphicsDevice); _SelectedBoneBrush.Load(graphicsDevice); _JointBrush.Load(graphicsDevice); } catch { } //Set the skeleton's position to be the same as its root bone. _Position = RootBoneExists() ? GetRootBone().AbsolutePosition : Vector2.Zero; }
/// <summary> /// Initialize the sprite. /// </summary> /// <param name="manager">The manager this sprite is a part of.</param> /// <param name="name">The name of the frame.</param> private void Initialize(SpriteManager manager, string name) { //Initialize some variables. _Manager = manager; _Name = name; _Position = Vector2.Zero; _TimePerFrame = 1; _Scale = Vector2.One; _Depth = 0; _Rotation = 0; _PositionOffset = 0; _OrbitOffset = 0; _RotationOffset = 0; _Tag = ""; _Transparence = 1; _Visibility = Visibility.Visible; _Orientation = Orientation.Right; _Frames = new List<Frame>(); }
/// <summary> /// Initialize the component. /// </summary> /// <param name="gui">The GUI that this component will be a part of.</param> /// <param name="position">The position of the component.</param> /// <param name="width">The width of this component.</param> /// <param name="height">The height of this component.</param> protected virtual void Initialize(GraphicalUserInterface gui, Vector2 position, float width, float height) { //Initialize some variables. _GUI = gui; _Position = position; _Sprite = new SpriteManager(); _Width = width; _Height = height; _IsActive = true; _IsVisible = true; _HasFocus = false; _IsMouseHovering = false; _Transparence = .5f; _MaxTransparence = 0; _MinTransparence = 1; _DrawOrder = 0; _CellStyle = CellStyle.Dynamic; _Items = new List<Component>(); _Parent = null; //Subscribe to events. _GUI.FocusNotification += OnFocusNotification; }
/// <summary> /// Initialize the skeleton. /// </summary> /// <param name="graphicsDevice">The graphics device to be used.</param> public void Initialize(GraphicsDevice graphicsDevice) { //Initialize variables. _Bones = new List<Bone>(); _BoneUpdateOrder = _Bones; _Animations = new List<Animation>(); _Sprites = new SpriteManager(); _Position = HasRootBone() ? GetRootBone().StartPosition : Vector2.Zero; _Rotation = 0; //Initialize the bone brushes. _BoneBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Black); _SelectedBoneBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Green); _JointBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Red); try { _BoneBrush.Load(graphicsDevice); _SelectedBoneBrush.Load(graphicsDevice); _JointBrush.Load(graphicsDevice); } catch { } }
/// <summary> /// Constructor a sprite. /// </summary> /// <param name="manager">The manager this sprite is a part of.</param> /// <param name="name">The name of the sprite. Has nothing to do with the path of any sprite.</param> public Sprite(SpriteManager manager, string name) { Initialize(manager, name); }
/// <summary> /// Add a sprite. /// </summary> /// <param name="manager">The manager to add the sprite to.</param> /// <param name="name">The name of the sprite.</param> /// <param name="texture">The texture of the sprite.</param> /// <param name="position">The position of the sprite.</param> /// <param name="timePerFrame">The time per frame.</param> /// <param name="scale">The scale of the sprite.</param> /// <param name="depth">The depth of the sprite.</param> /// <param name="rotation">The rotation of the sprite.</param> /// <param name="offset">The offset of the sprite.</param> /// <param name="tag">The tag of the sprite, that is something to link it with.</param> /// <param name="origin">The origin of the sprite.</param> public Sprite AddSprite(SpriteManager manager, string name, Texture2D texture, Vector2 position, float timePerFrame, Vector2 scale, int depth, float rotation, float offset, string tag, Vector2 origin) { //Create the sprite and add it to the manager. Sprite sprite = manager.Add(new Sprite(manager, name)); //Set the properties. sprite.Position = position; sprite.TimePerFrame = timePerFrame; sprite.Scale = scale; sprite.Depth = depth; sprite.Rotation = rotation; sprite.PositionOffset = offset; sprite.Tag = tag; //Add a frame to the sprite. sprite.AddFrame(texture, origin); manager.ManageSprites(); //Return the sprite. return sprite; }
/// <summary> /// Initialize the item. /// </summary> /// <param name="level">The level that this item belongs to.</param> /// <param name="name">The name of the item.</param> /// <param name="position">The position of the item.</param> /// <param name="rotation">The rotation of the item.</param> /// <param name="scale">The scale of the item.</param> /// <param name="width">The width of the item.</param> /// <param name="height">The height of the item.</param> protected override void Initialize(Level level, string name, Vector2 position, float rotation, Vector2 scale, float width, float height) { //Call the base method. base.Initialize(level, name, position, rotation, scale, width, height); //Initialize some variables. _Sprites = new SpriteManager(); _Type = Enums.ItemType.TextureItem; }
/// <summary> /// Add a sprite to a manager. /// </summary> /// <param name="manager">The manager to add the sprite to.</param> /// <param name="name">The name of the sprite.</param> /// <param name="path">The path of the texture.</param> /// <param name="position">The position of the sprite.</param> /// <param name="orbitRotation">The orbit rotation of the sprite.</param> /// <param name="timePerFrame">The time per frame.</param> /// <param name="scale">The scale of the sprite.</param> /// <param name="depth">The depth of the sprite.</param> /// <param name="rotation">The rotation of the sprite.</param> /// <param name="tag">The tag of the sprite, that is something to link it with.</param> /// <param name="offset">The offset of the sprite.</param> public Sprite AddSprite(SpriteManager manager, string name, string path, Vector2 position, float orbitRotation, float timePerFrame, Vector2 scale, int depth, float rotation, string tag, float offset) { //Create the sprite. Sprite sprite = new Sprite(manager, name); //Set the properties. sprite.Position = Helper.CalculateOrbitPosition(position, orbitRotation, offset); sprite.TimePerFrame = timePerFrame; sprite.Scale = scale; sprite.Depth = depth; sprite.Rotation = rotation; sprite.PositionOffset = offset; sprite.RotationOffset = Helper.SubtractAngles(rotation, orbitRotation); //Add a frame to the sprite. sprite.AddFrame(path); //Add the sprite to the manager. manager.Add(sprite); manager.ManageSprites(); //Return the sprite. return sprite; }
/// <summary> /// Add a sprite to a manager. /// </summary> /// <param name="manager">The manager to add the sprite to.</param> /// <param name="name">The name of the sprite.</param> /// <param name="path">The path of the texture.</param> /// <param name="rotationOffset">The rotation offset of the sprite.</param> /// <param name="tag">The tag of the sprite, that is something to link it with.</param> public Sprite AddSprite(SpriteManager manager, string name, string path, float rotationOffset, string tag) { //Create the sprite. Sprite sprite = new Sprite(manager, name); //Set the properties. sprite.Tag = tag; sprite.RotationOffset = rotationOffset; //Add a frame to the sprite. sprite.AddFrame(path); //Add the sprite to the manager. manager.Add(sprite); manager.ManageSprites(); //Return the sprite. return sprite; }
/// <summary> /// Add a sprite to a manager. /// </summary> /// <param name="manager">The manager to add the sprite to.</param> /// <param name="name">The name of the sprite.</param> /// <param name="path">The path of the texture.</param> /// <param name="origin">The origin of the sprite.</param> /// <returns>The recently added sprite.</returns> public Sprite AddSprite(SpriteManager manager, string name, string path, Vector2 origin) { //Create the sprite. Sprite sprite = new Sprite(manager, name); //Add a frame to the sprite. sprite.AddFrame(path, origin); //Add the sprite to the manager. manager.Add(sprite); manager.ManageSprites(); //Return the sprite. return sprite; }
/// <summary> /// Add a sprite. /// </summary> /// <param name="manager">The manager to add the sprite to.</param> /// <param name="name">The name of the sprite.</param> /// <param name="texture">The texture of the sprite.</param> public Sprite AddSprite(SpriteManager manager, string name, Texture2D texture) { //Create the sprite. Sprite sprite = new Sprite(manager, name); //Add a frame to the sprite. sprite.AddFrame(texture); //Add the sprite to the manager. manager.Add(sprite); manager.ManageSprites(); //Return the sprite. return sprite; }
/// <summary> /// Set the picturebox's picture. /// </summary> /// <param name="manager">The sprite manager of the asset to set.</param> public void SetPicture(SpriteManager manager) { //If the sprite is null, stop here. if (manager == null || manager.Count == 0) { return; } //Change the texture into the sprite's first frame. PictureChangeInvoke(manager[0].Texture); }