using UnityEngine;
using System.Collections;

public class MainBodyStateTwoD : FiniteState
{
    MainBody self;
    float radius;
    float speed = 10;
    public override void Init()
    {
        self = subject as MainBody;
        self.StopAllCoroutines();
        self.sphere.gameObject.SetActive(true);
        self.sphere.GetComponent<TrailRenderer>().enabled = true;
        self.sphere.GetComponent<MeshRenderer>().enabled = true;
        radius = self.transform.localPosition.z;
        self.halo.gameObject.SetActive(false);
        self.sphere.GetComponent<SphereCollider>().radius = 0.5f;
    }
    public override void Update()
    {
        if (Input.GetMouseButton(0))
        {
            radius = Mathf.Clamp(radius + self.radiusDelta * Time.deltaTime, self.minRadius, self.maxRadius);
        }
        else
        {
            radius = Mathf.Clamp(radius - self.radiusDelta * Time.deltaTime, self.minRadius, self.maxRadius);
        }
        //assign zAxis by radius
        Vector3 local = self.sphere.localPosition;
        local.z = radius;
        self.sphere.localPosition = local;
        self.MoveSelf(speed);
        self.RotateSelf(self.rotate_2);
        //self.halo.position = self.sphere.position;
        //self.halo.eulerAngles = new Vector3(0, self.halo.eulerAngles.y, self.halo.eulerAngles.z);
    }
}
