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


namespace ActionGame.GameArtifacts.Operators.Items
{
    public class Clawer
    {
        private IRawContentManager rawContentManager;
        private GameData gameData;
        private Boolean isFixedAttackPower;
        private Int32 attackPower;


        public Clawer(IRawContentManager rawContentManager, GameData gameData, Boolean isFixedAttackPower, Int32 attackPower)
        {
            this.rawContentManager = rawContentManager;
            this.gameData = gameData;
            this.isFixedAttackPower = isFixedAttackPower;
            this.attackPower = attackPower;
        }


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

            Claw claw = new Claw(rawContentManager, gameData, caster, caster.WorldPosition, attack);

            //starting position
            claw.WorldPosition.PositionY += 1;

            //modify position based on direction
            Vector2 direction = caster.CharacterSet.GetDirection();
            Int32 dx = 0;
            Int32 dy = 0;
            if (direction.Y == 1)
            {
                dy = claw.SIZE;
            }
            else if (direction.Y == -1)
            {
                dy = claw.SIZE * -1;
            }
            else if (direction.X == -1)
            {
                dx = claw.SIZE * -1;
            }
            else if (direction.X == 1)
            {
                dx = claw.SIZE;
            }

            claw.WorldPosition.PositionX += dx;
            claw.WorldPosition.PositionY += dy;

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

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