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;
using Microsoft.Xna.Framework.Audio;
using System;
using System.Collections.Generic;

namespace ActionGame.GameArtifacts.Operators.Items
{
    public class DynamiteThrower
    {
        private IRawContentManager rawContentManager;
        private GameData gameData;
        private Boolean isFixedAttackPower;
        private Int32 attackPower;
        private IList<IBattleObject> ignoredObjects;


        public DynamiteThrower(IRawContentManager rawContentManager, GameData gameData, Boolean isFixedAttackPower, Int32 attackPower, IList<IBattleObject> ignoredObjects)
        {
            this.rawContentManager = rawContentManager;
            this.gameData = gameData;
            this.isFixedAttackPower = isFixedAttackPower;
            this.attackPower = attackPower;
            this.ignoredObjects = ignoredObjects;
        }


        public void Do(IBattleObject caster)
        {
            Int32 attack = attackPower;
            if (isFixedAttackPower == false) attack += caster.CharacterStats.Attack;

            ExplosionMaker maker = new ExplosionMaker(rawContentManager, gameData, ignoredObjects);
            WorldPosition position = null;
            Int32 size = 64;
            Int32 buffer = 4;
            Int32 xd = -8;

            //right
            position = caster.WorldPosition.Copy();
            position.PositionX += 64 + buffer + xd;
            maker.Do(position, attack, size);

            //left
            position = caster.WorldPosition.Copy();
            position.PositionX += -48 - buffer + xd;
            maker.Do(position, attack, size);

            //up
            position = caster.WorldPosition.Copy();
            position.PositionX += 8 + xd;
            position.PositionY += -56 - buffer;
            maker.Do(position, attack, size);

            //down
            position = caster.WorldPosition.Copy();
            position.PositionX += 8 + xd;
            position.PositionY += 52 + buffer;
            maker.Do(position, attack, size);

            //right down
            position = caster.WorldPosition.Copy();
            position.PositionX += 64 + buffer + xd;
            position.PositionY += 52 + buffer;
            maker.Do(position, attack, size);

            //left down
            position = caster.WorldPosition.Copy();
            position.PositionX += -48 - buffer + xd;
            position.PositionY += 52 + buffer;
            maker.Do(position, attack, size);

            //right up
            position = caster.WorldPosition.Copy();
            position.PositionX += 64 + buffer + xd;
            position.PositionY += -56 - buffer;
            maker.Do(position, attack, size);

            //left up
            position = caster.WorldPosition.Copy();
            position.PositionX += -48 - buffer + xd;
            position.PositionY += -56 - buffer;
            maker.Do(position, attack, size);
        }

    }
}
