/// <summary>Construct an instance.</summary> /// <param name="standingAnimation">The animation information to be used when the character is standing.</param> /// <param name="walkingAnimation">The animation information to be used when the character is walking/moving.</param> /// <param name="swimmingAnimation">The animation information to be used when the character is walking/moving.</param> public BasicRenderer(StandardCharacterAnimation standingAnimation, StandardCharacterAnimation walkingAnimation, StandardCharacterAnimation swimmingAnimation) { this.animationList = new Dictionary <string, StandardCharacterAnimation>(); this.animationList.Add(AnimationKeys.standingKey, standingAnimation); this.animationList.Add(AnimationKeys.walkingKey, walkingAnimation); this.animationList.Add(AnimationKeys.swimmingKey, swimmingAnimation); this.setAnimation(AnimationKeys.standingKey); }
/// <summary> /// Sets the animation associated with the key name; If it fails the npc will just default to standing. /// </summary> /// <param name="key"></param> public virtual void setAnimation(string key) { this.currentAnimation = animationList[key]; if (this.currentAnimation == null) { this.setAnimation(AnimationKeys.standingKey); } }
/// <summary>Sets the animation associated with the key name; If it fails the npc will just default to standing.</summary> /// <param name="key">The name of the animation to swap the current animation to.</param> public virtual void setAnimation(string key) { this.currentAnimation = this.animationList[key]; if (this.currentAnimation == null) { Class1.ModMonitor.Log("ERROR SETTING AN ANIMATION: " + key); this.setAnimation(AnimationKeys.standingKey); } }
/// <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> 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(); } // Get all of the appropriate animations. StandardCharacterAnimation standingAnimation = this.generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, AnimationType.standing, drawColors); StandardCharacterAnimation movingAnimation = this.generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, AnimationType.walking, drawColors); StandardCharacterAnimation swimmingAnimation = this.generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, AnimationType.swimming, drawColors); return(new BasicRenderer(standingAnimation, movingAnimation, swimmingAnimation)); }
/// <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); 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); } if (DrawColors == null) { DrawColors = new StandardColorCollection(); } StandardCharacterAnimation standingAnimation = new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection, DrawColors); return(standingAnimation); }