/// <summary> /// Initializes a new instance of the <see cref="NPCUnit"/> class. /// </summary> /// <param name="name"> The name. </param> /// <param name="x"> The x location of the unit. </param> /// <param name="y"> The y location of the unit. </param> /// <param name="sprite"> The sprite. </param> /// <param name="unitClass"> The class of the unit. </param> public NPCUnit(string name, int x, int y, AnimatedSprite sprite, UnitClass unitClass) : base(name, x, y, sprite, unitClass) { }
/// <summary> /// Initializes a new instance of the <see cref="NPCUnit"/> class. /// </summary> /// <param name="id"> The id of the unit. </param> /// <param name="name"> The name. </param> /// <param name="position"> The position of the unit. </param> /// <param name="sprite"> The sprite. </param> /// <param name="unitClass"> The class of the unit. </param> public NPCUnit(int id, string name, Vector position, AnimatedSprite sprite, UnitClass unitClass) : base(id, name, position, sprite, unitClass) { }
/// <summary> /// Makes a sprite from the given string. /// </summary> /// <param name="faction"> "Ally" or "Enemy". </param> /// <param name="spriteSheet"> The name of the sprite sheet. </param> /// <param name="spriteHeight"> The height of each sprite. </param> /// <param name="spriteWidth"> The width of each sprite. </param> /// <returns> /// An AnimatedSprite based on the spritesheet. /// </returns> private AnimatedSprite MakeSprite(string faction, string spriteSheet, int spriteHeight, int spriteWidth) { var animations = new Dictionary<AnimationKey, Animation>(); var animation = new Animation(4, spriteHeight, spriteWidth, 0, 0); animations.Add(AnimationKey.Idle, animation); animation = new Animation(4, spriteHeight, spriteWidth, 0, spriteWidth); animations.Add(AnimationKey.Selected, animation); animation = new Animation(4, spriteHeight, spriteWidth, 0, spriteWidth * 2); animations.Add(AnimationKey.Left, animation); animation = new Animation(4, spriteHeight, spriteWidth, 0, spriteWidth * 3); animations.Add(AnimationKey.Down, animation); animation = new Animation(4, spriteHeight, spriteWidth, 0, spriteWidth * 4); animations.Add(AnimationKey.Up, animation); animation = new Animation(4, spriteHeight, spriteWidth, 0, spriteWidth * 5); animations.Add(AnimationKey.Right, animation); var sprite = new AnimatedSprite( this.Content.Load<Texture2D>(@"Textures\Sprites\" + faction + "\\" + spriteSheet), animations); return sprite; }