package app.brest.utils.app.brest.game;

import android.app.Activity;

import java.io.Serializable;

import app.brest.testmin3d.ARActivity;
import app.brest.utils.SensorsManager;
import app.brest.utils.geometry.GPSPoint;

/**
 * Created by ptitcois on 20/08/16.
 */
public class Player implements Serializable{
    protected transient SensorsManager mSensors;

    public Player(Activity sm)
    {
        mSensors=new SensorsManager(sm);
    }

    public void setSensorsManager(SensorsManager sm)
    {
        mSensors=sm;
    }

    public SensorsManager getSensorsManager()
    {
        return mSensors;
    }

    public void onPause()
    {
        mSensors.onPause();
    }


    public void onResume(ARActivity act)
    {
        mSensors.onResume();
    }

    public GPSPoint getPosition()
    {
        return mSensors.getPosition();
    }

    public float getOrientation()
    {
        return mSensors.getOrientation();
    }

    public float getOrientationX()
    {
        return mSensors.getAzimuth();
    }

    public float getOrientationY()
    {
        return mSensors.getAngleY();
    }


    public float getOrientationZ()
    {
        return mSensors.getAngleZ();
    }

    public double getAngleWith(Place p)
    {
        double d=mSensors.getPosition().getAngleWith(p.getLocation());;
        while(d<0) d+=360;
        return d;
    }

    public double getXWith(Place p)
    {
        return mSensors.getPosition().getDistanceXWith(p.getLocation());
    }

    public double getYWith(Place p)
    {
        return mSensors.getPosition().getDistanceYWith(p.getLocation());
    }

    public double getRelXWith(Place p)
    {
        return mSensors.getPosition().getRelXWith(p.getLocation());
    }

    public double getRelYWith(Place p)
    {
        return mSensors.getPosition().getRelYWith(p.getLocation());
    }

    public void newSensorManager(Activity act)
    {
        mSensors = new SensorsManager(act);
    }

    public void nextStub()
    {
        mSensors.nextStub();
    }
}
