using UnityEngine;
using System.Collections;

public class MainBodyStateThreeD : FiniteState
{
    MainBody self;
    float radius;
    public override void Init()
    {
        self = subject as MainBody;
        self.StopAllCoroutines();
        self.sphere.gameObject.SetActive(true);
        radius = self.sphere.transform.localPosition.z;
        self.parti_2.Play();
        self.sphere.GetComponent<SphereCollider>().radius = 1f;
        self.sphere.GetComponent<MeshRenderer>().enabled = true;
    }

    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(self.speed_3);
        self.RotateSelf(self.rotate_3);
    }
}
