package com.adoria.river;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

/**
 * Created by cemancini on 16/10/2015.
 */
public class Commons {
    public int cameraW;
    public int cameraH;
    public int generalSpeedY;
    public TextureAtlas atlas;
    public TextureRegion[] regionsWoods;
    public TextureRegion[] regionsFishes;
    public TextureRegion[] regionsWater;
    public float generalSpeed;
    public float generalSpeedBoat;

    static Commons instance = null;

    public static Commons getInstance(){
        if(instance == null){
            instance = new Commons();
        }

        return instance;
    }

    public Commons(){
        cameraW = 720;
        cameraH = 1280;
        generalSpeedY = -220;
        generalSpeed = 1.0f;
        generalSpeedBoat = 1.0f;
    }

    public void update(float delta){
        if(generalSpeed <= 1.0004) {
            generalSpeed += (delta / 270000f);
            generalSpeedBoat += (delta / 287000f);
        }
    }

    public void restartSpeeds(){
        generalSpeed = 1.0f;
        generalSpeedBoat = 1.0f;
    }

    public void reloadTextures(){
        atlas = new TextureAtlas("textures/textures.atlas");

        regionsWoods = new TextureRegion[3];
        regionsWoods[0] = atlas.findRegion("wood1");
        regionsWoods[1] = atlas.findRegion("wood3");
        regionsWoods[2] = atlas.findRegion("wood5");

        regionsFishes = new TextureRegion[4];
        regionsFishes[0] = atlas.findRegion("fish5");
        regionsFishes[1] = atlas.findRegion("fish6");
        regionsFishes[2] = atlas.findRegion("fish7");
        regionsFishes[3] = atlas.findRegion("fish8");

        regionsWater = new TextureRegion[2];
        regionsWater[0] = atlas.findRegion("water1");
        regionsWater[1] = atlas.findRegion("water2");
    }
}
