Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (OnPlayer)
        {
            changeColor.ChangeAxisState(ChangeColor.AxisState.OnPlayer);
        }
        if (isRotate)
        {
            float deg        = rotateState == RotateState.NoRotate ? 180.0f : 0;
            float angleSpeed = rotateValue * rotateSpeed * Time.deltaTime;
            angles[(int)rotateAxis] += angleSpeed;
            transform.rotation       = transform.rotation * Quaternion.AngleAxis(angleSpeed, GetAxis());
            Singleton <RotatePointSelector> .Instance.IsRotating = true;
            Singleton <PlayerMove> .Instance.SaveDirection();

            if (IsRotateComplete(angles[(int)rotateAxis], deg))
            {
                angles[(int)rotateAxis] = deg;
                if (rotateState == RotateState.NoRotate)
                {
                    rotateState = RotateState.Rotated;
                }
                else
                {
                    rotateState = RotateState.NoRotate;
                }
                Vector3 ang = transform.rotation.eulerAngles;
                ang.z = deg;
                transform.rotation = Quaternion.Euler(ang);
                Bake();
                Singleton <AxisState> .Instance.NowAxisState         = AxisState.AxisStateEnum.NoRotate;
                Singleton <RotatePointSelector> .Instance.IsRotating = false;
                Singleton <PlayerMove> .Instance.LoadDirection();

                Singleton <SoundManager> .Instance.PlaySeByName("endRotate");

                GameObject efc = Instantiate(effect, transform.position, Quaternion.identity);
                Destroy(efc, 1.0f);
            }
        }
    }