spaceconquest.Warship.Attack C# (CSharp) Method

Attack() public method

public Attack ( Unit u ) : void
u Unit
return void
        public void Attack(Unit u)
        {
            double x = u.getCenter().X - hex.getCenter().X;
            double y = hex.getCenter().Y - u.getCenter().Y;
            targetangle = Math.Atan(x / y);
            if (y < 0) targetangle = targetangle + Math.PI;

            u.hit(damage);

            firingsource = this.getCenter();
            firingpercent = 0;
            firingtarget = u.getCenter();
            firinganimation = true;
        }