The asset loader should now have all like assets bundled together. So all swimming animations will pull from the same body sprite as defined instead of always random.

This commit is contained in:
2018-03-04 14:32:59 -08:00
parent d5536b9e52
commit c737024599
5 changed files with 38 additions and 32 deletions

View File

@ -131,7 +131,7 @@ namespace CustomNPCFramework
if (!File.Exists(filePath2))
{
ExtendedAssetInfo info2 = new ExtendedAssetInfo("AdvancedExample", new NamePairings("AdvancedExampleL", "AdvancedExampleR", "AdvancedExampleU", "AdvancedExampleD"), new Vector2(16, 16), false, Genders.female, new List<Seasons>()
ExtendedAssetInfo info2 = new ExtendedAssetInfo("AdvancedExample", new NamePairings("AdvancedStandingExampleL", "AdvancedStandingExampleR", "AdvancedStandingExampleU", "AdvancedStandingExampleD"), new NamePairings("AdvancedMovingExampleL", "AdvancedMovingExampleR", "AdvancedMovingExampleU", "AdvancedMovingExampleD"), new NamePairings("AdvancedSwimmingExampleL", "AdvancedSwimmingExampleR", "AdvancedSwimmingExampleU", "AdvancedSwimmingExampleD"), new NamePairings("AdvancedSittingExampleL", "AdvancedSittingExampleR", "AdvancedSittingExampleU", "AdvancedSittingExampleD"), new Vector2(16, 16), false, Genders.female, new List<Seasons>()
{
Seasons.spring,
Seasons.summer

View File

@ -14,7 +14,6 @@ namespace CustomNPCFramework.Framework.Graphics
public NamePairings swimmingAssetPaths;
public NamePairings movingAssetPaths;
public NamePairings sittingAssetPaths;
public string downAssetName;
public Vector2 assetSize;
public bool randomizeUponLoad;
@ -25,6 +24,7 @@ namespace CustomNPCFramework.Framework.Graphics
public AssetInfo(string assetName,NamePairings StandingAssetPaths, NamePairings MovingAssetPaths, NamePairings SwimmingAssetPaths, NamePairings SittingAssetPaths, Vector2 assetSize, bool randomizeUponLoad)
{
this.assetName = assetName;
this.sittingAssetPaths = SittingAssetPaths;
this.standingAssetPaths = StandingAssetPaths;
this.movingAssetPaths = MovingAssetPaths;

View File

@ -87,16 +87,12 @@ namespace CustomNPCFramework.Framework.Graphics
public AnimatedSpriteCollection getSpriteCollectionFromSheet(AssetSheet assetSheet, AnimationType type)
{
if (type == AnimationType.standing)
{
var ok = assetSheet.getTexture(Direction, AnimationType);
var left = new AnimatedSpriteExtended(assetSheet.clone().textures.standingTexture.leftTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y);
var right = new AnimatedSpriteExtended(assetSheet.clone().texture.rightTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y);
var up = new AnimatedSpriteExtended(assetSheet.clone().texture.upTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y);
var down = new AnimatedSpriteExtended(assetSheet.clone().texture.downTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y);
return new AnimatedSpriteCollection(left, right, up, down, Direction.down);
}
{
var left = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.left, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y);
var right = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.right, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y);
var up = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.up, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y);
var down = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.down, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y);
return new AnimatedSpriteCollection(left, right, up, down, Direction.down);
}
@ -219,29 +215,41 @@ namespace CustomNPCFramework.Framework.Graphics
accessorySheet.Add(accessoryList.ElementAt(v));
}
var bodySprite = getSpriteCollectionFromSheet(bodySheet);
var eyesSprite = getSpriteCollectionFromSheet(eyesSheet);
var hairSprite = getSpriteCollectionFromSheet(hairSheet);
var shirtSprite = getSpriteCollectionFromSheet(shirtSheet);
var pantsSprite = getSpriteCollectionFromSheet(pantsSheet);
var shoesSprite = getSpriteCollectionFromSheet(shoesSheet);
List<AnimatedSpriteCollection> accessoryCollection = new List<AnimatedSpriteCollection>();
foreach(var v in accessorySheet)
{
AnimatedSpriteCollection acc = getSpriteCollectionFromSheet(v);
accessoryCollection.Add(acc);
}
StandardCharacterAnimation standingAnimation = new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection);
AnimationType type = AnimationType.standing;
var standingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type);
type = AnimationType.walking;
var movingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type);
type = AnimationType.swimming;
var swimmingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type);
//type = AnimationType.standing;
//var sAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type);
BasicRenderer render = new BasicRenderer(standingAnimation,standingAnimation,standingAnimation);
BasicRenderer render = new BasicRenderer(standingAnimation,movingAnimation,swimmingAnimation);
ExtendedNPC npc = new ExtendedNPC(null, render, new Microsoft.Xna.Framework.Vector2(13, 15) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender));
}
public virtual StandardCharacterAnimation generateCharacterAnimation(AssetSheet body, AssetSheet eyes, AssetSheet hair, AssetSheet shirt, AssetSheet pants, AssetSheet shoes,List<AssetSheet> accessories, AnimationType animationType)
{
var bodySprite = getSpriteCollectionFromSheet(body, animationType);
var eyesSprite = getSpriteCollectionFromSheet(eyes, animationType);
var hairSprite = getSpriteCollectionFromSheet(hair, animationType);
var shirtSprite = getSpriteCollectionFromSheet(shirt, animationType);
var pantsSprite = getSpriteCollectionFromSheet(pants, animationType);
var shoesSprite = getSpriteCollectionFromSheet(shoes, animationType);
List<AnimatedSpriteCollection> accessoryCollection = new List<AnimatedSpriteCollection>();
foreach (var v in accessories)
{
AnimatedSpriteCollection acc = getSpriteCollectionFromSheet(v, AnimationType.standing);
accessoryCollection.Add(acc);
}
StandardCharacterAnimation standingAnimation = new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection);
return standingAnimation;
}
/*
public void generateNPC(string assetManagerName,Genders gender, Seasons season, int minNumOfAccessories,int maxNumOfAccessories)

View File

@ -1,4 +1,5 @@
using CustomNPCFramework.Framework.Enums;
using CustomNPCFramework.Framework.Graphics.TextureGroups;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
@ -27,12 +28,9 @@ namespace CustomNPCFramework.Framework.Graphics
public AssetSheet(AssetInfo info,string path,Direction direction=Direction.down)
{
this.assetInfo = info;
this.textures = new TextureGroup(info,path,direction);
this.path = Class1.getShortenedDirectory(path);
this.index = 0;
}
public virtual KeyValuePair<string, Texture2D> getPathTexturePair()

View File

@ -28,7 +28,7 @@ namespace CustomNPCFramework.Framework.Graphics
/// <param name="randomizeOnLoad"></param>
/// <param name="Gender">The type of gender this asset will be associated with.</param>
/// <param name="Season">The type of season this asset will be associated with.</param>
public ExtendedAssetInfo(string name,NamePairings pair,Vector2 assetSize, bool randomizeOnLoad, Genders Gender, List<Seasons> Season, PartType Type): base(name,pair, assetSize, randomizeOnLoad)
public ExtendedAssetInfo(string name, NamePairings StandingAssetPaths, NamePairings MovingAssetPaths, NamePairings SwimmingAssetPaths, NamePairings SittingAssetPaths, Vector2 assetSize, bool randomizeOnLoad, Genders Gender, List<Seasons> Season, PartType Type): base(name,StandingAssetPaths,MovingAssetPaths,SwimmingAssetPaths,SittingAssetPaths, assetSize, randomizeOnLoad)
{
this.gender = Gender;
this.seasons = Season;