diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index a666b961..bf42db8c 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -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() + 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.spring, Seasons.summer diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs index a326bf22..da3239ca 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs @@ -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; diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs index 7c6d223e..e52d930b 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs @@ -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 accessoryCollection = new List(); - 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 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 accessoryCollection = new List(); + 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) diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs index 875ab188..7d2c1b13 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs @@ -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 getPathTexturePair() diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs index 09521a8e..161ac213 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs @@ -28,7 +28,7 @@ namespace CustomNPCFramework.Framework.Graphics /// /// The type of gender this asset will be associated with. /// The type of season this asset will be associated with. - public ExtendedAssetInfo(string name,NamePairings pair,Vector2 assetSize, bool randomizeOnLoad, Genders Gender, List 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 Season, PartType Type): base(name,StandingAssetPaths,MovingAssetPaths,SwimmingAssetPaths,SittingAssetPaths, assetSize, randomizeOnLoad) { this.gender = Gender; this.seasons = Season;