public void AddWeapons(ICharacterSpriteDefinition character)
        {
            var hand = Hand.Right;

            if (RandomHelper.Random.Next(0, 100) > 80)
            {
                hand = Hand.Both;
            }

            var weapons = GetSprites(SpriteLayer.Weapon, Race.Any, character.Gender).ToList();

            weapons = weapons.Where(s => s.Tags.Contains(hand.ToString(), StringComparer.OrdinalIgnoreCase))
                      .ToList();

            if (weapons.Count > 0)
            {
                character.AddLayer(weapons[RandomHelper.Random.Next(0, weapons.Count)]);
            }

            if (hand == Hand.Right && RandomHelper.Random.Next(0, 100) > 50)
            {
                var shields = GetSprites(SpriteLayer.Shield, Race.Any, character.Gender).ToList();
                if (shields.Count > 0)
                {
                    character.AddLayer(shields[RandomHelper.Random.Next(0, shields.Count)]);
                }
            }
        }
 public void AddArmor(ICharacterSpriteDefinition character, ArmorType armorType)
 {
     AddArmorLayer(character, SpriteLayer.Greaves, armorType);
     AddArmorLayer(character, SpriteLayer.Shoulders, armorType);
     AddArmorLayer(character, SpriteLayer.Clothes, armorType);
     AddArmorLayer(character, SpriteLayer.Hats, armorType);
 }
        private void AddClothesLayer(ICharacterSpriteDefinition character, SpriteLayer layer)
        {
            var sprites = GetSprites(layer, Race.Any, character.Gender).ToList();

            sprites = sprites.Where(s => !s.Tags.Contains("chain") && !s.Tags.Contains("leather") && !s.Tags.Contains("plate") &&
                                    !s.Tags.Contains("overskirt") && !s.Tags.Contains("overskirtDark")).ToList();

            if (sprites.Count > 0)
            {
                character.AddLayer(sprites[RandomHelper.Random.Next(0, sprites.Count)]);
            }
        }
        public void AddClothes(ICharacterSpriteDefinition character)
        {
            AddClothesLayer(character, SpriteLayer.Legs);
            AddClothesLayer(character, SpriteLayer.Belts);
            AddClothesLayer(character, SpriteLayer.Buckles);
            AddClothesLayer(character, SpriteLayer.Clothes);

            if (RandomHelper.Random.Next(0, 100) > 80)
            {
                AddClothesLayer(character, SpriteLayer.Hats);
            }
        }
        private void AddArmorLayer(ICharacterSpriteDefinition character, SpriteLayer layer, ArmorType armorType)
        {
            var sprites = GetSprites(layer, Race.Any, character.Gender).ToList();

            if (layer != SpriteLayer.Greaves && layer != SpriteLayer.Shoulders)
            {
                sprites = sprites.Where(s => s.Tags.Contains(armorType.ToString(), StringComparer.OrdinalIgnoreCase)).ToList();
            }

            if (sprites.Count > 0)
            {
                character.AddLayer(sprites[RandomHelper.Random.Next(0, sprites.Count)]);
            }
        }
        public CharacterSpriteSheet(ICharacterSpriteDefinition characterSprite)
        {
            Texture = TextureRenderer.GetFullSheetTexture(characterSprite);

            foreach (var renderConstant in Settings.SpriteSheetAnimationDefinition)
            {
                if (!_animationDictionary.ContainsKey(renderConstant.Key.animation))
                {
                    _animationDictionary.Add(renderConstant.Key.animation, new Dictionary <Orientation, Sprite[]>());
                }
                var sprites = new Sprite[renderConstant.Value.frames];
                for (int frame = 0; frame < renderConstant.Value.frames; frame++)
                {
                    sprites[frame] = Sprite.Create(Texture, new Rect(frame * Settings.SpriteWidth,
                                                                     (20 - renderConstant.Value.row) * Settings.SpriteHeight,
                                                                     Settings.SpriteWidth,
                                                                     Settings.SpriteHeight),
                                                   new Vector2(0.5f, 0.5f),
                                                   Settings.PixelsPerUnit);
                }
                _animationDictionary[renderConstant.Key.animation].Add(renderConstant.Key.orientation, sprites);
            }
        }
 public static Texture2D GetPartialSpriteSheet(ICharacterSpriteDefinition sprite, Interfaces.Animation animation, Orientation orientation)
 {
     var(row, _) = Settings.SpriteSheetAnimationDefinition[(animation, orientation)];
 public static Texture2D GetFullSheetTexture(ICharacterSpriteDefinition sprite)
 {
     return(GetSpriteSheet(sprite, new RectInt(0, 0, Settings.SheetWidth, Settings.SheetHeight)));
 }
 public static Image GetPartialSpriteSheet(ICharacterSpriteDefinition sprite, Animation animation, Orientation orientation)
 {
     var(row, _) = Settings.SpriteSheetAnimationDefinition[(animation, orientation)];
 public static Image GetFullSpriteSheet(ICharacterSpriteDefinition sprite)
 {
     return(GetSpriteSheet(sprite, new Rectangle(0, 0, Settings.SheetWidth, Settings.SheetHeight)));
 }