<commit_before>package donnu.zolotarev.SpaceShip.Units;

import android.graphics.Point;
import donnu.zolotarev.SpaceShip.AI.EnemyAI.HeroAI;
import donnu.zolotarev.SpaceShip.Bullets.BaseBullet;
import donnu.zolotarev.SpaceShip.Bullets.BulletColorRandomizer;
import donnu.zolotarev.SpaceShip.Effects.Shield;
import donnu.zolotarev.SpaceShip.GameData.HeroFeatures;
import donnu.zolotarev.SpaceShip.GameData.Settings;
import donnu.zolotarev.SpaceShip.Textures.TextureLoader;
import donnu.zolotarev.SpaceShip.UI.IHealthBar;
import donnu.zolotarev.SpaceShip.Utils.Constants;
import donnu.zolotarev.SpaceShip.Utils.Utils;
import donnu.zolotarev.SpaceShip.Utils.VibroHelper;
import donnu.zolotarev.SpaceShip.Weapons.*;
import donnu.zolotarev.SpaceShip.Weapons.Modificator.DamageModificator;
import donnu.zolotarev.SpaceShip.Weapons.Modificator.IWeaponModificator;
import org.andengine.engine.camera.hud.controls.AnalogOnScreenControl;
import org.andengine.engine.camera.hud.controls.BaseOnScreenControl;
import org.andengine.engine.handler.physics.PhysicsHandler;
import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.ColorModifier;
import org.andengine.entity.modifier.IEntityModifier;
import org.andengine.entity.sprite.Sprite;
import org.andengine.util.color.Color;
import org.andengine.util.modifier.IModifier;

import java.util.Random;

public class Hero extends BaseUnit {
    private final int MAX_ANGLE = 7;
    private final int SPEED = 500;
    private final Settings settings;
    private int health;

    private boolean isAlive = true;
    private IHealthBar healthBar;
    private HeroFeatures heroFeatures;

    protected RocketController rocketController;

    private float needX;
    private float needY;

    private float acceX = 200;
    private float acceY = 200;


    public Hero(IHealthBar healthBar, final boolean isAnalog) {
        super(0);
        settings = Settings.get();
        this.healthBar = healthBar;
        sprite =  new HeroAI(TextureLoader.getShip(), engine.getVertexBufferObjectManager()){
            @Override
            protected void doAfterUpdate() {
                weaponController.weaponCooldown();
            }

            @Override
            protected void doBeforeUpdate() {
                super.doBeforeUpdate();

                if (!isAnalog){
                    float ang = Utils.getAngle(mX,mY,needX,needY);
                    float dist = Utils.distanceSqr(mX,mY,needX,needY);
                    int R = 900;
                    if ( R < dist ){
                        physicsHandler.setAccelerationX((float) (SPEED * Math.cos(Utils.degreeToRad(ang))));
                        physicsHandler.setAccelerationY((float) (SPEED * Math.sin(Utils.degreeToRad(ang))));
                    }else{
                        if ( 400 < dist ){
                            physicsHandler.setAccelerationX((float) (-1*SPEED * Math.cos(Utils.degreeToRad(ang))));
                            physicsHandler.setAccelerationY((float) (-1*SPEED * Math.sin(Utils.degreeToRad(ang))));
                        } else {
                            physicsHandler.setVelocity(0,0);
                            physicsHandler.setAcceleration(0,0);
                        }
                    }
                }

            }
        };
        hero = this;
        attachToScene();
        heroFeatures = HeroFeatures.get();

      /*  Paint myPaint =  new Paint(Paint.ANTI_ALIAS_FLAG);
        myPaint.setColorFilter(new LightingColorFilter(Color.rgb(120, 176, 209),0));*/
    }

    @Override
    protected void loadWeapon(int level) {
        weaponController = new WeaponController(new WeaponPos[]{
                        new WeaponPos(sprite, 80, 56, 0)});


        Random random = new Random();
        IWeaponModificator[] mode = {new DamageModificator(heroFeatures.getExtraBulletDamege(), IWeaponModificator.Mode.ADD),
                BulletColorRandomizer.getNextColorForHero()};
        IGun gun;
        // todo получаить инко об оружии.
        boolean useD =  heroFeatures.isHaveDoubleAmmo() && heroFeatures.isNeedUseDoubleAmmo();
        if (useD){
            heroFeatures.useDoubleGun();
            gun =  new DoubleGun(true, BaseBullet.TYPE_SIMPLE_BULLET,mode);
        }else{<commit_msg>added rotate angle in touch mode<commit_after>package donnu.zolotarev.SpaceShip.Units;

import android.graphics.Point;
import donnu.zolotarev.SpaceShip.AI.EnemyAI.HeroAI;
import donnu.zolotarev.SpaceShip.Bullets.BaseBullet;
import donnu.zolotarev.SpaceShip.Bullets.BulletColorRandomizer;
import donnu.zolotarev.SpaceShip.Effects.Shield;
import donnu.zolotarev.SpaceShip.GameData.HeroFeatures;
import donnu.zolotarev.SpaceShip.GameData.Settings;
import donnu.zolotarev.SpaceShip.Textures.TextureLoader;
import donnu.zolotarev.SpaceShip.UI.IHealthBar;
import donnu.zolotarev.SpaceShip.Utils.Constants;
import donnu.zolotarev.SpaceShip.Utils.Utils;
import donnu.zolotarev.SpaceShip.Utils.VibroHelper;
import donnu.zolotarev.SpaceShip.Weapons.*;
import donnu.zolotarev.SpaceShip.Weapons.Modificator.DamageModificator;
import donnu.zolotarev.SpaceShip.Weapons.Modificator.IWeaponModificator;
import org.andengine.engine.camera.hud.controls.AnalogOnScreenControl;
import org.andengine.engine.camera.hud.controls.BaseOnScreenControl;
import org.andengine.engine.handler.physics.PhysicsHandler;
import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.ColorModifier;
import org.andengine.entity.modifier.IEntityModifier;
import org.andengine.entity.sprite.Sprite;
import org.andengine.util.color.Color;
import org.andengine.util.modifier.IModifier;

import java.util.Random;

public class Hero extends BaseUnit {
    private final int MAX_ANGLE = 7;
    private final int SPEED = 500;
    private final Settings settings;
    private int health;

    private boolean isAlive = true;
    private IHealthBar healthBar;
    private HeroFeatures heroFeatures;

    protected RocketController rocketController;

    private float needX;
    private float needY;

    private float acceX = 200;
    private float acceY = 200;


    public Hero(IHealthBar healthBar, final boolean isAnalog) {
        super(0);
        settings = Settings.get();
        this.healthBar = healthBar;
        sprite =  new HeroAI(TextureLoader.getShip(), engine.getVertexBufferObjectManager()){
            @Override
            protected void doAfterUpdate() {
                weaponController.weaponCooldown();
            }

            @Override
            protected void doBeforeUpdate() {
                super.doBeforeUpdate();

                if (!isAnalog){
                    float ang = (float)Utils.degreeToRad(Utils.getAngle(mX, mY, needX, needY));
                    float dist = Utils.distanceSqr(mX,mY,needX,needY);
                    int R = 900;
                    float angR = (float)(MAX_ANGLE*Math.sin(ang));
                    if ( R < dist ){
                        physicsHandler.setAccelerationX((float) (SPEED * Math.cos(ang)));
                        physicsHandler.setAccelerationY((float) (SPEED * Math.sin(ang)));
                    }else{
                        if ( 400 < dist ){
                            physicsHandler.setAccelerationX((float) (-1*SPEED * Math.cos(ang)));
                            physicsHandler.setAccelerationY((float) (-1*SPEED * Math.sin(ang)));
                            angR /= 2;
                        } else {
                            angR = 0;
                            physicsHandler.setVelocity(0,0);
                            physicsHandler.setAcceleration(0,0);
                        }
                    }

                    sprite.setRotateAngle(angR);
                }

            }
        };
        hero = this;
        attachToScene();
        heroFeatures = HeroFeatures.get();

      /*  Paint myPaint =  new Paint(Paint.ANTI_ALIAS_FLAG);
        myPaint.setColorFilter(new LightingColorFilter(Color.rgb(120, 176, 209),0));*/
    }

    @Override
    protected void loadWeapon(int level) {
        weaponController = new WeaponController(new WeaponPos[]{
                        new WeaponPos(sprite, 80, 56, 0)});


        Random random = new Random();
        IWeaponModificator[] mode = {new DamageModificator(heroFeatures.getExtraBulletDamege(), IWeaponModificator.Mode.ADD),
                BulletColorRandomizer.getNextColorForHero()};
        IGun gun;
        // todo получаить инко об оружии.
        boolean useD =  heroFeatures.isHaveDoubleAmmo() && heroFeatures.isNeedUseDoubleAmmo();
        if (useD){
            heroFeatures.useDoubleGun();
            gun =  new DoubleGun(true, BaseBullet.TYPE_SIMPLE_BULLET,mode);
        }else{
{'fraction_non_alphanumeric': 0.09598163030998852, 'fraction_numerical': 0.008955223880597015, 'mean_word_length': 2.499799116110888, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4730820', 'n_tokens_mistral': 2696, 'n_tokens_neox': 2565, 'n_words': 445}