using UnityEngine;
using System.Collections;

public class MainBody : MonoBehaviour
{
    InputUnit input;
    public StateMachine sm;
    public Transform halo;
    public Transform sphere;
    public ParticleSystem parti;
    public ParticleSystem parti_2;
    [Header("1D")]
    public float vanishDuration = 0.5f;
    public float speed_1 = 5;
    public Sprite normal;
    public Sprite click;
    [Header("2D")]
    public float speed_2 = 7;
    public float rotate_2 = 360;
    [Header("3D")]
    public float speed_3 = 15;
    public float rotate_3 = 360;
    [Space]
    public float minRadius = 0.2f;
    public float maxRadius = 4.5f;
    public float radiusDelta = 2f;
    // Use this for initialization
	void Awake()
	{
		sm = new StateMachine(this);
		
	}
    void Start()
    {
        input = GetComponentInChildren<InputUnit>();
       // parti.Stop();
       // parti_2.Stop();
        sphere.GetComponent<TrailRenderer>().enabled = false;
    }

    // Update is called once per frame
    void Update()
    {
        sm.Update();
        parti.transform.position = sphere.position;
        parti_2.transform.position = sphere.position;
    }

    public void ChangeState(State state)
    {
        switch (state)
        {
            case State.OneD:
                sm.SwitchTo<MainBodyStateOneD>();
                break;
            case State.TwoD:
                sm.SwitchTo<MainBodyStateTwoD>();
                break;
            case State.ThreeD:
                sm.SwitchTo<MainBodyStateThreeD>();
                break;
            default:
                break;
        }
    }
    public void MoveSelf(float speed)
    {
        transform.Translate(Vector2.right * speed * Time.deltaTime);
    }
    public void RotateSelf(float speed)
    {
        transform.Rotate(Vector2.right * speed * Time.deltaTime);
    }
    public enum State
    {
        OneD, TwoD, ThreeD,
    }
}
