using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HumanLikeBattleRobots.Graphic;

namespace HumanLikeBattleRobots.Logic
{
    class RoboBomb : EnemyRobot, ICollidable
    {
        public RoboBomb(Vec2f position) : base(position) { }

        public override void Proceed(double delta)
        {    
            base.Proceed(delta);
            Vec2f aimVector = myRobotPosition - this.Position;

            if (aimVector.Length() < 800)
                this.speedDirection = -1;
            else
                this.speedDirection = 0;

            this.rotationDirection = -Math.Sign((aimVector.X * this.Normal.Y
               - aimVector.Y * this.Normal.X));

            if (aimVector.Length() < 80)
                Explode();
        }

        private void Explode()
        {
            this.health = 0;
            (GameManager.myRobot as ICollidable).GetDamage(20);
            // и нанести дамаг игроку
        }

        protected override void SetParams()
        {
            float angle = 0;

            health = 0.5f;
            forwardSpeed = 300;
            backwardSpeed = 300;
            forwardAngularVelocity = 1.0f;
            backwardAngularVelocity = 0.7f;
            size = 20;
            legs = new MineLegs(this.position, angle, sprites);
            body = new MineBodySprite(2);
            shadow = new RobotShadowSmallSprite(0);
            sprites[body.Stage - 1].Add(body);
        }

        void ICollidable.GetDamage(float damage)
        {
            health -= damage / 5;
        }
    }
}
