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 TomahawkThrower
    {
        private IRawContentManager rawContentManager;
        private GameData gameData;
        private Boolean isFixedAttackPower;
        private Int32 attackPower;


        public TomahawkThrower(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;

            Tomahawk star = new Tomahawk(rawContentManager, gameData, caster, caster.WorldPosition, attack);

            //movement physics
            Vector2 direction = caster.CharacterSet.GetDirection();
            Int32 speed = 8;
            Vector2 velocity = direction * speed;

            star.MovementPhysics.VelocityX = velocity.X;
            star.MovementPhysics.VelocityY = velocity.Y;

            //starting position
            if (direction.X != 0)
            {
                star.WorldPosition.PositionY -= 1;
            }

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

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


    }
}
