package donnu.zolotarev.SpaceShip.Scenes;

import android.view.KeyEvent;
import donnu.zolotarev.SpaceShip.GameData.HeroFeatures;
import donnu.zolotarev.SpaceShip.GameState.IParentScene;
import donnu.zolotarev.SpaceShip.Scenes.Interfaces.ISimpleClick;
import donnu.zolotarev.SpaceShip.SpaceShipActivity;
import donnu.zolotarev.SpaceShip.Textures.TextureLoader;
import donnu.zolotarev.SpaceShip.Utils.Constants;
import donnu.zolotarev.SpaceShip.Utils.HALIGMENT;
import donnu.zolotarev.SpaceShip.Utils.MenuFactory;
import donnu.zolotarev.SpaceShip.Utils.WALIGMENT;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.menu.MenuScene;

public class ShopScene extends MyScene {
    private final Scene sceneMain;
    private final Scene entity;
    private final IParentScene parentScene;
    private MenuScene scene;
    private ISimpleClick lAddHealth;

    public ShopScene(Scene entity,IParentScene parentScene) {
        super(parentScene);
        this.parentScene = parentScene;
        this.entity = entity;
        sceneMain = new Scene();
        createUI();
    }

    private void createUI() {
        lAddHealth = new ISimpleClick() {
            @Override
            public void onClick(int id) {
                HeroFeatures heroFeatures =  HeroFeatures.get();
                heroFeatures.setMaxHealth(heroFeatures.getMaxHealth()+200);
            }
        };

        SpaceShipActivity activity =  SpaceShipActivity.getInstance();
        scene = MenuFactory.createMenu(activity.getEngine(), activity.getCamera())
                .addedText("Магазин", TextureLoader.getFont(), Constants.CAMERA_WIDTH_HALF, 50, WALIGMENT.CENTER,
                        HALIGMENT.CENTER)
                .addedText("Броня: ", TextureLoader.getFont(), Constants.CAMERA_WIDTH/4, 100, WALIGMENT.LEFT,
                        HALIGMENT.CENTER)
                .addedText("+", TextureLoader.getFontBig(),lAddHealth, (Constants.CAMERA_WIDTH*3)/4, 100, WALIGMENT.LEFT,
                        HALIGMENT.CENTER)
                .enableAnimation()
                .build();


        sceneMain.setBackgroundEnabled(false);
        entity.setChildScene(sceneMain);
        show();
    }

    public void show(){
        sceneMain.setChildScene(scene,false,true,true);
    }

    public void hide(){
        sceneMain.back();

    }

    @Override
    public void onKeyPressed(int keyCode, KeyEvent event) {
       // hide();
        parentScene.returnToParentScene(IParentScene.EXIT_SHOP);
    }
}

@@ -645,16 +645,55 @@
 nuScene;
+%0Aimport org.andengine.entity.text.Text;
 %0A%0Apublic
@@ -903,16 +903,82 @@
 dHealth;
+%0A    private Text goldBar;%0A    private SpaceShipActivity activity;
 %0A%0A    pu
@@ -1407,16 +1407,64 @@
         
+ // TODO %D0%BE%D1%82%D0%BD%D0%B8%D0%BC%D0%B0%D1%82%D1%8C %D0%B4%D0%B5%D0%BD%D1%8C%D0%B3%D0%B8%0A                int h =
  heroFea
@@ -1469,17 +1469,17 @@
 eatures.
-s
+g
 etMaxHea
@@ -1482,16 +1482,39 @@
 xHealth(
+)+200;%0A                
 heroFeat
@@ -1510,33 +1510,33 @@
    heroFeatures.
-g
+s
 etMaxHealth()+20
@@ -1531,21 +1531,70 @@
 xHealth(
-)+200
+h);%0A                goldBar.setText( String.valueOf(h)
 );%0A     
@@ -1622,34 +1622,16 @@
         
-SpaceShipActivity 
 activity
@@ -2042,38 +2042,35 @@
       HALIGMENT.
-CENTER
+TOP
 )%0A              
@@ -2325,24 +2325,49 @@
 led(false);%0A
+        createGoldBar();%0A
         enti
@@ -2410,32 +2410,538 @@
  show();%0A    %7D%0A%0A
+    //todo %D0%BF%D0%B5%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B0%D1%82%D1%8C%0A    private void createGoldBar()%7B%0A        try %7B%0A            int y = 100;%0A            int x = Constants.CAMERA_WIDTH/4+100;%0A            goldBar = new Text(x,y,TextureLoader.getFont(),%220000%22,activity.getEngine().getVertexBufferObjectManager());%0A            goldBar.setPosition(x,y);%0A            scene.attachChild(goldBar);%0A            goldBar.setText(String.valueOf(HeroFeatures.get().getMaxHealth()));%0A        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A%0A
     public void 

update health view in shop