More comments round 2
This commit is contained in:
parent
fabef6ba82
commit
a915a06460
|
@ -7,21 +7,58 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace CustomNPCFramework.Framework.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// A class to be used to hold information regarding assets such as the name of the assets and the paths to the images.
|
||||
/// </summary>
|
||||
public class AssetInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the asset to be used in the main asset pool.
|
||||
/// </summary>
|
||||
public string assetName;
|
||||
/// <summary>
|
||||
/// The list of files to be used for the standing animation.
|
||||
/// </summary>
|
||||
public NamePairings standingAssetPaths;
|
||||
/// <summary>
|
||||
/// The list of files to be used for the swimming animation.
|
||||
/// </summary>
|
||||
public NamePairings swimmingAssetPaths;
|
||||
/// <summary>
|
||||
/// The list of files to be used with the moving animation.
|
||||
/// </summary>
|
||||
public NamePairings movingAssetPaths;
|
||||
/// <summary>
|
||||
/// The list of files to be used with the sitting animation.
|
||||
/// </summary>
|
||||
public NamePairings sittingAssetPaths;
|
||||
/// <summary>
|
||||
/// The size of the asset texture. Width and height.
|
||||
/// </summary>
|
||||
public Vector2 assetSize;
|
||||
/// <summary>
|
||||
/// Not really used anymore. More of a legacy feature.
|
||||
/// </summary>
|
||||
public bool randomizeUponLoad;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Empty constructor.
|
||||
/// </summary>
|
||||
public AssetInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor that assigns values to the class.
|
||||
/// </summary>
|
||||
/// <param name="assetName">The name of the asset. This is the name that will be referenced in any asset manager or asset pool.</param>
|
||||
/// <param name="StandingAssetPaths">The name of the files to be used for the standing animation.</param>
|
||||
/// <param name="MovingAssetPaths">The name of the files to be used for the moving animation.</param>
|
||||
/// <param name="SwimmingAssetPaths">The name of the files to be used for the swimming animation.</param>
|
||||
/// <param name="SittingAssetPaths">The name of the files to be used for the sitting animation.</param>
|
||||
/// <param name="assetSize">The size of the asset. Width and height of the texture.</param>
|
||||
/// <param name="randomizeUponLoad">Legacy, not really used anymore.</param>
|
||||
public AssetInfo(string assetName,NamePairings StandingAssetPaths, NamePairings MovingAssetPaths, NamePairings SwimmingAssetPaths, NamePairings SittingAssetPaths, Vector2 assetSize, bool randomizeUponLoad)
|
||||
{
|
||||
this.assetName = assetName;
|
||||
|
|
|
@ -8,9 +8,18 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace CustomNPCFramework.Framework.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to hold assets from specified directories.
|
||||
/// </summary>
|
||||
public class AssetManager
|
||||
{
|
||||
/// <summary>
|
||||
/// A list of all of the assets held by this asset manager.
|
||||
/// </summary>
|
||||
public List<AssetSheet> assets;
|
||||
/// <summary>
|
||||
/// A list of all of the directories managed by this asset manager.
|
||||
/// </summary>
|
||||
public Dictionary<string,string> paths;
|
||||
|
||||
/// <summary>
|
||||
|
@ -22,6 +31,10 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
this.paths = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="assetsPathsToLoadFrom">A list of all directories to be managed by the asset manager. Name, path is the key pair value.</param>
|
||||
public AssetManager(Dictionary<string,string> assetsPathsToLoadFrom)
|
||||
{
|
||||
this.assets = new List<AssetSheet>();
|
||||
|
@ -155,6 +168,11 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
return aSheet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the assets of this kind of part.
|
||||
/// </summary>
|
||||
/// <param name="type">The type of part to return a list of from this asset manager.</param>
|
||||
/// <returns></returns>
|
||||
public List<AssetSheet> getListOfAssetsThatMatchThisCriteria(PartType type)
|
||||
{
|
||||
List<AssetSheet> aSheet = new List<AssetSheet>();
|
||||
|
@ -168,6 +186,12 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
return aSheet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of assets that match the critera.
|
||||
/// </summary>
|
||||
/// <param name="gender">The gender criteria for this asset, such as if this part belongs to either a female or male character.</param>
|
||||
/// <param name="type">The type of asset to return. Hair eyes, shoes, etc.</param>
|
||||
/// <returns></returns>
|
||||
public List<AssetSheet> getListOfAssetsThatMatchThisCriteria(Genders gender,PartType type)
|
||||
{
|
||||
List<AssetSheet> aSheet = new List<AssetSheet>();
|
||||
|
@ -225,6 +249,13 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
return aSheet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of asssets that match certain critera.
|
||||
/// </summary>
|
||||
/// <param name="gender">The gengder certain assets belong to, such as male or female.</param>
|
||||
/// <param name="season">The season that an asset can be displayed in. Good for seasonal assets.</param>
|
||||
/// <param name="type">The type of part to return a list of such as hair, eyes, or pants.</param>
|
||||
/// <returns></returns>
|
||||
public List<AssetSheet> getListOfAssetsThatMatchThisCriteria(Genders gender, Seasons season, PartType type)
|
||||
{
|
||||
List<AssetSheet> aSheet = new List<AssetSheet>();
|
||||
|
|
|
@ -16,11 +16,10 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace CustomNPCFramework.Framework.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to contain all of the asset managers.
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
/// <summary>
|
||||
/// Used to hold a collection of strings.
|
||||
/// </summary>
|
||||
public class NamePairings
|
||||
{
|
||||
public string leftString;
|
||||
|
@ -36,37 +35,67 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to contain all of the asset managers.
|
||||
/// </summary>
|
||||
public class AssetPool
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A dictionary holding all of the asset managers. (Name, AssetManager)
|
||||
/// </summary>
|
||||
public Dictionary<string, AssetManager> assetPool;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
public AssetPool()
|
||||
{
|
||||
this.assetPool = new Dictionary<string, AssetManager>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an asset manager to the asset pool.
|
||||
/// </summary>
|
||||
/// <param name="pair">A key value pair with the convention being (Manager Name, Asset Manager)</param>
|
||||
public void addAssetManager(KeyValuePair<string, AssetManager> pair)
|
||||
{
|
||||
this.assetPool.Add(pair.Key, pair.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an asset manager to the asset pool.
|
||||
/// </summary>
|
||||
/// <param name="assetManagerName">The name of the asset manager to be added.</param>
|
||||
/// <param name="assetManager">The asset manager object to be added to the asset pool.</param>
|
||||
public void addAssetManager(string assetManagerName, AssetManager assetManager)
|
||||
{
|
||||
this.assetPool.Add(assetManagerName, assetManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get an asset manager from the asset pool from a name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the asset manager to return.</param>
|
||||
/// <returns></returns>
|
||||
public AssetManager getAssetManager(string name)
|
||||
{
|
||||
assetPool.TryGetValue(name, out AssetManager asset);
|
||||
return asset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove an asset manager from the asset pool.
|
||||
/// </summary>
|
||||
/// <param name="key">The name of the asset manager to remove.</param>
|
||||
public void removeAssetManager(string key)
|
||||
{
|
||||
assetPool.Remove(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Go through all of the asset managers and load assets according to their respective paths.
|
||||
/// </summary>
|
||||
public void loadAllAssets()
|
||||
{
|
||||
foreach (KeyValuePair<string, AssetManager> assetManager in this.assetPool)
|
||||
|
@ -88,7 +117,12 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Generates a new AnimatedSpriteCollection object from the data held in an asset sheet.
|
||||
/// </summary>
|
||||
/// <param name="assetSheet">An asset sheet that holds the data for textures.</param>
|
||||
/// <param name="type">The type of asset to get from the sheet. Hair, eyes, shoes, etc.</param>
|
||||
/// <returns></returns>
|
||||
public AnimatedSpriteCollection getSpriteCollectionFromSheet(AssetSheet assetSheet, AnimationType type)
|
||||
{
|
||||
var left = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.left, type),assetSheet.path.Clone().ToString(),assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y);
|
||||
|
@ -118,11 +152,29 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get an AnimatedSpriteCollection from a name pairing.
|
||||
/// </summary>
|
||||
/// <param name="pair">A collection of strings that hold information on directional textures.</param>
|
||||
/// <param name="startingDirection">The direction in which the sprite should face.</param>
|
||||
/// <returns></returns>
|
||||
public AnimatedSpriteCollection getAnimatedSpriteCollectionFromAssets(NamePairings pair, Direction startingDirection = Direction.down)
|
||||
{
|
||||
return getAnimatedSpriteCollectionFromAssets(pair.leftString, pair.rightString, pair.upString, pair.downString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a collection of sprites to generate a collective animated sprite.
|
||||
/// </summary>
|
||||
/// <param name="BodySprites">The collection of sprites to be used for the boyd of the npc.</param>
|
||||
/// <param name="EyeSprites">The collection of sprites to be used for the eye of the npc.</param>
|
||||
/// <param name="HairSprites">The collection of sprites to be used for the hair of the npc.</param>
|
||||
/// <param name="ShirtsSprites">The collection of sprites to be used for the shirts of the npc.</param>
|
||||
/// <param name="PantsSprites">The collection of sprites to be used for the pants of the npc.</param>
|
||||
/// <param name="ShoesSprites">The collection of sprites to be used for the shoes of the npc.</param>
|
||||
/// <param name="AccessoriesSprites">The collection of sprites to be used for the accessories of the npc.</param>
|
||||
/// <param name="DrawColors">The collection of collors to be used for chaing the color of an individual asset.</param>
|
||||
/// <returns></returns>
|
||||
public StandardCharacterAnimation GetStandardCharacterAnimation(NamePairings BodySprites, NamePairings EyeSprites, NamePairings HairSprites, NamePairings ShirtsSprites, NamePairings PantsSprites, NamePairings ShoesSprites,List<NamePairings> AccessoriesSprites,StandardColorCollection DrawColors=null)
|
||||
{
|
||||
var body = getAnimatedSpriteCollectionFromAssets(BodySprites);
|
||||
|
@ -140,6 +192,14 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
return new StandardCharacterAnimation(body,eyes,hair,shirts,pants,shoes,accessories,DrawColors);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of parts that can apply for this criteria.
|
||||
/// </summary>
|
||||
/// <param name="assetManagerName">The name of the asset manager.</param>
|
||||
/// <param name="gender">The gender critera.</param>
|
||||
/// <param name="season">The season critera.</param>
|
||||
/// <param name="type">The part type critera.</param>
|
||||
/// <returns></returns>
|
||||
public List<AssetSheet> getListOfApplicableBodyParts(string assetManagerName,Genders gender, Seasons season, PartType type)
|
||||
{
|
||||
var parts = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, type);
|
||||
|
@ -300,6 +360,18 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
return npc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a character renderer (a collection of textures) from a bunch of different asset sheets.
|
||||
/// </summary>
|
||||
/// <param name="bodySheet">The textures for the npc's body.</param>
|
||||
/// <param name="eyesSheet">The textures for the npc's eyes.</param>
|
||||
/// <param name="hairSheet">The textures for the npc's hair.</param>
|
||||
/// <param name="shirtSheet">The textures for the npc's shirt.</param>
|
||||
/// <param name="pantsSheet">The textures for the npc's pants.</param>
|
||||
/// <param name="shoesSheet">The textures for the npc's shoes.</param>
|
||||
/// <param name="accessorySheet">The textures for the npc's accessories.</param>
|
||||
/// <param name="DrawColors">The colors for the npc's different assets.</param>
|
||||
/// <returns></returns>
|
||||
public virtual BasicRenderer generateBasicRenderer(AssetSheet bodySheet, AssetSheet eyesSheet, AssetSheet hairSheet, AssetSheet shirtSheet, AssetSheet pantsSheet, AssetSheet shoesSheet, List<AssetSheet> accessorySheet, StandardColorCollection DrawColors=null)
|
||||
{
|
||||
if (DrawColors == null) DrawColors = new StandardColorCollection();
|
||||
|
@ -315,6 +387,19 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
return render;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a Standard Character Animation from some asset sheets.
|
||||
/// (collection of textures to animations)
|
||||
/// </summary>
|
||||
/// <param name="body">The textures for the npc's body.</param>
|
||||
/// <param name="eyes">The textures for the npc's eyes.</param>
|
||||
/// <param name="hair">The textures for the npc's hair.</param>
|
||||
/// <param name="shirt">The textures for the npc's shirt.</param>
|
||||
/// <param name="pants">The textures for the npc's pants.</param>
|
||||
/// <param name="shoes">The textures for the npc's shoes.</param>
|
||||
/// <param name="accessoryType">The textures for the npc's accessories.</param>
|
||||
/// <param name="DrawColors">The colors for the npc's different assets.</param>
|
||||
/// <returns></returns>
|
||||
public virtual StandardCharacterAnimation generateCharacterAnimation(AssetSheet body, AssetSheet eyes, AssetSheet hair, AssetSheet shirt, AssetSheet pants, AssetSheet shoes,List<AssetSheet> accessories, AnimationType animationType, StandardColorCollection DrawColors=null)
|
||||
{
|
||||
var bodySprite = getSpriteCollectionFromSheet(body, animationType);
|
||||
|
@ -334,6 +419,11 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
return standingAnimation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string for the standard character sprite to be used from this asset sheet.
|
||||
/// </summary>
|
||||
/// <param name="imageGraphics">The standard asset sheet to be used.</param>
|
||||
/// <returns></returns>
|
||||
public virtual string getDefaultSpriteImage(AssetSheet imageGraphics)
|
||||
{
|
||||
return Class1.getRelativeDirectory(Path.Combine(imageGraphics.path, imageGraphics.assetInfo.standingAssetPaths.downString));
|
||||
|
|
|
@ -16,15 +16,34 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
/// </summary>
|
||||
public class AssetSheet
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to hold the textures for the AssetSheet.
|
||||
/// </summary>
|
||||
public TextureGroups.TextureGroup textures;
|
||||
|
||||
/// <summary>
|
||||
/// Used to hold the info for the paths to these textures.
|
||||
/// </summary>
|
||||
public AssetInfo assetInfo;
|
||||
|
||||
/// <summary>
|
||||
/// The path to this assetinfo.json file
|
||||
/// </summary>
|
||||
public string path;
|
||||
|
||||
/// <summary>
|
||||
/// The soruce rectangle for the current texture to draw.
|
||||
/// </summary>
|
||||
public Rectangle currentAsset;
|
||||
|
||||
public int index;
|
||||
|
||||
public Rectangle currentAsset;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="info">The asset info file to be read in or created. Holds path information.</param>
|
||||
/// <param name="path">The path to the assetinfo file.</param>
|
||||
/// <param name="direction">The direction to set the animation.</param>
|
||||
public AssetSheet(AssetInfo info,string path,Direction direction=Direction.down)
|
||||
{
|
||||
this.assetInfo = info;
|
||||
|
@ -37,9 +56,14 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the path to the current texture.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual KeyValuePair<string, Texture2D> getPathTexturePair()
|
||||
{
|
||||
return new KeyValuePair<string, Texture2D>(this.path, this.textures.currentTexture.currentTexture);
|
||||
|
@ -55,32 +79,53 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
return asset;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets the textures for this sheet to face left.
|
||||
/// </summary>
|
||||
public virtual void setLeft()
|
||||
{
|
||||
this.textures.setLeft();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the textures for this sheet to face up.
|
||||
/// </summary>
|
||||
public virtual void setUp()
|
||||
{
|
||||
this.textures.setUp();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the textures for this sheet to face down.
|
||||
/// </summary>
|
||||
public virtual void setDown()
|
||||
{
|
||||
this.textures.setDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the textures for this sheet to face left.
|
||||
/// </summary>
|
||||
public virtual void setRight()
|
||||
{
|
||||
this.textures.setRight();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the current animation texture.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual Texture2D getCurrentSpriteTexture()
|
||||
{
|
||||
return this.textures.currentTexture.currentTexture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the specific texture depending on the direction and animation type.
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public virtual Texture2D getTexture(Direction direction,AnimationType type)
|
||||
{
|
||||
return this.textures.getTextureFromAnimation(type).getTextureFromDirection(direction);
|
||||
|
|
|
@ -9,15 +9,42 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace CustomNPCFramework.Framework.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// A class that's used to hold textures for different directions.
|
||||
/// </summary>
|
||||
public class DirectionalTexture
|
||||
{
|
||||
/// <summary>
|
||||
/// The left texture for this group.
|
||||
/// </summary>
|
||||
public Texture2D leftTexture;
|
||||
/// <summary>
|
||||
/// The right texture for this group.
|
||||
/// </summary>
|
||||
public Texture2D rightTexture;
|
||||
|
||||
/// <summary>
|
||||
/// The down textiure for this group.
|
||||
/// </summary>
|
||||
public Texture2D downTexture;
|
||||
/// <summary>
|
||||
/// The up texture for this group.
|
||||
/// </summary>
|
||||
public Texture2D upTexture;
|
||||
|
||||
/// <summary>
|
||||
/// The current texture for this group.
|
||||
/// </summary>
|
||||
public Texture2D currentTexture;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="left">The left texture to use.</param>
|
||||
/// <param name="right">The right texture to use.</param>
|
||||
/// <param name="up">The up texture to use.</param>
|
||||
/// <param name="down">The down texture to use.</param>
|
||||
/// <param name="direction">The direction texture for the sprite to face.</param>
|
||||
public DirectionalTexture(Texture2D left, Texture2D right, Texture2D up, Texture2D down, Direction direction=Direction.down)
|
||||
{
|
||||
this.leftTexture = left;
|
||||
|
@ -33,6 +60,12 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="info">A list of name pairings to hold the info for the directional texture.</param>
|
||||
/// <param name="path">The path location of the textures to load.</param>
|
||||
/// <param name="direction">The direction the textures should be facing.</param>
|
||||
public DirectionalTexture(NamePairings info, string path, Direction direction = Direction.down)
|
||||
{
|
||||
this.leftTexture = Class1.ModHelper.Content.Load<Texture2D>(Class1.getShortenedDirectory(Path.Combine(path, info.leftString + ".png")).Remove(0, 1));
|
||||
|
@ -46,26 +79,43 @@ namespace CustomNPCFramework.Framework.Graphics
|
|||
if (direction == Direction.down) this.currentTexture = downTexture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the direction of this current texture to left.
|
||||
/// </summary>
|
||||
public void setLeft()
|
||||
{
|
||||
this.currentTexture = leftTexture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the direction of this current texture to up.
|
||||
/// </summary>
|
||||
public void setUp()
|
||||
{
|
||||
this.currentTexture = upTexture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the direction of this current texture to down.
|
||||
/// </summary>
|
||||
public void setDown()
|
||||
{
|
||||
this.currentTexture = downTexture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the direction of this current texture to right.
|
||||
/// </summary>
|
||||
public void setRight()
|
||||
{
|
||||
this.currentTexture = rightTexture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the texture from this texture group depending on the direction.
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
public virtual Texture2D getTextureFromDirection(Direction direction)
|
||||
{
|
||||
if (direction == Direction.left) return this.leftTexture;
|
||||
|
|
|
@ -8,12 +8,27 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace CustomNPCFramework.Framework.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// An expanded Asset info class that deals with seasons and genders.
|
||||
/// </summary>
|
||||
public class ExtendedAssetInfo :AssetInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The genders this part is associated with. 0=Male, 1=female, 2=other.
|
||||
/// </summary>
|
||||
public Genders gender;
|
||||
/// <summary>
|
||||
/// A list of seasons where this part can be displayed
|
||||
/// </summary>
|
||||
public List<Seasons> seasons=new List<Seasons>();
|
||||
/// <summary>
|
||||
/// The part type to be used for this asset such as hair, eyes, etc.
|
||||
/// </summary>
|
||||
public PartType type;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
public ExtendedAssetInfo()
|
||||
{
|
||||
this.seasons = new List<Seasons>();
|
||||
|
|
|
@ -52,6 +52,13 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups
|
|||
/// </summary>
|
||||
private AnimationType type;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="info">The asset info file to be stored with this texture group.</param>
|
||||
/// <param name="path">Use to locate the files on disk.</param>
|
||||
/// <param name="direction">Used to determine the current direction/animation to load</param>
|
||||
/// <param name="animationType">The type of asset this is. Eyes, Hair, Shirts, etc</param>
|
||||
public TextureGroup(AssetInfo info, string path,Direction direction ,AnimationType animationType=AnimationType.standing)
|
||||
{
|
||||
this.standingTexture = new DirectionalTexture(info.standingAssetPaths, path, direction);
|
||||
|
@ -71,12 +78,19 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a clone of this texture group.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TextureGroup clone()
|
||||
{
|
||||
return new TextureGroup(this.info, this.path, this.dir, this.type);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets all of the different animations to use their left facing sprites.
|
||||
/// </summary>
|
||||
public virtual void setLeft()
|
||||
{
|
||||
this.movingTexture.setLeft();
|
||||
|
@ -85,6 +99,9 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups
|
|||
this.swimmingTexture.setLeft();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets all of the different animations to use their up facing sprites.
|
||||
/// </summary>
|
||||
public virtual void setUp()
|
||||
{
|
||||
this.movingTexture.setUp();
|
||||
|
@ -93,6 +110,9 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups
|
|||
this.swimmingTexture.setUp();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets all of the different animations to use their down facing sprites.
|
||||
/// </summary>
|
||||
public virtual void setDown()
|
||||
{
|
||||
this.movingTexture.setDown();
|
||||
|
@ -101,6 +121,9 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups
|
|||
this.swimmingTexture.setDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets all of the different animations to use their right facing sprites.
|
||||
/// </summary>
|
||||
public virtual void setRight()
|
||||
{
|
||||
this.movingTexture.setRight();
|
||||
|
@ -109,6 +132,11 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups
|
|||
this.swimmingTexture.setRight();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get's the appropriate animation texture based on the type of animation key passed in.
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public virtual DirectionalTexture getTextureFromAnimation(AnimationType type)
|
||||
{
|
||||
if (type == AnimationType.standing) return this.standingTexture;
|
||||
|
|
|
@ -9,39 +9,70 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace CustomNPCFramework.Framework.ModularNPCS
|
||||
{
|
||||
/// <summary>
|
||||
/// Used as a base class for character animations.
|
||||
/// </summary>
|
||||
public class CharacterAnimationBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
public CharacterAnimationBase()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the character sprites to left.
|
||||
/// </summary>
|
||||
public virtual void setLeft()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the character sprites to right.
|
||||
/// </summary>
|
||||
public virtual void setRight()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the character sprites to up.
|
||||
/// </summary>
|
||||
public virtual void setUp()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Set the character sprites to down.
|
||||
/// </summary>
|
||||
public virtual void setDown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to reload the sprite textures.
|
||||
/// </summary>
|
||||
public virtual void reload()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Animate the sprites.
|
||||
/// </summary>
|
||||
/// <param name="animationInterval">How long between animation frames in milliseconds.</param>
|
||||
public virtual void Animate(float animationInterval)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Used to animate sprites.
|
||||
/// </summary>
|
||||
/// <param name="animationInterval">How long between animation frames in milliseconds.</param>
|
||||
/// <param name="loop">Loop the animation.</param>
|
||||
public virtual void Animate(float animationInterval, bool loop=true)
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in New Issue