Exemplo n.º 1
0
    IEnumerable PerformRotation(FaceRotation rot, float duration)
    {
        _cubelets = PerformRotationOnCubelets(_cubelets, rot, setParent: true);

        var elapsed = 0f;

        while (elapsed < duration)
        {
            yield return(null);

            var delta = Time.deltaTime;
            elapsed += delta;
            OnAxis.localRotation = rot.Rotation(Easing.OutSine(elapsed, 0, 90, duration));
        }
        OnAxis.localRotation = rot.Rotation(90);

        for (int x = 0; x < 3; x++)
        {
            for (int y = 0; y < 3; y++)
            {
                for (int z = 0; z < 3; z++)
                {
                    if (x != 1 || y != 1 || z != 1)
                    {
                        _cubelets[x, y, z].Cubelet.parent = OffAxis;
                    }
                }
            }
        }

        OnAxis.localEulerAngles = new Vector3(0, 0, 0);
    }
Exemplo n.º 2
0
    CubeletInfo[,,] PerformRotationOnCubelets(CubeletInfo[,,] cubelets, FaceRotation rot, bool setParent = false)
    {
        var newCubelets = new CubeletInfo[3, 3, 3];

        for (int x = 0; x < 3; x++)
        {
            for (int y = 0; y < 3; y++)
            {
                for (int z = 0; z < 3; z++)
                {
                    if (x != 1 || y != 1 || z != 1)
                    {
                        if (rot.OnAxis(x, y, z))
                        {
                            if (setParent)
                            {
                                cubelets[x, y, z].Cubelet.parent = OnAxis;
                            }
                            var otherCubelet = cubelets[rot.MapX(x, y, z), rot.MapY(x, y, z), rot.MapZ(x, y, z)];
                            newCubelets[x, y, z] = new CubeletInfo(otherCubelet.Cubelet, rot.Rotation(90) * otherCubelet.Rotation);
                        }
                        else
                        {
                            newCubelets[x, y, z] = cubelets[x, y, z];
                        }
                    }
                }
            }
        }
        return(newCubelets);
    }