Exemplo n.º 1
0
        private LayerMove IntsToLayerMove(int axis, int power)
        {
            string[]  axes    = new string[] { "U", "R", "F", "D", "L", "B" };
            LayerMove newMove = LayerMove.Parse(string.Format("{0}{1}", axes[axis], power == 3 ? "'" : power == 2 ? "2" : ""));

            return(newMove);
        }
        /// <summary>
        /// Initializes a new instance of the AnimatedLayerMove class
        /// </summary>
        /// <param name="move">Movement that will be performed</param>
        public AnimatedLayerMove(LayerMove move)
        {
            var d = move.Direction;
            if (move.Layer == CubeFlag.TopLayer || move.Layer == CubeFlag.MiddleLayer || move.Layer == CubeFlag.LeftSlice || move.Layer == CubeFlag.FrontSlice || move.Layer == CubeFlag.MiddleSlice) d = !d;
            var rotationTarget = move.Twice ? 180 : 90;
            if (d) rotationTarget *= -1;
            this.Target = rotationTarget;

            this.Move = new LayerMove(move.Layer, move.Direction, move.Twice);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes the given LayerMove
        /// </summary>
        /// <param name="move">Defines the LayerMove to be executed</param>
        private void RotateLayer(LayerMove move)
        {
            int repetitions = move.Twice ? 2 : 1;

            for (int i = 0; i < repetitions; i++)
            {
                IEnumerable <Cube> affected = Cubes.Where(c => c.Position.HasFlag(move.Layer));
                affected.ToList().ForEach(c => c.NextPos(move.Layer, move.Direction));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the AnimatedLayerMove class
        /// </summary>
        /// <param name="move">Movement that will be performed</param>
        public AnimatedLayerMove(LayerMove move)
        {
            bool d = move.Direction;

            if (move.Layer == CubeFlag.TopLayer || move.Layer == CubeFlag.MiddleLayer || move.Layer == CubeFlag.LeftSlice || move.Layer == CubeFlag.FrontSlice || move.Layer == CubeFlag.MiddleSlice)
            {
                d = !d;
            }
            int rotationTarget = move.Twice ? 180 : 90;

            if (d)
            {
                rotationTarget *= -1;
            }
            Target = rotationTarget;

            Move = new LayerMove(move.Layer, move.Direction, move.Twice);
        }
Exemplo n.º 5
0
 public TestScenario(Rubik rubik, LayerMove move) : this(rubik, new Algorithm(move.ToString()))
 {
 }
Exemplo n.º 6
0
 /// <summary>
 /// Executes the given LayerMove
 /// </summary>
 /// <param name="move">Defines the LayerMove to be executed</param>
 private void RotateLayer(LayerMove move)
 {
     int repetitions = move.Twice ? 2 : 1;
       for (int i = 0; i < repetitions; i++)
       {
     IEnumerable<Cube> affected = Cubes.Where(c => c.Position.HasFlag(move.Layer));
     affected.ToList().ForEach(c => c.NextPos(move.Layer, move.Direction));
       }
 }
Exemplo n.º 7
0
 public TestScenario(Rubik rubik, LayerMove move) : this(rubik, new Algorithm(move.ToString())) { }
 /// <summary>
 /// Executes the given LayerMove
 /// </summary>
 /// <param name="move">Defines the LayerMove to be executed</param>
 private void RotateLayer(LayerMove move)
 {
     var repetitions = move.Twice ? 2 : 1;
     for (var i = 0; i < repetitions; i++)
     {
         var affected = this.Cubes.Where(c => c.Position.HasFlag(move.Layer));
         affected.ToList().ForEach(c => c.NextPos(move.Layer, move.Direction));
     }
 }
Exemplo n.º 9
0
 //private Vector2 LoadWinScrollPos;
 // Use this for initialization
 void Start()
 {
     Move = new LayerMove();
     //DupLayer = new LayerDup();
     AutoSave = new Emblem();
     Save = new Emblem();
     AddNewLayer();
 }
Exemplo n.º 10
0
    void RenderLayersPanel()
    {
        if(showLoadWin)
            GUI.enabled = false;
        else
            GUI.enabled = true;
        GUI.BeginGroup(new Rect(windowRect.width - 405, 35, 400, 400));
        GUI.Box(new Rect(0,0, 400, 400), "Layers");
        LayersPanelScrollPos = GUI.BeginScrollView(new Rect(0, 25, 395, 340), LayersPanelScrollPos, new Rect(0,0, 375, 100 * Layers.Count + 5 * Layers.Count));
        foreach(Layer l in Layers)
        {
            if(!showLoadWin)
                GUI.enabled = l.enabled;
            GUI.BeginGroup(new Rect(0, 100 * Layers.IndexOf(l) + 5 * Layers.IndexOf(l), 400, 100));
            if(ActiveLayer == Layers.IndexOf(l))
            {
                GUI.Box(new Rect(10,0, 365, 100), "", ActiveLayerStyle);
            }else
            {
                GUI.Box(new Rect(10,0, 365, 100), "");
            }
            GUI.BeginGroup(new Rect(15, 5, 90, 90));
            GUI.DrawTexture(new Rect(l.posX *(90/EmblemSize.width), l.posY *(90/EmblemSize.height), 90, 90), l.texture, ScaleMode.ScaleToFit, l.blend);
            GUI.EndGroup();
            l.name = GUI.TextField(new Rect(115, 10, 150, 20), l.name);
        //			if(GUI.Button(new Rect(115, 40, 150, 20), new GUIContent("Duplicate Layer","Duplicate the current layer")))
        //			{
        //				DupLayer = new LayerDup();
        //				DupLayer.isDup = true;
        //				DupLayer.layer = l;
        //				DupLayer.to = Layers.IndexOf(l);
        //			}
            GUI.Label(new Rect(115, 35, 20, 20), "X: ");
            float.TryParse(GUI.TextField(new Rect(135, 35, 50, 20), l.posX.ToString()), out l.posX);
            GUI.Label(new Rect(195, 35, 20, 20), "Y: ");
            float.TryParse(GUI.TextField(new Rect(215, 35, 50, 20), l.posY.ToString()), out l.posY);
            if(Layers.IndexOf(l) == ActiveLayer)
            {
                if(GUI.Button(new Rect( 115, 65, 150, 20), new GUIContent("Deselect Layer", "Deselects this layer as the active layer to edit")))
                {
                    ActiveLayer = -1;
                }
            }else
            {
                if(GUI.Button(new Rect( 115, 65, 150, 20), new GUIContent("Select Layer","Selects this layer as the active layer to edit")))
                {
                    ActiveLayer = Layers.IndexOf(l);
                }
            }
            if(GUI.Button(new Rect(270, 50-25,55, 20), new GUIContent("Delete", "Deletes this layer")))
            {
                LayerToDelete = l;
            }
            l.blend = GUI.Toggle(new Rect(270, 55,55, 20), l.blend, new GUIContent("Alpha?", "Enable/Disable Alpha transparency for this layer"));
            if(!showLoadWin)
            {
                if(Layers.IndexOf(l) == 0)
                {
                    GUI.enabled = false;
                }else
                {
                    GUI.enabled = l.enabled;
                }
            }
            if(GUI.Button(new Rect(365 - 35, 50- 30, 25, 25), new GUIContent("^", "Moves this layer up by 1")))
            {
                int index = Layers.IndexOf(l);
                if(ActiveLayer == index)
                {
                    ActiveLayer = index - 1;
                }
                Move = new LayerMove();
                Move.isMove = true;
                Move.layer = l;
                Move.to = index - 1;
            }
            if(!showLoadWin)
            {
                if(Layers.IndexOf(l) == Layers.Count-1)
                {
                    GUI.enabled = false;
                }else
                {
                    GUI.enabled = l.enabled;
                }
            }
            if(GUI.Button(new Rect(365 - 35, 55, 25, 25), new GUIContent("v", "Moves this layer down by 1")))
            {
                int index = Layers.IndexOf(l);
                if(ActiveLayer == index)
                {
                    ActiveLayer = index + 1;
                }
                Move = new LayerMove();
                Move.isMove = true;
                Move.layer = l;
                Move.to = index + 1;
            }
            if(!showLoadWin)
                GUI.enabled = true;
            l.enabled = GUI.Toggle(new Rect(365 - 10, 50-10, 20, 20), l.enabled, new GUIContent("", "Enable/Disable this layer"));
            if(!showLoadWin)
                GUI.enabled = l.enabled;
            GUI.EndGroup();
        }
        if(Move.isMove)
        {
            Layers.Remove(Move.layer);
            Layers.Insert(Move.to, Move.layer);
            Move = new LayerMove();
        }
        //		if(DupLayer.isDup)
        //		{
        //			Layers.Insert(DupLayer.to + 1, DupLayer.layer);
        //			DupLayer = new LayerDup();
        //		}
        if(LayerToDelete != null)
        {
            Layers.Remove(LayerToDelete);
            LayerToDelete = null;

        }
        GUI.EndScrollView();
        if(!showLoadWin)
        {
            if(Layers.Count >= MaxLayers)
            {
                GUI.enabled = false;
            }else
            {
                GUI.enabled = true;
            }
        }
        if(GUI.Button(new Rect(10, 400 - 25, 20, 20), new GUIContent("+", "Adds a new layer")))
        {
            AddNewLayer();
            LayersPanelScrollPos.y = 1000000f;
            ActiveLayer = Layers.Count -1;
        }
        GUI.enabled = true;
        if(!showLoadWin)
        {
            if(ActiveLayer == -1)
            {
                GUI.enabled = false;
            }else
            {
                GUI.enabled = true;
            }
        }
        if(GUI.Button(new Rect(40, 400 - 25, 20, 20),new GUIContent("-", "Removes the curretly selected layer")))
        {
            Layers.RemoveAt(ActiveLayer);
            ActiveLayer = -1;
        }
        GUI.Label(new Rect(70, 400-25, 100, 20), new GUIContent(Layers.Count + " of " + MaxLayers + " layers.","The total number of layers of the maximum ammount of layers"));
        if(!showLoadWin)
            GUI.enabled = true;
        GUI.EndGroup();
    }