Пример #1
0
        public void AESTRELLA(Position endPos, int h = 1)
        {
            CleanInfo();
            flag.transform.position = new Vector3(board.GetBlock(endPos).transform.position.x, flag.transform.position.y, board.GetBlock(endPos).transform.position.z);
            time = Time.realtimeSinceStartup;
            UCM.IAV.Puzzles.Model.SlidingPuzzle.Node         start = new UCM.IAV.Puzzles.Model.SlidingPuzzle.Node(new Tuple <uint, uint> (getTank().getCurrent().GetRow(), getTank().getCurrent().GetColumn()), 1);
            UCM.IAV.Puzzles.Model.SlidingPuzzle.Node         end   = new UCM.IAV.Puzzles.Model.SlidingPuzzle.Node(new Tuple <uint, uint> (endPos.GetRow(), endPos.GetColumn()), 1);
            Stack <UCM.IAV.Puzzles.Model.SlidingPuzzle.Node> stack = puzzle.FindPath(start, end, h);

            if (stack != null)
            {
                Stack <UCM.IAV.Puzzles.Model.SlidingPuzzle.Node> stackC = new Stack <UCM.IAV.Puzzles.Model.SlidingPuzzle.Node>(stack);
                errorGO.SetActive(false);
                time  = Time.realtimeSinceStartup - time;
                steps = (uint)stack.Count;
                getTank().setStack(stack);
                ArrowPath(stackC);
                UpdateInfo();
            }
            else
            {
                errorGO.SetActive(true);
            }
            //InvokeRepeating("ArrowRemoval", 2f, 1f);

            /*print (stack.Count);
             *          while (stack.Count > 0) {
             *                  UCM.IAV.Puzzles.Model.SlidingPuzzle.Node n = stack.Pop();
             *                  print ("Posicion: " + n.Position);
             *          }*/
        }
Пример #2
0
        void ArrowPath(Stack <UCM.IAV.Puzzles.Model.SlidingPuzzle.Node> stack)
        {
            cost         = 0;
            quiver       = new GameObject[stack.Count];
            arrowCounter = quiver.Length - 1;
            UCM.IAV.Puzzles.Model.SlidingPuzzle.Node n = stack.Pop();
            while (stack.Count > 0)
            {
                cost += (uint)puzzle.valores[puzzle.getMatrix()[n.Position.Item1, n.Position.Item2]];
                quiver[quiver.Length - stack.Count] = Instantiate(arrow);
                quiver[quiver.Length - stack.Count].transform.position = new Vector3(board.GetBlock(new Position(stack.Peek().Position.Item1, stack.Peek().Position.Item2)).transform.position.x
                                                                                     , 0.2f, board.GetBlock(new Position(stack.Peek().Position.Item1, stack.Peek().Position.Item2)).transform.position.z);
                quiver[quiver.Length - stack.Count].name = ("Bloque[" + (quiver.Length - stack.Count) + "]");
                n = stack.Pop();
            }

            cost += (uint)puzzle.valores[puzzle.getMatrix()[n.Position.Item1, n.Position.Item2]];
        }