using ActionGame.GameArtifacts.Models.Characters;
using ActionGame.GameArtifacts.Models.Game;
using ActionGame.GameArtifacts.Models.WeaponSprites;
using ActionGame.GameResources.Models;
using ActionGame.RawResources.Manager;
using Microsoft.Xna.Framework.Audio;
using System;
using System.Collections.Generic;

namespace ActionGame.GameArtifacts.Operators.Items
{
    public class ExplosionMaker
    {
        private IRawContentManager rawContentManager;
        private GameData gameData;
        private IList<IBattleObject> ignoredObjects;


        public ExplosionMaker(IRawContentManager rawContentManager, GameData gameData, IList<IBattleObject> ignoredObjects)
        {
            this.rawContentManager = rawContentManager;
            this.gameData = gameData;
            this.ignoredObjects = ignoredObjects;
        }


        public void Do(WorldPosition position, Int32 attack, Int32 size)
        {
            Explosion explosion = new Explosion(rawContentManager, gameData, position, attack, size, ignoredObjects);

            //starting position
            explosion.WorldPosition.PositionX += ((-size) / 2) + (TileSet.DRAW_WIDTH / 2);
            explosion.WorldPosition.PositionY += ((size) / 2) - (TileSet.DRAW_WIDTH / 2);

            //add sprite to game
            gameData.GameState.ActiveWeaponSprites.Add(explosion);

            //sound effect
            SoundEffect sound = rawContentManager.SoundEffectRepository.GetContent(@"soundeffects\bomb-explosion");
            sound.Play();
        }

    }
}
