package de.frajul.endlessroll.main.screens;

import android.view.MotionEvent;
import android.view.View;

import de.frajul.endlessroll.entities.particles.ParticleSystem;
import de.frajul.endlessroll.entities.textures.TexturePack;
import de.frajul.endlessroll.main.GameActivity;
import de.frajul.endlessroll.main.GameLog;
import de.frajul.endlessroll.main.game.TestScreenScene;
import de.frajul.endlessroll.main.game.Timer;
import de.frajul.endlessroll.rendering.Rendering;

/**
 * Created by Julian on 20.07.2016.
 */
public class TestScreenRendering extends Rendering<TestScreenScene> {

    private GameActivity gameActivity;
    private Timer timer;
    private ParticleSystem particleSystem;

    public TestScreenRendering(GameActivity gameActivity) throws Exception{
        super(gameActivity);
        this.gameActivity = gameActivity;
        particleSystem = new ParticleSystem(gameActivity);
    }

    @Override
    public TestScreenScene init(TexturePack texturePack, Timer timer, boolean isFirstTime) {
        this.timer = timer;
        try {
            if (isFirstTime)
                scene = new TestScreenScene(gameActivity, texturePack, particleSystem);
            else
                scene.setTexturePack(texturePack);
        }catch (Exception e){
            GameLog.e(e);
        }
        try {
            particleSystem.loadTextures();
        } catch (Exception e) {
        }
        return scene;
    }

    @Override
    public void update() {
        particleSystem.update(timer);
        scene.update(timer);
    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return false;
    }

}
